From cf203ceb3fc8434b1b9ab31bfc3c59ef33d1c785 Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 13 Nov 2025 00:59:13 +0100 Subject: [PATCH] dhcpv6: set a static define for DUID max length MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/dhcpv6.c | 2 +- src/odhcp6c.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) 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; -- 2.30.2