f) SIP Options
g) Information-Refresh Options
h) SOL_MAX_RT default to 3600
+ i) DS-Lite AFTR-Name Option
4. Support for requesting and parsing Router Advertisements
a) parsing of prefixes, routes, MTU and RDNSS options
* RA_ROUTES A space-separated list of routes from the RA
Format: <address>/<length>,gateway,valid,metric
* RA_DNS A space-separated list of recursive DNS servers from the RA
+* AFTR The DS-Lite AFTR domain name
+* AFTR_IP The DS-Lite AFTR resolved IPv6 address
*/
#include <stdio.h>
+#include <netdb.h>
#include <resolv.h>
#include <stdlib.h>
#include <string.h>
}
+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);
+}
+
+
static void bin_to_env(uint8_t *opts, size_t len)
{
uint8_t *oend = opts + len, *odata;
fqdn_to_env("SNTP_FQDN", sntp_dns, sntp_dns_len);
fqdn_to_env("SIP_DOMAIN", sip_fqdn, sip_fqdn_len);
fqdn_to_env("AFTR", aftr_name, aftr_name_len);
+ fqdn_to_ip_env("AFTR_IP", aftr_name, aftr_name_len);
bin_to_env(custom, custom_len);
entry_to_env("PREFIXES", prefix, prefix_len, ENTRY_PREFIX);
entry_to_env("ADDRESSES", address, address_len, ENTRY_ADDRESS);