From: Paul Donald Date: Wed, 12 Nov 2025 23:59:13 +0000 (+0100) Subject: dhcpv6: set a static define for DUID max length X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=cf203ceb3fc8434b1b9ab31bfc3c59ef33d1c785;p=project%2Fodhcp6c.git dhcpv6: set a static define for DUID max length so the number 130 isn't so mysterious at first glance. Signed-off-by: Paul Donald Link: https://github.com/openwrt/odhcp6c/pull/118 Signed-off-by: Álvaro Fernández Rojas --- diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 21fd16b..a6fe176 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -1190,7 +1190,7 @@ static int dhcpv6_handle_advert(enum dhcpv6_msg orig, const int rc, switch (otype) { case DHCPV6_OPT_SERVERID: - if (olen <= 130) { + if (olen <= DHCPV6_DUID_MAX_LEN) { memcpy(cand.duid, odata, olen); cand.duid_len = olen; } diff --git a/src/odhcp6c.h b/src/odhcp6c.h index 405a2bf..6c669c0 100644 --- a/src/odhcp6c.h +++ b/src/odhcp6c.h @@ -272,6 +272,7 @@ struct dhcpv6_retx { #define DHCPV6_OPT_HDR_SIZE 4 #define DHCPV6_OPT_HDR_SIZE_U 4U +#define DHCPV6_DUID_MAX_LEN 130 // 2-byte type + 128-byte DUID, RFC8415, §11.1 // DHCPv6 Protocol Headers struct dhcpv6_header { @@ -364,7 +365,7 @@ struct dhcpv6_server_cand { bool wants_reconfigure; int16_t preference; uint8_t duid_len; - uint8_t duid[130]; + uint8_t duid[DHCPV6_DUID_MAX_LEN]; struct in6_addr server_addr; uint32_t sol_max_rt; uint32_t inf_max_rt;