Skip to content

Commit 9c0b818

Browse files
MarGasiorekjhedberg
authored andcommitted
net: dhcpv6: Add configurable DUID buffer length
According to the `RFC8415` the length of the DUID is at least 1 octet up to 128 octets. Now a user can choose buffer length without the need for source code modification. Signed-off-by: Marcin Gasiorek <[email protected]>
1 parent 45ff5af commit 9c0b818

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

include/zephyr/net/dhcpv6.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ enum net_dhcpv6_state {
3838
} __packed;
3939

4040
#define DHCPV6_TID_SIZE 3
41-
#define DHCPV6_DUID_MAX_SIZE 20
41+
42+
#ifndef CONFIG_NET_DHCPV6_DUID_MAX_LEN
43+
#define CONFIG_NET_DHCPV6_DUID_MAX_LEN 22
44+
#endif
4245

4346
struct net_dhcpv6_duid_raw {
4447
uint16_t type;
45-
uint8_t buf[DHCPV6_DUID_MAX_SIZE];
48+
uint8_t buf[CONFIG_NET_DHCPV6_DUID_MAX_LEN];
4649
} __packed;
4750

4851
struct net_dhcpv6_duid_storage {

subsys/net/lib/dhcpv6/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ config NET_DHCPV6
1515
select NET_MGMT_EVENT
1616
depends on NET_IPV6 && NET_UDP
1717

18+
config NET_DHCPV6_DUID_MAX_LEN
19+
int "The maximum DUID length (not including a type code)"
20+
range 1 128
21+
default 22
22+
help
23+
This will set the available number of bytes for the DUID.
24+
1825
if NET_DHCPV6
1926
module = NET_DHCPV6
2027
module-dep = NET_LOG

0 commit comments

Comments
 (0)