]> git.decadent.org.uk Git - odhcp6c.git/commitdiff
Fix generation of IA_PD and IA_NA attributes
authorSteven Barth <steven@midlink.org>
Sat, 2 Feb 2013 09:44:10 +0000 (10:44 +0100)
committerSteven Barth <steven@midlink.org>
Sat, 2 Feb 2013 09:44:10 +0000 (10:44 +0100)
src/dhcpv6.c

index 773e7ef930bc721988cdb26ef6e9f4cfb9666155..3f5948e979639ac4bd5fc1fc4321ef63da9b201b 100644 (file)
@@ -192,7 +192,7 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs)
        void *ia_pd_entries = odhcp6c_get_state(STATE_IA_PD, &ia_pd_entry_len);
        struct dhcpv6_ia_hdr hdr_ia_pd = {
                htons(DHCPV6_OPT_IA_PD),
-               htons(sizeof(hdr_ia_pd) - 4 + ia_pd_len),
+               htons(sizeof(hdr_ia_pd) - 4),
                1, 0, 0
        };
 
@@ -215,11 +215,13 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs)
                }
                ia_pd = p;
                ia_pd_len = sizeof(p);
+               hdr_ia_pd.len = htons(ntohs(hdr_ia_pd.len) + ia_pd_len);
        } else if (request_prefix > 0 &&
                        (type == DHCPV6_MSG_SOLICIT ||
                        type == DHCPV6_MSG_REQUEST)) {
                ia_pd = &pref;
                ia_pd_len = sizeof(pref);
+               hdr_ia_pd.len = htons(ntohs(hdr_ia_pd.len) + ia_pd_len);
        }
 
        // Build IA_NAs
@@ -228,7 +230,7 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs)
        void *ia_na_entries = odhcp6c_get_state(STATE_IA_NA, &ia_na_entry_len);
        struct dhcpv6_ia_hdr hdr_ia_na = {
                htons(DHCPV6_OPT_IA_NA),
-               htons(sizeof(hdr_ia_na) - 4 + ia_na_len),
+               htons(sizeof(hdr_ia_na) - 4),
                1, 0, 0
        };
 
@@ -245,6 +247,7 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs)
                }
                ia_na = p;
                ia_na_len = sizeof(p);
+               hdr_ia_na.len = htons(ntohs(hdr_ia_na.len) + ia_na_len);
        }
 
        // Reconfigure Accept