From: Steven Barth Date: Sun, 12 May 2013 09:03:48 +0000 (+0200) Subject: Add support for DS-Lite AFTR X-Git-Tag: debian/1.1+git20160131-1~151 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=82c9edbf4148365f529a9b49013691943eed7aac;p=odhcp6c.git Add support for DS-Lite AFTR --- diff --git a/src/dhcpv6.c b/src/dhcpv6.c index df73c86..d2cd656 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -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, diff --git a/src/odhcp6c.h b/src/odhcp6c.h index cfd1a53..b0a1980 100644 --- a/src/odhcp6c.h +++ b/src/odhcp6c.h @@ -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 }; diff --git a/src/script.c b/src/script.c index 051718f..2c62bf2 100644 --- a/src/script.c +++ b/src/script.c @@ -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);