Merge pull request #14599 from akshaim/Kconfig_dhcpv6
net/dhcpv6 : Expose configurations to Kconfig
This commit is contained in:
commit
cfdf30409a
@ -4,9 +4,11 @@ ZEP_PORT_BASE ?= 17754
|
|||||||
ZEP_PORT_MAX := $(shell expr $(ZEP_PORT_BASE) + $(ZEP_DEVICES) - 1)
|
ZEP_PORT_MAX := $(shell expr $(ZEP_PORT_BASE) + $(ZEP_DEVICES) - 1)
|
||||||
|
|
||||||
CFLAGS += -DSOCKET_ZEP_MAX=$(ZEP_DEVICES)
|
CFLAGS += -DSOCKET_ZEP_MAX=$(ZEP_DEVICES)
|
||||||
CFLAGS += -DDHCPV6_CLIENT_PFX_LEASE_MAX=$(ZEP_DEVICES)
|
|
||||||
CFLAGS += -DASYNC_READ_NUMOF=$(shell expr $(ZEP_DEVICES) + 1)
|
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
|
# -z [::1]:$PORT for each ZEP device
|
||||||
TERMFLAGS += $(patsubst %,-z [::1]:%, $(shell seq $(ZEP_PORT_BASE) $(ZEP_PORT_MAX)))
|
TERMFLAGS += $(patsubst %,-z [::1]:%, $(shell seq $(ZEP_PORT_BASE) $(ZEP_PORT_MAX)))
|
||||||
|
|
||||||
|
|||||||
@ -46,12 +46,19 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define DHCPV6_CLIENT_DUID_LEN (sizeof(dhcpv6_duid_l2_t) + 8U)
|
#define DHCPV6_CLIENT_DUID_LEN (sizeof(dhcpv6_duid_l2_t) + 8U)
|
||||||
#define DHCPV6_CLIENT_BUFLEN (256) /**< length for send and receive buffer */
|
#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
|
* @defgroup net_dhcpv6_conf DHCPv6 client compile configurations
|
||||||
#ifndef DHCPV6_CLIENT_PFX_LEASE_MAX
|
* @ingroup config
|
||||||
#define DHCPV6_CLIENT_PFX_LEASE_MAX (1U) /**< maximum number of prefix leases to store */
|
* @{
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @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
|
#endif
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name DHCPv6 unique identifier (DUID) definitions
|
* @name DHCPv6 unique identifier (DUID) definitions
|
||||||
|
|||||||
@ -13,3 +13,5 @@ rsource "gcoap/Kconfig"
|
|||||||
rsource "nanocoap/Kconfig"
|
rsource "nanocoap/Kconfig"
|
||||||
|
|
||||||
endmenu # CoAP
|
endmenu # CoAP
|
||||||
|
|
||||||
|
rsource "dhcpv6/Kconfig"
|
||||||
|
|||||||
19
sys/net/application_layer/dhcpv6/Kconfig
Normal file
19
sys/net/application_layer/dhcpv6/Kconfig
Normal 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
|
||||||
@ -68,7 +68,7 @@ static uint8_t send_buf[DHCPV6_CLIENT_BUFLEN];
|
|||||||
static uint8_t recv_buf[DHCPV6_CLIENT_BUFLEN];
|
static uint8_t recv_buf[DHCPV6_CLIENT_BUFLEN];
|
||||||
static uint8_t best_adv[DHCPV6_CLIENT_BUFLEN];
|
static uint8_t best_adv[DHCPV6_CLIENT_BUFLEN];
|
||||||
static uint8_t duid[DHCPV6_CLIENT_DUID_LEN];
|
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 server_t server;
|
||||||
static xtimer_t timer, rebind_timer;
|
static xtimer_t timer, rebind_timer;
|
||||||
static event_queue_t *event_queue;
|
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;
|
pfx_lease_t *lease = NULL;
|
||||||
|
|
||||||
assert(pfx_len <= 128);
|
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) {
|
if (pfx_leases[i].parent.ia_id.id == 0) {
|
||||||
lease = &pfx_leases[i];
|
lease = &pfx_leases[i];
|
||||||
lease->parent.ia_id.info.netif = netif;
|
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;
|
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;
|
uint32_t ia_id = pfx_leases[i].parent.ia_id.id;
|
||||||
if (ia_id != 0) {
|
if (ia_id != 0) {
|
||||||
dhcpv6_opt_ia_pd_t *ia_pd = (dhcpv6_opt_ia_pd_t *)(&buf[msg_len]);
|
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)) {
|
len > 0; len -= _opt_len(opt), opt = _opt_next(opt)) {
|
||||||
switch (byteorder_ntohs(opt->type)) {
|
switch (byteorder_ntohs(opt->type)) {
|
||||||
case DHCPV6_OPT_IA_PD:
|
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;
|
dhcpv6_opt_ia_pd_t *ia_pd = (dhcpv6_opt_ia_pd_t *)opt;
|
||||||
unsigned pd_t1, pd_t2;
|
unsigned pd_t1, pd_t2;
|
||||||
uint32_t ia_id = byteorder_ntohl(ia_pd->ia_id);
|
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)) {
|
len > 0; len -= _opt_len(opt), opt = _opt_next(opt)) {
|
||||||
switch (byteorder_ntohs(opt->type)) {
|
switch (byteorder_ntohs(opt->type)) {
|
||||||
case DHCPV6_OPT_IA_PD:
|
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;
|
dhcpv6_opt_iapfx_t *iapfx = NULL;
|
||||||
pfx_lease_t *lease = &pfx_leases[i];
|
pfx_lease_t *lease = &pfx_leases[i];
|
||||||
ia_pd = (dhcpv6_opt_ia_pd_t *)opt;
|
ia_pd = (dhcpv6_opt_ia_pd_t *)opt;
|
||||||
@ -777,7 +777,7 @@ static void _request_renew_rebind(uint8_t type)
|
|||||||
irt = DHCPV6_REB_TIMEOUT;
|
irt = DHCPV6_REB_TIMEOUT;
|
||||||
mrt = DHCPV6_REB_MAX_RT;
|
mrt = DHCPV6_REB_MAX_RT;
|
||||||
/* calculate MRD from prefix leases */
|
/* 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];
|
const pfx_lease_t *lease = &pfx_leases[i];
|
||||||
uint32_t valid_until = dhcpv6_client_prefix_valid_until(
|
uint32_t valid_until = dhcpv6_client_prefix_valid_until(
|
||||||
lease->parent.ia_id.info.netif,
|
lease->parent.ia_id.info.netif,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user