From 1a7133bbf28058393dca9450b8d91da7b2c28ac1 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Mon, 25 Apr 2016 14:51:25 +0200 Subject: [PATCH] Simplified configuration of RPL non-storing mode --- core/contiki-default-conf.h | 13 ++++++ core/net/rpl/rpl-conf.h | 21 ---------- core/net/rpl/rpl-private.h | 40 +++++++++++++++++++ .../ipv6/rpl-border-router/project-conf.h | 18 +++++---- examples/ipv6/rpl-collect/project-conf.h | 20 +++++----- examples/ipv6/rpl-udp/project-conf.h | 16 +++++--- .../23-rpl-non-storing/code/project-conf.h | 6 --- 7 files changed, 85 insertions(+), 49 deletions(-) diff --git a/core/contiki-default-conf.h b/core/contiki-default-conf.h index 36bf6afe1..c26a2b8df 100644 --- a/core/contiki-default-conf.h +++ b/core/contiki-default-conf.h @@ -148,12 +148,25 @@ #endif /* NBR_TABLE_FIND_REMOVABLE */ #endif /* UIP_CONF_IPV6_RPL */ +/* RPL_CONF_MOP specifies the RPL mode of operation that will be + * advertised by the RPL root. Possible values: RPL_MOP_NO_DOWNWARD_ROUTES, + * RPL_MOP_NON_STORING, RPL_MOP_STORING_NO_MULTICAST, RPL_MOP_STORING_MULTICAST */ +#ifndef RPL_CONF_MOP +#define RPL_CONF_MOP RPL_MOP_STORING_NO_MULTICAST +#endif /* RPL_CONF_MOP */ + /* UIP_CONF_MAX_ROUTES specifies the maximum number of routes that each node will be able to handle. */ #ifndef UIP_CONF_MAX_ROUTES #define UIP_CONF_MAX_ROUTES 20 #endif /* UIP_CONF_MAX_ROUTES */ +/* RPL_NS_CONF_LINK_NUM specifies the maximum number of links a RPL root + * will maintain in non-storing mode. */ +#ifndef RPL_NS_CONF_LINK_NUM +#define RPL_NS_CONF_LINK_NUM 20 +#endif /* RPL_NS_CONF_LINK_NUM */ + /* UIP_CONF_UDP specifies if UDP support should be included or not. Disabling UDP saves memory but breaks a lot of stuff. */ #ifndef UIP_CONF_UDP diff --git a/core/net/rpl/rpl-conf.h b/core/net/rpl/rpl-conf.h index 0148e11e5..6479dd374 100644 --- a/core/net/rpl/rpl-conf.h +++ b/core/net/rpl/rpl-conf.h @@ -235,27 +235,6 @@ #define RPL_PREFERENCE 0 #endif -/* - * Embed support for storing mode - */ -#ifdef RPL_CONF_WITH_STORING -#define RPL_WITH_STORING RPL_CONF_WITH_STORING -#else /* RPL_CONF_WITH_STORING */ -#define RPL_WITH_STORING 1 -#endif /* RPL_CONF_WITH_STORING */ - -/* - * Embed support for non-storing mode - */ -#ifdef RPL_CONF_WITH_NON_STORING -#define RPL_WITH_NON_STORING RPL_CONF_WITH_NON_STORING -#else /* RPL_CONF_WITH_NON_STORING */ -#define RPL_WITH_NON_STORING 0 -#endif /* RPL_CONF_WITH_NON_STORING */ - -#define RPL_IS_STORING(instance) (RPL_WITH_STORING && ((instance) != NULL) && ((instance)->mop > RPL_MOP_NON_STORING)) -#define RPL_IS_NON_STORING(instance) (RPL_WITH_NON_STORING && ((instance) != NULL) && ((instance)->mop == RPL_MOP_NON_STORING)) - /* * RPL DAO ACK support. When enabled, DAO ACK will be sent and requested. * This will also enable retransmission of DAO when no ack is received. diff --git a/core/net/rpl/rpl-private.h b/core/net/rpl/rpl-private.h index 72ac12198..34d2e4445 100644 --- a/core/net/rpl/rpl-private.h +++ b/core/net/rpl/rpl-private.h @@ -44,6 +44,8 @@ #include "sys/clock.h" #include "sys/ctimer.h" #include "net/ipv6/uip-ds6.h" +#include "net/ipv6/uip-ds6-route.h" +#include "net/rpl/rpl-ns.h" #include "net/ipv6/multicast/uip-mcast6.h" /*---------------------------------------------------------------------------*/ @@ -197,6 +199,7 @@ #define RPL_MOP_STORING_NO_MULTICAST 2 #define RPL_MOP_STORING_MULTICAST 3 +/* RPL Mode of operation */ #ifdef RPL_CONF_MOP #define RPL_MOP_DEFAULT RPL_CONF_MOP #else /* RPL_CONF_MOP */ @@ -207,6 +210,43 @@ #endif /* UIP_IPV6_MULTICAST_RPL */ #endif /* RPL_CONF_MOP */ +/* + * Embed support for storing mode + */ +#ifdef RPL_CONF_WITH_STORING +#define RPL_WITH_STORING RPL_CONF_WITH_STORING +#else /* RPL_CONF_WITH_STORING */ +/* By default: embed support for non-storing if and only if the configured MOP is not non-storing */ +#define RPL_WITH_STORING (RPL_MOP_DEFAULT != RPL_MOP_NON_STORING) +#endif /* RPL_CONF_WITH_STORING */ + +/* + * Embed support for non-storing mode + */ +#ifdef RPL_CONF_WITH_NON_STORING +#define RPL_WITH_NON_STORING RPL_CONF_WITH_NON_STORING +#else /* RPL_CONF_WITH_NON_STORING */ +/* By default: embed support for non-storing if and only if the configured MOP is non-storing */ +#define RPL_WITH_NON_STORING (RPL_MOP_DEFAULT == RPL_MOP_NON_STORING) +#endif /* RPL_CONF_WITH_NON_STORING */ + +#if RPL_WITH_STORING && (UIP_DS6_ROUTE_NB == 0) +#error "RPL with storing mode included but #routes == 0. Set UIP_CONF_MAX_ROUTES accordingly." +#if !RPL_WITH_NON_STORING && (RPL_NS_LINK_NUM > 0) +#error "You might also want to set RPL_NS_CONF_LINK_NUM to 0." +#endif +#endif + +#if RPL_WITH_NON_STORING && (RPL_NS_LINK_NUM == 0) +#error "RPL with non-storing mode included but #links == 0. Set RPL_NS_CONF_LINK_NUM accordingly." +#if !RPL_WITH_STORING && (UIP_DS6_ROUTE_NB > 0) +#error "You might also want to set UIP_CONF_MAX_ROUTES to 0." +#endif +#endif + +#define RPL_IS_STORING(instance) (RPL_WITH_STORING && ((instance) != NULL) && ((instance)->mop > RPL_MOP_NON_STORING)) +#define RPL_IS_NON_STORING(instance) (RPL_WITH_NON_STORING && ((instance) != NULL) && ((instance)->mop == RPL_MOP_NON_STORING)) + /* Emit a pre-processor error if the user configured multicast with bad MOP */ #if RPL_CONF_MULTICAST && (RPL_MOP_DEFAULT != RPL_MOP_STORING_MULTICAST) #error "RPL Multicast requires RPL_MOP_DEFAULT==3. Check contiki-conf.h" diff --git a/examples/ipv6/rpl-border-router/project-conf.h b/examples/ipv6/rpl-border-router/project-conf.h index c73735be6..ec3eb3f00 100644 --- a/examples/ipv6/rpl-border-router/project-conf.h +++ b/examples/ipv6/rpl-border-router/project-conf.h @@ -31,16 +31,18 @@ #ifndef PROJECT_ROUTER_CONF_H_ #define PROJECT_ROUTER_CONF_H_ -#ifndef RPL_CONF_WITH_NON_STORING -#define RPL_CONF_WITH_NON_STORING 0 /* Set this to run with non-storing mode */ -#endif /* RPL_CONF_WITH_NON_STORING */ +#ifndef WITH_NON_STORING +#define WITH_NON_STORING 0 /* Set this to run with non-storing mode */ +#endif /* WITH_NON_STORING */ -#if RPL_CONF_WITH_NON_STORING -#undef RPL_CONF_WITH_STORING -#define RPL_CONF_WITH_STORING 0 +#if WITH_NON_STORING +#undef RPL_NS_CONF_LINK_NUM +#define RPL_NS_CONF_LINK_NUM 40 /* Number of links maintained at the root */ +#undef UIP_CONF_MAX_ROUTES +#define UIP_CONF_MAX_ROUTES 0 /* No need for routes */ #undef RPL_CONF_MOP -#define RPL_CONF_MOP RPL_MOP_NON_STORING -#endif /* RPL_CONF_WITH_NON_STORING */ +#define RPL_CONF_MOP RPL_MOP_NON_STORING /* Mode of operation*/ +#endif /* WITH_NON_STORING */ #ifndef UIP_FALLBACK_INTERFACE #define UIP_FALLBACK_INTERFACE rpl_interface diff --git a/examples/ipv6/rpl-collect/project-conf.h b/examples/ipv6/rpl-collect/project-conf.h index e45518b73..a143b07cd 100644 --- a/examples/ipv6/rpl-collect/project-conf.h +++ b/examples/ipv6/rpl-collect/project-conf.h @@ -30,6 +30,10 @@ #ifndef PROJECT_CONF_H_ #define PROJECT_CONF_H_ +#ifndef WITH_NON_STORING +#define WITH_NON_STORING 0 /* Set this to run with non-storing mode */ +#endif /* WITH_NON_STORING */ + #undef NBR_TABLE_CONF_MAX_NEIGHBORS #undef UIP_CONF_MAX_ROUTES @@ -63,15 +67,13 @@ #undef SICSLOWPAN_CONF_FRAG #define SICSLOWPAN_CONF_FRAG 0 -#ifndef RPL_CONF_WITH_NON_STORING -#define RPL_CONF_WITH_NON_STORING 0 /* Set this to run with non-storing mode */ -#endif /* RPL_CONF_WITH_NON_STORING */ - -#if RPL_CONF_WITH_NON_STORING -#undef RPL_CONF_WITH_STORING -#define RPL_CONF_WITH_STORING 0 +#if WITH_NON_STORING +#undef RPL_NS_CONF_LINK_NUM +#define RPL_NS_CONF_LINK_NUM 40 /* Number of links maintained at the root. Can be set to 0 at non-root nodes. */ +#undef UIP_CONF_MAX_ROUTES +#define UIP_CONF_MAX_ROUTES 0 /* No need for routes */ #undef RPL_CONF_MOP -#define RPL_CONF_MOP RPL_MOP_NON_STORING -#endif /* RPL_CONF_WITH_NON_STORING */ +#define RPL_CONF_MOP RPL_MOP_NON_STORING /* Mode of operation*/ +#endif /* WITH_NON_STORING */ #endif /* PROJECT_CONF_H_ */ diff --git a/examples/ipv6/rpl-udp/project-conf.h b/examples/ipv6/rpl-udp/project-conf.h index 0217200b4..794897a46 100644 --- a/examples/ipv6/rpl-udp/project-conf.h +++ b/examples/ipv6/rpl-udp/project-conf.h @@ -30,6 +30,10 @@ #ifndef PROJECT_CONF_H_ #define PROJECT_CONF_H_ +#ifndef WITH_NON_STORING +#define WITH_NON_STORING 0 /* Set this to run with non-storing mode */ +#endif /* WITH_NON_STORING */ + #undef NBR_TABLE_CONF_MAX_NEIGHBORS #undef UIP_CONF_MAX_ROUTES @@ -60,11 +64,13 @@ #define RPL_CONF_WITH_NON_STORING 0 /* Set this to run with non-storing mode */ #endif /* RPL_CONF_WITH_NON_STORING */ -#if RPL_CONF_WITH_NON_STORING -#undef RPL_CONF_WITH_STORING -#define RPL_CONF_WITH_STORING 0 +#if WITH_NON_STORING +#undef RPL_NS_CONF_LINK_NUM +#define RPL_NS_CONF_LINK_NUM 40 /* Number of links maintained at the root. Can be set to 0 at non-root nodes. */ +#undef UIP_CONF_MAX_ROUTES +#define UIP_CONF_MAX_ROUTES 0 /* No need for routes */ #undef RPL_CONF_MOP -#define RPL_CONF_MOP RPL_MOP_NON_STORING -#endif /* RPL_CONF_WITH_NON_STORING */ +#define RPL_CONF_MOP RPL_MOP_NON_STORING /* Mode of operation*/ +#endif /* WITH_NON_STORING */ #endif diff --git a/regression-tests/23-rpl-non-storing/code/project-conf.h b/regression-tests/23-rpl-non-storing/code/project-conf.h index 2097e5f67..9270334fb 100644 --- a/regression-tests/23-rpl-non-storing/code/project-conf.h +++ b/regression-tests/23-rpl-non-storing/code/project-conf.h @@ -28,12 +28,6 @@ */ #define TCPIP_CONF_ANNOTATE_TRANSMISSIONS 1 -#undef RPL_CONF_WITH_NON_STORING -#define RPL_CONF_WITH_NON_STORING 1 - -#undef RPL_CONF_WITH_STORING -#define RPL_CONF_WITH_STORING 0 - #undef RPL_CONF_MOP #define RPL_CONF_MOP RPL_MOP_NON_STORING