1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #14599 from akshaim/Kconfig_dhcpv6

net/dhcpv6 : Expose configurations to Kconfig
This commit is contained in:
Leandro Lanzieri 2020-07-28 15:46:17 +02:00 committed by GitHub
commit cfdf30409a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 12 deletions

View File

@ -4,9 +4,11 @@ ZEP_PORT_BASE ?= 17754
ZEP_PORT_MAX := $(shell expr $(ZEP_PORT_BASE) + $(ZEP_DEVICES) - 1)
CFLAGS += -DSOCKET_ZEP_MAX=$(ZEP_DEVICES)
CFLAGS += -DDHCPV6_CLIENT_PFX_LEASE_MAX=$(ZEP_DEVICES)
CFLAGS += -DASYNC_READ_NUMOF=$(shell expr $(ZEP_DEVICES) + 1)
# Set CFLAGS if not being set via Kconfig
CFLAGS += $(if $(CONFIG_KCONFIG_MODULE_DHCPV6),,-DCONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX=$(ZEP_DEVICES))
# -z [::1]:$PORT for each ZEP device
TERMFLAGS += $(patsubst %,-z [::1]:%, $(shell seq $(ZEP_PORT_BASE) $(ZEP_PORT_MAX)))

View File

@ -46,12 +46,19 @@ extern "C" {
*/
#define DHCPV6_CLIENT_DUID_LEN (sizeof(dhcpv6_duid_l2_t) + 8U)
#define DHCPV6_CLIENT_BUFLEN (256) /**< length for send and receive buffer */
#ifndef DHCPV6_CLIENT_SERVER_MAX
#define DHCPV6_CLIENT_SERVER_MAX (1U) /**< maximum number of servers to store */
#endif
#ifndef DHCPV6_CLIENT_PFX_LEASE_MAX
#define DHCPV6_CLIENT_PFX_LEASE_MAX (1U) /**< maximum number of prefix leases to store */
/**
* @defgroup net_dhcpv6_conf DHCPv6 client compile configurations
* @ingroup config
* @{
*/
/**
* @brief Maximum number of prefix leases to be stored
*/
#ifndef CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX
#define CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX (1U)
#endif
/** @} */
/**
* @name DHCPv6 unique identifier (DUID) definitions

View File

@ -13,3 +13,5 @@ rsource "gcoap/Kconfig"
rsource "nanocoap/Kconfig"
endmenu # CoAP
rsource "dhcpv6/Kconfig"

View File

@ -0,0 +1,19 @@
# Copyright (c) 2020 Freie Universitaet Berlin
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
menuconfig KCONFIG_MODULE_DHCPV6
bool "Configure DHCPv6"
depends on MODULE_DHCPV6
help
Configure DHCPv6 client using Kconfig.
if KCONFIG_MODULE_DHCPV6
config DHCPV6_CLIENT_PFX_LEASE_MAX
int "Maximum number of prefix leases to be stored"
default 1
endif # KCONFIG_MODULE_DHCPv6

View File

@ -68,7 +68,7 @@ static uint8_t send_buf[DHCPV6_CLIENT_BUFLEN];
static uint8_t recv_buf[DHCPV6_CLIENT_BUFLEN];
static uint8_t best_adv[DHCPV6_CLIENT_BUFLEN];
static uint8_t duid[DHCPV6_CLIENT_DUID_LEN];
static pfx_lease_t pfx_leases[DHCPV6_CLIENT_PFX_LEASE_MAX];
static pfx_lease_t pfx_leases[CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX];
static server_t server;
static xtimer_t timer, rebind_timer;
static event_queue_t *event_queue;
@ -149,7 +149,7 @@ void dhcpv6_client_req_ia_pd(unsigned netif, unsigned pfx_len)
pfx_lease_t *lease = NULL;
assert(pfx_len <= 128);
for (unsigned i = 0; i < DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
for (unsigned i = 0; i < CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
if (pfx_leases[i].parent.ia_id.id == 0) {
lease = &pfx_leases[i];
lease->parent.ia_id.info.netif = netif;
@ -276,7 +276,7 @@ static inline size_t _add_ia_pd_from_config(uint8_t *buf)
{
size_t msg_len = 0;
for (unsigned i = 0; i < DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
for (unsigned i = 0; i < CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
uint32_t ia_id = pfx_leases[i].parent.ia_id.id;
if (ia_id != 0) {
dhcpv6_opt_ia_pd_t *ia_pd = (dhcpv6_opt_ia_pd_t *)(&buf[msg_len]);
@ -489,7 +489,7 @@ static void _parse_advertise(uint8_t *adv, size_t len)
len > 0; len -= _opt_len(opt), opt = _opt_next(opt)) {
switch (byteorder_ntohs(opt->type)) {
case DHCPV6_OPT_IA_PD:
for (unsigned i = 0; i < DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
for (unsigned i = 0; i < CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
dhcpv6_opt_ia_pd_t *ia_pd = (dhcpv6_opt_ia_pd_t *)opt;
unsigned pd_t1, pd_t2;
uint32_t ia_id = byteorder_ntohl(ia_pd->ia_id);
@ -602,7 +602,7 @@ static bool _parse_reply(uint8_t *rep, size_t len)
len > 0; len -= _opt_len(opt), opt = _opt_next(opt)) {
switch (byteorder_ntohs(opt->type)) {
case DHCPV6_OPT_IA_PD:
for (unsigned i = 0; i < DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
for (unsigned i = 0; i < CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
dhcpv6_opt_iapfx_t *iapfx = NULL;
pfx_lease_t *lease = &pfx_leases[i];
ia_pd = (dhcpv6_opt_ia_pd_t *)opt;
@ -777,7 +777,7 @@ static void _request_renew_rebind(uint8_t type)
irt = DHCPV6_REB_TIMEOUT;
mrt = DHCPV6_REB_MAX_RT;
/* calculate MRD from prefix leases */
for (unsigned i = 0; i < DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
for (unsigned i = 0; i < CONFIG_DHCPV6_CLIENT_PFX_LEASE_MAX; i++) {
const pfx_lease_t *lease = &pfx_leases[i];
uint32_t valid_until = dhcpv6_client_prefix_valid_until(
lease->parent.ia_id.info.netif,