]> git.decadent.org.uk Git - odhcp6c.git/commitdiff
Add support for DS-Lite AFTR
authorSteven Barth <steven@midlink.org>
Sun, 12 May 2013 09:03:48 +0000 (11:03 +0200)
committerSteven Barth <steven@midlink.org>
Sun, 12 May 2013 09:03:48 +0000 (11:03 +0200)
src/dhcpv6.c
src/odhcp6c.h
src/script.c

index df73c86b8b0dd6bfa405681d01993f8735dd86b0..d2cd656e5ae59bede3a2906d6c58ae3fc13ccfb6 100644 (file)
@@ -136,12 +136,15 @@ int init_dhcpv6(const char *ifname, int request_pd)
        }
 
        // Create ORO
-       uint16_t oro[] = {htons(DHCPV6_OPT_DNS_SERVERS),
+       uint16_t oro[] = {
+                       htons(DHCPV6_OPT_SIP_SERVER_D),
+                       htons(DHCPV6_OPT_SIP_SERVER_A),
+                       htons(DHCPV6_OPT_DNS_SERVERS),
                        htons(DHCPV6_OPT_DNS_DOMAIN),
                        htons(DHCPV6_OPT_NTP_SERVER),
-                       htons(DHCPV6_OPT_SIP_SERVER_A),
-                       htons(DHCPV6_OPT_SIP_SERVER_D),
-                       htons(DHCPV6_OPT_PD_EXCLUDE)};
+                       htons(DHCPV6_OPT_AFTR_NAME),
+                       htons(DHCPV6_OPT_PD_EXCLUDE),
+       };
        odhcp6c_add_state(STATE_ORO, oro, sizeof(oro));
 
 
@@ -694,6 +697,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig,
                odhcp6c_clear_state(STATE_SNTP_FQDN);
                odhcp6c_clear_state(STATE_SIP_IP);
                odhcp6c_clear_state(STATE_SIP_FQDN);
+               odhcp6c_clear_state(STATE_AFTR_NAME);
        }
 
        // Parse and find all matching IAs
@@ -779,6 +783,11 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig,
                        if (r->protocol == 3 && r->algorithm == 1 &&
                                        r->reconf_type == 1)
                                memcpy(reconf_key, r->key, sizeof(r->key));
+               } else if (otype == DHCPV6_OPT_AFTR_NAME && olen > 3) {
+                       size_t cur_len;
+                       odhcp6c_get_state(STATE_AFTR_NAME, &cur_len);
+                       if (cur_len == 0)
+                               odhcp6c_add_state(STATE_AFTR_NAME, odata, olen);
                } else if (otype != DHCPV6_OPT_CLIENTID &&
                                otype != DHCPV6_OPT_SERVERID) {
                        odhcp6c_add_state(STATE_CUSTOM_OPTS,
index cfd1a53565f580cca6a179b14dcc7d33b0044747..b0a198046df6c48c06115b18d8cf5191af85dc16 100644 (file)
@@ -51,6 +51,7 @@ enum dhcvp6_opt {
        DHCPV6_OPT_NTP_SERVER = 56,
        DHCPV6_OPT_SIP_SERVER_D = 21,
        DHCPV6_OPT_SIP_SERVER_A = 22,
+       DHCPV6_OPT_AFTR_NAME = 64,
        DHCPV6_OPT_PD_EXCLUDE = 67,
 };
 
@@ -177,6 +178,7 @@ enum odhcp6c_state {
        STATE_RA_ROUTE,
        STATE_RA_PREFIX,
        STATE_RA_DNS,
+       STATE_AFTR_NAME,
        _STATE_MAX
 };
 
index 051718f206ed2e7513fbd9808d09628a2b2d17ae..2c62bf25a564eee609173eb3625b3787c9bdb550 100644 (file)
@@ -198,7 +198,7 @@ void script_delay_call(const char *status, int timeout)
 void script_call(const char *status)
 {
        size_t dns_len, search_len, custom_len, sntp_ip_len, sntp_dns_len;
-       size_t sip_ip_len, sip_fqdn_len;
+       size_t sip_ip_len, sip_fqdn_len, aftr_name_len;
 
        odhcp6c_expire();
        if (delayed_call)
@@ -211,6 +211,7 @@ void script_call(const char *status)
        uint8_t *sntp_dns = odhcp6c_get_state(STATE_SNTP_FQDN, &sntp_dns_len);
        struct in6_addr *sip = odhcp6c_get_state(STATE_SIP_IP, &sip_ip_len);
        uint8_t *sip_fqdn = odhcp6c_get_state(STATE_SIP_FQDN, &sip_fqdn_len);
+       uint8_t *aftr_name = odhcp6c_get_state(STATE_AFTR_NAME, &aftr_name_len);
 
        size_t prefix_len, address_len, ra_pref_len, ra_route_len, ra_dns_len;
        uint8_t *prefix = odhcp6c_get_state(STATE_IA_PD, &prefix_len);
@@ -227,6 +228,7 @@ void script_call(const char *status)
                fqdn_to_env("DOMAINS", search, search_len);
                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);
                bin_to_env(custom, custom_len);
                entry_to_env("PREFIXES", prefix, prefix_len, ENTRY_PREFIX);
                entry_to_env("ADDRESSES", address, address_len, ENTRY_ADDRESS);