]> git.decadent.org.uk Git - odhcp6c.git/commitdiff
Merge remote-tracking branch 'up/master' into hnet
authorMarkus Stenberg <markus.stenberg@iki.fi>
Thu, 1 Aug 2013 09:05:56 +0000 (11:05 +0200)
committerMarkus Stenberg <markus.stenberg@iki.fi>
Thu, 1 Aug 2013 09:05:56 +0000 (11:05 +0200)
1  2 
src/dhcpv6.c

diff --combined src/dhcpv6.c
index 1df31cd1811c585ce35d5aa9d139abfbd2dfc31a,3f5bc83094d6589ce2dc509d77f0989ab0ac73c2..fe4cc0b48e8f5dd4ca56139ee1c7fdcc5e353f1f
@@@ -142,10 -142,8 +142,10 @@@ int init_dhcpv6(const char *ifname, in
                        htons(DHCPV6_OPT_DNS_SERVERS),
                        htons(DHCPV6_OPT_DNS_DOMAIN),
                        htons(DHCPV6_OPT_NTP_SERVER),
 +                      htons(DHCPV6_OPT_SIP_SERVER_A),
                        htons(DHCPV6_OPT_AFTR_NAME),
                        htons(DHCPV6_OPT_PD_EXCLUDE),
 +                      htons(DHCPV6_OPT_PREFIX_CLASS),
        };
        odhcp6c_add_state(STATE_ORO, oro, sizeof(oro));
  
@@@ -569,6 -567,13 +569,13 @@@ static int dhcpv6_handle_advert(enum dh
        struct dhcpv6_server_cand cand = {false, false, 0, 0, {0}, NULL, NULL, 0, 0};
  
        dhcpv6_for_each_option(opt, end, otype, olen, odata) {
+               if (orig == DHCPV6_MSG_SOLICIT &&
+                               (otype == DHCPV6_OPT_IA_PD || otype == DHCPV6_OPT_IA_NA) &&
+                               olen > sizeof(struct dhcpv6_ia_hdr)) {
+                       struct dhcpv6_ia_hdr *ia_hdr = (void*)(&odata[-4]);
+                       dhcpv6_parse_ia(&ia_hdr[1], odata + olen);
+               }
                if (otype == DHCPV6_OPT_SERVERID && olen <= 130) {
                        memcpy(cand.duid, odata, olen);
                        cand.duid_len = olen;
                                        cand.preference -= 2000;
                        }
                }
-               if (orig == DHCPV6_MSG_SOLICIT &&
-                               (otype == DHCPV6_OPT_IA_PD || otype == DHCPV6_OPT_IA_NA) &&
-                               olen > sizeof(struct dhcpv6_ia_hdr)) {
-                       struct dhcpv6_ia_hdr *ia_hdr = (void*)(&odata[-4]);
-                       dhcpv6_parse_ia(&ia_hdr[1], odata + olen);
-               }
        }
  
        if (cand.duid_len > 0) {
@@@ -829,11 -827,11 +829,11 @@@ static uint32_t dhcpv6_parse_ia(void *o
        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))
  
                        entry.length = prefix->prefix;
                        entry.target = prefix->addr;
 +                      uint16_t stype, slen;
 +                      uint8_t *sdata;
 +
 +                        // Find prefix class, if any
 +                      dhcpv6_for_each_option(&prefix[1], odata + olen,
 +                                               stype, slen, sdata)
 +                          if (stype == DHCPV6_OPT_PREFIX_CLASS && slen == 2) 
 +                            entry.prefix_class = ntohs(*((uint16_t*)sdata));
  
                        // Parse PD-exclude
                        bool ok = true;
 -                      uint16_t stype, slen;
 -                      uint8_t *sdata;
                        dhcpv6_for_each_option(odata + sizeof(*prefix) - 4U,
                                        odata + olen, stype, slen, sdata) {
                                if (stype != DHCPV6_OPT_PD_EXCLUDE || slen < 2)
                        entry.length = 128;
                        entry.target = addr->addr;
  
 +                      uint16_t stype, slen;
 +                      uint8_t *sdata;
 +                      
 +                      // Find prefix class, if any
 +                      dhcpv6_for_each_option(&addr[1], 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_NA, &entry);
                }