1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 14:03:55 +01:00

Merge pull request #13941 from leandrolanzieri/pr/kconfig_migrate/net/gnrc/rpl

gnrc/rpl: Expose configurations to Kconfig
This commit is contained in:
Cenk Gündoğan 2020-05-14 17:35:20 +02:00 committed by GitHub
commit dd610405d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 307 additions and 144 deletions

View File

@ -38,7 +38,7 @@ DEVELHELP ?= 1
# Comment this out to join RPL DODAGs even if DIOs do not contain
# DODAG Configuration Options (see the doc for more info)
# CFLAGS += -DGNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
# CFLAGS += -DCONFIG_GNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

View File

@ -44,7 +44,7 @@ DEVELHELP ?= 1
# Uncomment this to join RPL DODAGs even if DIOs do not contain
# DODAG Configuration Options (see the doc for more info)
# CFLAGS += -DGNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
# CFLAGS += -DCONFIG_GNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

View File

@ -53,7 +53,7 @@ DEVELHELP ?= 1
# Uncomment this to join RPL DODAGs even if DIOs do not contain
# DODAG Configuration Options (see the doc for more info)
# CFLAGS += -DGNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
# CFLAGS += -DCONFIG_GNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1

View File

@ -37,9 +37,9 @@
*
* If the application defines several interfaces (@ref gnrc_netif_highlander()
* returns false), then RPL will be initialized on the interface
* `GNRC_RPL_DEFAULT_NETIF`.
* Your application is responsible for setting `GNRC_RPL_DEFAULT_NETIF` to a
* valid interface PID, e.g. via `CFLAGS`.
* `CONFIG_GNRC_RPL_DEFAULT_NETIF`.
* Your application is responsible for setting `CONFIG_GNRC_RPL_DEFAULT_NETIF`
* to a valid interface PID, e.g. via `CFLAGS` or menuconfig.
*
* Initializing RPL on multiple interfaces automatically is currently not supported.
* Call `gnrc_rpl_init()` manually from your application for the desired interfaces in this case.
@ -49,14 +49,14 @@
*
* - Exclude Prefix Information Options from DIOs
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
* CFLAGS += -DGNRC_RPL_WITHOUT_PIO
* CFLAGS += -DCONFIG_GNRC_RPL_WITHOUT_PIO
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* - Modify trickle parameters
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
* CFLAGS += -DGNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS=20
* CFLAGS += -DGNRC_RPL_DEFAULT_DIO_INTERVAL_MIN=3
* CFLAGS += -DGNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT=10
* CFLAGS += -DCONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS=20
* CFLAGS += -DCONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN=3
* CFLAGS += -DCONFIG_GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT=10
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* - Make reception of DODAG_CONF optional when joining a DODAG.
@ -66,20 +66,20 @@
* The standard behaviour is to request a DODAG_CONF and join
* only a DODAG once a DODAG_CONF is received.
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
* CFLAGS += -DGNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
* CFLAGS += -DCONFIG_GNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* - Set interface for auto-initialization if more than one
* interface exists (@ref gnrc_netif_highlander() returns false)
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
* CFLAGS += -DGNRC_RPL_DEFAULT_NETIF=6
* CFLAGS += -DCONFIG_GNRC_RPL_DEFAULT_NETIF=6
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* - By default, all incoming control messages get checked for validation.
* This validation can be disabled in case the involved RPL implementations
* are known to produce valid messages.
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk}
* CFLAGS += -DGNRC_RPL_WITHOUT_VALIDATION
* CFLAGS += -DCONFIG_GNRC_RPL_WITHOUT_VALIDATION
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* @{
@ -101,6 +101,7 @@
#include <string.h>
#include <stdint.h>
#include "kernel_defines.h"
#include "net/gnrc.h"
#include "net/gnrc/ipv6.h"
#include "net/ipv6/addr.h"
@ -137,8 +138,8 @@ extern "C" {
/**
* @brief Default message queue size to use for the RPL thread.
*/
#ifndef GNRC_RPL_MSG_QUEUE_SIZE
#define GNRC_RPL_MSG_QUEUE_SIZE (8U)
#ifndef CONFIG_GNRC_RPL_MSG_QUEUE_SIZE
#define CONFIG_GNRC_RPL_MSG_QUEUE_SIZE (8U)
#endif
/**
@ -180,15 +181,15 @@ extern "C" {
* RFC 6550, section 17
* </a>
*/
#ifndef GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE
#define GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE (256)
#ifndef CONFIG_GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE
#define CONFIG_GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE (256)
#endif
/**
* @brief Maximum rank increase
*/
#ifndef GNRC_RPL_DEFAULT_MAX_RANK_INCREASE
#define GNRC_RPL_DEFAULT_MAX_RANK_INCREASE (0)
#ifndef CONFIG_GNRC_RPL_DEFAULT_MAX_RANK_INCREASE
#define CONFIG_GNRC_RPL_DEFAULT_MAX_RANK_INCREASE (0)
#endif
/**
@ -204,8 +205,8 @@ extern "C" {
/**
* @brief Default Instance ID
*/
#ifndef GNRC_RPL_DEFAULT_INSTANCE
#define GNRC_RPL_DEFAULT_INSTANCE (0)
#ifndef CONFIG_GNRC_RPL_DEFAULT_INSTANCE
#define CONFIG_GNRC_RPL_DEFAULT_INSTANCE (0)
#endif
/**
@ -217,6 +218,17 @@ extern "C" {
#define GNRC_RPL_MOP_STORING_MODE_NO_MC (0x02)
#define GNRC_RPL_MOP_STORING_MODE_MC (0x03)
/* translate Kconfig options to final value */
#if IS_ACTIVE(CONFIG_GNRC_RPL_MOP_NO_DOWNWARD_ROUTES)
#define GNRC_RPL_DEFAULT_MOP GNRC_RPL_MOP_NO_DOWNWARD_ROUTES
#elif IS_ACTIVE(CONFIG_GNRC_RPL_MOP_NON_STORING_MODE)
#define GNRC_RPL_DEFAULT_MOP GNRC_RPL_MOP_NON_STORING_MODE
#elif IS_ACTIVE(CONFIG_GNRC_RPL_MOP_STORING_MODE_NO_MC)
#define GNRC_RPL_DEFAULT_MOP GNRC_RPL_MOP_STORING_MODE_NO_MC
#elif IS_ACTIVE(CONFIG_GNRC_RPL_MOP_STORING_MODE_MC)
#define GNRC_RPL_DEFAULT_MOP GNRC_RPL_MOP_STORING_MODE_MC
#endif
/** default MOP set on compile time */
#ifndef GNRC_RPL_DEFAULT_MOP
#define GNRC_RPL_DEFAULT_MOP GNRC_RPL_MOP_STORING_MODE_NO_MC
@ -268,16 +280,16 @@ static inline bool GNRC_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
* </a>
* @{
*/
#ifndef GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS
#define GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS (20)
#ifndef CONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS
#define CONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS (20)
#endif
#ifndef GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN
#define GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN (3)
#ifndef CONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN
#define CONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN (3)
#endif
#ifndef GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT
#define GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT (10)
#ifndef CONFIG_GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT
#define CONFIG_GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT (10)
#endif
/** @} */
@ -289,11 +301,11 @@ static inline bool GNRC_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
</a>
* @{
*/
#ifndef GNRC_RPL_DEFAULT_LIFETIME
#define GNRC_RPL_DEFAULT_LIFETIME (5)
#ifndef CONFIG_GNRC_RPL_DEFAULT_LIFETIME
#define CONFIG_GNRC_RPL_DEFAULT_LIFETIME (5)
#endif
#ifndef GNRC_RPL_LIFETIME_UNIT
#define GNRC_RPL_LIFETIME_UNIT (60)
#ifndef CONFIG_GNRC_RPL_LIFETIME_UNIT
#define CONFIG_GNRC_RPL_LIFETIME_UNIT (60)
#endif
/** @} */
@ -326,37 +338,37 @@ static inline bool GNRC_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
</a>
* @{
*/
#ifndef GNRC_RPL_DAO_SEND_RETRIES
#define GNRC_RPL_DAO_SEND_RETRIES (4)
#ifndef CONFIG_GNRC_RPL_DAO_SEND_RETRIES
#define CONFIG_GNRC_RPL_DAO_SEND_RETRIES (4)
#endif
#ifndef GNRC_RPL_DAO_ACK_DELAY
#define GNRC_RPL_DAO_ACK_DELAY (3000UL)
#ifndef CONFIG_GNRC_RPL_DAO_ACK_DELAY
#define CONFIG_GNRC_RPL_DAO_ACK_DELAY (3000UL)
#endif
#ifndef GNRC_RPL_DAO_DELAY_LONG
#ifndef CONFIG_GNRC_RPL_DAO_DELAY_LONG
/**
* @brief Long delay for DAOs in milli seconds
*/
#define GNRC_RPL_DAO_DELAY_LONG (60000UL)
#define CONFIG_GNRC_RPL_DAO_DELAY_LONG (60000UL)
#endif
#ifndef GNRC_RPL_DAO_DELAY_DEFAULT
#ifndef CONFIG_GNRC_RPL_DAO_DELAY_DEFAULT
/**
* @brief Default delay for DAOs in milli seconds
*/
#define GNRC_RPL_DAO_DELAY_DEFAULT (1000UL)
#define CONFIG_GNRC_RPL_DAO_DELAY_DEFAULT (1000UL)
#endif
#ifndef GNRC_RPL_DAO_DELAY_JITTER
#ifndef CONFIG_GNRC_RPL_DAO_DELAY_JITTER
/**
* @brief Jitter for DAOs in milli seconds
*/
#define GNRC_RPL_DAO_DELAY_JITTER (1000UL)
#define CONFIG_GNRC_RPL_DAO_DELAY_JITTER (1000UL)
#endif
/** @} */
/**
* @brief Cleanup interval in milliseconds.
*/
#ifndef GNRC_RPL_CLEANUP_TIME
#define GNRC_RPL_CLEANUP_TIME (5 * MS_PER_SEC)
#ifndef CONFIG_GNRC_RPL_CLEANUP_TIME
#define CONFIG_GNRC_RPL_CLEANUP_TIME (5 * MS_PER_SEC)
#endif
/**
@ -391,7 +403,7 @@ static inline bool GNRC_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
/**
* @brief Rank of the root node
*/
#define GNRC_RPL_ROOT_RANK (GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE)
#define GNRC_RPL_ROOT_RANK (CONFIG_GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE)
/**
* @brief DIS ICMPv6 code
@ -484,15 +496,15 @@ extern netstats_rpl_t gnrc_rpl_netstats;
/**
* @brief Number of DIS retries before parent times out
*/
#ifndef GNRC_RPL_PARENT_TIMEOUT_DIS_RETRIES
#define GNRC_RPL_PARENT_TIMEOUT_DIS_RETRIES (3)
#ifndef CONFIG_GNRC_RPL_PARENT_TIMEOUT_DIS_RETRIES
#define CONFIG_GNRC_RPL_PARENT_TIMEOUT_DIS_RETRIES (3)
#endif
/**
* @brief Default network interface for GNRC RPL
*/
#ifndef GNRC_RPL_DEFAULT_NETIF
#define GNRC_RPL_DEFAULT_NETIF (KERNEL_PID_UNDEF)
#ifndef CONFIG_GNRC_RPL_DEFAULT_NETIF
#define CONFIG_GNRC_RPL_DEFAULT_NETIF (KERNEL_PID_UNDEF)
#endif
/**
@ -655,20 +667,21 @@ void gnrc_rpl_send(gnrc_pktsnip_t *pkt, kernel_pid_t iface, ipv6_addr_t *src, ip
*/
uint8_t gnrc_rpl_gen_instance_id(bool local);
#ifndef GNRC_RPL_WITHOUT_PIO
/**
* @brief (De-)Activate the transmission of Prefix Information Options within DIOs
* for a particular DODAG
* for a particular DODAG. This function has no effect if
* CONFIG_GNRC_RPL_WITHOUT_PIO is set.
*
* @param[in] dodag Pointer to the DODAG
* @param[in] status true for activating PIOs and false for deactivating them
*/
static inline void gnrc_rpl_config_pio(gnrc_rpl_dodag_t *dodag, bool status)
{
dodag->dio_opts = (dodag->dio_opts & ~GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO) |
(status << GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT);
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) {
dodag->dio_opts = (dodag->dio_opts & ~GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO) |
(status << GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT);
}
}
#endif
#ifdef __cplusplus
}

View File

@ -149,7 +149,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent);
/**
* @brief Removes the dodag state of @p dodag after
* GNRC_RPL_CLEANUP_TIME milliseconds
* CONFIG_GNRC_RPL_CLEANUP_TIME milliseconds
*
* @param[in] dodag Pointer to the DODAG
*/

View File

@ -12,5 +12,6 @@ rsource "link_layer/lorawan/Kconfig"
rsource "netif/Kconfig"
rsource "network_layer/ipv6/Kconfig"
rsource "network_layer/sixlowpan/Kconfig"
rsource "routing/rpl/Kconfig"
endmenu # GNRC Network Stack

View File

@ -164,12 +164,12 @@ void dhcpv6_client_conf_prefix(unsigned iface, const ipv6_addr_t *pfx,
if (IS_USED(MODULE_GNRC_RPL)) {
gnrc_rpl_init(netif->pid);
gnrc_rpl_instance_t *inst = gnrc_rpl_instance_get(
GNRC_RPL_DEFAULT_INSTANCE
CONFIG_GNRC_RPL_DEFAULT_INSTANCE
);
if (inst) {
gnrc_rpl_instance_remove(inst);
}
gnrc_rpl_root_init(GNRC_RPL_DEFAULT_INSTANCE, &addr, false, false);
gnrc_rpl_root_init(CONFIG_GNRC_RPL_DEFAULT_INSTANCE, &addr, false, false);
}
}
}

View File

@ -188,11 +188,11 @@ void uhcp_handle_prefix(uint8_t *prefix, uint8_t prefix_len, uint16_t lifetime,
#ifdef MODULE_GNRC_RPL
gnrc_rpl_init(gnrc_wireless_interface);
gnrc_rpl_instance_t *inst = gnrc_rpl_instance_get(
GNRC_RPL_DEFAULT_INSTANCE);
CONFIG_GNRC_RPL_DEFAULT_INSTANCE);
if (inst) {
gnrc_rpl_instance_remove(inst);
}
gnrc_rpl_root_init(GNRC_RPL_DEFAULT_INSTANCE, (ipv6_addr_t*)prefix, false,
gnrc_rpl_root_init(CONFIG_GNRC_RPL_DEFAULT_INSTANCE, (ipv6_addr_t*)prefix, false,
false);
#endif
LOG_INFO("gnrc_uhcpc: uhcp_handle_prefix(): configured new prefix %s/%u\n",

View File

@ -0,0 +1,150 @@
# Copyright (c) 2020 HAW Hamburg
#
# 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_GNRC_RPL
bool "Configure RPL routing protocol"
depends on MODULE_GNRC_RPL
if KCONFIG_MODULE_GNRC_RPL
menu "Trickle parameters"
config GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS
int "DIO interval doublings"
default 20
help
@see https://tools.ietf.org/html/rfc6550#section-8.3.1
config GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN
int "DIO interval minimum"
default 3
help
@see https://tools.ietf.org/html/rfc6550#section-8.3.1
config GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT
int "DIO redundancy constant"
default 10
help
@see https://tools.ietf.org/html/rfc6550#section-8.3.1
endmenu # Trickle parameters
menu "Default parent and route entry lifetime"
config GNRC_RPL_DEFAULT_LIFETIME
int "Default lifetime"
default 5
help
The default lifetime will be multiplied but the lifetime unit to obtain
the resulting lifetime.
@see https://tools.ietf.org/html/rfc6550#section-6.7.6
"DODAG Configuration"
config GNRC_RPL_LIFETIME_UNIT
int "Lifetime unit"
default 60
endmenu # Default parent and route entry lifetime
menu "Parameters used for DAO handling"
config GNRC_RPL_DAO_SEND_RETRIES
int "Send retries"
default 4
config GNRC_RPL_DAO_ACK_DELAY
int "Acknowledge delay in milliseconds [ms]"
default 3000
config GNRC_RPL_DAO_DELAY_LONG
int "Long delay for DAOs in milliseconds [ms]"
default 60000
config GNRC_RPL_DAO_DELAY_DEFAULT
int "Default delay for DAOs in milliseconds [ms]"
default 1000
config GNRC_RPL_DAO_DELAY_JITTER
int "Jitter for DAOs in milliseconds [ms]"
default 1000
config GNRC_RPL_CLEANUP_TIME
int "Cleanup interval in milliseconds [ms]"
default 5000
endmenu # Parameters used for DAO handling
choice
bool "Mode of Operation"
default GNRC_RPL_MOP_STORING_MODE_NO_MC
config GNRC_RPL_MOP_NO_DOWNWARD_ROUTES
bool "No downward routes"
config GNRC_RPL_MOP_NON_STORING_MODE
bool "Non storing"
config GNRC_RPL_MOP_STORING_MODE_NO_MC
bool "Storing and no multicast"
config GNRC_RPL_MOP_STORING_MODE_MC
bool "Storing and multicast"
endchoice
config GNRC_RPL_WITHOUT_PIO
bool "Exclude Prefix Information Options from DIOs"
config GNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
bool "Optional DODAG_CONF when joining a DODAG"
help
This will use the default trickle parameters until a DODAG_CONF is
received from the parent. The DODAG_CONF is requested once from the
parent while joining the DODAG. The standard behaviour is to request a
DODAG_CONF and join once a DODAG once a DODAG_CONF is received.
config GNRC_RPL_WITHOUT_VALIDATION
bool "Disable RPL control message validation"
help
By default, all incoming control messages get checked for validation.
This validation can be disabled in case the involved RPL implementations
are known to produce valid messages.
config GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE
int "Default minimum hop rank increase"
default 256
help
@see https://tools.ietf.org/html/rfc6550#section-17
config GNRC_RPL_DEFAULT_MAX_RANK_INCREASE
int "Maximum rank increase"
default 0
config GNRC_RPL_DEFAULT_INSTANCE
int "Default Instance ID"
default 0
config GNRC_RPL_PARENT_TIMEOUT_DIS_RETRIES
int "Number of DIS retries"
default 3
help
This is the number of DIS retries before the parent times out.
config GNRC_RPL_DEFAULT_NETIF
int "Default network interface to run the protocol on"
default 0
depends on MODULE_AUTO_INIT_GNRC_RPL
config GNRC_RPL_MSG_QUEUE_SIZE
int "Thread's message queue size"
default 8
endif # KCONFIG_MODULE_GNRC_RPL

View File

@ -16,6 +16,7 @@
*/
#include <string.h>
#include "kernel_defines.h"
#include "net/icmpv6.h"
#include "net/ipv6.h"
@ -43,7 +44,7 @@ static uint32_t _lt_time = GNRC_RPL_LIFETIME_UPDATE_STEP * US_PER_SEC;
static xtimer_t _lt_timer;
static msg_t _lt_msg = { .type = GNRC_RPL_MSG_TYPE_LIFETIME_UPDATE };
#endif
static msg_t _msg_q[GNRC_RPL_MSG_QUEUE_SIZE];
static msg_t _msg_q[CONFIG_GNRC_RPL_MSG_QUEUE_SIZE];
static gnrc_netreg_entry_t _me_reg;
static mutex_t _inst_id_mutex = MUTEX_INIT;
static uint8_t _instance_id;
@ -122,19 +123,20 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_
dodag->dtsn = 1;
dodag->prf = 0;
dodag->dio_interval_doubl = GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS;
dodag->dio_min = GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN;
dodag->dio_redun = GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT;
dodag->default_lifetime = GNRC_RPL_DEFAULT_LIFETIME;
dodag->lifetime_unit = GNRC_RPL_LIFETIME_UNIT;
dodag->dio_interval_doubl = CONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS;
dodag->dio_min = CONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN;
dodag->dio_redun = CONFIG_GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT;
dodag->default_lifetime = CONFIG_GNRC_RPL_DEFAULT_LIFETIME;
dodag->lifetime_unit = CONFIG_GNRC_RPL_LIFETIME_UNIT;
dodag->version = GNRC_RPL_COUNTER_INIT;
dodag->grounded = GNRC_RPL_GROUNDED;
dodag->node_status = GNRC_RPL_ROOT_NODE;
dodag->my_rank = GNRC_RPL_ROOT_RANK;
dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_DODAG_CONF;
#ifndef GNRC_RPL_WITHOUT_PIO
dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO;
#endif
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) {
dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO;
}
trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_MSG,
(1 << dodag->dio_min), dodag->dio_interval_doubl,
@ -245,7 +247,7 @@ static void *_event_loop(void *args)
msg_t msg, reply;
(void)args;
msg_init_queue(_msg_q, GNRC_RPL_MSG_QUEUE_SIZE);
msg_init_queue(_msg_q, CONFIG_GNRC_RPL_MSG_QUEUE_SIZE);
/* preinitialize ACK */
reply.type = GNRC_NETAPI_MSG_TYPE_ACK;
@ -323,8 +325,8 @@ void gnrc_rpl_delay_dao(gnrc_rpl_dodag_t *dodag)
{
evtimer_del(&gnrc_rpl_evtimer, (evtimer_event_t *)&dodag->dao_event);
((evtimer_event_t *)&(dodag->dao_event))->offset = random_uint32_range(
GNRC_RPL_DAO_DELAY_DEFAULT,
GNRC_RPL_DAO_DELAY_DEFAULT + GNRC_RPL_DAO_DELAY_JITTER
CONFIG_GNRC_RPL_DAO_DELAY_DEFAULT,
CONFIG_GNRC_RPL_DAO_DELAY_DEFAULT + CONFIG_GNRC_RPL_DAO_DELAY_JITTER
);
evtimer_add_msg(&gnrc_rpl_evtimer, &dodag->dao_event, gnrc_rpl_pid);
dodag->dao_counter = 0;
@ -335,8 +337,8 @@ void gnrc_rpl_long_delay_dao(gnrc_rpl_dodag_t *dodag)
{
evtimer_del(&gnrc_rpl_evtimer, (evtimer_event_t *)&dodag->dao_event);
((evtimer_event_t *)&(dodag->dao_event))->offset = random_uint32_range(
GNRC_RPL_DAO_DELAY_LONG,
GNRC_RPL_DAO_DELAY_LONG + GNRC_RPL_DAO_DELAY_JITTER
CONFIG_GNRC_RPL_DAO_DELAY_LONG,
CONFIG_GNRC_RPL_DAO_DELAY_LONG + CONFIG_GNRC_RPL_DAO_DELAY_JITTER
);
evtimer_add_msg(&gnrc_rpl_evtimer, &dodag->dao_event, gnrc_rpl_pid);
dodag->dao_counter = 0;
@ -353,11 +355,12 @@ void _dao_handle_send(gnrc_rpl_dodag_t *dodag)
return;
}
#endif
if ((dodag->dao_ack_received == false) && (dodag->dao_counter < GNRC_RPL_DAO_SEND_RETRIES)) {
if ((dodag->dao_ack_received == false) &&
(dodag->dao_counter < CONFIG_GNRC_RPL_DAO_SEND_RETRIES)) {
dodag->dao_counter++;
gnrc_rpl_send_DAO(dodag->instance, NULL, dodag->default_lifetime);
evtimer_del(&gnrc_rpl_evtimer, (evtimer_event_t *)&dodag->dao_event);
((evtimer_event_t *)&(dodag->dao_event))->offset = GNRC_RPL_DAO_ACK_DELAY;
((evtimer_event_t *)&(dodag->dao_event))->offset = CONFIG_GNRC_RPL_DAO_ACK_DELAY;
evtimer_add_msg(&gnrc_rpl_evtimer, &dodag->dao_event, gnrc_rpl_pid);
}
else if (dodag->dao_ack_received == false) {
@ -368,7 +371,7 @@ void _dao_handle_send(gnrc_rpl_dodag_t *dodag)
uint8_t gnrc_rpl_gen_instance_id(bool local)
{
mutex_lock(&_inst_id_mutex);
uint8_t instance_id = GNRC_RPL_DEFAULT_INSTANCE;
uint8_t instance_id = CONFIG_GNRC_RPL_DEFAULT_INSTANCE;
if (local) {
instance_id = ((_instance_id++) | GNRC_RPL_INSTANCE_ID_MSB);

View File

@ -41,24 +41,24 @@ void auto_init_gnrc_rpl(void)
gnrc_rpl_init(netif->pid);
return;
}
else if (GNRC_RPL_DEFAULT_NETIF != KERNEL_PID_UNDEF) {
if (gnrc_netif_get_by_pid(GNRC_RPL_DEFAULT_NETIF) != NULL) {
else if (CONFIG_GNRC_RPL_DEFAULT_NETIF != KERNEL_PID_UNDEF) {
if (gnrc_netif_get_by_pid(CONFIG_GNRC_RPL_DEFAULT_NETIF) != NULL) {
DEBUG("auto_init_gnrc_rpl: initializing RPL on interface %" PRIkernel_pid "\n",
(kernel_pid_t) GNRC_RPL_DEFAULT_NETIF);
gnrc_rpl_init(GNRC_RPL_DEFAULT_NETIF);
(kernel_pid_t) CONFIG_GNRC_RPL_DEFAULT_NETIF);
gnrc_rpl_init(CONFIG_GNRC_RPL_DEFAULT_NETIF);
return;
}
/* XXX this is just a work-around ideally this would happen with
* an `up` event of the GNRC_RPL_DEFAULT_NETIF */
* an `up` event of the CONFIG_GNRC_RPL_DEFAULT_NETIF */
DEBUG("auto_init_gnrc_rpl: could not initialize RPL on interface %" PRIkernel_pid" - "
"interface does not exist\n", (kernel_pid_t) GNRC_RPL_DEFAULT_NETIF);
"interface does not exist\n", (kernel_pid_t) CONFIG_GNRC_RPL_DEFAULT_NETIF);
return;
}
else {
/* XXX this is just a work-around ideally this should be defined in some
* run-time interface configuration */
DEBUG("auto_init_gnrc_rpl: please specify an interface "
"by setting GNRC_RPL_DEFAULT_NETIF\n");
"by setting CONFIG_GNRC_RPL_DEFAULT_NETIF\n");
}
}
#else

View File

@ -17,6 +17,7 @@
*/
#include <string.h>
#include "kernel_defines.h"
#include "net/af.h"
#include "net/icmpv6.h"
@ -33,9 +34,7 @@
#endif
#include "net/gnrc/rpl.h"
#ifndef GNRC_RPL_WITHOUT_VALIDATION
#include "gnrc_rpl_internal/validation.h"
#endif
#ifdef MODULE_GNRC_RPL_P2P
#include "net/gnrc/rpl/p2p_structs.h"
@ -285,7 +284,6 @@ gnrc_pktsnip_t *_dis_solicited_opt_build(gnrc_pktsnip_t *pkt, gnrc_rpl_internal_
return opt_snip;
}
#ifndef GNRC_RPL_WITHOUT_PIO
static bool _get_pl_entry(unsigned iface, ipv6_addr_t *pfx,
unsigned pfx_len, gnrc_ipv6_nib_pl_t *ple)
{
@ -340,7 +338,6 @@ gnrc_pktsnip_t *_dio_prefix_info_build(gnrc_pktsnip_t *pkt, gnrc_rpl_dodag_t *do
prefix_info->prefix_len);
return opt_snip;
}
#endif
void gnrc_rpl_send_DIO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination)
{
@ -365,13 +362,12 @@ void gnrc_rpl_send_DIO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination)
}
#endif
#ifndef GNRC_RPL_WITHOUT_PIO
if (dodag->dio_opts & GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO) {
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO) &&
dodag->dio_opts & GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO) {
if ((pkt = _dio_prefix_info_build(pkt, dodag)) == NULL) {
return;
}
}
#endif
if (dodag->dio_opts & GNRC_RPL_REQ_DIO_OPT_DODAG_CONF) {
if ((pkt = _dio_dodag_conf_build(pkt, dodag)) == NULL) {
@ -506,13 +502,11 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
eui64_t iid;
*included_opts = 0;
#ifndef GNRC_RPL_WITHOUT_VALIDATION
if (!gnrc_rpl_validation_options(msg_type, inst, opt, len)) {
return false;
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_VALIDATION)){
if (!gnrc_rpl_validation_options(msg_type, inst, opt, len)) {
return false;
}
}
#else
(void) msg_type;
#endif
while(l < len) {
switch(opt->type) {
@ -556,9 +550,11 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
case (GNRC_RPL_OPT_PREFIX_INFO):
DEBUG("RPL: Prefix Information DIO option parsed\n");
*included_opts |= ((uint32_t) 1) << GNRC_RPL_OPT_PREFIX_INFO;
#ifndef GNRC_RPL_WITHOUT_PIO
dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO;
#endif
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) {
dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO;
}
gnrc_rpl_opt_prefix_info_t *pi = (gnrc_rpl_opt_prefix_info_t *) opt;
/* check for the auto address-configuration flag */
gnrc_netif_t *netif = gnrc_netif_get_by_pid(dodag->iface);
@ -681,11 +677,11 @@ void gnrc_rpl_recv_DIS(gnrc_rpl_dis_t *dis, kernel_pid_t iface, ipv6_addr_t *src
gnrc_rpl_netstats_rx_DIS(&gnrc_rpl_netstats, len, (dst && !ipv6_addr_is_multicast(dst)));
#endif
#ifndef GNRC_RPL_WITHOUT_VALIDATION
if (!gnrc_rpl_validation_DIS(dis, len)) {
return;
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_VALIDATION)) {
if (!gnrc_rpl_validation_DIS(dis, len)) {
return;
}
}
#endif
if (ipv6_addr_is_multicast(dst)) {
for (uint8_t i = 0; i < GNRC_RPL_INSTANCES_NUMOF; ++i) {
@ -731,11 +727,11 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
gnrc_rpl_netstats_rx_DIO(&gnrc_rpl_netstats, len, (dst && !ipv6_addr_is_multicast(dst)));
#endif
#ifndef GNRC_RPL_WITHOUT_VALIDATION
if (!gnrc_rpl_validation_DIO(dio, len)) {
return;
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_VALIDATION)) {
if (!gnrc_rpl_validation_DIO(dio, len)) {
return;
}
}
#endif
len -= (sizeof(gnrc_rpl_dio_t) + sizeof(icmpv6_hdr_t));
@ -790,15 +786,16 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
}
if (!(included_opts & (((uint32_t) 1) << GNRC_RPL_OPT_DODAG_CONF))) {
#ifndef GNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN
DEBUG("RPL: DIO without DODAG_CONF option - remove DODAG and request new DIO\n");
gnrc_rpl_instance_remove(inst);
gnrc_rpl_send_DIS(NULL, src, NULL, 0);
return;
#else
DEBUG("RPL: DIO without DODAG_CONF option - use default trickle parameters\n");
gnrc_rpl_send_DIS(NULL, src, NULL, 0);
#endif
if (!IS_ACTIVE(CONFIG_GNRC_RPL_DODAG_CONF_OPTIONAL_ON_JOIN)) {
DEBUG("RPL: DIO without DODAG_CONF option - remove DODAG and request new DIO\n");
gnrc_rpl_instance_remove(inst);
gnrc_rpl_send_DIS(NULL, src, NULL, 0);
return;
}
else {
DEBUG("RPL: DIO without DODAG_CONF option - use default trickle parameters\n");
gnrc_rpl_send_DIS(NULL, src, NULL, 0);
}
}
/* if there was no address created manually or by a PIO on the interface,
@ -1147,11 +1144,11 @@ void gnrc_rpl_recv_DAO(gnrc_rpl_dao_t *dao, kernel_pid_t iface, ipv6_addr_t *src
gnrc_rpl_instance_t *inst = NULL;
gnrc_rpl_dodag_t *dodag = NULL;
#ifndef GNRC_RPL_WITHOUT_VALIDATION
if (!gnrc_rpl_validation_DAO(dao, len)) {
return;
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_VALIDATION)) {
if (!gnrc_rpl_validation_DAO(dao, len)) {
return;
}
}
#endif
gnrc_rpl_opt_t *opts = (gnrc_rpl_opt_t *) (dao + 1);
@ -1215,11 +1212,11 @@ void gnrc_rpl_recv_DAO_ACK(gnrc_rpl_dao_ack_t *dao_ack, kernel_pid_t iface, ipv6
gnrc_rpl_netstats_rx_DAO_ACK(&gnrc_rpl_netstats, len, (dst && !ipv6_addr_is_multicast(dst)));
#endif
#ifndef GNRC_RPL_WITHOUT_VALIDATION
if (!gnrc_rpl_validation_DAO_ACK(dao_ack, len, dst)) {
return;
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_VALIDATION)) {
if (!gnrc_rpl_validation_DAO_ACK(dao_ack, len, dst)) {
return;
}
}
#endif
if ((inst = gnrc_rpl_instance_get(dao_ack->instance_id)) == NULL) {
DEBUG("RPL: DAO-ACK with unknown instance id (%d) received\n", dao_ack->instance_id);

View File

@ -87,8 +87,8 @@ bool gnrc_rpl_instance_add(uint8_t instance_id, gnrc_rpl_instance_t **inst)
if (*inst != NULL) {
(*inst)->id = instance_id;
(*inst)->state = 1;
(*inst)->max_rank_inc = GNRC_RPL_DEFAULT_MAX_RANK_INCREASE;
(*inst)->min_hop_rank_inc = GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE;
(*inst)->max_rank_inc = CONFIG_GNRC_RPL_DEFAULT_MAX_RANK_INCREASE;
(*inst)->min_hop_rank_inc = CONFIG_GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE;
(*inst)->dodag.parents = NULL;
(*inst)->cleanup_event.msg.content.ptr = (*inst);
return true;
@ -145,11 +145,11 @@ bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, k
dodag->my_rank = GNRC_RPL_INFINITE_RANK;
dodag->trickle.callback.func = &_rpl_trickle_send_dio;
dodag->trickle.callback.args = instance;
dodag->dio_interval_doubl = GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS;
dodag->dio_min = GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN;
dodag->dio_redun = GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT;
dodag->default_lifetime = GNRC_RPL_DEFAULT_LIFETIME;
dodag->lifetime_unit = GNRC_RPL_LIFETIME_UNIT;
dodag->dio_interval_doubl = CONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS;
dodag->dio_min = CONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_MIN;
dodag->dio_redun = CONFIG_GNRC_RPL_DEFAULT_DIO_REDUNDANCY_CONSTANT;
dodag->default_lifetime = CONFIG_GNRC_RPL_DEFAULT_LIFETIME;
dodag->lifetime_unit = CONFIG_GNRC_RPL_LIFETIME_UNIT;
dodag->node_status = GNRC_RPL_NORMAL_NODE;
dodag->dao_seq = GNRC_RPL_COUNTER_INIT;
dodag->dtsn = 0;
@ -249,7 +249,7 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent)
void gnrc_rpl_cleanup_start(gnrc_rpl_dodag_t *dodag)
{
evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)&dodag->instance->cleanup_event);
((evtimer_event_t *)&(dodag->instance->cleanup_event))->offset = GNRC_RPL_CLEANUP_TIME;
((evtimer_event_t *)&(dodag->instance->cleanup_event))->offset = CONFIG_GNRC_RPL_CLEANUP_TIME;
dodag->instance->cleanup_event.msg.type = GNRC_RPL_MSG_TYPE_INSTANCE_CLEANUP;
evtimer_add_msg(&gnrc_rpl_evtimer, &dodag->instance->cleanup_event, gnrc_rpl_pid);
}
@ -388,8 +388,8 @@ gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_
if (gnrc_rpl_instance_add(instance_id, &inst)) {
inst->of = (gnrc_rpl_of_t *) gnrc_rpl_get_of_for_ocp(GNRC_RPL_DEFAULT_OCP);
inst->mop = mop;
inst->min_hop_rank_inc = GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE;
inst->max_rank_inc = GNRC_RPL_DEFAULT_MAX_RANK_INCREASE;
inst->min_hop_rank_inc = CONFIG_GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE;
inst->max_rank_inc = CONFIG_GNRC_RPL_DEFAULT_MAX_RANK_INCREASE;
}
else if (inst == NULL) {
DEBUG("RPL: could not allocate memory for a new instance with id %d\n", instance_id);

View File

@ -72,7 +72,8 @@ extern evtimer_msg_t gnrc_rpl_evtimer;
/**
* @brief Parent has timed out.
*/
#define GNRC_RPL_PARENT_TIMEOUT (GNRC_RPL_PARENT_STALE + GNRC_RPL_PARENT_TIMEOUT_DIS_RETRIES)
#define GNRC_RPL_PARENT_TIMEOUT (GNRC_RPL_PARENT_STALE + \
CONFIG_GNRC_RPL_PARENT_TIMEOUT_DIS_RETRIES)
/** @} */
#ifdef __cplusplus

View File

@ -66,7 +66,7 @@ uint16_t calc_rank(gnrc_rpl_dodag_t *dodag, uint16_t base_rank)
add = dodag->instance->min_hop_rank_inc;
}
else {
add = GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE;
add = CONFIG_GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE;
}
if ((base_rank + add) < base_rank) {

View File

@ -87,7 +87,7 @@ gnrc_rpl_instance_t *gnrc_rpl_p2p_root_init(uint8_t instance_id, ipv6_addr_t *do
instance->max_rank_inc = 0;
dodag->dtsn = 0;
dodag->prf = 0;
dodag->dio_interval_doubl = GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS;
dodag->dio_interval_doubl = CONFIG_GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS;
dodag->dio_min = GNRC_RPL_P2P_DEFAULT_DIO_INTERVAL_MIN;
dodag->dio_redun = GNRC_RPL_P2P_DEFAULT_DIO_REDUNDANCY_CONSTANT;
dodag->default_lifetime = GNRC_RPL_P2P_DEFAULT_LIFETIME;

View File

@ -344,7 +344,6 @@ int _gnrc_rpl_operation(bool leaf, char *arg1)
return 0;
}
#ifndef GNRC_RPL_WITHOUT_PIO
int _gnrc_rpl_set_pio(char *inst_id, bool status)
{
uint8_t instance_id = atoi(inst_id);
@ -360,7 +359,6 @@ int _gnrc_rpl_set_pio(char *inst_id, bool status)
printf("success: %sactivated PIO transmissions\n", status ? "" : "de");
return 0;
}
#endif
int _gnrc_rpl(int argc, char **argv)
{
@ -408,8 +406,7 @@ int _gnrc_rpl(int argc, char **argv)
}
}
else if (strcmp(argv[1], "set") == 0) {
if (argc > 2) {
#ifndef GNRC_RPL_WITHOUT_PIO
if ((argc > 2) && !IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) {
if (strcmp(argv[2], "pio") == 0) {
if ((argc == 5) && (strcmp(argv[3], "on") == 0)) {
return _gnrc_rpl_set_pio(argv[4], true);
@ -418,7 +415,6 @@ int _gnrc_rpl(int argc, char **argv)
return _gnrc_rpl_set_pio(argv[4], false);
}
}
#endif
}
}
#ifdef MODULE_GNRC_RPL_P2P
@ -448,9 +444,11 @@ int _gnrc_rpl(int argc, char **argv)
puts("* router <instance_id>\t\t\t- operate as router in the instance");
puts("* send dis\t\t\t\t- send a multicast DIS");
puts("* send dis <VID_flags> <version> <instance_id> <dodag_id> - send a multicast DIS with SOL option");
#ifndef GNRC_RPL_WITHOUT_PIO
puts("* set pio <on/off> <instance_id>\t- (de-)activate PIO transmissions in DIOs");
#endif
if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) {
puts("* set pio <on/off> <instance_id>\t- (de-)activate PIO transmissions in DIOs");
}
puts("* show\t\t\t\t\t- show instance and dodag tables");
return 0;
}