@@ -587,14 +587,14 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
587587 uint16_t val ;
588588 } o_status = {
589589 .type = htons (DHCPV6_OPT_STATUS ),
590- .len = htons (sizeof (o_status ) - 4 ),
590+ .len = htons (sizeof (o_status ) - DHCPV6_OPT_HDR_SIZE ),
591591 .val = htons (status ),
592592 };
593593
594594 memcpy (buf + ia_len , & o_status , sizeof (o_status ));
595595 ia_len += sizeof (o_status );
596596
597- o_ia .len = htons (ia_len - 4 );
597+ o_ia .len = htons (ia_len - DHCPV6_OPT_HDR_SIZE );
598598 memcpy (buf , & o_ia , sizeof (o_ia ));
599599
600600 return ia_len ;
@@ -668,7 +668,7 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
668668 if (a -> flags & OAF_DHCPV6_PD ) {
669669 struct dhcpv6_ia_prefix o_ia_p = {
670670 .type = htons (DHCPV6_OPT_IA_PREFIX ),
671- .len = htons (sizeof (o_ia_p ) - 4 ),
671+ .len = htons (sizeof (o_ia_p ) - DHCPV6_OPT_HDR_SIZE ),
672672 .preferred_lt = htonl (prefix_preferred_lt ),
673673 .valid_lt = htonl (prefix_valid_lt ),
674674 .prefix_len = a -> length ,
@@ -691,7 +691,7 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
691691 if (a -> flags & OAF_DHCPV6_NA ) {
692692 struct dhcpv6_ia_addr o_ia_a = {
693693 .type = htons (DHCPV6_OPT_IA_ADDR ),
694- .len = htons (sizeof (o_ia_a ) - 4 ),
694+ .len = htons (sizeof (o_ia_a ) - DHCPV6_OPT_HDR_SIZE ),
695695 .addr = in6_from_prefix_and_iid (& addrs [i ], a -> assigned_host_id ),
696696 .preferred_lt = htonl (prefix_preferred_lt ),
697697 .valid_lt = htonl (prefix_valid_lt )
@@ -736,16 +736,16 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
736736 }
737737
738738 if (!request ) {
739- uint8_t * odata , * end = ((uint8_t * )ia ) + htons (ia -> len ) + 4 ;
739+ uint8_t * odata , * end = ((uint8_t * )ia ) + htons (ia -> len ) + DHCPV6_OPT_HDR_SIZE ;
740740 uint16_t otype , olen ;
741741
742742 dhcpv6_for_each_option ((uint8_t * )& ia [1 ], end , otype , olen , odata ) {
743- struct dhcpv6_ia_prefix * ia_p = (struct dhcpv6_ia_prefix * )& odata [-4 ];
744- struct dhcpv6_ia_addr * ia_a = (struct dhcpv6_ia_addr * )& odata [-4 ];
743+ struct dhcpv6_ia_prefix * ia_p = (struct dhcpv6_ia_prefix * )& odata [- DHCPV6_OPT_HDR_SIZE ];
744+ struct dhcpv6_ia_addr * ia_a = (struct dhcpv6_ia_addr * )& odata [- DHCPV6_OPT_HDR_SIZE ];
745745 bool found = false;
746746
747- if ((otype != DHCPV6_OPT_IA_PREFIX || olen < sizeof (* ia_p ) - 4 ) &&
748- (otype != DHCPV6_OPT_IA_ADDR || olen < sizeof (* ia_a ) - 4 ))
747+ if ((otype != DHCPV6_OPT_IA_PREFIX || olen < sizeof (* ia_p ) - DHCPV6_OPT_HDR_SIZE ) &&
748+ (otype != DHCPV6_OPT_IA_ADDR || olen < sizeof (* ia_a ) - DHCPV6_OPT_HDR_SIZE ))
749749 continue ;
750750
751751 if (a ) {
@@ -785,7 +785,7 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
785785 if (otype == DHCPV6_OPT_IA_PREFIX ) {
786786 struct dhcpv6_ia_prefix o_ia_p = {
787787 .type = htons (DHCPV6_OPT_IA_PREFIX ),
788- .len = htons (sizeof (o_ia_p ) - 4 ),
788+ .len = htons (sizeof (o_ia_p ) - DHCPV6_OPT_HDR_SIZE ),
789789 .preferred_lt = 0 ,
790790 .valid_lt = 0 ,
791791 .prefix_len = ia_p -> prefix_len ,
@@ -800,7 +800,7 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
800800 } else {
801801 struct dhcpv6_ia_addr o_ia_a = {
802802 .type = htons (DHCPV6_OPT_IA_ADDR ),
803- .len = htons (sizeof (o_ia_a ) - 4 ),
803+ .len = htons (sizeof (o_ia_a ) - DHCPV6_OPT_HDR_SIZE ),
804804 .addr = ia_a -> addr ,
805805 .preferred_lt = 0 ,
806806 .valid_lt = 0 ,
@@ -816,7 +816,7 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
816816 }
817817 }
818818
819- o_ia .len = htons (ia_len - 4 );
819+ o_ia .len = htons (ia_len - DHCPV6_OPT_HDR_SIZE );
820820 memcpy (buf , & o_ia , sizeof (o_ia ));
821821 return ia_len ;
822822}
@@ -906,16 +906,16 @@ static bool dhcpv6_ia_on_link(const struct dhcpv6_ia_hdr *ia, struct dhcpv6_leas
906906 struct odhcpd_ipaddr * addrs = iface -> addr6 ;
907907 size_t addrlen = iface -> addr6_len ;
908908 time_t now = odhcpd_time ();
909- uint8_t * odata , * end = ((uint8_t * )ia ) + htons (ia -> len ) + 4 ;
909+ uint8_t * odata , * end = ((uint8_t * )ia ) + htons (ia -> len ) + DHCPV6_OPT_HDR_SIZE ;
910910 uint16_t otype , olen ;
911911 bool onlink = true;
912912
913913 dhcpv6_for_each_option ((uint8_t * )& ia [1 ], end , otype , olen , odata ) {
914- struct dhcpv6_ia_prefix * p = (struct dhcpv6_ia_prefix * )& odata [-4 ];
915- struct dhcpv6_ia_addr * n = (struct dhcpv6_ia_addr * )& odata [-4 ];
914+ struct dhcpv6_ia_prefix * p = (struct dhcpv6_ia_prefix * )& odata [- DHCPV6_OPT_HDR_SIZE ];
915+ struct dhcpv6_ia_addr * n = (struct dhcpv6_ia_addr * )& odata [- DHCPV6_OPT_HDR_SIZE ];
916916
917- if ((otype != DHCPV6_OPT_IA_PREFIX || olen < sizeof (* p ) - 4 ) &&
918- (otype != DHCPV6_OPT_IA_ADDR || olen < sizeof (* n ) - 4 ))
917+ if ((otype != DHCPV6_OPT_IA_PREFIX || olen < sizeof (* p ) - DHCPV6_OPT_HDR_SIZE ) &&
918+ (otype != DHCPV6_OPT_IA_ADDR || olen < sizeof (* n ) - DHCPV6_OPT_HDR_SIZE ))
919919 continue ;
920920
921921 onlink = false;
@@ -992,7 +992,7 @@ ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *ifac
992992 if (!is_pd && !is_na )
993993 continue ;
994994
995- struct dhcpv6_ia_hdr * ia = (struct dhcpv6_ia_hdr * )& odata [-4 ];
995+ struct dhcpv6_ia_hdr * ia = (struct dhcpv6_ia_hdr * )& odata [- DHCPV6_OPT_HDR_SIZE ];
996996 size_t ia_response_len = 0 ;
997997 uint8_t reqlen = (is_pd ) ? 62 : 128 ;
998998 uint32_t reqhint = 0 ;
@@ -1010,10 +1010,10 @@ ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *ifac
10101010 uint8_t * sdata ;
10111011 uint16_t stype , slen ;
10121012 dhcpv6_for_each_sub_option (& ia [1 ], odata + olen , stype , slen , sdata ) {
1013- if (stype != DHCPV6_OPT_IA_PREFIX || slen < sizeof (struct dhcpv6_ia_prefix ) - 4 )
1013+ if (stype != DHCPV6_OPT_IA_PREFIX || slen < sizeof (struct dhcpv6_ia_prefix ) - DHCPV6_OPT_HDR_SIZE )
10141014 continue ;
10151015
1016- struct dhcpv6_ia_prefix * p = (struct dhcpv6_ia_prefix * )& sdata [-4 ];
1016+ struct dhcpv6_ia_prefix * p = (struct dhcpv6_ia_prefix * )& sdata [- DHCPV6_OPT_HDR_SIZE ];
10171017 if (p -> prefix_len ) {
10181018 reqlen = p -> prefix_len ;
10191019 reqhint = ntohl (p -> addr .s6_addr32 [1 ]);
@@ -1053,7 +1053,7 @@ ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *ifac
10531053 uint8_t * sdata ;
10541054 uint16_t stype , slen ;
10551055 dhcpv6_for_each_sub_option (& ia [1 ], odata + olen , stype , slen , sdata ) {
1056- if (stype != DHCPV6_OPT_IA_ADDR || slen < sizeof (struct dhcpv6_ia_addr ) - 4 )
1056+ if (stype != DHCPV6_OPT_IA_ADDR || slen < sizeof (struct dhcpv6_ia_addr ) - DHCPV6_OPT_HDR_SIZE )
10571057 continue ;
10581058
10591059 ia_addr_present = true;
@@ -1211,7 +1211,7 @@ ssize_t dhcpv6_ia_handle_IAs(uint8_t *buf, size_t buflen, struct interface *ifac
12111211 if (hdr -> msg_type == DHCPV6_MSG_REQUEST ) {
12121212 struct dhcpv6_auth_reconfigure auth = {
12131213 htons (DHCPV6_OPT_AUTH ),
1214- htons (sizeof (auth ) - 4 ),
1214+ htons (sizeof (auth ) - DHCPV6_OPT_HDR_SIZE ),
12151215 3 , 1 , 0 ,
12161216 {htonl (time (NULL )), htonl (++ serial )},
12171217 1 ,
0 commit comments