+static void fqdn_to_ip_env(const char *name, const uint8_t *fqdn, size_t len)
+{
+ size_t buf_len = strlen(name);
+ char *buf = realloc(NULL, INET6_ADDRSTRLEN + buf_len + 3);
+ memcpy(buf, name, buf_len);
+ buf[buf_len++] = '=';
+
+ char namebuf[256];
+ if (dn_expand(fqdn, fqdn + len, fqdn, namebuf, sizeof(namebuf)) <= 0)
+ return;
+
+ struct addrinfo hints = {.ai_family = AF_INET6}, *r;
+ if (getaddrinfo(namebuf, NULL, &hints, &r))
+ return;
+
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)r->ai_addr;
+ inet_ntop(AF_INET6, &sin6->sin6_addr, &buf[buf_len], INET6_ADDRSTRLEN);
+
+ freeaddrinfo(r);
+ putenv(buf);
+}
+
+