Skip to content

Commit

Permalink
[nrf fromtree] net: dhcpv6: Add configurable DUID buffer length
Browse files Browse the repository at this point in the history
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]>
(cherry picked from commit 9c0b818)
  • Loading branch information
MarGasiorek committed Apr 3, 2024
1 parent 390323c commit 7160fe9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions include/zephyr/net/dhcpv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ enum net_dhcpv6_state {
} __packed;

#define DHCPV6_TID_SIZE 3
#define DHCPV6_DUID_MAX_SIZE 20

#ifndef CONFIG_NET_DHCPV6_DUID_MAX_LEN
#define CONFIG_NET_DHCPV6_DUID_MAX_LEN 22
#endif

struct net_dhcpv6_duid_raw {
uint16_t type;
uint8_t buf[DHCPV6_DUID_MAX_SIZE];
uint8_t buf[CONFIG_NET_DHCPV6_DUID_MAX_LEN];
} __packed;

struct net_dhcpv6_duid_storage {
Expand Down
7 changes: 7 additions & 0 deletions subsys/net/lib/dhcpv6/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ config NET_DHCPV6
select NET_MGMT_EVENT
depends on NET_IPV6 && NET_UDP

config NET_DHCPV6_DUID_MAX_LEN
int "The maximum DUID length (not including a type code)"
range 1 128
default 22
help
This will set the available number of bytes for the DUID.

if NET_DHCPV6
module = NET_DHCPV6
module-dep = NET_LOG
Expand Down

0 comments on commit 7160fe9

Please sign in to comment.