X-Git-Url: https://git.decadent.org.uk/gitweb/?p=odhcp6c.git;a=blobdiff_plain;f=src%2Fdhcpv6.c;h=7e62a2b97cddf393020d202a6b24d3b5e48ba6bf;hp=d2da0535bed59cc9f22d9642516d164a5d45f6d6;hb=fa2696854e200258d266e8655b65259e9117a050;hpb=797317aae708139b358b7b58d611fddde869f04a diff --git a/src/dhcpv6.c b/src/dhcpv6.c index d2da053..7e62a2b 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -135,7 +135,8 @@ int init_dhcpv6(const char *ifname, int request_pd) 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_PREFIX_CLASS) + }; odhcp6c_add_state(STATE_ORO, oro, sizeof(oro)); @@ -729,11 +730,11 @@ static uint32_t dhcpv6_parse_ia(void *opt, void *end) uint16_t otype, olen; uint8_t *odata; - struct odhcp6c_entry entry = {IN6ADDR_ANY_INIT, - 0, 0, IN6ADDR_ANY_INIT, 0, 0}; - // Update address IA dhcpv6_for_each_option(opt, end, otype, olen, odata) { + struct odhcp6c_entry entry = {IN6ADDR_ANY_INIT, + 0, 0, IN6ADDR_ANY_INIT, 0, 0, 0}; + if (otype == DHCPV6_OPT_IA_PREFIX) { struct dhcpv6_ia_prefix *prefix = (void*)&odata[-4]; if (olen + 4U < sizeof(*prefix)) @@ -747,6 +748,14 @@ static uint32_t dhcpv6_parse_ia(void *opt, void *end) entry.length = prefix->prefix; entry.target = prefix->addr; + uint16_t stype, slen; + uint8_t *sdata; + + // Find prefix class, if any + dhcpv6_for_each_option(odata, odata + olen, + stype, slen, sdata) + if (stype == DHCPV6_OPT_PREFIX_CLASS && slen == 2) + entry.prefix_class = ntohs(*((uint16_t*)sdata)); odhcp6c_update_entry(STATE_IA_PD, &entry); } else if (otype == DHCPV6_OPT_IA_ADDR) {