From 871ee1e34f42ad756e52f750641b7ee910824d15 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 00:53:48 -0800 Subject: [PATCH 01/43] Added routing module with only routing.h, now included wherever RPL is used --- Makefile.include | 2 +- examples/6tisch/etsi-plugtest-2017/node.c | 6 +- examples/6tisch/simple-node/node.c | 6 +- examples/6tisch/sixtop/node-sixtop.c | 6 +- examples/ip64-router/ip64-router.c | 2 +- examples/ipso-objects/example-server.c | 3 +- examples/ipv6-hooks/ipv6-hooks.c | 2 +- examples/multicast/root.c | 3 +- .../cc2538-common/mqtt-demo/mqtt-demo.c | 5 +- .../cc26xx-web-demo/cetic-6lbr-client.c | 2 +- .../cc26xx/cc26xx-web-demo/mqtt-client.c | 5 +- .../very-sleepy-demo/very-sleepy-demo.c | 5 +- .../platform-specific/jn516x/rpl/node/node.c | 2 +- .../jn516x/rpl/tools/rpl-tools.c | 3 +- .../tsch/simple-sensor-network/node/node.c | 5 +- .../jn516x/tsch/tools/rpl-tools.c | 3 +- .../rpl-border-router/rpl-border-router.c | 2 +- .../zoul/orion/client/client.c | 2 +- .../zoul/orion/client/ifttt-client.c | 2 +- .../zoul/orion/ip64-router/ip64-router.c | 3 +- .../rpl-border-router/webserver/webserver.c | 5 +- examples/rpl-udp/udp-client.c | 2 +- examples/rpl-udp/udp-server.c | 3 +- os/contiki-net.h | 1 + os/net/ipv6/multicast/esmrf.c | 7 +- os/net/ipv6/multicast/smrf.c | 6 +- os/net/ipv6/sicslowpan.c | 7 +- os/net/ipv6/tcpip.c | 10 +-- os/net/ipv6/uip-ds6-nbr.h | 1 - os/net/ipv6/uip-ds6-route.h | 8 +- os/net/ipv6/uip-ds6.h | 2 +- os/net/ipv6/uip-icmp6.c | 10 +-- os/net/ipv6/uip6.c | 10 +-- os/net/mac/tsch/tsch-rpl.c | 8 +- os/net/mac/tsch/tsch-rpl.h | 6 +- os/net/mac/tsch/tsch.c | 8 +- os/net/routing/routing.h | 73 +++++++++++++++++++ os/net/rpl-classic/rpl-dag-root.c | 5 +- os/net/rpl-classic/rpl-dag.c | 3 +- os/net/rpl-lite/rpl-icmp6.h | 1 + os/services/lwm2m/lwm2m-engine.c | 2 + ...ra-rule-unicast-per-neighbor-rpl-storing.c | 5 +- os/services/orchestra/orchestra.c | 5 +- .../embedded/border-router-embedded.c | 2 +- .../native/border-router-cmds.c | 2 +- .../native/border-router-native.c | 3 +- .../rpl-border-router/rpl-border-router.c | 2 +- os/services/shell/shell-commands.c | 7 +- .../code-ipv6/sender/unicast-sender.c | 3 +- .../code-slip-radio/wait-dag.c | 2 +- tests/14-rpl-lite/code/receiver-node.c | 2 +- tests/14-rpl-lite/code/root-node.c | 3 +- tests/15-rpl-classic/code/receiver-node.c | 2 +- tests/15-rpl-classic/code/root-node.c | 5 +- 54 files changed, 132 insertions(+), 158 deletions(-) create mode 100644 os/net/routing/routing.h diff --git a/Makefile.include b/Makefile.include index 5ca9cd5da..b74b2c878 100644 --- a/Makefile.include +++ b/Makefile.include @@ -52,7 +52,7 @@ ifneq ("$(wildcard project-conf.h)","") CFLAGS += -DPROJECT_CONF_PATH=\"project-conf.h\" endif -MODULES += os os/net os/net/mac os/storage +MODULES += os os/net os/net/mac os/net/routing os/storage oname = ${patsubst %.c,%.o,${patsubst %.S,%.o,$(1)}} diff --git a/examples/6tisch/etsi-plugtest-2017/node.c b/examples/6tisch/etsi-plugtest-2017/node.c index 578727d1f..25035f7f4 100644 --- a/examples/6tisch/etsi-plugtest-2017/node.c +++ b/examples/6tisch/etsi-plugtest-2017/node.c @@ -38,15 +38,11 @@ #include "contiki.h" #include "node-id.h" -#include "rpl.h" -#include "rpl-dag-root.h" #include "sys/log.h" #include "net/ipv6/uip-ds6-route.h" #include "net/mac/tsch/tsch.h" #include "net/mac/tsch/tsch-log.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" #include "serial-shell.h" #include "sf-plugtest.h" #if CONTIKI_TARGET_SRF06_CC26XX diff --git a/examples/6tisch/simple-node/node.c b/examples/6tisch/simple-node/node.c index 9884b4e0e..c11f8420c 100644 --- a/examples/6tisch/simple-node/node.c +++ b/examples/6tisch/simple-node/node.c @@ -38,15 +38,11 @@ #include "contiki.h" #include "node-id.h" -#include "rpl.h" -#include "rpl-dag-root.h" #include "sys/log.h" #include "net/ipv6/uip-ds6-route.h" #include "net/mac/tsch/tsch.h" #include "net/mac/tsch/tsch-log.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" #define DEBUG DEBUG_PRINT #include "net/ipv6/uip-debug.h" diff --git a/examples/6tisch/sixtop/node-sixtop.c b/examples/6tisch/sixtop/node-sixtop.c index 4c60db3a7..b8b1e9e90 100755 --- a/examples/6tisch/sixtop/node-sixtop.c +++ b/examples/6tisch/sixtop/node-sixtop.c @@ -39,17 +39,13 @@ #include "contiki.h" #include "node-id.h" -#include "rpl.h" -#include "rpl-dag-root.h" #include "sys/log.h" #include "net/ipv6/uip-ds6-route.h" #include "net/mac/tsch/tsch.h" #include "net/mac/tsch/tsch-log.h" #include "net/mac/tsch/tsch-schedule.h" #include "net/mac/tsch/sixtop/sixtop.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" #include "sf-simple.h" diff --git a/examples/ip64-router/ip64-router.c b/examples/ip64-router/ip64-router.c index a6a5af450..3ce6ece6d 100644 --- a/examples/ip64-router/ip64-router.c +++ b/examples/ip64-router/ip64-router.c @@ -2,7 +2,7 @@ #include "contiki-net.h" #include "ip64/ip64.h" #include "net/netstack.h" -#include "rpl-dag-root.h" +#include "net/routing/routing.h" #include "sys/autostart.h" /*---------------------------------------------------------------------------*/ diff --git a/examples/ipso-objects/example-server.c b/examples/ipso-objects/example-server.c index a62ba4ffd..f8bd44171 100644 --- a/examples/ipso-objects/example-server.c +++ b/examples/ipso-objects/example-server.c @@ -38,9 +38,8 @@ #include "contiki.h" #include "net/ipv6/uip.h" -#include "rpl.h" -#include "rpl-dag-root.h" #include "net/netstack.h" +#include "net/routing/routing.h" #include "coap-constants.h" #include "coap-engine.h" #include "lwm2m-engine.h" diff --git a/examples/ipv6-hooks/ipv6-hooks.c b/examples/ipv6-hooks/ipv6-hooks.c index 30269b030..eafc45654 100644 --- a/examples/ipv6-hooks/ipv6-hooks.c +++ b/examples/ipv6-hooks/ipv6-hooks.c @@ -1,5 +1,5 @@ #include "contiki.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "random.h" #include "net/netstack.h" #include "net/ipv6/simple-udp.h" diff --git a/examples/multicast/root.c b/examples/multicast/root.c index b4bf9dcdb..451c638ea 100644 --- a/examples/multicast/root.c +++ b/examples/multicast/root.c @@ -48,8 +48,7 @@ #define DEBUG DEBUG_PRINT #include "net/ipv6/uip-debug.h" -#include "rpl.h" -#include "rpl-dag-root.h" +#include "net/routing/routing.h" #define MAX_PAYLOAD_LEN 120 #define MCAST_SINK_UDP_PORT 3001 /* Host byte order */ diff --git a/examples/platform-specific/cc2538-common/mqtt-demo/mqtt-demo.c b/examples/platform-specific/cc2538-common/mqtt-demo/mqtt-demo.c index 18b806ac9..c28b5c741 100644 --- a/examples/platform-specific/cc2538-common/mqtt-demo/mqtt-demo.c +++ b/examples/platform-specific/cc2538-common/mqtt-demo/mqtt-demo.c @@ -42,11 +42,8 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" #include "mqtt.h" -#include "rpl.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-icmp6.h" #include "net/ipv6/sicslowpan.h" diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c b/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c index e12f2cd16..11171e51e 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c @@ -35,7 +35,7 @@ #include "contiki.h" #include "contiki-lib.h" #include "contiki-net.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "net/ipv6/uip.h" #include diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/mqtt-client.c b/examples/platform-specific/cc26xx/cc26xx-web-demo/mqtt-client.c index 59ecee1ce..7eb4ab5ee 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/mqtt-client.c +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/mqtt-client.c @@ -36,11 +36,8 @@ */ /*---------------------------------------------------------------------------*/ #include "contiki.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" #include "mqtt.h" -#include "rpl.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-icmp6.h" #include "sys/etimer.h" diff --git a/examples/platform-specific/cc26xx/very-sleepy-demo/very-sleepy-demo.c b/examples/platform-specific/cc26xx/very-sleepy-demo/very-sleepy-demo.c index 5c6690f34..e24aac689 100644 --- a/examples/platform-specific/cc26xx/very-sleepy-demo/very-sleepy-demo.c +++ b/examples/platform-specific/cc26xx/very-sleepy-demo/very-sleepy-demo.c @@ -40,10 +40,7 @@ #include "net/netstack.h" #include "net/ipv6/uip-ds6-nbr.h" #include "net/ipv6/uip-ds6-route.h" -#include "rpl.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" #include "coap-engine.h" #include "coap.h" diff --git a/examples/platform-specific/jn516x/rpl/node/node.c b/examples/platform-specific/jn516x/rpl/node/node.c index 3c24f36c1..f4fe4d813 100644 --- a/examples/platform-specific/jn516x/rpl/node/node.c +++ b/examples/platform-specific/jn516x/rpl/node/node.c @@ -37,7 +37,7 @@ #include "contiki.h" #include "net/ipv6/uip-ds6.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "tools/rpl-tools.h" #define DEBUG DEBUG_PRINT diff --git a/examples/platform-specific/jn516x/rpl/tools/rpl-tools.c b/examples/platform-specific/jn516x/rpl/tools/rpl-tools.c index 570be8566..a17f971d2 100644 --- a/examples/platform-specific/jn516x/rpl/tools/rpl-tools.c +++ b/examples/platform-specific/jn516x/rpl/tools/rpl-tools.c @@ -36,8 +36,7 @@ #include "contiki.h" #include "contiki-net.h" #include "net/ipv6/uip.h" -#include "rpl.h" -#include "rpl-dag-root.h" +#include "net/routing/routing.h" #include #include diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c index 0b1bc3414..2b6f69015 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c @@ -37,10 +37,7 @@ #include "net/mac/tsch/tsch-schedule.h" #include "net/mac/tsch/tsch.h" #include "net/mac/tsch/tsch-private.h" -#include "rpl.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" #include "net/mac/tsch/tsch-schedule.h" #include "net/ipv6/uip-debug.h" #include "lib/random.h" diff --git a/examples/platform-specific/jn516x/tsch/tools/rpl-tools.c b/examples/platform-specific/jn516x/tsch/tools/rpl-tools.c index e71a19bc9..bd576a918 100644 --- a/examples/platform-specific/jn516x/tsch/tools/rpl-tools.c +++ b/examples/platform-specific/jn516x/tsch/tools/rpl-tools.c @@ -36,8 +36,7 @@ #include "contiki.h" #include "contiki-net.h" #include "net/ipv6/uip.h" -#include "rpl.h" -#include "rpl-dag-root.h" +#include "net/routing/routing.h" #include #include diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c index 5d9f83df1..3cc1dc266 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c @@ -36,7 +36,7 @@ #include "contiki-net.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "simple-udp.h" #include "net/mac/tsch/tsch.h" #include "net/mac/tsch/tsch-schedule.h" diff --git a/examples/platform-specific/zoul/orion/client/client.c b/examples/platform-specific/zoul/orion/client/client.c index 18f1a5e91..ebbd34fb0 100644 --- a/examples/platform-specific/zoul/orion/client/client.c +++ b/examples/platform-specific/zoul/orion/client/client.c @@ -33,7 +33,7 @@ #include "http-socket.h" #include "ipv6/ip64-addr.h" #include "dev/leds.h" -#include "rpl.h" +#include "net/routing/routing.h" #include /*---------------------------------------------------------------------------*/ static struct http_socket s; diff --git a/examples/platform-specific/zoul/orion/client/ifttt-client.c b/examples/platform-specific/zoul/orion/client/ifttt-client.c index ec1288753..7cc962c18 100644 --- a/examples/platform-specific/zoul/orion/client/ifttt-client.c +++ b/examples/platform-specific/zoul/orion/client/ifttt-client.c @@ -33,7 +33,7 @@ #include "http-socket.h" #include "ipv6/ip64-addr.h" #include "dev/leds.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "dev/button-sensor.h" #include /*---------------------------------------------------------------------------*/ diff --git a/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c b/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c index 433f58426..0f321074e 100644 --- a/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c +++ b/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c @@ -45,8 +45,7 @@ #include "contiki-net.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" -#include "rpl.h" -#include "rpl-dag-root.h" +#include "net/routing/routing.h" #include "dev/leds.h" #include "ip64/ip64.h" #include "net/netstack.h" diff --git a/examples/rpl-border-router/webserver/webserver.c b/examples/rpl-border-router/webserver/webserver.c index 61be96086..1343de71d 100644 --- a/examples/rpl-border-router/webserver/webserver.c +++ b/examples/rpl-border-router/webserver/webserver.c @@ -31,10 +31,7 @@ */ #include "contiki.h" -#include "rpl.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" #include #include diff --git a/examples/rpl-udp/udp-client.c b/examples/rpl-udp/udp-client.c index 10e336dac..dec64b61e 100644 --- a/examples/rpl-udp/udp-client.c +++ b/examples/rpl-udp/udp-client.c @@ -1,5 +1,5 @@ #include "contiki.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "random.h" #include "net/netstack.h" #include "net/ipv6/simple-udp.h" diff --git a/examples/rpl-udp/udp-server.c b/examples/rpl-udp/udp-server.c index 222556d59..9603b9e11 100644 --- a/examples/rpl-udp/udp-server.c +++ b/examples/rpl-udp/udp-server.c @@ -28,8 +28,7 @@ */ #include "contiki.h" -#include "rpl.h" -#include "rpl-dag-root.h" +#include "net/routing/routing.h" #include "net/netstack.h" #include "net/ipv6/simple-udp.h" diff --git a/os/contiki-net.h b/os/contiki-net.h index 9b467363f..1eb50dd8d 100644 --- a/os/contiki-net.h +++ b/os/contiki-net.h @@ -42,6 +42,7 @@ #include "net/ipv6/uip-udp-packet.h" #include "net/ipv6/simple-udp.h" #include "net/ipv6/uip-nameserver.h" +#include "net/routing/routing.h" #if NETSTACK_CONF_WITH_IPV6 #include "net/ipv6/uip-icmp6.h" diff --git a/os/net/ipv6/multicast/esmrf.c b/os/net/ipv6/multicast/esmrf.c index adbea25e0..bc8415a24 100644 --- a/os/net/ipv6/multicast/esmrf.c +++ b/os/net/ipv6/multicast/esmrf.c @@ -46,12 +46,7 @@ #include "net/ipv6/multicast/uip-mcast6-route.h" #include "net/ipv6/multicast/uip-mcast6-stats.h" #include "net/ipv6/multicast/esmrf.h" -#if UIP_CONF_IPV6_RPL_LITE == 1 -#include "net/rpl-lite/rpl.h" -#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 1 */ +#include "net/routing/routing.h" #include "net/ipv6/uip.h" #include "net/netstack.h" #include "net/packetbuf.h" diff --git a/os/net/ipv6/multicast/smrf.c b/os/net/ipv6/multicast/smrf.c index 00043d60b..d6f86615b 100644 --- a/os/net/ipv6/multicast/smrf.c +++ b/os/net/ipv6/multicast/smrf.c @@ -47,11 +47,7 @@ #include "net/ipv6/multicast/uip-mcast6-route.h" #include "net/ipv6/multicast/uip-mcast6-stats.h" #include "net/ipv6/multicast/smrf.h" -#if UIP_CONF_IPV6_RPL_LITE == 1 -#include "net/rpl-lite/rpl.h" -#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#include "net/rpl-classic/rpl.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 1 */ +#include "net/routing/routing.h" #include "net/netstack.h" #include "net/packetbuf.h" #include diff --git a/os/net/ipv6/sicslowpan.c b/os/net/ipv6/sicslowpan.c index 060699e93..be6821275 100644 --- a/os/net/ipv6/sicslowpan.c +++ b/os/net/ipv6/sicslowpan.c @@ -74,12 +74,7 @@ #include "net/packetbuf.h" #include "net/queuebuf.h" -#if UIP_CONF_IPV6_RPL_LITE == 1 -#include "net/rpl-lite/rpl.h" -#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 1 */ +#include "net/routing/routing.h" /* Log configuration */ #include "sys/log.h" diff --git a/os/net/ipv6/tcpip.c b/os/net/ipv6/tcpip.c index e096ce44b..53a7c30f4 100644 --- a/os/net/ipv6/tcpip.c +++ b/os/net/ipv6/tcpip.c @@ -44,15 +44,7 @@ #include "net/ipv6/uip-nd6.h" #include "net/ipv6/uip-ds6.h" #include "net/linkaddr.h" - -#if UIP_CONF_IPV6_RPL -#if UIP_CONF_IPV6_RPL_LITE == 1 -#include "net/rpl-lite/rpl.h" -#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#endif +#include "net/routing/routing.h" #include diff --git a/os/net/ipv6/uip-ds6-nbr.h b/os/net/ipv6/uip-ds6-nbr.h index ebb7de2d8..f10a415b0 100644 --- a/os/net/ipv6/uip-ds6-nbr.h +++ b/os/net/ipv6/uip-ds6-nbr.h @@ -49,7 +49,6 @@ #include "net/ipv6/uip.h" #include "net/nbr-table.h" #include "sys/stimer.h" -#include "net/ipv6/uip-ds6.h" #if UIP_CONF_IPV6_QUEUE_PKT #include "net/ipv6/uip-packetqueue.h" #endif /*UIP_CONF_QUEUE_PKT */ diff --git a/os/net/ipv6/uip-ds6-route.h b/os/net/ipv6/uip-ds6-route.h index acc417670..8f2bc377d 100644 --- a/os/net/ipv6/uip-ds6-route.h +++ b/os/net/ipv6/uip-ds6-route.h @@ -44,13 +44,7 @@ #include "net/nbr-table.h" #include "sys/stimer.h" #include "lib/list.h" -#if UIP_CONF_IPV6_RPL -#if UIP_CONF_IPV6_RPL_LITE == 1 -#include "net/rpl-lite/rpl-conf.h" -#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#include "net/rpl-classic/rpl-conf.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#endif +#include "net/routing/routing.h" #ifdef UIP_CONF_MAX_ROUTES #define UIP_MAX_ROUTES UIP_CONF_MAX_ROUTES diff --git a/os/net/ipv6/uip-ds6.h b/os/net/ipv6/uip-ds6.h index 736f9bfeb..29f9249c3 100644 --- a/os/net/ipv6/uip-ds6.h +++ b/os/net/ipv6/uip-ds6.h @@ -46,8 +46,8 @@ #include "sys/stimer.h" /* The size of uip_ds6_addr_t depends on UIP_ND6_DEF_MAXDADNS. Include uip-nd6.h to define it. */ #include "net/ipv6/uip-nd6.h" -#include "net/ipv6/uip-ds6-route.h" #include "net/ipv6/uip-ds6-nbr.h" +#include "net/ipv6/uip-ds6-route.h" /*--------------------------------------------------*/ /** Configuration. For all tables (Neighbor cache, Prefix List, Routing Table, diff --git a/os/net/ipv6/uip-icmp6.c b/os/net/ipv6/uip-icmp6.c index d46a9cd68..5d04cf979 100644 --- a/os/net/ipv6/uip-icmp6.c +++ b/os/net/ipv6/uip-icmp6.c @@ -46,6 +46,7 @@ #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-icmp6.h" #include "contiki-default-conf.h" +#include "net/routing/routing.h" /* Log configuration */ #include "sys/log.h" @@ -58,15 +59,6 @@ #define UIP_EXT_BUF ((struct uip_ext_hdr *)&uip_buf[uip_l2_l3_hdr_len]) #define UIP_FIRST_EXT_BUF ((struct uip_ext_hdr *)&uip_buf[UIP_LLIPH_LEN]) -#if UIP_CONF_IPV6_RPL -#if UIP_CONF_IPV6_RPL_LITE == 1 -#include "net/rpl-lite/rpl.h" -#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#endif /* UIP_CONF_IPV6_RPL */ - /** \brief temporary IP address */ static uip_ipaddr_t tmp_ipaddr; diff --git a/os/net/ipv6/uip6.c b/os/net/ipv6/uip6.c index 72384414a..edc037468 100644 --- a/os/net/ipv6/uip6.c +++ b/os/net/ipv6/uip6.c @@ -79,15 +79,7 @@ #include "net/ipv6/uip-nd6.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/multicast/uip-mcast6.h" - -#if UIP_CONF_IPV6_RPL -#if UIP_CONF_IPV6_RPL_LITE == 1 -#include "net/rpl-lite/rpl.h" -#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#endif +#include "net/routing/routing.h" #if UIP_ND6_SEND_NS #include "net/ipv6/uip-ds6-nbr.h" diff --git a/os/net/mac/tsch/tsch-rpl.c b/os/net/mac/tsch/tsch-rpl.c index ec3f24d8b..78d102fad 100644 --- a/os/net/mac/tsch/tsch-rpl.c +++ b/os/net/mac/tsch/tsch-rpl.c @@ -43,18 +43,12 @@ #if UIP_CONF_IPV6_RPL #include "contiki.h" -#if UIP_CONF_IPV6_RPL_LITE == 1 -#include "net/rpl-lite/rpl.h" -#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 1 */ +#include "net/routing/routing.h" #include "net/mac/tsch/tsch.h" #include "net/mac/tsch/tsch-private.h" #include "net/mac/tsch/tsch-schedule.h" #include "net/mac/tsch/tsch-log.h" #include "net/mac/tsch/tsch-rpl.h" -#include "tsch-rpl.h" /* Log configuration */ #include "sys/log.h" diff --git a/os/net/mac/tsch/tsch-rpl.h b/os/net/mac/tsch/tsch-rpl.h index 15be760f5..fd71c6437 100644 --- a/os/net/mac/tsch/tsch-rpl.h +++ b/os/net/mac/tsch/tsch-rpl.h @@ -38,11 +38,7 @@ /********** Includes **********/ -#if UIP_CONF_IPV6_RPL_LITE == 1 -#include "net/rpl-lite/rpl.h" -#else /* UIP_CONF_IPV6_RPL_LITE == 1 */ -#include "net/rpl-classic/rpl.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 1 */ +#include "net/routing/routing.h" #include "net/mac/tsch/tsch-queue.h" /********** Functions *********/ diff --git a/os/net/mac/tsch/tsch.c b/os/net/mac/tsch/tsch.c index 6d60f097a..b5b572f40 100644 --- a/os/net/mac/tsch/tsch.c +++ b/os/net/mac/tsch/tsch.c @@ -60,12 +60,12 @@ #include "net/mac/tsch/tsch-log.h" #include "net/mac/tsch/tsch-packet.h" #include "net/mac/tsch/tsch-security.h" -#include "net/mac/mac-sequence.h" -#include "lib/random.h" - #if UIP_CONF_IPV6_RPL #include "net/mac/tsch/tsch-rpl.h" -#endif /* UIP_CONF_IPV6_RPL */ +#endif /* #if UIP_CONF_IPV6_RPL */ +#include "net/mac/mac-sequence.h" +#include "lib/random.h" +#include "net/routing/routing.h" #if TSCH_WITH_SIXTOP #include "net/mac/tsch/sixtop/sixtop.h" diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h new file mode 100644 index 000000000..e4bc65938 --- /dev/null +++ b/os/net/routing/routing.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2017, RISE SICS. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + * + */ + +/** + * \file + * Routing driver header file + * \author + * Simon Duquennoy + */ + +#ifndef ROUTING_H_ +#define ROUTING_H_ + +#include "contiki.h" + +#include "rpl.h" +#include "rpl-dag-root.h" +#if UIP_CONF_IPV6_RPL_LITE == 0 +#include "rpl-private.h" +#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ + +/** + * The structure of a routing protocol driver. + */ +struct routing_driver { + char *name; + /** Initialize the routing protocol */ + void (* init)(void); + /** + * Set the prefix, for nodes that will operate as root + * + * \param prefix The prefix. If NULL, UIP_DS6_DEFAULT_PREFIX is used instead + * \param iid The IID. If NULL, it will be built from uip_ds6_set_addr_iid. + */ + void (* root_set_prefix)(uip_ipaddr_t *prefix, uip_ipaddr_t *iid); + /** + * Set the node as root and start a network + * + * \return 0 in case of success, -1 otherwise + */ + int (* root_start)(void); +}; + +#endif /* ROUTING_H_ */ diff --git a/os/net/rpl-classic/rpl-dag-root.c b/os/net/rpl-classic/rpl-dag-root.c index 96d00f6e1..4082d936e 100644 --- a/os/net/rpl-classic/rpl-dag-root.c +++ b/os/net/rpl-classic/rpl-dag-root.c @@ -32,9 +32,8 @@ #include "contiki.h" #include "contiki-net.h" -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" -#include "net/rpl-classic/rpl-dag-root.h" +#include "rpl.h" +#include "rpl-private.h" #include "net/ipv6/uip-ds6-route.h" #include diff --git a/os/net/rpl-classic/rpl-dag.c b/os/net/rpl-classic/rpl-dag.c index aeed6194e..074485f67 100644 --- a/os/net/rpl-classic/rpl-dag.c +++ b/os/net/rpl-classic/rpl-dag.c @@ -45,7 +45,8 @@ #include "contiki.h" #include "net/link-stats.h" -#include "net/rpl-classic/rpl-private.h" +#include "rpl.h" +#include "rpl-private.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-nd6.h" #include "net/ipv6/uip-ds6-nbr.h" diff --git a/os/net/rpl-lite/rpl-icmp6.h b/os/net/rpl-lite/rpl-icmp6.h index 443d28ef6..fc877b948 100644 --- a/os/net/rpl-lite/rpl-icmp6.h +++ b/os/net/rpl-lite/rpl-icmp6.h @@ -44,6 +44,7 @@ #include "uip.h" #include "uip-ds6.h" +#include "uip-ds6-nbr.h" /********** Data structures **********/ diff --git a/os/services/lwm2m/lwm2m-engine.c b/os/services/lwm2m/lwm2m-engine.c index a36b4f7b1..7f67be2c8 100644 --- a/os/services/lwm2m/lwm2m-engine.c +++ b/os/services/lwm2m/lwm2m-engine.c @@ -53,6 +53,8 @@ #include "lwm2m-tlv-writer.h" #include "lib/list.h" #include "sys/cc.h" +#include "net/ipv6/uip-ds6.h" +#include "net/routing/routing.h" #include #include #include diff --git a/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-storing.c b/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-storing.c index fbafa4654..723b9e847 100644 --- a/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-storing.c +++ b/os/services/orchestra/orchestra-rule-unicast-per-neighbor-rpl-storing.c @@ -44,10 +44,7 @@ #include "orchestra.h" #include "net/ipv6/uip-ds6-route.h" #include "net/packetbuf.h" -#include "rpl.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" /* * The body of this rule should be compiled only when "nbr_routes" is available, diff --git a/os/services/orchestra/orchestra.c b/os/services/orchestra/orchestra.c index 3ea78ca96..efd5b9f5d 100644 --- a/os/services/orchestra/orchestra.c +++ b/os/services/orchestra/orchestra.c @@ -40,10 +40,7 @@ #include "orchestra.h" #include "net/packetbuf.h" #include "net/ipv6/uip-icmp6.h" -#include "rpl.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/routing/routing.h" #define DEBUG DEBUG_PRINT #include "net/ipv6/uip-debug.h" diff --git a/os/services/rpl-border-router/embedded/border-router-embedded.c b/os/services/rpl-border-router/embedded/border-router-embedded.c index 8ec4bd49c..7d6f4125f 100644 --- a/os/services/rpl-border-router/embedded/border-router-embedded.c +++ b/os/services/rpl-border-router/embedded/border-router-embedded.c @@ -36,7 +36,7 @@ */ #include "contiki.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "dev/button-sensor.h" #include "dev/slip.h" #include "rpl-border-router.h" diff --git a/os/services/rpl-border-router/native/border-router-cmds.c b/os/services/rpl-border-router/native/border-router-cmds.c index 4a044f96e..8d11d725d 100644 --- a/os/services/rpl-border-router/native/border-router-cmds.c +++ b/os/services/rpl-border-router/native/border-router-cmds.c @@ -40,7 +40,7 @@ #include "border-router.h" #include "border-router-cmds.h" #include "dev/serial-line.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "net/ipv6/uiplib.h" #include #include "shell.h" diff --git a/os/services/rpl-border-router/native/border-router-native.c b/os/services/rpl-border-router/native/border-router-native.c index 36516429d..ea7ccd61b 100644 --- a/os/services/rpl-border-router/native/border-router-native.c +++ b/os/services/rpl-border-router/native/border-router-native.c @@ -40,7 +40,8 @@ #include "contiki.h" #include "contiki-net.h" -#include "rpl.h" + +#include "net/routing/routing.h" #include "rpl-border-router.h" #include "cmd.h" #include "border-router.h" diff --git a/os/services/rpl-border-router/rpl-border-router.c b/os/services/rpl-border-router/rpl-border-router.c index 59426d7f9..13421b232 100644 --- a/os/services/rpl-border-router/rpl-border-router.c +++ b/os/services/rpl-border-router/rpl-border-router.c @@ -31,8 +31,8 @@ */ #include "contiki.h" +#include "net/routing/routing.h" #include "rpl-border-router.h" -#include "rpl-dag-root.h" /* Log configuration */ #include "sys/log.h" diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index 09edda827..c9ca49e3d 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -58,12 +58,7 @@ #include "net/mac/tsch/tsch-log.h" #include "net/mac/tsch/tsch-private.h" #endif /* MAC_CONF_WITH_TSCH */ -#if UIP_CONF_IPV6_RPL_LITE -#include "net/rpl-lite/rpl.h" -#elif UIP_CONF_IPV6_RPL_CLASSIC -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" -#endif +#include "net/routing/routing.h" #include "net/mac/llsec802154.h" #include diff --git a/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c b/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c index 929e0d584..44cf49196 100644 --- a/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c +++ b/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c @@ -1,8 +1,7 @@ #include "contiki.h" #include "contiki-lib.h" #include "contiki-net.h" -#include "rpl.h" -#include "rpl-dag-root.h" +#include "net/routing/routing.h" #include diff --git a/tests/07-simulation-base/code-slip-radio/wait-dag.c b/tests/07-simulation-base/code-slip-radio/wait-dag.c index 83e3d28f7..e824ea55b 100644 --- a/tests/07-simulation-base/code-slip-radio/wait-dag.c +++ b/tests/07-simulation-base/code-slip-radio/wait-dag.c @@ -33,7 +33,7 @@ #include "contiki.h" #include "contiki-lib.h" #include "contiki-net.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "net/ipv6/uip.h" #include diff --git a/tests/14-rpl-lite/code/receiver-node.c b/tests/14-rpl-lite/code/receiver-node.c index 352f23cb5..b5265d3f7 100644 --- a/tests/14-rpl-lite/code/receiver-node.c +++ b/tests/14-rpl-lite/code/receiver-node.c @@ -38,7 +38,7 @@ #include "simple-udp.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "dev/leds.h" #include diff --git a/tests/14-rpl-lite/code/root-node.c b/tests/14-rpl-lite/code/root-node.c index ef3c982ee..153464842 100644 --- a/tests/14-rpl-lite/code/root-node.c +++ b/tests/14-rpl-lite/code/root-node.c @@ -38,8 +38,7 @@ #include "simple-udp.h" -#include "rpl.h" -#include "rpl-dag-root.h" +#include "net/routing/routing.h" #include #include diff --git a/tests/15-rpl-classic/code/receiver-node.c b/tests/15-rpl-classic/code/receiver-node.c index 770f50f77..02142c317 100644 --- a/tests/15-rpl-classic/code/receiver-node.c +++ b/tests/15-rpl-classic/code/receiver-node.c @@ -38,7 +38,7 @@ #include "simple-udp.h" -#include "rpl.h" +#include "net/routing/routing.h" #include "dev/leds.h" #include diff --git a/tests/15-rpl-classic/code/root-node.c b/tests/15-rpl-classic/code/root-node.c index ef3c982ee..9983739b8 100644 --- a/tests/15-rpl-classic/code/root-node.c +++ b/tests/15-rpl-classic/code/root-node.c @@ -35,12 +35,9 @@ #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-debug.h" - +#include "net/routing/routing.h" #include "simple-udp.h" -#include "rpl.h" -#include "rpl-dag-root.h" - #include #include From 3a39b5105686df51a03db836f89047dc22906677 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 01:18:42 -0800 Subject: [PATCH 02/43] JN516x examples: remove obsolte RPL tools --- .../jn516x/rpl/coap-dongle-node/Makefile | 2 +- .../jn516x/rpl/coap-dongle-node/dongle-node.c | 11 +- .../jn516x/rpl/coap-dr1175-node/Makefile | 2 +- .../jn516x/rpl/coap-dr1175-node/dr1175-node.c | 11 +- .../jn516x/rpl/coap-dr1199-node/Makefile | 2 +- .../jn516x/rpl/coap-dr1199-node/dr1199-node.c | 11 +- .../jn516x/rpl/node/Makefile | 2 +- .../platform-specific/jn516x/rpl/node/node.c | 19 +-- .../jn516x/rpl/tools/rpl-tools.c | 127 ------------------ .../jn516x/rpl/tools/rpl-tools.h | 36 ----- .../tsch/simple-sensor-network/node/Makefile | 2 +- .../tsch/simple-sensor-network/node/node.c | 12 +- .../jn516x/tsch/tools/rpl-tools.c | 120 ----------------- .../jn516x/tsch/tools/rpl-tools.h | 36 ----- .../tsch/tx-power-verification/node/Makefile | 2 +- .../tsch/tx-power-verification/node/node.c | 20 ++- .../rpl-border-router/Makefile | 2 +- .../rpl-border-router/rpl-border-router.c | 8 +- .../jn516x/tsch/uart1-test-node/Makefile | 2 +- .../tsch/uart1-test-node/uart1-test-node.c | 46 +++---- 20 files changed, 58 insertions(+), 415 deletions(-) delete mode 100644 examples/platform-specific/jn516x/rpl/tools/rpl-tools.c delete mode 100644 examples/platform-specific/jn516x/rpl/tools/rpl-tools.h delete mode 100644 examples/platform-specific/jn516x/tsch/tools/rpl-tools.c delete mode 100644 examples/platform-specific/jn516x/tsch/tools/rpl-tools.h diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile index 1b39fbae3..538bacf91 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/Makefile @@ -8,7 +8,7 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json -MODULES_REL += .. ../tools +MODULES_REL += .. MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c index a41c64b1c..8920bdd3b 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c @@ -34,7 +34,6 @@ #include "contiki.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" -#include "tools/rpl-tools.h" #include "coap-engine.h" #include "sys/ctimer.h" #include @@ -130,12 +129,10 @@ PROCESS_THREAD(start_app, ev, data) /* Start net stack */ if(is_coordinator) { - uip_ipaddr_t prefix; - uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); - rpl_tools_init(&prefix); - } else { - rpl_tools_init(NULL); - } printf("Starting RPL node\n"); + rpl_dag_root_init_dag_immediately(); + } + NETSTACK_MAC.on(); + printf("Starting RPL node\n"); coap_engine_init(); coap_activate_resource(&resource_led_toggle, "Dongle/LED-toggle"); diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile index 79a7e7f13..6fb119351 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/Makefile @@ -8,7 +8,7 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json -MODULES_REL += .. ../tools +MODULES_REL += .. MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c index 4c59f3d7b..f7c60b718 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c @@ -35,7 +35,6 @@ #include "contiki.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" -#include "tools/rpl-tools.h" #include "coap-engine.h" #include "light-sensor.h" #include "ht-sensor.h" @@ -350,12 +349,10 @@ PROCESS_THREAD(start_app, ev, data) /* Start net stack */ if(is_coordinator) { - uip_ipaddr_t prefix; - uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); - rpl_tools_init(&prefix); - } else { - rpl_tools_init(NULL); - } printf("Starting RPL node\n"); + rpl_dag_root_init_dag_immediately(); + } + NETSTACK_MAC.on(); + printf("Starting RPL node\n"); coap_engine_init(); coap_activate_resource(&resource_light_sensor_value, "DR1175/LightSensor/Value"); diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile index a5887a8ef..bdef1a42a 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/Makefile @@ -8,7 +8,7 @@ CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/lib/json -MODULES_REL += .. ../tools +MODULES_REL += .. MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c index e03e76747..44b482ce5 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c @@ -34,7 +34,6 @@ #include "contiki.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" -#include "tools/rpl-tools.h" #include "coap-engine.h" #include "dev/leds.h" #include "button-sensor.h" @@ -351,12 +350,10 @@ PROCESS_THREAD(start_app, ev, data) /* Start net stack */ if(is_coordinator) { - uip_ipaddr_t prefix; - uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); - rpl_tools_init(&prefix); - } else { - rpl_tools_init(NULL); - } printf("Starting RPL node\n"); + rpl_dag_root_init_dag_immediately(); + } + NETSTACK_MAC.on(); + printf("Starting RPL node\n"); coap_engine_init(); coap_activate_resource(&resource_switch_sw1, "DR1199/Switch/SW1"); diff --git a/examples/platform-specific/jn516x/rpl/node/Makefile b/examples/platform-specific/jn516x/rpl/node/Makefile index 83cd48869..228287cf8 100644 --- a/examples/platform-specific/jn516x/rpl/node/Makefile +++ b/examples/platform-specific/jn516x/rpl/node/Makefile @@ -6,6 +6,6 @@ TARGET ?= jn516x CONTIKI=../../../../.. MAKE_MAC = MAKE_MAC_TSCH -MODULES_REL += .. ../tools +MODULES_REL += .. include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/jn516x/rpl/node/node.c b/examples/platform-specific/jn516x/rpl/node/node.c index f4fe4d813..cb63f890f 100644 --- a/examples/platform-specific/jn516x/rpl/node/node.c +++ b/examples/platform-specific/jn516x/rpl/node/node.c @@ -38,7 +38,6 @@ #include "contiki.h" #include "net/ipv6/uip-ds6.h" #include "net/routing/routing.h" -#include "tools/rpl-tools.h" #define DEBUG DEBUG_PRINT #include "net/ipv6/uip-debug.h" @@ -59,7 +58,6 @@ AUTOSTART_PROCESSES(&node_process); /*---------------------------------------------------------------------------*/ PROCESS_THREAD(node_process, ev, data) { - static struct etimer et; PROCESS_BEGIN(); /* 3 possible roles: @@ -73,6 +71,7 @@ PROCESS_THREAD(node_process, ev, data) #if CONFIG_VIA_BUTTON { #define CONFIG_WAIT_TIME 5 + static struct etimer et; SENSORS_ACTIVATE(button_sensor); etimer_set(&et, CLOCK_SECOND * CONFIG_WAIT_TIME); @@ -96,22 +95,10 @@ PROCESS_THREAD(node_process, ev, data) node_role == role_6ln ? "6ln" : "6dr"); is_coordinator = node_role > role_6ln; - if(is_coordinator) { - uip_ipaddr_t prefix; - uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); - rpl_tools_init(&prefix); - } else { - rpl_tools_init(NULL); - } - - /* Print out routing tables every minute */ - etimer_set(&et, CLOCK_SECOND * 60); - while(1) { - print_network_status(); - PROCESS_YIELD_UNTIL(etimer_expired(&et)); - etimer_reset(&et); + rpl_dag_root_init_dag_immediately(); } + NETSTACK_MAC.on(); PROCESS_END(); } diff --git a/examples/platform-specific/jn516x/rpl/tools/rpl-tools.c b/examples/platform-specific/jn516x/rpl/tools/rpl-tools.c deleted file mode 100644 index a17f971d2..000000000 --- a/examples/platform-specific/jn516x/rpl/tools/rpl-tools.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2015, SICS Swedish ICT. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/** - * \file - * - * \author Simon Duquennoy - */ - -#include "contiki.h" -#include "contiki-net.h" -#include "net/ipv6/uip.h" -#include "net/routing/routing.h" -#include -#include - -#define DEBUG DEBUG_PRINT -#include "net/ipv6/uip-debug.h" - -/*---------------------------------------------------------------------------*/ -void -print_network_status(void) -{ - int i; - uint8_t state; - uip_ds6_defrt_t *default_route; - uip_ds6_route_t *route; - - PRINTA("--- Network status ---\n"); - - /* Our IPv6 addresses */ - PRINTA("- Server IPv6 addresses:\n"); - for(i = 0; i < UIP_DS6_ADDR_NB; i++) { - state = uip_ds6_if.addr_list[i].state; - if(uip_ds6_if.addr_list[i].isused && - (state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) { - PRINTA("-- "); - uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr); - PRINTA("\n"); - } - } - - /* Our default route */ - PRINTA("- Default route:\n"); - default_route = uip_ds6_defrt_lookup(uip_ds6_defrt_choose()); - if(default_route != NULL) { - PRINTA("-- "); - uip_debug_ipaddr_print(&default_route->ipaddr);; - PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)default_route->lifetime.interval); - } else { - PRINTA("-- None\n"); - } - - /* Our routing entries */ - PRINTA("- Routing entries (%u in total):\n", uip_ds6_route_num_routes()); - route = uip_ds6_route_head(); - while(route != NULL) { - PRINTA("-- "); - uip_debug_ipaddr_print(&route->ipaddr); - PRINTA(" via "); - uip_debug_ipaddr_print(uip_ds6_route_nexthop(route)); - PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)route->state.lifetime); - route = uip_ds6_route_next(route); - } - - PRINTA("----------------------\n"); -} -/*---------------------------------------------------------------------------*/ -static void -print_local_addresses(void) -{ - int i; - uint8_t state; - - PRINTA("Server IPv6 addresses:\n"); - for(i = 0; i < UIP_DS6_ADDR_NB; i++) { - state = uip_ds6_if.addr_list[i].state; - if(uip_ds6_if.addr_list[i].isused && - (state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) { - PRINTA(" "); - uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr); - PRINTA("\n"); - } - } -} -/*---------------------------------------------------------------------------*/ -void -rpl_tools_init(uip_ipaddr_t *br_prefix) -{ - if(br_prefix) { /* We are root */ - rpl_dag_root_init(br_prefix, NULL); - rpl_dag_root_init_dag_immediately(); - } else { - rpl_dag_root_init(NULL, NULL); - } - - - NETSTACK_MAC.on(); - - print_local_addresses(); -} diff --git a/examples/platform-specific/jn516x/rpl/tools/rpl-tools.h b/examples/platform-specific/jn516x/rpl/tools/rpl-tools.h deleted file mode 100644 index f14ec1d86..000000000 --- a/examples/platform-specific/jn516x/rpl/tools/rpl-tools.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2015, SICS Swedish ICT. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/** - - * \author Simon Duquennoy - */ - -void rpl_tools_init(uip_ipaddr_t *br_prefix); -void print_network_status(void); diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile index 2e7e32585..82685c610 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/Makefile @@ -5,7 +5,7 @@ JN516x_WITH_DONGLE = 1 CONTIKI=../../../../../.. -MODULES_REL += .. ../../tools +MODULES_REL += .. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap MODULES += os/services/orchestra os/lib/json diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c index 2b6f69015..1abeb2f46 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c @@ -41,7 +41,6 @@ #include "net/mac/tsch/tsch-schedule.h" #include "net/ipv6/uip-debug.h" #include "lib/random.h" -#include "rpl-tools.h" #include "node-id.h" #include "waveform.h" #include "leds.h" @@ -170,12 +169,9 @@ PROCESS_THREAD(node_process, ev, data) is_coordinator = node_role > role_6ln; if(is_coordinator) { - uip_ipaddr_t prefix; - uip_ip6addr(&prefix, 0xbbbb, 0, 0, 0, 0, 0, 0, 0); - rpl_tools_init(&prefix); - } else { - rpl_tools_init(NULL); + rpl_dag_root_init_dag_immediately(); } + NETSTACK_MAC.on(); /* Selected waveform depends on LS byte of MAC */ selected_waveform = node_mac[7] % NUMBER_OF_WAVEFORMS; @@ -211,10 +207,6 @@ PROCESS_THREAD(node_process, ev, data) printf("No host\n"); } etimer_restart(&et); - if (total_time%60 == 0) { - /* Print network status once per minute */ - print_network_status(); - } } } PROCESS_END(); diff --git a/examples/platform-specific/jn516x/tsch/tools/rpl-tools.c b/examples/platform-specific/jn516x/tsch/tools/rpl-tools.c deleted file mode 100644 index bd576a918..000000000 --- a/examples/platform-specific/jn516x/tsch/tools/rpl-tools.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2014, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/** - * \file - * - * \author Simon Duquennoy - */ - -#include "contiki.h" -#include "contiki-net.h" -#include "net/ipv6/uip.h" -#include "net/routing/routing.h" -#include -#include - -#define DEBUG DEBUG_PRINT -#include "net/ipv6/uip-debug.h" - -void -print_network_status(void) -{ - int i; - uint8_t state; - uip_ds6_defrt_t *default_route; - uip_ds6_route_t *route; - PRINTA("--- Network status ---\n"); - /* Our IPv6 addresses */ - PRINTA("- Server IPv6 addresses:\n"); - for(i = 0; i < UIP_DS6_ADDR_NB; i++) { - state = uip_ds6_if.addr_list[i].state; - if(uip_ds6_if.addr_list[i].isused && - (state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) { - PRINTA("-- "); - uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr); - PRINTA("\n"); - } - } - /* Our default route */ - PRINTA("- Default route:\n"); - default_route = uip_ds6_defrt_lookup(uip_ds6_defrt_choose()); - if(default_route != NULL) { - PRINTA("-- "); - uip_debug_ipaddr_print(&default_route->ipaddr);; - PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)default_route->lifetime.interval); - } else { - PRINTA("-- None\n"); - } - /* Our routing entries */ - PRINTA("- Routing entries (%u in total):\n", uip_ds6_route_num_routes()); - route = uip_ds6_route_head(); - while(route != NULL) { - PRINTA("-- "); - uip_debug_ipaddr_print(&route->ipaddr); - PRINTA(" via "); - uip_debug_ipaddr_print(uip_ds6_route_nexthop(route)); - PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)route->state.lifetime); - route = uip_ds6_route_next(route); - } - PRINTA("----------------------\n"); -} -/*---------------------------------------------------------------------------*/ -static void -print_local_addresses(void) -{ - int i; - uint8_t state; - - PRINTA("Server IPv6 addresses:\n"); - for(i = 0; i < UIP_DS6_ADDR_NB; i++) { - state = uip_ds6_if.addr_list[i].state; - if(uip_ds6_if.addr_list[i].isused && - (state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) { - PRINTA(" "); - uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr); - PRINTA("\n"); - } - } -} -/*---------------------------------------------------------------------------*/ -void -rpl_tools_init(uip_ipaddr_t *br_prefix) -{ - if(br_prefix) { /* We are root */ - rpl_dag_root_init(br_prefix, NULL); - rpl_dag_root_init_dag_immediately(); - } else { - rpl_dag_root_init(NULL, NULL); - } - - /* Start TSCH */ - NETSTACK_MAC.on(); - print_local_addresses(); -} diff --git a/examples/platform-specific/jn516x/tsch/tools/rpl-tools.h b/examples/platform-specific/jn516x/tsch/tools/rpl-tools.h deleted file mode 100644 index b04cdb712..000000000 --- a/examples/platform-specific/jn516x/tsch/tools/rpl-tools.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2014, Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - */ -/** - - * \author Simon Duquennoy - */ - -void rpl_tools_init(uip_ipaddr_t *br_prefix); -void print_network_status(void); diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile index 3884b9d30..43a0490ce 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/Makefile @@ -5,7 +5,7 @@ JN516x_WITH_DONGLE = 1 CONTIKI=../../../../../.. -MODULES_REL += .. ../../tools +MODULES_REL += .. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c index b8ad8bc7b..a2f3c0a1e 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c @@ -36,10 +36,9 @@ #include "net/netstack.h" #include "net/ipv6/uip.h" #include "net/linkaddr.h" -#include "rpl-tools.h" #include "coap-engine.h" -#include -#include +#include +#include #include static void set_tx_power_handler(coap_message_t *request, coap_message_t *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); @@ -56,7 +55,7 @@ AUTOSTART_PROCESSES(&start_app); /*---------------------------------------------------------------------------*/ /*********** sensor/ resource ************************************************/ -RESOURCE(resource_set_tx_power, +RESOURCE(resource_set_tx_power, "title=\"Set TX Power\"", NULL, set_tx_power_handler, @@ -77,7 +76,7 @@ set_tx_power_handler(coap_message_t *request, coap_message_t *response, uint8_t } } -RESOURCE(resource_get_tx_power, +RESOURCE(resource_get_tx_power, "title=\"Get TX Power\"", get_tx_power_handler, NULL, @@ -102,17 +101,14 @@ PROCESS_THREAD(start_app, ev, data) { PROCESS_BEGIN(); static int is_coordinator = 0; - + /* Start network stack */ if(is_coordinator) { - uip_ipaddr_t prefix; - uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); - rpl_tools_init(&prefix); - } else { - rpl_tools_init(NULL); + rpl_dag_root_init_dag_immediately(); } + NETSTACK_MAC.on(); printf("Starting RPL node\n"); - + coap_engine_init(); coap_activate_resource(&resource_set_tx_power, "Set-TX-Power"); coap_activate_resource(&resource_get_tx_power, "Get-TX-Power"); diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile index 3773e04a5..edbc2fe19 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/Makefile @@ -7,7 +7,7 @@ CONTIKI=../../../../../.. PROJECT_SOURCEFILES += slip-bridge.c slip.c -MODULES_REL += .. ../../tools +MODULES_REL += .. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c index 3cc1dc266..fe72d1fc0 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c @@ -43,7 +43,6 @@ #include "net/netstack.h" #include "dev/slip.h" #include "coap-engine.h" -#include "rpl-tools.h" #include #include @@ -67,7 +66,7 @@ static int content_len = 0; PROCESS(border_router_process, "Border router process"); AUTOSTART_PROCESSES(&border_router_process); -RESOURCE(resource_get_rssi, +RESOURCE(resource_get_rssi, "title=\"Get RSSI\"", get_rssi_handler, NULL, @@ -88,7 +87,7 @@ get_rssi_handler(coap_message_t *request, coap_message_t *response, uint8_t *buf } } -RESOURCE(resource_get_last_rssi, +RESOURCE(resource_get_last_rssi, "title=\"Get last RSSI\"", get_last_rssi_handler, NULL, @@ -157,7 +156,8 @@ PROCESS_THREAD(border_router_process, ev, data) uip_debug_ipaddr_print(&prefix); PRINTF("\n"); - rpl_tools_init(&prefix); + rpl_dag_root_init(&prefix, NULL); + rpl_dag_root_init_dag_immediately(); coap_engine_init(); coap_activate_resource(&resource_get_rssi, "Get-RSSI"); diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile index 640495432..1dd86cc3d 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/Makefile @@ -6,7 +6,7 @@ TARGET_WITH_UART1 = 1 CONTIKI=../../../../.. -MODULES_REL += .. ../tools +MODULES_REL += .. MAKE_MAC = MAKE_MAC_TSCH MODULES += os/net/app-layer/coap diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c index affb6e6ca..71ea980e4 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c @@ -35,7 +35,6 @@ #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip.h" #include "net/linkaddr.h" -#include "rpl-tools.h" #include "coap-engine.h" #include "sys/ctimer.h" #include "dev/uart-driver.h" @@ -64,7 +63,7 @@ static int tail_index = 0; /* index where last read took place */ /* String aligned buffer */ #define RX_BUFFER_SIZE RINGBUF_SIZE -static uint8_t rx_buf[RX_BUFFER_SIZE+1]; +static uint8_t rx_buf[RX_BUFFER_SIZE+1]; static uint8_t rx_buf_index = 0; /* index for rx_buf */ /*---------------------------------------------------------------------------*/ @@ -75,7 +74,7 @@ AUTOSTART_PROCESSES(&start_app, &rx_data_process); /*********** COAP resources *************************************************/ /*****************************************************************************/ -/* Observable resource and event handler to obtain terminal input from UART1 */ +/* Observable resource and event handler to obtain terminal input from UART1 */ /*****************************************************************************/ EVENT_RESOURCE(resource_coap_rx_uart1, /* name */ "obs;title=\"rx_uart1\"", /* attributes */ @@ -95,7 +94,7 @@ get_coap_rx_uart1_handler(coap_message_t *request, coap_message_t *response, uin coap_set_header_content_format(response, TEXT_PLAIN); coap_set_payload(response, (uint8_t *)content, content_len); } -} +} static void event_coap_rx_uart1_handler(void) @@ -105,7 +104,7 @@ event_coap_rx_uart1_handler(void) } /*****************************************************************************/ -/* GET/PUT resource to send data to terminal on UART1 */ +/* GET/PUT resource to send data to terminal on UART1 */ /*****************************************************************************/ RESOURCE(resource_coap_tx_uart1, /* name */ "obs;title=\"tx_uart1\"", /* attributes */ @@ -140,20 +139,17 @@ PROCESS_THREAD(start_app, ev, data) /* Define process that handles data */ process_start(&rx_data_process ,NULL); /* Initialise UART1 */ - uart1_init(UART1_BAUD_RATE); + uart1_init(UART1_BAUD_RATE); /* Callback received byte */ uart1_set_input(handleRxChar); /* Start network stack */ if(is_coordinator) { - uip_ipaddr_t prefix; - uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); - rpl_tools_init(&prefix); - } else { - rpl_tools_init(NULL); + rpl_dag_root_init_dag_immediately(); } + NETSTACK_MAC.on(); printf("Starting RPL node\n"); - + coap_engine_init(); coap_activate_resource(&resource_coap_rx_uart1, "UART1-RX"); coap_activate_resource(&resource_coap_tx_uart1, "UART1-TX"); @@ -166,29 +162,29 @@ PROCESS_THREAD(start_app, ev, data) PROCESS_THREAD(rx_data_process, ev, data) { PROCESS_BEGIN(); - + /* Process is polled whenever data is available from uart isr */ uint8_t c; while(1) { PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL); - /* Read RX ringbuffer. ASCII chars Output when LF is seen. - If overflowed, strings are skipped */ + /* Read RX ringbuffer. ASCII chars Output when LF is seen. + If overflowed, strings are skipped */ do { if (get_ringbuf(&c) == -1) { break; /* No more rx char's in ringbuffer */ } else { if (rx_buf_index == RX_BUFFER_SIZE) { /* Skip current content if buffer full */ rx_buf_index = 0; - } + } rx_buf[rx_buf_index++] = c; if ((c == '\n')||(c == '\r')) { rx_buf[rx_buf_index] = '\0'; - printf("RX on UART1: %s", rx_buf); + printf("RX on UART1: %s", rx_buf); /* Signal event to coap clients. Demo assumes data is consumed before new data comes in */ - event_coap_rx_uart1_handler(); - rx_buf_index = 0; + event_coap_rx_uart1_handler(); + rx_buf_index = 0; } } } while (1); @@ -200,7 +196,7 @@ PROCESS_THREAD(rx_data_process, ev, data) /* Local test functions */ /*************************************************************************/ /* TX function for UART1 */ -static void +static void string2uart1(uint8_t *c) { while (*c!= '\0') { @@ -210,7 +206,7 @@ string2uart1(uint8_t *c) } /* handleRxChar runs on uart isr */ -static int +static int handleRxChar(uint8_t c) { if (put_ringbuf(c) == -1) { @@ -225,7 +221,7 @@ handleRxChar(uint8_t c) /* Simple ringbuffer if tail==head, no data has been written yet on that position. So, empty buffer is also initial state */ -static int +static int get_ringbuf(uint8_t *c) { int return_val = 0; @@ -241,7 +237,7 @@ get_ringbuf(uint8_t *c) return return_val; } -static int +static int put_ringbuf(uint8_t c) { int return_val = 0; @@ -249,10 +245,10 @@ put_ringbuf(uint8_t c) uart1_disable_interrupts(); if (head_index != tail_index) { ringbuf[head_index] = c; - head_index = ((head_index+1)&RINGBUF_MAX_INDEX); + head_index = ((head_index+1)&RINGBUF_MAX_INDEX); } else { return_val = -1; } uart1_enable_interrupts(); - return return_val; + return return_val; } From 14ccd337c9cbbc67754fa823e26b7d0200d131de Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 04:36:14 -0800 Subject: [PATCH 03/43] rpl_dag_root module simplification --- examples/6tisch/etsi-plugtest-2017/node.c | 2 +- examples/6tisch/simple-node/node.c | 2 +- examples/6tisch/sixtop/node-sixtop.c | 2 +- examples/ip64-router/ip64-router.c | 2 +- examples/ipso-objects/example-server.c | 4 +- examples/multicast/root.c | 2 +- .../jn516x/rpl/coap-dongle-node/dongle-node.c | 2 +- .../jn516x/rpl/coap-dr1175-node/dr1175-node.c | 2 +- .../jn516x/rpl/coap-dr1199-node/dr1199-node.c | 2 +- .../platform-specific/jn516x/rpl/node/node.c | 2 +- .../tsch/simple-sensor-network/node/node.c | 2 +- .../tsch/tx-power-verification/node/node.c | 2 +- .../rpl-border-router/rpl-border-router.c | 4 +- .../tsch/uart1-test-node/uart1-test-node.c | 2 +- .../zoul/orion/ip64-router/ip64-router.c | 4 +- examples/rpl-udp/udp-server.c | 2 +- os/net/rpl-classic/rpl-dag-root.c | 132 ++---------------- os/net/rpl-classic/rpl-dag-root.h | 5 +- os/net/rpl-lite/rpl-dag-root.c | 61 +------- os/net/rpl-lite/rpl-dag-root.h | 12 +- .../rpl-border-router/rpl-border-router.c | 4 +- os/services/shell/shell-commands.c | 4 +- .../code-ipv6/sender/unicast-sender.c | 2 +- tests/14-rpl-lite/code/root-node.c | 2 +- tests/15-rpl-classic/code/root-node.c | 2 +- 25 files changed, 42 insertions(+), 220 deletions(-) diff --git a/examples/6tisch/etsi-plugtest-2017/node.c b/examples/6tisch/etsi-plugtest-2017/node.c index 25035f7f4..a397dd4e1 100644 --- a/examples/6tisch/etsi-plugtest-2017/node.c +++ b/examples/6tisch/etsi-plugtest-2017/node.c @@ -77,7 +77,7 @@ PROCESS_THREAD(node_process, ev, data) #endif if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); diff --git a/examples/6tisch/simple-node/node.c b/examples/6tisch/simple-node/node.c index c11f8420c..8548f80ef 100644 --- a/examples/6tisch/simple-node/node.c +++ b/examples/6tisch/simple-node/node.c @@ -65,7 +65,7 @@ PROCESS_THREAD(node_process, ev, data) #endif if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); diff --git a/examples/6tisch/sixtop/node-sixtop.c b/examples/6tisch/sixtop/node-sixtop.c index b8b1e9e90..bd3cc97ea 100755 --- a/examples/6tisch/sixtop/node-sixtop.c +++ b/examples/6tisch/sixtop/node-sixtop.c @@ -73,7 +73,7 @@ PROCESS_THREAD(node_process, ev, data) #endif if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); diff --git a/examples/ip64-router/ip64-router.c b/examples/ip64-router/ip64-router.c index 3ce6ece6d..0d2078b91 100644 --- a/examples/ip64-router/ip64-router.c +++ b/examples/ip64-router/ip64-router.c @@ -14,7 +14,7 @@ PROCESS_THREAD(router_node_process, ev, data) PROCESS_BEGIN(); /* Set us up as a RPL root node. */ - rpl_dag_root_init_dag_delay(); + rpl_dag_root_start(); /* Initialize the IP64 module so we'll start translating packets */ ip64_init(); diff --git a/examples/ipso-objects/example-server.c b/examples/ipso-objects/example-server.c index f8bd44171..aa715f4d7 100644 --- a/examples/ipso-objects/example-server.c +++ b/examples/ipso-objects/example-server.c @@ -236,8 +236,8 @@ setup_network(void) uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); #endif - rpl_dag_root_init(&ipaddr, &ipaddr); - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_set_prefix(&ipaddr, &ipaddr); + rpl_dag_root_start(); #endif /* UIP_CONF_ROUTER */ PRINTF("IPv6 addresses: "); diff --git a/examples/multicast/root.c b/examples/multicast/root.c index 451c638ea..06b2534ba 100644 --- a/examples/multicast/root.c +++ b/examples/multicast/root.c @@ -111,7 +111,7 @@ PROCESS_THREAD(rpl_root_process, ev, data) PRINTF("Multicast Engine: '%s'\n", UIP_MCAST6.name); - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); prepare_mcast(); diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c index 8920bdd3b..a39ea774f 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c @@ -129,7 +129,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start net stack */ if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c index f7c60b718..0c5da13a3 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c @@ -349,7 +349,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start net stack */ if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c index 44b482ce5..6839b7cf5 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c @@ -350,7 +350,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start net stack */ if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/jn516x/rpl/node/node.c b/examples/platform-specific/jn516x/rpl/node/node.c index cb63f890f..6ba854093 100644 --- a/examples/platform-specific/jn516x/rpl/node/node.c +++ b/examples/platform-specific/jn516x/rpl/node/node.c @@ -96,7 +96,7 @@ PROCESS_THREAD(node_process, ev, data) is_coordinator = node_role > role_6ln; if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c index 1abeb2f46..8e64ac001 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c @@ -169,7 +169,7 @@ PROCESS_THREAD(node_process, ev, data) is_coordinator = node_role > role_6ln; if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c index a2f3c0a1e..ec1052e86 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c @@ -104,7 +104,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start network stack */ if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c index fe72d1fc0..16915f32a 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c @@ -156,8 +156,8 @@ PROCESS_THREAD(border_router_process, ev, data) uip_debug_ipaddr_print(&prefix); PRINTF("\n"); - rpl_dag_root_init(&prefix, NULL); - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_set_prefix(&prefix, NULL); + rpl_dag_root_start(); coap_engine_init(); coap_activate_resource(&resource_get_rssi, "Get-RSSI"); diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c index 71ea980e4..bf17f1f96 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c @@ -145,7 +145,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start network stack */ if(is_coordinator) { - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c b/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c index 0f321074e..f2b9f4606 100644 --- a/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c +++ b/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c @@ -247,7 +247,7 @@ PT_THREAD(generate_routes(struct httpd_state *s)) #if WEBSERVER_CONF_LOADTIME numticks = clock_time() - numticks + 1; - ADD(" (%u.%02u sec)", numticks / CLOCK_SECOND, + ADD(" (%u.%02u sec)", numticks / CLOCK_SECOND, (100 * (numticks % CLOCK_SECOND)) / CLOCK_SECOND)); #endif @@ -307,7 +307,7 @@ PROCESS_THREAD(router_node_process, ev, data) leds_off(LEDS_DHCP); /* Set us up as a RPL root node. */ - rpl_dag_root_init_dag_delay(); + rpl_dag_root_start(); /* ... and do nothing more. */ while(1) { diff --git a/examples/rpl-udp/udp-server.c b/examples/rpl-udp/udp-server.c index 9603b9e11..918da3c00 100644 --- a/examples/rpl-udp/udp-server.c +++ b/examples/rpl-udp/udp-server.c @@ -71,7 +71,7 @@ PROCESS_THREAD(udp_server_process, ev, data) PROCESS_BEGIN(); /* Initialize DAG root */ - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); /* Initialize UDP connection */ simple_udp_register(&udp_conn, UDP_SERVER_PORT, NULL, diff --git a/os/net/rpl-classic/rpl-dag-root.c b/os/net/rpl-classic/rpl-dag-root.c index 4082d936e..684b3c8ab 100644 --- a/os/net/rpl-classic/rpl-dag-root.c +++ b/os/net/rpl-classic/rpl-dag-root.c @@ -41,105 +41,6 @@ #define DEBUG DEBUG_NONE #include "net/ipv6/uip-debug.h" -#define RPL_DAG_GRACE_PERIOD (CLOCK_SECOND * 20 * 1) - -#if (UIP_MAX_ROUTES != 0) -static struct uip_ds6_notification n; -#endif /* (UIP_MAX_ROUTES != 0) */ -static uint8_t to_become_root; -static struct ctimer c; -/*---------------------------------------------------------------------------*/ -static const uip_ipaddr_t * -dag_root(void) -{ - rpl_dag_t *dag; - - dag = rpl_get_any_dag(); - if(dag != NULL) { - return &dag->dag_id; - } - - return NULL; -} -/*---------------------------------------------------------------------------*/ -static const uip_ipaddr_t * -get_global_address(void) -{ - int i; - uint8_t state; - uip_ipaddr_t *ipaddr = NULL; - - for(i = 0; i < UIP_DS6_ADDR_NB; i++) { - state = uip_ds6_if.addr_list[i].state; - if(uip_ds6_if.addr_list[i].isused && - state == ADDR_PREFERRED && - !uip_is_addr_linklocal(&uip_ds6_if.addr_list[i].ipaddr)) { - ipaddr = &uip_ds6_if.addr_list[i].ipaddr; - } - } - return ipaddr; -} -/*---------------------------------------------------------------------------*/ -static void -create_dag_callback(void *ptr) -{ - const uip_ipaddr_t *root, *ipaddr; - - root = dag_root(); - ipaddr = get_global_address(); - - if(root == NULL || uip_ipaddr_cmp(root, ipaddr)) { - /* The RPL network we are joining is one that we created, so we - become root. */ - if(to_become_root) { - rpl_dag_root_init_dag_immediately(); - to_become_root = 0; - } - } else { - rpl_dag_t *dag; - - dag = rpl_get_any_dag(); -#if DEBUG - printf("Found a network we did not create\n"); - printf("version %d grounded %d preference %d used %d joined %d rank %d\n", - dag->version, dag->grounded, - dag->preference, dag->used, - dag->joined, dag->rank); -#endif /* DEBUG */ - - /* We found a RPL network that we did not create so we just join - it without becoming root. But if the network has an infinite - rank, we assume the network has broken, and we become the new - root of the network. */ - - if(dag->rank == RPL_INFINITE_RANK) { - if(to_become_root) { - rpl_dag_root_init_dag_immediately(); - to_become_root = 0; - } - } - - /* Try again after the grace period */ - ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL); - } -} -#if (UIP_MAX_ROUTES != 0) -/*---------------------------------------------------------------------------*/ -static void -route_callback(int event, uip_ipaddr_t *route, uip_ipaddr_t *ipaddr, - int numroutes) -{ - if(event == UIP_DS6_NOTIFICATION_DEFRT_ADD) { - if(route != NULL && ipaddr != NULL && - !uip_is_addr_unspecified(route) && - !uip_is_addr_unspecified(ipaddr)) { - if(to_become_root) { - ctimer_set(&c, 0, create_dag_callback, NULL); - } - } - } -} -#endif /* (UIP_MAX_ROUTES != 0) */ /*---------------------------------------------------------------------------*/ static void set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) @@ -175,29 +76,25 @@ set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) } /*---------------------------------------------------------------------------*/ void -rpl_dag_root_init(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) +rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) { static uint8_t initialized = 0; if(!initialized) { - to_become_root = 0; set_global_address(prefix, iid); -#if (UIP_MAX_ROUTES != 0) - uip_ds6_notification_add(&n, route_callback); -#endif /* (UIP_MAX_ROUTES != 0) */ initialized = 1; } } /*---------------------------------------------------------------------------*/ int -rpl_dag_root_init_dag_immediately(void) +rpl_dag_root_start(void) { struct uip_ds6_addr *root_if; int i; uint8_t state; uip_ipaddr_t *ipaddr = NULL; - rpl_dag_root_init(NULL, NULL); + rpl_dag_root_set_prefix(NULL, NULL); for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; @@ -222,38 +119,25 @@ rpl_dag_root_init_dag_immediately(void) if(RPL_IS_STORING(dag->instance)) { rpl_remove_routes(dag); } - if(dag->instance != NULL && - dag->instance->def_route != NULL) { - uip_ds6_defrt_rm(dag->instance->def_route); + if(dag->instance != NULL && dag->instance->def_route != NULL) { + uip_ds6_defrt_rm(dag->instance->def_route); dag->instance->def_route = NULL; } uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); rpl_set_prefix(dag, &prefix, 64); - PRINTF("rpl_dag_root_init_dag: created a new RPL dag\n"); + PRINTF("rpl_dag_root_set_prefix_dag: created a new RPL dag\n"); return 0; } else { - PRINTF("rpl_dag_root_init_dag: failed to create a new RPL DAG\n"); + PRINTF("rpl_dag_root_set_prefix_dag: failed to create a new RPL DAG\n"); return -1; } } else { - PRINTF("rpl_dag_root_init_dag: failed to create a new RPL DAG, no preferred IP address found\n"); + PRINTF("rpl_dag_root_set_prefix_dag: failed to create a new RPL DAG, no preferred IP address found\n"); return -2; } } /*---------------------------------------------------------------------------*/ -void -rpl_dag_root_init_dag_delay(void) -{ - rpl_dag_root_init(NULL, NULL); - - ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL); - to_become_root = 1; - - /* Send a DIS packet to request RPL info from neighbors. */ - dis_output(NULL); -} -/*---------------------------------------------------------------------------*/ int rpl_dag_root_is_root(void) { diff --git a/os/net/rpl-classic/rpl-dag-root.h b/os/net/rpl-classic/rpl-dag-root.h index 05daec15b..9d2d09b02 100644 --- a/os/net/rpl-classic/rpl-dag-root.h +++ b/os/net/rpl-classic/rpl-dag-root.h @@ -32,9 +32,8 @@ #ifndef RPL_DAG_ROOT_H_ #define RPL_DAG_ROOT_H_ -void rpl_dag_root_init(uip_ipaddr_t *prefix, uip_ipaddr_t *iid); -void rpl_dag_root_init_dag_delay(void); -int rpl_dag_root_init_dag_immediately(void); +void rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid); +int rpl_dag_root_start(void); int rpl_dag_root_is_root(void); diff --git a/os/net/rpl-lite/rpl-dag-root.c b/os/net/rpl-lite/rpl-dag-root.c index cfe227d4c..fbd74e735 100644 --- a/os/net/rpl-lite/rpl-dag-root.c +++ b/os/net/rpl-lite/rpl-dag-root.c @@ -48,48 +48,6 @@ #define LOG_MODULE "RPL" #define LOG_LEVEL LOG_LEVEL_RPL -#define RPL_DAG_GRACE_PERIOD (CLOCK_SECOND * 20 * 1) - -static uint8_t to_become_root; -static struct ctimer c; - -/*---------------------------------------------------------------------------*/ -static void -create_dag_callback(void *ptr) -{ - const uip_ipaddr_t *root, *ipaddr; - - root = curr_instance.used ? &curr_instance.dag.dag_id : NULL; - ipaddr = rpl_get_global_address(); - - if(root == NULL || uip_ipaddr_cmp(root, ipaddr)) { - /* The RPL network we are joining is one that we created, so we - become root. */ - if(to_become_root) { - rpl_dag_root_init_dag_immediately(); - to_become_root = 0; - } - } else { - LOG_WARN("found a network we did not create: version %d grounded %d preference %d rank %d\n", - curr_instance.dag.version, curr_instance.dag.grounded, - curr_instance.dag.preference, curr_instance.dag.rank); - - /* We found a RPL network that we did not create so we just join - it without becoming root. But if the network has an infinite - rank, we assume the network has broken, and we become the new - root of the network. */ - - if(curr_instance.dag.rank == RPL_INFINITE_RANK) { - if(to_become_root) { - rpl_dag_root_init_dag_immediately(); - to_become_root = 0; - } - } - - /* Try again after the grace period */ - ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL); - } -} /*---------------------------------------------------------------------------*/ static void set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) @@ -125,26 +83,25 @@ set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) } /*---------------------------------------------------------------------------*/ void -rpl_dag_root_init(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) +rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) { static uint8_t initialized = 0; if(!initialized) { - to_become_root = 0; set_global_address(prefix, iid); initialized = 1; } } /*---------------------------------------------------------------------------*/ int -rpl_dag_root_init_dag_immediately(void) +rpl_dag_root_start(void) { struct uip_ds6_addr *root_if; int i; uint8_t state; uip_ipaddr_t *ipaddr = NULL; - rpl_dag_root_init(NULL, NULL); + rpl_dag_root_set_prefix(NULL, NULL); for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; @@ -170,18 +127,6 @@ rpl_dag_root_init_dag_immediately(void) } } /*---------------------------------------------------------------------------*/ -void -rpl_dag_root_init_dag_delay(void) -{ - rpl_dag_root_init(NULL, NULL); - - ctimer_set(&c, RPL_DAG_GRACE_PERIOD, create_dag_callback, NULL); - to_become_root = 1; - - /* Send a DIS packet to request RPL info from neighbors. */ - rpl_icmp6_dis_output(NULL); -} -/*---------------------------------------------------------------------------*/ int rpl_dag_root_is_root(void) { diff --git a/os/net/rpl-lite/rpl-dag-root.h b/os/net/rpl-lite/rpl-dag-root.h index d6260ff21..509367030 100644 --- a/os/net/rpl-lite/rpl-dag-root.h +++ b/os/net/rpl-lite/rpl-dag-root.h @@ -49,20 +49,14 @@ * \param prefix The prefix. If NULL, UIP_DS6_DEFAULT_PREFIX is used instead * \param iid The IID. If NULL, it will be built from uip_ds6_set_addr_iid. */ -void rpl_dag_root_init(uip_ipaddr_t *prefix, uip_ipaddr_t *iid); +void rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid); /** - * Initializes the node as DAG root after a delay. Until the delay, the node - * gets a chance to hear another DAG and join it instead. -*/ -void rpl_dag_root_init_dag_delay(void); - -/** - * Initializes the node as DAG root immediatly. + * Set the node as root and start a DAG * * \return 0 in case of success, -1 otherwise */ -int rpl_dag_root_init_dag_immediately(void); +int rpl_dag_root_start(void); /** * Tells whether we are DAG root or not diff --git a/os/services/rpl-border-router/rpl-border-router.c b/os/services/rpl-border-router/rpl-border-router.c index 13421b232..60cbf2ce1 100644 --- a/os/services/rpl-border-router/rpl-border-router.c +++ b/os/services/rpl-border-router/rpl-border-router.c @@ -64,8 +64,8 @@ void set_prefix_64(uip_ipaddr_t *prefix_64) { prefix_set = 1; - rpl_dag_root_init(prefix_64, NULL); - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_set_prefix(prefix_64, NULL); + rpl_dag_root_start(); } /*---------------------------------------------------------------------------*/ void diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index c9ca49e3d..e6789163b 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -324,8 +324,8 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args)) SHELL_OUTPUT(output, "Setting as DAG root with prefix "); shell_output_6addr(output, &prefix); SHELL_OUTPUT(output, "/64\n"); - rpl_dag_root_init(&prefix, NULL); - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_set_prefix(&prefix, NULL); + rpl_dag_root_start(); } else { SHELL_OUTPUT(output, "Node is already a DAG root\n"); } diff --git a/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c b/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c index 44cf49196..2899530af 100644 --- a/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c +++ b/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c @@ -40,7 +40,7 @@ PROCESS_THREAD(udp_process, ev, data) PROCESS_BEGIN(); - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); simple_udp_register(&broadcast_connection, UDP_PORT, NULL, UDP_PORT, diff --git a/tests/14-rpl-lite/code/root-node.c b/tests/14-rpl-lite/code/root-node.c index 153464842..9e584d4a0 100644 --- a/tests/14-rpl-lite/code/root-node.c +++ b/tests/14-rpl-lite/code/root-node.c @@ -74,7 +74,7 @@ PROCESS_THREAD(unicast_receiver_process, ev, data) { PROCESS_BEGIN(); - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); simple_udp_register(&unicast_connection, UDP_PORT, NULL, UDP_PORT, receiver); diff --git a/tests/15-rpl-classic/code/root-node.c b/tests/15-rpl-classic/code/root-node.c index 9983739b8..389add307 100644 --- a/tests/15-rpl-classic/code/root-node.c +++ b/tests/15-rpl-classic/code/root-node.c @@ -72,7 +72,7 @@ PROCESS_THREAD(unicast_receiver_process, ev, data) { PROCESS_BEGIN(); - rpl_dag_root_init_dag_immediately(); + rpl_dag_root_start(); simple_udp_register(&unicast_connection, UDP_PORT, NULL, UDP_PORT, receiver); From 7ddee2c66a3f1eba92429c457cdf5a8b5ff30478 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 04:55:57 -0800 Subject: [PATCH 04/43] Move rpl-lite and rpl-classic to os/net/routing --- Makefile.include | 4 ++-- os/net/{ => routing}/rpl-classic/rpl-conf.h | 0 .../{ => routing}/rpl-classic/rpl-dag-root.c | 0 .../{ => routing}/rpl-classic/rpl-dag-root.h | 0 os/net/{ => routing}/rpl-classic/rpl-dag.c | 0 .../rpl-classic/rpl-ext-header.c | 4 ++-- os/net/{ => routing}/rpl-classic/rpl-icmp6.c | 4 ++-- os/net/{ => routing}/rpl-classic/rpl-mrhof.c | 4 ++-- .../rpl-classic/rpl-nbr-policy.c | 2 +- os/net/{ => routing}/rpl-classic/rpl-ns.c | 6 +++--- os/net/{ => routing}/rpl-classic/rpl-ns.h | 2 +- os/net/{ => routing}/rpl-classic/rpl-of0.c | 4 ++-- .../{ => routing}/rpl-classic/rpl-private.h | 4 ++-- os/net/{ => routing}/rpl-classic/rpl-timers.c | 4 ++-- os/net/{ => routing}/rpl-classic/rpl.c | 4 ++-- os/net/{ => routing}/rpl-classic/rpl.h | 2 +- os/net/{ => routing}/rpl-lite/rpl-conf.h | 0 os/net/{ => routing}/rpl-lite/rpl-const.h | 0 os/net/{ => routing}/rpl-lite/rpl-dag-root.c | 2 +- os/net/{ => routing}/rpl-lite/rpl-dag-root.h | 0 os/net/{ => routing}/rpl-lite/rpl-dag.c | 2 +- os/net/{ => routing}/rpl-lite/rpl-dag.h | 0 .../{ => routing}/rpl-lite/rpl-ext-header.c | 2 +- .../{ => routing}/rpl-lite/rpl-ext-header.h | 0 os/net/{ => routing}/rpl-lite/rpl-icmp6.c | 2 +- os/net/{ => routing}/rpl-lite/rpl-icmp6.h | 0 os/net/{ => routing}/rpl-lite/rpl-mrhof.c | 2 +- .../{ => routing}/rpl-lite/rpl-nbr-policy.c | 2 +- os/net/{ => routing}/rpl-lite/rpl-neighbor.c | 2 +- os/net/{ => routing}/rpl-lite/rpl-neighbor.h | 2 +- os/net/{ => routing}/rpl-lite/rpl-ns.c | 2 +- os/net/{ => routing}/rpl-lite/rpl-ns.h | 2 +- os/net/{ => routing}/rpl-lite/rpl-of0.c | 2 +- os/net/{ => routing}/rpl-lite/rpl-timers.c | 2 +- os/net/{ => routing}/rpl-lite/rpl-timers.h | 2 +- os/net/{ => routing}/rpl-lite/rpl-types.h | 0 os/net/{ => routing}/rpl-lite/rpl.c | 2 +- os/net/{ => routing}/rpl-lite/rpl.h | 20 +++++++++---------- 38 files changed, 46 insertions(+), 46 deletions(-) rename os/net/{ => routing}/rpl-classic/rpl-conf.h (100%) rename os/net/{ => routing}/rpl-classic/rpl-dag-root.c (100%) rename os/net/{ => routing}/rpl-classic/rpl-dag-root.h (100%) rename os/net/{ => routing}/rpl-classic/rpl-dag.c (100%) rename os/net/{ => routing}/rpl-classic/rpl-ext-header.c (99%) rename os/net/{ => routing}/rpl-classic/rpl-icmp6.c (99%) rename os/net/{ => routing}/rpl-classic/rpl-mrhof.c (99%) rename os/net/{ => routing}/rpl-classic/rpl-nbr-policy.c (99%) rename os/net/{ => routing}/rpl-classic/rpl-ns.c (98%) rename os/net/{ => routing}/rpl-classic/rpl-ns.h (98%) rename os/net/{ => routing}/rpl-classic/rpl-of0.c (98%) rename os/net/{ => routing}/rpl-classic/rpl-private.h (99%) rename os/net/{ => routing}/rpl-classic/rpl-timers.c (99%) rename os/net/{ => routing}/rpl-classic/rpl.c (99%) rename os/net/{ => routing}/rpl-classic/rpl.h (99%) rename os/net/{ => routing}/rpl-lite/rpl-conf.h (100%) rename os/net/{ => routing}/rpl-lite/rpl-const.h (100%) rename os/net/{ => routing}/rpl-lite/rpl-dag-root.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-dag-root.h (100%) rename os/net/{ => routing}/rpl-lite/rpl-dag.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-dag.h (100%) rename os/net/{ => routing}/rpl-lite/rpl-ext-header.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-ext-header.h (100%) rename os/net/{ => routing}/rpl-lite/rpl-icmp6.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-icmp6.h (100%) rename os/net/{ => routing}/rpl-lite/rpl-mrhof.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-nbr-policy.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-neighbor.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-neighbor.h (99%) rename os/net/{ => routing}/rpl-lite/rpl-ns.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-ns.h (99%) rename os/net/{ => routing}/rpl-lite/rpl-of0.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-timers.c (99%) rename os/net/{ => routing}/rpl-lite/rpl-timers.h (98%) rename os/net/{ => routing}/rpl-lite/rpl-types.h (100%) rename os/net/{ => routing}/rpl-lite/rpl.c (99%) rename os/net/{ => routing}/rpl-lite/rpl.h (89%) diff --git a/Makefile.include b/Makefile.include index b74b2c878..4da1ce33c 100644 --- a/Makefile.include +++ b/Makefile.include @@ -153,11 +153,11 @@ endif ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC) CFLAGS += -DUIP_CONF_IPV6_RPL=1 CFLAGS += -DUIP_CONF_IPV6_RPL_CLASSIC=1 - MODULES += os/net/rpl-classic + MODULES += os/net/routing/rpl-classic else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_LITE) CFLAGS += -DUIP_CONF_IPV6_RPL=1 CFLAGS += -DUIP_CONF_IPV6_RPL_LITE=1 - MODULES += os/net/rpl-lite + MODULES += os/net/routing/rpl-lite else CFLAGS += -DUIP_CONF_IPV6_RPL=0 endif diff --git a/os/net/rpl-classic/rpl-conf.h b/os/net/routing/rpl-classic/rpl-conf.h similarity index 100% rename from os/net/rpl-classic/rpl-conf.h rename to os/net/routing/rpl-classic/rpl-conf.h diff --git a/os/net/rpl-classic/rpl-dag-root.c b/os/net/routing/rpl-classic/rpl-dag-root.c similarity index 100% rename from os/net/rpl-classic/rpl-dag-root.c rename to os/net/routing/rpl-classic/rpl-dag-root.c diff --git a/os/net/rpl-classic/rpl-dag-root.h b/os/net/routing/rpl-classic/rpl-dag-root.h similarity index 100% rename from os/net/rpl-classic/rpl-dag-root.h rename to os/net/routing/rpl-classic/rpl-dag-root.h diff --git a/os/net/rpl-classic/rpl-dag.c b/os/net/routing/rpl-classic/rpl-dag.c similarity index 100% rename from os/net/rpl-classic/rpl-dag.c rename to os/net/routing/rpl-classic/rpl-dag.c diff --git a/os/net/rpl-classic/rpl-ext-header.c b/os/net/routing/rpl-classic/rpl-ext-header.c similarity index 99% rename from os/net/rpl-classic/rpl-ext-header.c rename to os/net/routing/rpl-classic/rpl-ext-header.c index 083d26741..250aeb924 100644 --- a/os/net/rpl-classic/rpl-ext-header.c +++ b/os/net/routing/rpl-classic/rpl-ext-header.c @@ -47,8 +47,8 @@ #include "net/ipv6/uip.h" #include "net/ipv6/tcpip.h" #include "net/ipv6/uip-ds6.h" -#include "net/rpl-classic/rpl-private.h" -#include "net/rpl-classic/rpl-ns.h" +#include "net/routing/rpl-classic/rpl-private.h" +#include "net/routing/rpl-classic/rpl-ns.h" #include "net/packetbuf.h" #define DEBUG DEBUG_NONE diff --git a/os/net/rpl-classic/rpl-icmp6.c b/os/net/routing/rpl-classic/rpl-icmp6.c similarity index 99% rename from os/net/rpl-classic/rpl-icmp6.c rename to os/net/routing/rpl-classic/rpl-icmp6.c index 6d9a2bca3..2e121b5e2 100644 --- a/os/net/rpl-classic/rpl-icmp6.c +++ b/os/net/routing/rpl-classic/rpl-icmp6.c @@ -50,8 +50,8 @@ #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-nd6.h" #include "net/ipv6/uip-icmp6.h" -#include "net/rpl-classic/rpl-private.h" -#include "net/rpl-classic/rpl-ns.h" +#include "net/routing/rpl-classic/rpl-private.h" +#include "net/routing/rpl-classic/rpl-ns.h" #include "net/packetbuf.h" #include "net/ipv6/multicast/uip-mcast6.h" #include "random.h" diff --git a/os/net/rpl-classic/rpl-mrhof.c b/os/net/routing/rpl-classic/rpl-mrhof.c similarity index 99% rename from os/net/rpl-classic/rpl-mrhof.c rename to os/net/routing/rpl-classic/rpl-mrhof.c index 21db377e7..4f5189384 100644 --- a/os/net/rpl-classic/rpl-mrhof.c +++ b/os/net/routing/rpl-classic/rpl-mrhof.c @@ -46,8 +46,8 @@ * @{ */ -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" +#include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-private.h" #include "net/nbr-table.h" #include "net/link-stats.h" diff --git a/os/net/rpl-classic/rpl-nbr-policy.c b/os/net/routing/rpl-classic/rpl-nbr-policy.c similarity index 99% rename from os/net/rpl-classic/rpl-nbr-policy.c rename to os/net/routing/rpl-classic/rpl-nbr-policy.c index 1804fd4b7..077977a10 100644 --- a/os/net/rpl-classic/rpl-nbr-policy.c +++ b/os/net/routing/rpl-classic/rpl-nbr-policy.c @@ -44,7 +44,7 @@ * */ -#include "net/rpl-classic/rpl-private.h" +#include "net/routing/rpl-classic/rpl-private.h" #include "net/nbr-table.h" #include "net/ipv6/uip-ds6-nbr.h" #include "net/ipv6/uip-ds6-route.h" diff --git a/os/net/rpl-classic/rpl-ns.c b/os/net/routing/rpl-classic/rpl-ns.c similarity index 98% rename from os/net/rpl-classic/rpl-ns.c rename to os/net/routing/rpl-classic/rpl-ns.c index dc2eb23e4..b28a7c002 100644 --- a/os/net/rpl-classic/rpl-ns.c +++ b/os/net/routing/rpl-classic/rpl-ns.c @@ -37,14 +37,14 @@ * \author Simon Duquennoy */ -#include "net/rpl-classic/rpl-conf.h" +#include "net/routing/rpl-classic/rpl-conf.h" #include "net/ipv6/uip.h" #include "net/ipv6/tcpip.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-icmp6.h" -#include "net/rpl-classic/rpl-private.h" -#include "net/rpl-classic/rpl-ns.h" +#include "net/routing/rpl-classic/rpl-private.h" +#include "net/routing/rpl-classic/rpl-ns.h" #include "lib/list.h" #include "lib/memb.h" diff --git a/os/net/rpl-classic/rpl-ns.h b/os/net/routing/rpl-classic/rpl-ns.h similarity index 98% rename from os/net/rpl-classic/rpl-ns.h rename to os/net/routing/rpl-classic/rpl-ns.h index dcc7e584a..83f2621b8 100644 --- a/os/net/rpl-classic/rpl-ns.h +++ b/os/net/routing/rpl-classic/rpl-ns.h @@ -41,7 +41,7 @@ #ifndef RPL_NS_H #define RPL_NS_H -#include "net/rpl-classic/rpl-conf.h" +#include "net/routing/rpl-classic/rpl-conf.h" #ifdef RPL_NS_CONF_LINK_NUM #define RPL_NS_LINK_NUM RPL_NS_CONF_LINK_NUM diff --git a/os/net/rpl-classic/rpl-of0.c b/os/net/routing/rpl-classic/rpl-of0.c similarity index 98% rename from os/net/rpl-classic/rpl-of0.c rename to os/net/routing/rpl-classic/rpl-of0.c index aa18823cb..1a679d23b 100644 --- a/os/net/rpl-classic/rpl-of0.c +++ b/os/net/routing/rpl-classic/rpl-of0.c @@ -42,8 +42,8 @@ * @{ */ -#include "net/rpl-classic/rpl.h" -#include "net/rpl-classic/rpl-private.h" +#include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-private.h" #include "net/nbr-table.h" #include "net/link-stats.h" diff --git a/os/net/rpl-classic/rpl-private.h b/os/net/routing/rpl-classic/rpl-private.h similarity index 99% rename from os/net/rpl-classic/rpl-private.h rename to os/net/routing/rpl-classic/rpl-private.h index 723154cdd..ab77329a0 100644 --- a/os/net/rpl-classic/rpl-private.h +++ b/os/net/routing/rpl-classic/rpl-private.h @@ -37,7 +37,7 @@ #ifndef RPL_PRIVATE_H #define RPL_PRIVATE_H -#include "net/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl.h" #include "lib/list.h" #include "net/ipv6/uip.h" @@ -45,7 +45,7 @@ #include "sys/ctimer.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-ds6-route.h" -#include "net/rpl-classic/rpl-ns.h" +#include "net/routing/rpl-classic/rpl-ns.h" #include "net/ipv6/multicast/uip-mcast6.h" /*---------------------------------------------------------------------------*/ diff --git a/os/net/rpl-classic/rpl-timers.c b/os/net/routing/rpl-classic/rpl-timers.c similarity index 99% rename from os/net/rpl-classic/rpl-timers.c rename to os/net/routing/rpl-classic/rpl-timers.c index 7742a5fcc..dd61c5ff4 100644 --- a/os/net/rpl-classic/rpl-timers.c +++ b/os/net/routing/rpl-classic/rpl-timers.c @@ -42,8 +42,8 @@ */ #include "contiki.h" -#include "net/rpl-classic/rpl-private.h" -#include "net/rpl-classic/rpl-ns.h" +#include "net/routing/rpl-classic/rpl-private.h" +#include "net/routing/rpl-classic/rpl-ns.h" #include "net/link-stats.h" #include "net/ipv6/multicast/uip-mcast6.h" #include "lib/random.h" diff --git a/os/net/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c similarity index 99% rename from os/net/rpl-classic/rpl.c rename to os/net/routing/rpl-classic/rpl.c index dfa7c99cf..47dae7358 100644 --- a/os/net/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -46,8 +46,8 @@ #include "net/ipv6/tcpip.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-icmp6.h" -#include "net/rpl-classic/rpl-private.h" -#include "net/rpl-classic/rpl-ns.h" +#include "net/routing/rpl-classic/rpl-private.h" +#include "net/routing/rpl-classic/rpl-ns.h" #include "net/ipv6/multicast/uip-mcast6.h" #define DEBUG DEBUG_NONE diff --git a/os/net/rpl-classic/rpl.h b/os/net/routing/rpl-classic/rpl.h similarity index 99% rename from os/net/rpl-classic/rpl.h rename to os/net/routing/rpl-classic/rpl.h index 2fe9f1dbf..5500affce 100644 --- a/os/net/rpl-classic/rpl.h +++ b/os/net/routing/rpl-classic/rpl.h @@ -38,7 +38,7 @@ #ifndef RPL_H #define RPL_H -#include "net/rpl-classic/rpl-conf.h" +#include "net/routing/rpl-classic/rpl-conf.h" #include "lib/list.h" #include "net/ipv6/uip.h" diff --git a/os/net/rpl-lite/rpl-conf.h b/os/net/routing/rpl-lite/rpl-conf.h similarity index 100% rename from os/net/rpl-lite/rpl-conf.h rename to os/net/routing/rpl-lite/rpl-conf.h diff --git a/os/net/rpl-lite/rpl-const.h b/os/net/routing/rpl-lite/rpl-const.h similarity index 100% rename from os/net/rpl-lite/rpl-const.h rename to os/net/routing/rpl-lite/rpl-const.h diff --git a/os/net/rpl-lite/rpl-dag-root.c b/os/net/routing/rpl-lite/rpl-dag-root.c similarity index 99% rename from os/net/rpl-lite/rpl-dag-root.c rename to os/net/routing/rpl-lite/rpl-dag-root.c index fbd74e735..0d5cebe92 100644 --- a/os/net/rpl-lite/rpl-dag-root.c +++ b/os/net/routing/rpl-lite/rpl-dag-root.c @@ -40,7 +40,7 @@ #include "contiki.h" #include "contiki-net.h" -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "net/ipv6/uip-ds6-route.h" /* Log configuration */ diff --git a/os/net/rpl-lite/rpl-dag-root.h b/os/net/routing/rpl-lite/rpl-dag-root.h similarity index 100% rename from os/net/rpl-lite/rpl-dag-root.h rename to os/net/routing/rpl-lite/rpl-dag-root.h diff --git a/os/net/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c similarity index 99% rename from os/net/rpl-lite/rpl-dag.c rename to os/net/routing/rpl-lite/rpl-dag.c index 36373dfb1..a89b972c1 100644 --- a/os/net/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -42,7 +42,7 @@ * Contributors: George Oikonomou (multicast) */ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "net/nbr-table.h" #include "net/link-stats.h" diff --git a/os/net/rpl-lite/rpl-dag.h b/os/net/routing/rpl-lite/rpl-dag.h similarity index 100% rename from os/net/rpl-lite/rpl-dag.h rename to os/net/routing/rpl-lite/rpl-dag.h diff --git a/os/net/rpl-lite/rpl-ext-header.c b/os/net/routing/rpl-lite/rpl-ext-header.c similarity index 99% rename from os/net/rpl-lite/rpl-ext-header.c rename to os/net/routing/rpl-lite/rpl-ext-header.c index 6031d7eef..eda59a744 100644 --- a/os/net/rpl-lite/rpl-ext-header.c +++ b/os/net/routing/rpl-lite/rpl-ext-header.c @@ -43,7 +43,7 @@ * Simon Duquennoy */ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "net/packetbuf.h" /* Log configuration */ diff --git a/os/net/rpl-lite/rpl-ext-header.h b/os/net/routing/rpl-lite/rpl-ext-header.h similarity index 100% rename from os/net/rpl-lite/rpl-ext-header.h rename to os/net/routing/rpl-lite/rpl-ext-header.h diff --git a/os/net/rpl-lite/rpl-icmp6.c b/os/net/routing/rpl-lite/rpl-icmp6.c similarity index 99% rename from os/net/rpl-lite/rpl-icmp6.c rename to os/net/routing/rpl-lite/rpl-icmp6.c index 65c486be5..1e4a50423 100644 --- a/os/net/rpl-lite/rpl-icmp6.c +++ b/os/net/routing/rpl-lite/rpl-icmp6.c @@ -44,7 +44,7 @@ * George Oikonomou (multicast) */ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "net/ipv6/uip-icmp6.h" #include "net/packetbuf.h" #include "lib/random.h" diff --git a/os/net/rpl-lite/rpl-icmp6.h b/os/net/routing/rpl-lite/rpl-icmp6.h similarity index 100% rename from os/net/rpl-lite/rpl-icmp6.h rename to os/net/routing/rpl-lite/rpl-icmp6.h diff --git a/os/net/rpl-lite/rpl-mrhof.c b/os/net/routing/rpl-lite/rpl-mrhof.c similarity index 99% rename from os/net/rpl-lite/rpl-mrhof.c rename to os/net/routing/rpl-lite/rpl-mrhof.c index 9f9ba2889..a0b2546eb 100644 --- a/os/net/rpl-lite/rpl-mrhof.c +++ b/os/net/routing/rpl-lite/rpl-mrhof.c @@ -45,7 +45,7 @@ * Simon Duquennoy */ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "net/nbr-table.h" #include "net/link-stats.h" diff --git a/os/net/rpl-lite/rpl-nbr-policy.c b/os/net/routing/rpl-lite/rpl-nbr-policy.c similarity index 99% rename from os/net/rpl-lite/rpl-nbr-policy.c rename to os/net/routing/rpl-lite/rpl-nbr-policy.c index 0a8da44d4..f848ddb39 100644 --- a/os/net/rpl-lite/rpl-nbr-policy.c +++ b/os/net/routing/rpl-lite/rpl-nbr-policy.c @@ -42,7 +42,7 @@ * */ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "net/nbr-table.h" /* Log configuration */ diff --git a/os/net/rpl-lite/rpl-neighbor.c b/os/net/routing/rpl-lite/rpl-neighbor.c similarity index 99% rename from os/net/rpl-lite/rpl-neighbor.c rename to os/net/routing/rpl-lite/rpl-neighbor.c index 96c85a886..d6a545e13 100644 --- a/os/net/rpl-lite/rpl-neighbor.c +++ b/os/net/routing/rpl-lite/rpl-neighbor.c @@ -43,7 +43,7 @@ */ #include "contiki.h" -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "net/link-stats.h" #include "net/nbr-table.h" diff --git a/os/net/rpl-lite/rpl-neighbor.h b/os/net/routing/rpl-lite/rpl-neighbor.h similarity index 99% rename from os/net/rpl-lite/rpl-neighbor.h rename to os/net/routing/rpl-lite/rpl-neighbor.h index 319ab2414..028d089c7 100644 --- a/os/net/rpl-lite/rpl-neighbor.h +++ b/os/net/routing/rpl-lite/rpl-neighbor.h @@ -47,7 +47,7 @@ /********** Includes **********/ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "lib/list.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" diff --git a/os/net/rpl-lite/rpl-ns.c b/os/net/routing/rpl-lite/rpl-ns.c similarity index 99% rename from os/net/rpl-lite/rpl-ns.c rename to os/net/routing/rpl-lite/rpl-ns.c index 0b31484b8..12c23ff30 100644 --- a/os/net/rpl-lite/rpl-ns.c +++ b/os/net/routing/rpl-lite/rpl-ns.c @@ -40,7 +40,7 @@ * \author Simon Duquennoy */ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "lib/list.h" #include "lib/memb.h" diff --git a/os/net/rpl-lite/rpl-ns.h b/os/net/routing/rpl-lite/rpl-ns.h similarity index 99% rename from os/net/rpl-lite/rpl-ns.h rename to os/net/routing/rpl-lite/rpl-ns.h index 5f6e3d86d..6e4a1e471 100644 --- a/os/net/rpl-lite/rpl-ns.h +++ b/os/net/routing/rpl-lite/rpl-ns.h @@ -47,7 +47,7 @@ /********** Includes **********/ #include "net/ipv6/uip.h" -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" /********** Data Structures **********/ diff --git a/os/net/rpl-lite/rpl-of0.c b/os/net/routing/rpl-lite/rpl-of0.c similarity index 99% rename from os/net/rpl-lite/rpl-of0.c rename to os/net/routing/rpl-lite/rpl-of0.c index 0e94f73f9..c6f820157 100644 --- a/os/net/rpl-lite/rpl-of0.c +++ b/os/net/routing/rpl-lite/rpl-of0.c @@ -41,7 +41,7 @@ * Simon Duquennoy */ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "net/nbr-table.h" #include "net/link-stats.h" diff --git a/os/net/rpl-lite/rpl-timers.c b/os/net/routing/rpl-lite/rpl-timers.c similarity index 99% rename from os/net/rpl-lite/rpl-timers.c rename to os/net/routing/rpl-lite/rpl-timers.c index 486ccd5b4..0925c8f6b 100644 --- a/os/net/rpl-lite/rpl-timers.c +++ b/os/net/routing/rpl-lite/rpl-timers.c @@ -41,7 +41,7 @@ */ #include "contiki.h" -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" #include "net/link-stats.h" #include "lib/random.h" #include "sys/ctimer.h" diff --git a/os/net/rpl-lite/rpl-timers.h b/os/net/routing/rpl-lite/rpl-timers.h similarity index 98% rename from os/net/rpl-lite/rpl-timers.h rename to os/net/routing/rpl-lite/rpl-timers.h index c32f3775c..884a55696 100644 --- a/os/net/rpl-lite/rpl-timers.h +++ b/os/net/routing/rpl-lite/rpl-timers.h @@ -47,7 +47,7 @@ /********** Includes **********/ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" /********** Public functions **********/ diff --git a/os/net/rpl-lite/rpl-types.h b/os/net/routing/rpl-lite/rpl-types.h similarity index 100% rename from os/net/rpl-lite/rpl-types.h rename to os/net/routing/rpl-lite/rpl-types.h diff --git a/os/net/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c similarity index 99% rename from os/net/rpl-lite/rpl.c rename to os/net/routing/rpl-lite/rpl.c index 29eca52b0..20d77343c 100644 --- a/os/net/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -41,7 +41,7 @@ * Simon Duquennoy */ -#include "net/rpl-lite/rpl.h" +#include "net/routing/rpl-lite/rpl.h" /* Log configuration */ #include "sys/log.h" diff --git a/os/net/rpl-lite/rpl.h b/os/net/routing/rpl-lite/rpl.h similarity index 89% rename from os/net/rpl-lite/rpl.h rename to os/net/routing/rpl-lite/rpl.h index 9557f41c3..e049cb2f4 100644 --- a/os/net/rpl-lite/rpl.h +++ b/os/net/routing/rpl-lite/rpl.h @@ -48,16 +48,16 @@ /********** Includes **********/ #include "net/ipv6/uip.h" -#include "net/rpl-lite/rpl-const.h" -#include "net/rpl-lite/rpl-conf.h" -#include "net/rpl-lite/rpl-types.h" -#include "net/rpl-lite/rpl-icmp6.h" -#include "net/rpl-lite/rpl-dag.h" -#include "net/rpl-lite/rpl-ns.h" -#include "net/rpl-lite/rpl-dag-root.h" -#include "net/rpl-lite/rpl-neighbor.h" -#include "net/rpl-lite/rpl-ext-header.h" -#include "net/rpl-lite/rpl-timers.h" +#include "net/routing/rpl-lite/rpl-const.h" +#include "net/routing/rpl-lite/rpl-conf.h" +#include "net/routing/rpl-lite/rpl-types.h" +#include "net/routing/rpl-lite/rpl-icmp6.h" +#include "net/routing/rpl-lite/rpl-dag.h" +#include "net/routing/rpl-lite/rpl-ns.h" +#include "net/routing/rpl-lite/rpl-dag-root.h" +#include "net/routing/rpl-lite/rpl-neighbor.h" +#include "net/routing/rpl-lite/rpl-ext-header.h" +#include "net/routing/rpl-lite/rpl-timers.h" /********** Public symbols **********/ From 4c9f62ebe4a9e4cfdb52c5925752d3fd79e66652 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 05:13:09 -0800 Subject: [PATCH 05/43] Added NETSTACK_ROUTING for routing protocol selection. Only used for init() so far. --- Makefile.include | 4 ++ os/net/ipv6/tcpip.c | 6 +- os/net/netstack.h | 1 + os/net/routing/nullrouting/nullrouting.c | 56 +++++++++++++++++++ os/net/routing/routing.h | 9 +-- os/net/routing/rpl-classic/rpl.c | 9 ++- os/net/routing/rpl-classic/rpl.h | 1 - os/net/routing/rpl-lite/rpl.c | 8 ++- os/net/routing/rpl-lite/rpl.h | 5 -- .../native/border-router-native.c | 2 +- 10 files changed, 82 insertions(+), 19 deletions(-) create mode 100644 os/net/routing/nullrouting/nullrouting.c diff --git a/Makefile.include b/Makefile.include index 4da1ce33c..c8110ad66 100644 --- a/Makefile.include +++ b/Makefile.include @@ -153,13 +153,17 @@ endif ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC) CFLAGS += -DUIP_CONF_IPV6_RPL=1 CFLAGS += -DUIP_CONF_IPV6_RPL_CLASSIC=1 + CFLAGS += -DNETSTACK_ROUTING=rpl_classic_driver MODULES += os/net/routing/rpl-classic else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_LITE) CFLAGS += -DUIP_CONF_IPV6_RPL=1 CFLAGS += -DUIP_CONF_IPV6_RPL_LITE=1 + CFLAGS += -DNETSTACK_ROUTING=rpl_lite_driver MODULES += os/net/routing/rpl-lite else CFLAGS += -DUIP_CONF_IPV6_RPL=0 + CFLAGS += -DNETSTACK_ROUTING=nullrouting_driver + MODULES += os/net/routing/nullrouting endif MODULEDIRS = $(MODULES_REL) ${wildcard ${addprefix $(CONTIKI)/, $(MODULES)}} diff --git a/os/net/ipv6/tcpip.c b/os/net/ipv6/tcpip.c index 53a7c30f4..dc2af6174 100644 --- a/os/net/ipv6/tcpip.c +++ b/os/net/ipv6/tcpip.c @@ -847,10 +847,8 @@ PROCESS_THREAD(tcpip_process, ev, data) #ifdef UIP_FALLBACK_INTERFACE UIP_FALLBACK_INTERFACE.init(); #endif - /* initialize RPL if configured for using RPL */ -#if UIP_CONF_IPV6_RPL - rpl_init(); -#endif /* UIP_CONF_IPV6_RPL */ + /* Initialize routing protocol */ + NETSTACK_ROUTING.init(); while(1) { PROCESS_YIELD(); diff --git a/os/net/netstack.h b/os/net/netstack.h index 4251ef5e9..963b40c42 100644 --- a/os/net/netstack.h +++ b/os/net/netstack.h @@ -110,6 +110,7 @@ struct network_driver { }; +extern const struct routing_driver NETSTACK_ROUTING; extern const struct network_driver NETSTACK_NETWORK; extern const struct mac_driver NETSTACK_MAC; extern const struct radio_driver NETSTACK_RADIO; diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c new file mode 100644 index 000000000..706c590ff --- /dev/null +++ b/os/net/routing/nullrouting/nullrouting.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, RISE SICS. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of the Contiki operating system. + */ + +/** + * \addtogroup null-routing + * @{ + * + * \file + * A routing protocol that does nothing + * + * \author Simon Duquennoy + */ + +#include "net/routing/routing.h" + +/*---------------------------------------------------------------------------*/ +static void +init(void) +{ +} +/*---------------------------------------------------------------------------*/ +const struct routing_driver nullrouting_driver = { + "Null Routing", + init, +}; +/*---------------------------------------------------------------------------*/ + +/** @}*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index e4bc65938..a213cc92d 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -41,12 +41,9 @@ #define ROUTING_H_ #include "contiki.h" - -#include "rpl.h" -#include "rpl-dag-root.h" -#if UIP_CONF_IPV6_RPL_LITE == 0 -#include "rpl-private.h" -#endif /* UIP_CONF_IPV6_RPL_LITE == 0 */ +#include "net/ipv6/uip.h" +#include "net/ipv6/uip-ds6-route.h" +#include "net/linkaddr.h" /** * The structure of a routing protocol driver. diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 47dae7358..2821e615e 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -46,8 +46,10 @@ #include "net/ipv6/tcpip.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-icmp6.h" +#include "net/routing/routing.h" #include "net/routing/rpl-classic/rpl-private.h" #include "net/routing/rpl-classic/rpl-ns.h" +#include "net/routing/rpl-classic/rpl-dag-root.h" #include "net/ipv6/multicast/uip-mcast6.h" #define DEBUG DEBUG_NONE @@ -327,7 +329,7 @@ rpl_purge_dags(void) } } /*---------------------------------------------------------------------------*/ -void +static void rpl_init(void) { uip_ipaddr_t rplmaddr; @@ -351,5 +353,10 @@ rpl_init(void) #endif /* RPL_WITH_NON_STORING */ } /*---------------------------------------------------------------------------*/ +const struct routing_driver rpl_classic_driver = { + "RPL Classic", + rpl_init, +}; +/*---------------------------------------------------------------------------*/ /** @}*/ diff --git a/os/net/routing/rpl-classic/rpl.h b/os/net/routing/rpl-classic/rpl.h index 5500affce..85f092606 100644 --- a/os/net/routing/rpl-classic/rpl.h +++ b/os/net/routing/rpl-classic/rpl.h @@ -266,7 +266,6 @@ struct rpl_instance { /*---------------------------------------------------------------------------*/ /* Public RPL functions. */ -void rpl_init(void); void uip_rpl_input(void); rpl_dag_t *rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id); int rpl_set_prefix(rpl_dag_t *dag, uip_ipaddr_t *prefix, unsigned len); diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 20d77343c..7851c0535 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -42,6 +42,7 @@ */ #include "net/routing/rpl-lite/rpl.h" +#include "net/routing/routing.h" /* Log configuration */ #include "sys/log.h" @@ -175,7 +176,7 @@ rpl_set_prefix(rpl_prefix_t *prefix) return 0; } /*---------------------------------------------------------------------------*/ -void +static void rpl_init(void) { LOG_INFO("initializing\n"); @@ -192,5 +193,10 @@ rpl_init(void) rpl_ns_init(); } /*---------------------------------------------------------------------------*/ +const struct routing_driver rpl_lite_driver = { + "RPL Lite", + rpl_init, +}; +/*---------------------------------------------------------------------------*/ /** @}*/ diff --git a/os/net/routing/rpl-lite/rpl.h b/os/net/routing/rpl-lite/rpl.h index e049cb2f4..cb43f4f79 100644 --- a/os/net/routing/rpl-lite/rpl.h +++ b/os/net/routing/rpl-lite/rpl.h @@ -127,11 +127,6 @@ int rpl_is_reachable(void); */ int rpl_lollipop_greater_than(int a, int b); -/** - * Initialize RPL main module - */ -void rpl_init(void); - /** @} */ #endif /* RPL_H */ diff --git a/os/services/rpl-border-router/native/border-router-native.c b/os/services/rpl-border-router/native/border-router-native.c index ea7ccd61b..3da0ef000 100644 --- a/os/services/rpl-border-router/native/border-router-native.c +++ b/os/services/rpl-border-router/native/border-router-native.c @@ -82,7 +82,7 @@ border_router_set_mac(const uint8_t *data) add them back again - a bit messy... ?*/ PROCESS_CONTEXT_BEGIN(&tcpip_process); uip_ds6_init(); - rpl_init(); + NETSTACK_ROUTING.init(); PROCESS_CONTEXT_END(&tcpip_process); mac_set = 1; From 83e9414a71304ac92c6c10800a411f1aafa5c9fc Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 05:19:01 -0800 Subject: [PATCH 06/43] Add root_set_prefix to routing driver --- examples/ipso-objects/example-server.c | 2 +- .../rpl-border-router/rpl-border-router.c | 2 +- os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl-dag-root.h | 3 +-- os/net/routing/rpl-lite/rpl.c | 1 + os/services/rpl-border-router/rpl-border-router.c | 2 +- os/services/shell/shell-commands.c | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/ipso-objects/example-server.c b/examples/ipso-objects/example-server.c index aa715f4d7..ec902bacb 100644 --- a/examples/ipso-objects/example-server.c +++ b/examples/ipso-objects/example-server.c @@ -236,7 +236,7 @@ setup_network(void) uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); #endif - rpl_dag_root_set_prefix(&ipaddr, &ipaddr); + NETSTACK_ROUTING.root_set_prefix(&ipaddr, &ipaddr); rpl_dag_root_start(); #endif /* UIP_CONF_ROUTER */ diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c index 16915f32a..df51d6968 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c @@ -156,7 +156,7 @@ PROCESS_THREAD(border_router_process, ev, data) uip_debug_ipaddr_print(&prefix); PRINTF("\n"); - rpl_dag_root_set_prefix(&prefix, NULL); + NETSTACK_ROUTING.root_set_prefix(&prefix, NULL); rpl_dag_root_start(); coap_engine_init(); diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 2821e615e..fbb14cbf7 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -356,6 +356,7 @@ rpl_init(void) const struct routing_driver rpl_classic_driver = { "RPL Classic", rpl_init, + rpl_dag_root_set_prefix, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl-dag-root.h b/os/net/routing/rpl-lite/rpl-dag-root.h index 509367030..af0048c4d 100644 --- a/os/net/routing/rpl-lite/rpl-dag-root.h +++ b/os/net/routing/rpl-lite/rpl-dag-root.h @@ -43,8 +43,7 @@ /********** Public functions **********/ /** - * Initialize dag-root module and sets a prefix in case the node is later - * set as dag root. + * Set a prefix in case the node is later set as dag root. * * \param prefix The prefix. If NULL, UIP_DS6_DEFAULT_PREFIX is used instead * \param iid The IID. If NULL, it will be built from uip_ds6_set_addr_iid. diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 7851c0535..ee4cb774d 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -196,6 +196,7 @@ rpl_init(void) const struct routing_driver rpl_lite_driver = { "RPL Lite", rpl_init, + rpl_dag_root_set_prefix, }; /*---------------------------------------------------------------------------*/ diff --git a/os/services/rpl-border-router/rpl-border-router.c b/os/services/rpl-border-router/rpl-border-router.c index 60cbf2ce1..167b599ac 100644 --- a/os/services/rpl-border-router/rpl-border-router.c +++ b/os/services/rpl-border-router/rpl-border-router.c @@ -64,7 +64,7 @@ void set_prefix_64(uip_ipaddr_t *prefix_64) { prefix_set = 1; - rpl_dag_root_set_prefix(prefix_64, NULL); + NETSTACK_ROUTING.root_set_prefix(prefix_64, NULL); rpl_dag_root_start(); } /*---------------------------------------------------------------------------*/ diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index e6789163b..e5d36c2af 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -324,7 +324,7 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args)) SHELL_OUTPUT(output, "Setting as DAG root with prefix "); shell_output_6addr(output, &prefix); SHELL_OUTPUT(output, "/64\n"); - rpl_dag_root_set_prefix(&prefix, NULL); + NETSTACK_ROUTING.root_set_prefix(&prefix, NULL); rpl_dag_root_start(); } else { SHELL_OUTPUT(output, "Node is already a DAG root\n"); From bc73bb32847393cf664874a7b5ac4670058596e7 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 05:23:35 -0800 Subject: [PATCH 07/43] Added root_start to routing driver --- examples/6tisch/etsi-plugtest-2017/node.c | 2 +- examples/6tisch/simple-node/node.c | 2 +- examples/6tisch/sixtop/node-sixtop.c | 2 +- examples/ip64-router/ip64-router.c | 2 +- examples/ipso-objects/example-server.c | 2 +- examples/multicast/root.c | 2 +- .../platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c | 2 +- .../platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c | 2 +- .../platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c | 2 +- examples/platform-specific/jn516x/rpl/node/node.c | 2 +- .../jn516x/tsch/simple-sensor-network/node/node.c | 2 +- .../jn516x/tsch/tx-power-verification/node/node.c | 2 +- .../tx-power-verification/rpl-border-router/rpl-border-router.c | 2 +- .../jn516x/tsch/uart1-test-node/uart1-test-node.c | 2 +- examples/platform-specific/zoul/orion/ip64-router/ip64-router.c | 2 +- examples/rpl-udp/udp-server.c | 2 +- os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl.c | 1 + os/services/rpl-border-router/rpl-border-router.c | 2 +- os/services/shell/shell-commands.c | 2 +- tests/07-simulation-base/code-ipv6/sender/unicast-sender.c | 2 +- tests/14-rpl-lite/code/root-node.c | 2 +- tests/15-rpl-classic/code/root-node.c | 2 +- 23 files changed, 23 insertions(+), 21 deletions(-) diff --git a/examples/6tisch/etsi-plugtest-2017/node.c b/examples/6tisch/etsi-plugtest-2017/node.c index a397dd4e1..3e16666dd 100644 --- a/examples/6tisch/etsi-plugtest-2017/node.c +++ b/examples/6tisch/etsi-plugtest-2017/node.c @@ -77,7 +77,7 @@ PROCESS_THREAD(node_process, ev, data) #endif if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); diff --git a/examples/6tisch/simple-node/node.c b/examples/6tisch/simple-node/node.c index 8548f80ef..ce4c15093 100644 --- a/examples/6tisch/simple-node/node.c +++ b/examples/6tisch/simple-node/node.c @@ -65,7 +65,7 @@ PROCESS_THREAD(node_process, ev, data) #endif if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); diff --git a/examples/6tisch/sixtop/node-sixtop.c b/examples/6tisch/sixtop/node-sixtop.c index bd3cc97ea..73e9fab2e 100755 --- a/examples/6tisch/sixtop/node-sixtop.c +++ b/examples/6tisch/sixtop/node-sixtop.c @@ -73,7 +73,7 @@ PROCESS_THREAD(node_process, ev, data) #endif if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); diff --git a/examples/ip64-router/ip64-router.c b/examples/ip64-router/ip64-router.c index 0d2078b91..632b9ba2e 100644 --- a/examples/ip64-router/ip64-router.c +++ b/examples/ip64-router/ip64-router.c @@ -14,7 +14,7 @@ PROCESS_THREAD(router_node_process, ev, data) PROCESS_BEGIN(); /* Set us up as a RPL root node. */ - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); /* Initialize the IP64 module so we'll start translating packets */ ip64_init(); diff --git a/examples/ipso-objects/example-server.c b/examples/ipso-objects/example-server.c index ec902bacb..4eac38f69 100644 --- a/examples/ipso-objects/example-server.c +++ b/examples/ipso-objects/example-server.c @@ -237,7 +237,7 @@ setup_network(void) #endif NETSTACK_ROUTING.root_set_prefix(&ipaddr, &ipaddr); - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); #endif /* UIP_CONF_ROUTER */ PRINTF("IPv6 addresses: "); diff --git a/examples/multicast/root.c b/examples/multicast/root.c index 06b2534ba..d536211c1 100644 --- a/examples/multicast/root.c +++ b/examples/multicast/root.c @@ -111,7 +111,7 @@ PROCESS_THREAD(rpl_root_process, ev, data) PRINTF("Multicast Engine: '%s'\n", UIP_MCAST6.name); - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); prepare_mcast(); diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c index a39ea774f..5e8c3cca1 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c @@ -129,7 +129,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start net stack */ if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c index 0c5da13a3..75d654a1e 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c @@ -349,7 +349,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start net stack */ if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c index 6839b7cf5..b901414d6 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c @@ -350,7 +350,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start net stack */ if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/jn516x/rpl/node/node.c b/examples/platform-specific/jn516x/rpl/node/node.c index 6ba854093..71e015e6d 100644 --- a/examples/platform-specific/jn516x/rpl/node/node.c +++ b/examples/platform-specific/jn516x/rpl/node/node.c @@ -96,7 +96,7 @@ PROCESS_THREAD(node_process, ev, data) is_coordinator = node_role > role_6ln; if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); diff --git a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c index 8e64ac001..12350a5f4 100644 --- a/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c +++ b/examples/platform-specific/jn516x/tsch/simple-sensor-network/node/node.c @@ -169,7 +169,7 @@ PROCESS_THREAD(node_process, ev, data) is_coordinator = node_role > role_6ln; if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c index ec1052e86..45a2f191a 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c @@ -104,7 +104,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start network stack */ if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c index df51d6968..642e370d1 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/rpl-border-router/rpl-border-router.c @@ -157,7 +157,7 @@ PROCESS_THREAD(border_router_process, ev, data) PRINTF("\n"); NETSTACK_ROUTING.root_set_prefix(&prefix, NULL); - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); coap_engine_init(); coap_activate_resource(&resource_get_rssi, "Get-RSSI"); diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c index bf17f1f96..0d96527bc 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c @@ -145,7 +145,7 @@ PROCESS_THREAD(start_app, ev, data) /* Start network stack */ if(is_coordinator) { - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } NETSTACK_MAC.on(); printf("Starting RPL node\n"); diff --git a/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c b/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c index f2b9f4606..5f2a98e24 100644 --- a/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c +++ b/examples/platform-specific/zoul/orion/ip64-router/ip64-router.c @@ -307,7 +307,7 @@ PROCESS_THREAD(router_node_process, ev, data) leds_off(LEDS_DHCP); /* Set us up as a RPL root node. */ - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); /* ... and do nothing more. */ while(1) { diff --git a/examples/rpl-udp/udp-server.c b/examples/rpl-udp/udp-server.c index 918da3c00..399cabfc4 100644 --- a/examples/rpl-udp/udp-server.c +++ b/examples/rpl-udp/udp-server.c @@ -71,7 +71,7 @@ PROCESS_THREAD(udp_server_process, ev, data) PROCESS_BEGIN(); /* Initialize DAG root */ - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); /* Initialize UDP connection */ simple_udp_register(&udp_conn, UDP_SERVER_PORT, NULL, diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index fbb14cbf7..7e02f8fa1 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -357,6 +357,7 @@ const struct routing_driver rpl_classic_driver = { "RPL Classic", rpl_init, rpl_dag_root_set_prefix, + rpl_dag_root_start, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index ee4cb774d..28d6ae614 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -197,6 +197,7 @@ const struct routing_driver rpl_lite_driver = { "RPL Lite", rpl_init, rpl_dag_root_set_prefix, + rpl_dag_root_start, }; /*---------------------------------------------------------------------------*/ diff --git a/os/services/rpl-border-router/rpl-border-router.c b/os/services/rpl-border-router/rpl-border-router.c index 167b599ac..f07a41fdd 100644 --- a/os/services/rpl-border-router/rpl-border-router.c +++ b/os/services/rpl-border-router/rpl-border-router.c @@ -65,7 +65,7 @@ set_prefix_64(uip_ipaddr_t *prefix_64) { prefix_set = 1; NETSTACK_ROUTING.root_set_prefix(prefix_64, NULL); - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } /*---------------------------------------------------------------------------*/ void diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index e5d36c2af..0aebbc06c 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -325,7 +325,7 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args)) shell_output_6addr(output, &prefix); SHELL_OUTPUT(output, "/64\n"); NETSTACK_ROUTING.root_set_prefix(&prefix, NULL); - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); } else { SHELL_OUTPUT(output, "Node is already a DAG root\n"); } diff --git a/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c b/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c index 2899530af..4e2e664b3 100644 --- a/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c +++ b/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c @@ -40,7 +40,7 @@ PROCESS_THREAD(udp_process, ev, data) PROCESS_BEGIN(); - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); simple_udp_register(&broadcast_connection, UDP_PORT, NULL, UDP_PORT, diff --git a/tests/14-rpl-lite/code/root-node.c b/tests/14-rpl-lite/code/root-node.c index 9e584d4a0..7c9fc8c99 100644 --- a/tests/14-rpl-lite/code/root-node.c +++ b/tests/14-rpl-lite/code/root-node.c @@ -74,7 +74,7 @@ PROCESS_THREAD(unicast_receiver_process, ev, data) { PROCESS_BEGIN(); - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); simple_udp_register(&unicast_connection, UDP_PORT, NULL, UDP_PORT, receiver); diff --git a/tests/15-rpl-classic/code/root-node.c b/tests/15-rpl-classic/code/root-node.c index 389add307..e25b2872f 100644 --- a/tests/15-rpl-classic/code/root-node.c +++ b/tests/15-rpl-classic/code/root-node.c @@ -72,7 +72,7 @@ PROCESS_THREAD(unicast_receiver_process, ev, data) { PROCESS_BEGIN(); - rpl_dag_root_start(); + NETSTACK_ROUTING.root_start(); simple_udp_register(&unicast_connection, UDP_PORT, NULL, UDP_PORT, receiver); From 52b10b6389be0fa904c1f595798a4dbfc91ea799 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 07:27:08 -0800 Subject: [PATCH 08/43] RPL border router Web server cleanup --- .../rpl-border-router/webserver/webserver.c | 260 ++++-------------- 1 file changed, 55 insertions(+), 205 deletions(-) diff --git a/examples/rpl-border-router/webserver/webserver.c b/examples/rpl-border-router/webserver/webserver.c index 1343de71d..f71b80915 100644 --- a/examples/rpl-border-router/webserver/webserver.c +++ b/examples/rpl-border-router/webserver/webserver.c @@ -32,46 +32,34 @@ #include "contiki.h" #include "net/routing/routing.h" +#if RPL_WITH_NON_STORING +/* For RPL non-storing specific link printout. + * Note that traditional DS6 routes are printed in addition, + * whenever UIP_MAX_ROUTES != 0 */ +#include "rpl-ns.h" +#endif #include #include /*---------------------------------------------------------------------------*/ -static const char *TOP = "Contiki-NG\n"; -static const char *BOTTOM = "\n"; -#if BUF_USES_STACK -static char *bufptr, *bufend; -#define ADD(...) do { \ - bufptr += snprintf(bufptr, bufend - bufptr, __VA_ARGS__); \ - } while(0) -#else +static const char *TOP = "\n \n Contiki-NG\n \n\n"; +static const char *BOTTOM = "\n\n\n"; static char buf[256]; static int blen; #define ADD(...) do { \ blen += snprintf(&buf[blen], sizeof(buf) - blen, __VA_ARGS__); \ } while(0) -#endif +#define SEND(s) do { \ + SEND_STRING(s, buf); \ + blen = 0; \ +} while(0); /* Use simple webserver with only one page for minimum footprint. * Multiple connections can result in interleaved tcp segments since * a single static buffer is used for all segments. */ #include "httpd-simple.h" -/* The internal webserver can provide additional information if - * enough program flash is available. - */ -#define WEBSERVER_CONF_LOADTIME 0 -#define WEBSERVER_CONF_FILESTATS 0 -#define WEBSERVER_CONF_NEIGHBOR_STATUS 0 -/* Adding links requires a larger RAM buffer. To avoid static allocation - * the stack can be used for formatting; however tcp retransmissions - * and multiple connections can result in garbled segments. - * TODO:use PSOCk_GENERATOR_SEND and tcp state storage to fix this. - */ -#define WEBSERVER_CONF_ROUTE_LINKS 0 -#if WEBSERVER_CONF_ROUTE_LINKS -#define BUF_USES_STACK 1 -#endif /*---------------------------------------------------------------------------*/ static void @@ -99,210 +87,72 @@ ipaddr_add(const uip_ipaddr_t *addr) static PT_THREAD(generate_routes(struct httpd_state *s)) { - static uip_ds6_route_t *r; -#if RPL_WITH_NON_STORING - static rpl_ns_node_t *link; -#endif /* RPL_WITH_NON_STORING */ static uip_ds6_nbr_t *nbr; -#if BUF_USES_STACK - char buf[256]; -#endif -#if WEBSERVER_CONF_LOADTIME - static clock_time_t numticks; - numticks = clock_time(); -#endif PSOCK_BEGIN(&s->sout); - SEND_STRING(&s->sout, TOP); -#if BUF_USES_STACK - bufptr = buf; - bufend = bufptr + sizeof(buf); -#else - blen = 0; -#endif - ADD("Neighbors
");
 
+  ADD("  Neighbors\n  
    \n"); + SEND(&s->sout); for(nbr = nbr_table_head(ds6_neighbors); nbr != NULL; nbr = nbr_table_next(ds6_neighbors, nbr)) { - -#if WEBSERVER_CONF_NEIGHBOR_STATUS -#if BUF_USES_STACK - { char *j = bufptr + 25; - ipaddr_add(&nbr->ipaddr); - while(bufptr < j) ADD(" "); - switch(nbr->state) { - case NBR_INCOMPLETE: ADD(" INCOMPLETE"); - break; - case NBR_REACHABLE: ADD(" REACHABLE"); - break; - case NBR_STALE: ADD(" STALE"); - break; - case NBR_DELAY: ADD(" DELAY"); - break; - case NBR_PROBE: ADD(" NBR_PROBE"); - break; - } - } -#else - { uint8_t j = blen + 25; - ipaddr_add(&nbr->ipaddr); - while(blen < j) ADD(" "); - switch(nbr->state) { - case NBR_INCOMPLETE: ADD(" INCOMPLETE"); - break; - case NBR_REACHABLE: ADD(" REACHABLE"); - break; - case NBR_STALE: ADD(" STALE"); - break; - case NBR_DELAY: ADD(" DELAY"); - break; - case NBR_PROBE: ADD(" NBR_PROBE"); - break; - } - } -#endif -#else + ADD("
  • "); ipaddr_add(&nbr->ipaddr); -#endif - - ADD("\n"); -#if BUF_USES_STACK - if(bufptr > bufend - 45) { - SEND_STRING(&s->sout, buf); - bufptr = buf; - bufend = bufptr + sizeof(buf); - } -#else - if(blen > sizeof(buf) - 45) { - SEND_STRING(&s->sout, buf); - blen = 0; - } -#endif + ADD("
  • \n"); + SEND(&s->sout); } - ADD("
Routes
\n");
-  SEND_STRING(&s->sout, buf);
-#if BUF_USES_STACK
-  bufptr = buf;
-  bufend = bufptr + sizeof(buf);
-#else
-  blen = 0;
-#endif
+  ADD("  \n");
+  SEND(&s->sout);
 
-  for(r = uip_ds6_route_head(); r != NULL; r = uip_ds6_route_next(r)) {
-
-#if BUF_USES_STACK
-#if WEBSERVER_CONF_ROUTE_LINKS
-    ADD("ipaddr);
-    ADD("]/status.shtml>");
-    ipaddr_add(&r->ipaddr);
-    ADD("");
-#else
-    ipaddr_add(&r->ipaddr);
-#endif
-#else
-#if WEBSERVER_CONF_ROUTE_LINKS
-    ADD("ipaddr);
-    ADD("]/status.shtml>");
-    SEND_STRING(&s->sout, buf);
-    blen = 0;
-    ipaddr_add(&r->ipaddr);
-    ADD("");
-#else
-    ipaddr_add(&r->ipaddr);
-#endif
-#endif
-    ADD("/%u (via ", r->length);
-    ipaddr_add(uip_ds6_route_nexthop(r));
-    if(1 || (r->state.lifetime < 600)) {
-      ADD(") %lus\n", (unsigned long)r->state.lifetime);
-    } else {
-      ADD(")\n");
+#if (UIP_MAX_ROUTES != 0)
+  {
+    static uip_ds6_route_t *r;
+    ADD("  Routes\n  
    \n"); + SEND(&s->sout); + for(r = uip_ds6_route_head(); r != NULL; r = uip_ds6_route_next(r)) { + ADD("
  • "); + ipaddr_add(&r->ipaddr); + ADD("/%u (via ", r->length); + ipaddr_add(uip_ds6_route_nexthop(r)); + ADD(") %lus", (unsigned long)r->state.lifetime); + ADD("
  • \n"); + SEND(&s->sout); } - SEND_STRING(&s->sout, buf); -#if BUF_USES_STACK - bufptr = buf; - bufend = bufptr + sizeof(buf); -#else - blen = 0; -#endif + ADD("
\n"); + SEND(&s->sout); } - ADD("
"); +#endif /* UIP_MAX_ROUTES != 0 */ #if RPL_WITH_NON_STORING - ADD("Links
\n");
-  SEND_STRING(&s->sout, buf);
-#if BUF_USES_STACK
-  bufptr = buf;
-  bufend = bufptr + sizeof(buf);
-#else
-  blen = 0;
-#endif
-  for(link = rpl_ns_node_head(); link != NULL; link = rpl_ns_node_next(link)) {
-    if(link->parent != NULL) {
-      uip_ipaddr_t child_ipaddr;
-      uip_ipaddr_t parent_ipaddr;
+  {
+    static rpl_ns_node_t *link;
+    ADD("  Routing links\n  
    \n"); + SEND(&s->sout); + for(link = rpl_ns_node_head(); link != NULL; link = rpl_ns_node_next(link)) { + if(link->parent != NULL) { + uip_ipaddr_t child_ipaddr; + uip_ipaddr_t parent_ipaddr; - rpl_ns_get_node_global_addr(&child_ipaddr, link); - rpl_ns_get_node_global_addr(&parent_ipaddr, link->parent); + rpl_ns_get_node_global_addr(&child_ipaddr, link); + rpl_ns_get_node_global_addr(&parent_ipaddr, link->parent); -#if BUF_USES_STACK -#if WEBSERVER_CONF_ROUTE_LINKS - ADD(""); - ipaddr_add(&child_ipaddr); - ADD(""); -#else - ipaddr_add(&child_ipaddr); -#endif -#else -#if WEBSERVER_CONF_ROUTE_LINKS - ADD(""); - SEND_STRING(&s->sout, buf); - blen = 0; - ipaddr_add(&child_ipaddr); - ADD(""); -#else - ipaddr_add(&child_ipaddr); -#endif -#endif + ADD("
  • "); + ipaddr_add(&child_ipaddr); - ADD(" (parent: "); - ipaddr_add(&parent_ipaddr); - if(1 || (link->lifetime < 600)) { - ADD(") %us\n", (unsigned int)link->lifetime); - } else { - ADD(")\n"); + ADD(" (parent: "); + ipaddr_add(&parent_ipaddr); + ADD(") %us", (unsigned int)link->lifetime); + + ADD("
  • \n"); + SEND(&s->sout); } - SEND_STRING(&s->sout, buf); -#if BUF_USES_STACK - bufptr = buf; - bufend = bufptr + sizeof(buf); -#else - blen = 0; -#endif } + ADD("
"); + SEND(&s->sout); } - ADD("
"); #endif /* RPL_WITH_NON_STORING */ -#if WEBSERVER_CONF_FILESTATS - static uint16_t numtimes; - ADD("
This page sent %u times", ++numtimes); -#endif - -#if WEBSERVER_CONF_LOADTIME - numticks = clock_time() - numticks + 1; - ADD(" (%u.%02u sec)", numticks / CLOCK_SECOND, (100 * (numticks % CLOCK_SECOND)) / CLOCK_SECOND)); -#endif - - SEND_STRING(&s->sout, buf); SEND_STRING(&s->sout, BOTTOM); PSOCK_END(&s->sout); From 8db37afb289ec381b08d816fb021a3b6ee5ae53f Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 08:25:26 -0800 Subject: [PATCH 09/43] Adding missing functions in nullrouting.c --- os/net/routing/nullrouting/nullrouting.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 706c590ff..152b43bc5 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -47,9 +47,22 @@ init(void) { } /*---------------------------------------------------------------------------*/ +static void +root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) +{ +} +/*---------------------------------------------------------------------------*/ +static int +root_start(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ const struct routing_driver nullrouting_driver = { "Null Routing", init, + root_set_prefix, + root_start, }; /*---------------------------------------------------------------------------*/ From ab41114727d1887bd48f02a6f535e0a90db6b472 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 08:27:57 -0800 Subject: [PATCH 10/43] 'rpl_init' is now static, rename to 'init' --- os/net/routing/rpl-classic/rpl.c | 4 ++-- os/net/routing/rpl-lite/rpl.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 7e02f8fa1..4677b316a 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -330,7 +330,7 @@ rpl_purge_dags(void) } /*---------------------------------------------------------------------------*/ static void -rpl_init(void) +init(void) { uip_ipaddr_t rplmaddr; PRINTF("RPL started\n"); @@ -355,7 +355,7 @@ rpl_init(void) /*---------------------------------------------------------------------------*/ const struct routing_driver rpl_classic_driver = { "RPL Classic", - rpl_init, + init, rpl_dag_root_set_prefix, rpl_dag_root_start, }; diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 28d6ae614..53ca4d6c0 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -177,7 +177,7 @@ rpl_set_prefix(rpl_prefix_t *prefix) } /*---------------------------------------------------------------------------*/ static void -rpl_init(void) +init(void) { LOG_INFO("initializing\n"); @@ -195,7 +195,7 @@ rpl_init(void) /*---------------------------------------------------------------------------*/ const struct routing_driver rpl_lite_driver = { "RPL Lite", - rpl_init, + init, rpl_dag_root_set_prefix, rpl_dag_root_start, }; From 4cab396d48386446a6505dbc82a570be12eaff44 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 08:29:28 -0800 Subject: [PATCH 11/43] Shell: explicitly include rpl-ns.h when needed --- os/services/shell/shell-commands.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index 0aebbc06c..fe5d03b3b 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -60,6 +60,11 @@ #endif /* MAC_CONF_WITH_TSCH */ #include "net/routing/routing.h" #include "net/mac/llsec802154.h" +#if RPL_WITH_NON_STORING +/* For RPL non-storing specific link printout */ +#include "rpl-ns.h" +#endif + #include From 53facf941ea9234cd0e121ad0bdb2bbab1e6cc71 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sat, 9 Dec 2017 08:45:10 -0800 Subject: [PATCH 12/43] Routing API: added toplogy repair --- os/net/mac/tsch/tsch-rpl.c | 9 +-------- os/net/routing/nullrouting/nullrouting.c | 12 +++++++++++ os/net/routing/routing.h | 13 ++++++++++++ os/net/routing/rpl-classic/rpl.c | 20 +++++++++++++++++++ os/net/routing/rpl-lite/rpl-dag.c | 8 ++++---- os/net/routing/rpl-lite/rpl-dag.h | 4 +++- os/net/routing/rpl-lite/rpl.c | 2 ++ .../embedded/border-router-embedded.c | 6 +----- .../native/border-router-cmds.c | 6 +----- os/services/shell/shell-commands.c | 8 ++++---- 10 files changed, 61 insertions(+), 27 deletions(-) diff --git a/os/net/mac/tsch/tsch-rpl.c b/os/net/mac/tsch/tsch-rpl.c index 78d102fad..99cb8d9a2 100644 --- a/os/net/mac/tsch/tsch-rpl.c +++ b/os/net/mac/tsch/tsch-rpl.c @@ -75,14 +75,7 @@ tsch_rpl_callback_joining_network(void) void tsch_rpl_callback_leaving_network(void) { - rpl_dag_t *dag = rpl_get_any_dag(); - if(dag != NULL) { -#if UIP_CONF_IPV6_RPL_LITE - rpl_local_repair("TSCH leaving"); -#else - rpl_local_repair(dag->instance); -#endif - } + NETSTACK_ROUTING.local_repair("TSCH leaving"); } /*---------------------------------------------------------------------------*/ /* Set TSCH EB period based on current RPL DIO period. diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 152b43bc5..01e7a7d46 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -58,11 +58,23 @@ root_start(void) return 0; } /*---------------------------------------------------------------------------*/ +static void +global_repair(const char *str) +{ +} +/*---------------------------------------------------------------------------*/ +static void +local_repair(const char *str) +{ +} +/*---------------------------------------------------------------------------*/ const struct routing_driver nullrouting_driver = { "Null Routing", init, root_set_prefix, root_start, + global_repair, + local_repair }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index a213cc92d..5a61c98cc 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -65,6 +65,19 @@ struct routing_driver { * \return 0 in case of success, -1 otherwise */ int (* root_start)(void); + /** + * Triggers a global topology repair + * + * \param str A textual description of the cause for triggering a repair + */ + void (* global_repair)(const char *str); + + /** + * Triggers a RPL local topology repair + * + * \param str A textual description of the cause for triggering a repair + */ + void (* local_repair)(const char *str); }; #endif /* ROUTING_H_ */ diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 4677b316a..517f98cdf 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -353,11 +353,31 @@ init(void) #endif /* RPL_WITH_NON_STORING */ } /*---------------------------------------------------------------------------*/ +static void +global_repair(const char *str) +{ + rpl_dag_t *dag = rpl_get_any_dag(); + if(dag != NULL && dag->instance != NULL) { + rpl_repair_root(dag->instance->instance_id); + } +} +/*---------------------------------------------------------------------------*/ +static void +local_repair(const char *str) +{ + rpl_dag_t *dag = rpl_get_any_dag(); + if(dag != NULL) { + rpl_local_repair(dag->instance); + } +} +/*---------------------------------------------------------------------------*/ const struct routing_driver rpl_classic_driver = { "RPL Classic", init, rpl_dag_root_set_prefix, rpl_dag_root_start, + global_repair, + local_repair, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index a89b972c1..2f89cc1ff 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -169,11 +169,11 @@ find_objective_function(rpl_ocp_t ocp) } /*---------------------------------------------------------------------------*/ void -rpl_global_repair(void) +rpl_global_repair(const char *str) { if(rpl_dag_root_is_root()) { - LOG_WARN("initiating global repair, version %u, rank %u)\n", - curr_instance.dag.version, curr_instance.dag.rank); + LOG_WARN("initiating global repair (%s), version %u, rank %u)\n", + str, curr_instance.dag.version, curr_instance.dag.rank); #if LOG_INFO_ENABLED rpl_neighbor_print_list("Global repair (before)"); #endif /* LOG_INFO_ENABLED */ @@ -391,7 +391,7 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio) LOG_ERR("inconsistent DIO version (current: %u, received: %u), initiate global repair\n", curr_instance.dag.version, dio->version); curr_instance.dag.version = dio->version; /* Update version and trigger global repair */ - rpl_global_repair(); + rpl_global_repair("Inconsistent DIO version"); } else { LOG_WARN("new DIO version (current: %u, received: %u), apply global repair\n", curr_instance.dag.version, dio->version); diff --git a/os/net/routing/rpl-lite/rpl-dag.h b/os/net/routing/rpl-lite/rpl-dag.h index bc59ac4bb..52e14c9f3 100644 --- a/os/net/routing/rpl-lite/rpl-dag.h +++ b/os/net/routing/rpl-lite/rpl-dag.h @@ -78,8 +78,10 @@ void rpl_dag_periodic(unsigned seconds); /** * Triggers a RPL global repair + * + * \param str A textual description of the cause for triggering a repair */ -void rpl_global_repair(void); +void rpl_global_repair(const char *str); /** * Triggers a RPL local repair diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 53ca4d6c0..7a79a3a3f 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -198,6 +198,8 @@ const struct routing_driver rpl_lite_driver = { init, rpl_dag_root_set_prefix, rpl_dag_root_start, + rpl_global_repair, + rpl_local_repair, }; /*---------------------------------------------------------------------------*/ diff --git a/os/services/rpl-border-router/embedded/border-router-embedded.c b/os/services/rpl-border-router/embedded/border-router-embedded.c index 7d6f4125f..884f60a97 100644 --- a/os/services/rpl-border-router/embedded/border-router-embedded.c +++ b/os/services/rpl-border-router/embedded/border-router-embedded.c @@ -88,11 +88,7 @@ PROCESS_THREAD(border_router_process, ev, data) PROCESS_YIELD(); if(ev == sensors_event && data == &button_sensor) { LOG_INFO("Initiating global repair\n"); -#if UIP_CONF_IPV6_RPL_LITE - rpl_global_repair(); -#else - rpl_repair_root(RPL_DEFAULT_INSTANCE); -#endif + NETSTACK_ROUTING.global_repair("Button press"); } } diff --git a/os/services/rpl-border-router/native/border-router-cmds.c b/os/services/rpl-border-router/native/border-router-cmds.c index 8d11d725d..9d0e2eb9f 100644 --- a/os/services/rpl-border-router/native/border-router-cmds.c +++ b/os/services/rpl-border-router/native/border-router-cmds.c @@ -121,11 +121,7 @@ border_router_cmd_handler(const uint8_t *data, int len) case 'G': /* This is supposed to be from stdin */ printf("Performing Global Repair...\n"); -#if UIP_CONF_IPV6_RPL_LITE - rpl_global_repair(); -#else - rpl_repair_root(RPL_DEFAULT_INSTANCE); -#endif + NETSTACK_ROUTING.global_repair("Command"); return 1; case 'C': { /* send on a set-param thing! */ diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index fe5d03b3b..25812eebd 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -395,8 +395,8 @@ PT_THREAD(cmd_rpl_global_repair(struct pt *pt, shell_output_func output, char *a { PT_BEGIN(pt); - SHELL_OUTPUT(output, "Triggering RPL global repair\n") - rpl_global_repair(); + SHELL_OUTPUT(output, "Triggering routing global repair\n") + NETSTACK_ROUTING.global_repair("Shell"); PT_END(pt); } @@ -406,8 +406,8 @@ PT_THREAD(cmd_rpl_local_repair(struct pt *pt, shell_output_func output, char *ar { PT_BEGIN(pt); - SHELL_OUTPUT(output, "Triggering RPL local repair\n"); - rpl_local_repair("Shell"); + SHELL_OUTPUT(output, "Triggering routing local repair\n"); + NETSTACK_ROUTING.local_repair("Shell"); PT_END(pt); } From 03bab6f119147cc3c945f97ccdbda8a8c6cc37ec Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 05:59:19 -0800 Subject: [PATCH 13/43] Routing API: added ext_header_remove --- os/net/ipv6/uip-icmp6.c | 7 ++----- os/net/routing/nullrouting/nullrouting.c | 9 ++++++++- os/net/routing/routing.h | 5 ++++- os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl.c | 1 + 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/os/net/ipv6/uip-icmp6.c b/os/net/ipv6/uip-icmp6.c index 5d04cf979..be33a1101 100644 --- a/os/net/ipv6/uip-icmp6.c +++ b/os/net/ipv6/uip-icmp6.c @@ -185,11 +185,8 @@ uip_icmp6_error_output(uint8_t type, uint8_t code, uint32_t param) { } } -#if UIP_CONF_IPV6_RPL - rpl_ext_header_remove(); -#else - uip_ext_len = 0; -#endif /* UIP_CONF_IPV6_RPL */ + /* Remove all extension headers related to the routing protocol in place */ + NETSTACK_ROUTING.ext_header_remove(); /* remember data of original packet before shifting */ uip_ipaddr_copy(&tmp_ipaddr, &UIP_IP_BUF->destipaddr); diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 01e7a7d46..54e7e62e3 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -68,13 +68,20 @@ local_repair(const char *str) { } /*---------------------------------------------------------------------------*/ +static void +ext_header_remove(void) +{ + uip_ext_len = 0; +} +/*---------------------------------------------------------------------------*/ const struct routing_driver nullrouting_driver = { "Null Routing", init, root_set_prefix, root_start, global_repair, - local_repair + local_repair, + ext_header_remove }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index 5a61c98cc..e946a2d11 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -71,13 +71,16 @@ struct routing_driver { * \param str A textual description of the cause for triggering a repair */ void (* global_repair)(const char *str); - /** * Triggers a RPL local topology repair * * \param str A textual description of the cause for triggering a repair */ void (* local_repair)(const char *str); + /** + * Removes all extension headers that pertain to the routing protocol. + */ + void (* ext_header_remove)(void); }; #endif /* ROUTING_H_ */ diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 517f98cdf..406b693c3 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -378,6 +378,7 @@ const struct routing_driver rpl_classic_driver = { rpl_dag_root_start, global_repair, local_repair, + rpl_ext_header_remove, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 7a79a3a3f..41d39f1de 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -200,6 +200,7 @@ const struct routing_driver rpl_lite_driver = { rpl_dag_root_start, rpl_global_repair, rpl_local_repair, + rpl_ext_header_remove, }; /*---------------------------------------------------------------------------*/ From 4cdf2d4819bd2310a6a75324474ef512f7a6e49a Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 06:10:35 -0800 Subject: [PATCH 14/43] Routing API: added ext_header_srh_get_next_hop --- os/net/ipv6/tcpip.c | 7 +------ os/net/routing/nullrouting/nullrouting.c | 9 ++++++++- os/net/routing/routing.h | 7 +++++++ os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl.c | 1 + 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/os/net/ipv6/tcpip.c b/os/net/ipv6/tcpip.c index dc2af6174..3c870d433 100644 --- a/os/net/ipv6/tcpip.c +++ b/os/net/ipv6/tcpip.c @@ -95,11 +95,6 @@ enum { PACKET_INPUT }; -#if UIP_CONF_IPV6_RPL && RPL_WITH_NON_STORING -#define NEXTHOP_NON_STORING(addr) rpl_ext_header_srh_get_next_hop(addr) -#else -#define NEXTHOP_NON_STORING(addr) 0 -#endif /*---------------------------------------------------------------------------*/ static void init_appstate(uip_tcp_appstate_t *as, void *state) @@ -525,7 +520,7 @@ get_nexthop(uip_ipaddr_t *addr) LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); LOG_INFO_("\n"); - if(NEXTHOP_NON_STORING(addr)) { + if(NETSTACK_ROUTING.ext_header_srh_get_next_hop(addr)) { LOG_INFO("output: selected next hop from SRH: "); LOG_INFO_6ADDR(addr); LOG_INFO_("\n"); diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 54e7e62e3..9bcca0e3e 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -74,6 +74,12 @@ ext_header_remove(void) uip_ext_len = 0; } /*---------------------------------------------------------------------------*/ +static int +ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ const struct routing_driver nullrouting_driver = { "Null Routing", init, @@ -81,7 +87,8 @@ const struct routing_driver nullrouting_driver = { root_start, global_repair, local_repair, - ext_header_remove + ext_header_remove, + ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index e946a2d11..1d00aa106 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -81,6 +81,13 @@ struct routing_driver { * Removes all extension headers that pertain to the routing protocol. */ void (* ext_header_remove)(void); + /** + * Look for next hop from SRH of current uIP packet. + * + * \param ipaddr A pointer to the address where to store the next hop. + * \return 1 if a next hop was found, 0 otherwise + */ + int (* ext_header_srh_get_next_hop)(uip_ipaddr_t *ipaddr); }; #endif /* ROUTING_H_ */ diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 406b693c3..807808e1c 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -379,6 +379,7 @@ const struct routing_driver rpl_classic_driver = { global_repair, local_repair, rpl_ext_header_remove, + rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 41d39f1de..13e3c820e 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -201,6 +201,7 @@ const struct routing_driver rpl_lite_driver = { rpl_global_repair, rpl_local_repair, rpl_ext_header_remove, + rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ From 54655335c6f2e8e0fb2444c7fb531238d79e1aa9 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 06:11:01 -0800 Subject: [PATCH 15/43] Routing API: added ext_header_update --- os/net/ipv6/tcpip.c | 7 ++-- os/net/routing/nullrouting/nullrouting.c | 7 ++++ os/net/routing/routing.h | 6 ++++ os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl-ext-header.h | 44 ++++++++++++------------ os/net/routing/rpl-lite/rpl.c | 1 + 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/os/net/ipv6/tcpip.c b/os/net/ipv6/tcpip.c index 3c870d433..903498532 100644 --- a/os/net/ipv6/tcpip.c +++ b/os/net/ipv6/tcpip.c @@ -665,14 +665,13 @@ tcpip_ipv6_output(void) goto exit; } -#if UIP_CONF_IPV6_RPL - if(!rpl_ext_header_update()) { + + if(!NETSTACK_ROUTING.ext_header_update()) { /* Packet can not be forwarded */ - LOG_ERR("output: RPL header update error\n"); + LOG_ERR("output: routing protocol extension header update error\n"); uip_clear_buf(); return; } -#endif /* UIP_CONF_IPV6_RPL */ if(uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) { linkaddr = NULL; diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 9bcca0e3e..d7b643b5b 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -75,6 +75,12 @@ ext_header_remove(void) } /*---------------------------------------------------------------------------*/ static int +ext_header_update(void) +{ + return 1; +} +/*---------------------------------------------------------------------------*/ +static int ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) { return 0; @@ -88,6 +94,7 @@ const struct routing_driver nullrouting_driver = { global_repair, local_repair, ext_header_remove, + ext_header_update, ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index 1d00aa106..bfa639f1c 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -81,6 +81,12 @@ struct routing_driver { * Removes all extension headers that pertain to the routing protocol. */ void (* ext_header_remove)(void); + /** + * Adds/updates routing protocol extension headers to current uIP packet. + * + * \return 1 in case of success, 0 otherwise + */ + int (* ext_header_update)(void); /** * Look for next hop from SRH of current uIP packet. * diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 807808e1c..2b1dc81fd 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -379,6 +379,7 @@ const struct routing_driver rpl_classic_driver = { global_repair, local_repair, rpl_ext_header_remove, + rpl_ext_header_update, rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl-ext-header.h b/os/net/routing/rpl-lite/rpl-ext-header.h index 3e339e6e2..59d637b1c 100644 --- a/os/net/routing/rpl-lite/rpl-ext-header.h +++ b/os/net/routing/rpl-lite/rpl-ext-header.h @@ -44,30 +44,30 @@ /********** Public functions **********/ - /** - * Look for next hop from SRH of current uIP packet. - * - * \param ipaddr A pointer to the address where to store the next hop. - * \return 1 if a next hop was found, 0 otherwise - */ - int rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr); +/** +* Look for next hop from SRH of current uIP packet. +* +* \param ipaddr A pointer to the address where to store the next hop. +* \return 1 if a next hop was found, 0 otherwise +*/ +int rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr); - /** - * Process and update SRH in-place, - * i.e. internal address swapping as per RFC6554 - * \return 1 if SRH found, 0 otherwise - */ - int rpl_ext_header_srh_update(void); +/** +* Process and update SRH in-place, +* i.e. internal address swapping as per RFC6554 +* \return 1 if SRH found, 0 otherwise +*/ +int rpl_ext_header_srh_update(void); - /** - * Process and update the RPL extension headers of the current uIP packet. - * - * \param uip_ext_opt_offset The offset within the uIP packet where - * extension headers start - * \return 1 in case the packet is valid and to be processed further, - * 0 in case the packet must be dropped. - */ - int rpl_ext_header_hbh_update(int uip_ext_opt_offset); +/** +* Process and update the RPL extension headers of the current uIP packet. +* +* \param uip_ext_opt_offset The offset within the uIP packet where +* extension headers start +* \return 1 in case the packet is valid and to be processed further, +* 0 in case the packet must be dropped. +*/ +int rpl_ext_header_hbh_update(int uip_ext_opt_offset); /** * Adds/updates RPL extension headers to current uIP packet. diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 13e3c820e..cb677eedd 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -201,6 +201,7 @@ const struct routing_driver rpl_lite_driver = { rpl_global_repair, rpl_local_repair, rpl_ext_header_remove, + rpl_ext_header_update, rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ From 25e07b7d239a21fc1ddbc1561ca2d22bf6325c95 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 06:21:37 -0800 Subject: [PATCH 16/43] Routing API: added ext_header_hbh_update --- os/net/ipv6/uip6.c | 5 +---- os/net/routing/nullrouting/nullrouting.c | 7 +++++++ os/net/routing/routing.h | 10 ++++++++++ os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl-ext-header.h | 5 +++-- os/net/routing/rpl-lite/rpl.c | 1 + 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/os/net/ipv6/uip6.c b/os/net/ipv6/uip6.c index edc037468..aa6b8a537 100644 --- a/os/net/ipv6/uip6.c +++ b/os/net/ipv6/uip6.c @@ -875,13 +875,10 @@ ext_hdr_options_process(void) * Using this fix, the header is ignored, and the next header (if * present) is processed. */ -#if UIP_CONF_IPV6_RPL - LOG_DBG("Processing RPL option\n"); - if(!rpl_ext_header_hbh_update(uip_ext_opt_offset)) { + if(!NETSTACK_ROUTING.ext_header_hbh_update(uip_ext_opt_offset)) { LOG_ERR("RPL Option Error: Dropping Packet\n"); return 1; } -#endif /* UIP_CONF_IPV6_RPL */ uip_ext_opt_offset += (UIP_EXT_HDR_OPT_BUF->len) + 2; return 0; default: diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index d7b643b5b..3f7c2487f 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -81,6 +81,12 @@ ext_header_update(void) } /*---------------------------------------------------------------------------*/ static int +ext_header_hbh_update(int uip_ext_opt_offset) +{ + return 1; +} +/*---------------------------------------------------------------------------*/ +static int ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) { return 0; @@ -95,6 +101,7 @@ const struct routing_driver nullrouting_driver = { local_repair, ext_header_remove, ext_header_update, + ext_header_hbh_update, ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index bfa639f1c..2edf50b40 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -87,6 +87,16 @@ struct routing_driver { * \return 1 in case of success, 0 otherwise */ int (* ext_header_update)(void); + /** + * Process and update the routing protocol hob-by-hop + * extention headers of the current uIP packet. + * + * \param uip_ext_opt_offset The offset within the uIP packet where + * extension headers start + * \return 1 in case the packet is valid and to be processed further, + * 0 in case the packet must be dropped. + */ + int (* ext_header_hbh_update)(int uip_ext_opt_offset); /** * Look for next hop from SRH of current uIP packet. * diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 2b1dc81fd..ffc46ea9d 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -380,6 +380,7 @@ const struct routing_driver rpl_classic_driver = { local_repair, rpl_ext_header_remove, rpl_ext_header_update, + rpl_ext_header_hbh_update, rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl-ext-header.h b/os/net/routing/rpl-lite/rpl-ext-header.h index 59d637b1c..df61bc325 100644 --- a/os/net/routing/rpl-lite/rpl-ext-header.h +++ b/os/net/routing/rpl-lite/rpl-ext-header.h @@ -60,7 +60,8 @@ int rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr); int rpl_ext_header_srh_update(void); /** -* Process and update the RPL extension headers of the current uIP packet. +* Process and update the RPL hop-by-hop extension headers of +* the current uIP packet. * * \param uip_ext_opt_offset The offset within the uIP packet where * extension headers start @@ -70,7 +71,7 @@ int rpl_ext_header_srh_update(void); int rpl_ext_header_hbh_update(int uip_ext_opt_offset); /** - * Adds/updates RPL extension headers to current uIP packet. + * Adds/updates all RPL extension headers to current uIP packet. * * \return 1 in case of success, 0 otherwise */ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index cb677eedd..ab67d8be0 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -202,6 +202,7 @@ const struct routing_driver rpl_lite_driver = { rpl_local_repair, rpl_ext_header_remove, rpl_ext_header_update, + rpl_ext_header_hbh_update, rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ From fdbd89d0188456bfde580d159fbb087996aa9e34 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 06:35:50 -0800 Subject: [PATCH 17/43] Routing API: added ext_header_srh_update --- os/net/ipv6/uip6.c | 4 +--- os/net/routing/nullrouting/nullrouting.c | 7 +++++++ os/net/routing/routing.h | 6 ++++++ os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl.c | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/os/net/ipv6/uip6.c b/os/net/ipv6/uip6.c index aa6b8a537..c491baf64 100644 --- a/os/net/ipv6/uip6.c +++ b/os/net/ipv6/uip6.c @@ -1352,8 +1352,7 @@ uip_process(uint8_t flag) LOG_DBG("Processing Routing header\n"); if(UIP_ROUTING_BUF->seg_left > 0) { -#if UIP_CONF_IPV6_RPL && RPL_WITH_NON_STORING - if(rpl_ext_header_srh_update()) { + if(NETSTACK_ROUTING.ext_header_srh_update()) { /* With routing header, the detination address is us and will * be swapped later to the next hop. Because of this, the MTU @@ -1381,7 +1380,6 @@ uip_process(uint8_t flag) goto send; /* Proceed to forwarding */ } -#endif /* UIP_CONF_IPV6_RPL && RPL_WITH_NON_STORING */ uip_icmp6_error_output(ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, UIP_IPH_LEN + uip_ext_len + 2); UIP_STAT(++uip_stat.ip.drop); LOG_ERR("unrecognized routing type"); diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 3f7c2487f..a133cf34f 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -87,6 +87,12 @@ ext_header_hbh_update(int uip_ext_opt_offset) } /*---------------------------------------------------------------------------*/ static int +ext_header_srh_update(void) +{ + return 0; /* Means SRH not found */ +} +/*---------------------------------------------------------------------------*/ +static int ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) { return 0; @@ -102,6 +108,7 @@ const struct routing_driver nullrouting_driver = { ext_header_remove, ext_header_update, ext_header_hbh_update, + ext_header_srh_update, ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index 2edf50b40..ec982c9ad 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -97,6 +97,12 @@ struct routing_driver { * 0 in case the packet must be dropped. */ int (* ext_header_hbh_update)(int uip_ext_opt_offset); + /** + * Process and update SRH in-place, + * i.e. internal address swapping as per RFC6554 + * \return 1 if SRH found, 0 otherwise + */ + int (* ext_header_srh_update)(void); /** * Look for next hop from SRH of current uIP packet. * diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index ffc46ea9d..6ac987ebf 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -381,6 +381,7 @@ const struct routing_driver rpl_classic_driver = { rpl_ext_header_remove, rpl_ext_header_update, rpl_ext_header_hbh_update, + rpl_ext_header_srh_update, rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index ab67d8be0..9a27d7262 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -203,6 +203,7 @@ const struct routing_driver rpl_lite_driver = { rpl_ext_header_remove, rpl_ext_header_update, rpl_ext_header_hbh_update, + rpl_ext_header_srh_update, rpl_ext_header_srh_get_next_hop, }; /*---------------------------------------------------------------------------*/ From fac66307f682a3b5fcaea4bd90e6cf07fa0b8c04 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 06:36:26 -0800 Subject: [PATCH 18/43] RPL Lite: enable custom configuration of RPL_CONF_WITH_NON_STORING --- os/net/routing/rpl-lite/rpl-conf.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/os/net/routing/rpl-lite/rpl-conf.h b/os/net/routing/rpl-lite/rpl-conf.h index 410cce988..eceb2843c 100644 --- a/os/net/routing/rpl-lite/rpl-conf.h +++ b/os/net/routing/rpl-lite/rpl-conf.h @@ -62,7 +62,16 @@ * We only support non-storing mode */ #define RPL_WITH_STORING 0 + +/* + * 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 */ /* The number of non-storing nodes, i.e. the maximum netwrok size at the root */ #ifdef RPL_NS_CONF_LINK_NUM From eaa3b6ad792b929e418ebfad9fe83c4f6a8a7c61 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 06:39:38 -0800 Subject: [PATCH 19/43] Routing API: added link_callback --- os/net/ipv6/sicslowpan.c | 6 ++---- os/net/mac/tsch/tsch-rpl.c | 2 +- os/net/routing/nullrouting/nullrouting.c | 6 ++++++ os/net/routing/routing.h | 8 ++++++++ os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl.c | 1 + 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/os/net/ipv6/sicslowpan.c b/os/net/ipv6/sicslowpan.c index be6821275..9bb906f6d 100644 --- a/os/net/ipv6/sicslowpan.c +++ b/os/net/ipv6/sicslowpan.c @@ -1431,10 +1431,8 @@ packet_sent(void *ptr, int status, int transmissions) /* Update neighbor link statistics */ link_stats_packet_sent(dest, status, transmissions); -#if UIP_CONF_IPV6_RPL - /* Call RPL link callback */ - rpl_link_callback(dest, status, transmissions); -#endif /* UIP_CONF_IPV6_RPL */ + /* Call routing protocol link callback */ + NETSTACK_ROUTING.link_callback(dest, status, transmissions); /* DS6 callback, used for UIP_DS6_LL_NUD */ uip_ds6_link_callback(status, transmissions); diff --git a/os/net/mac/tsch/tsch-rpl.c b/os/net/mac/tsch/tsch-rpl.c index 99cb8d9a2..f603c0e60 100644 --- a/os/net/mac/tsch/tsch-rpl.c +++ b/os/net/mac/tsch/tsch-rpl.c @@ -60,7 +60,7 @@ void tsch_rpl_callback_ka_sent(int status, int transmissions) { - rpl_link_callback(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), status, transmissions); + NETSTACK_ROUTING.link_callback(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), status, transmissions); } /*---------------------------------------------------------------------------*/ /* To use, set #define TSCH_CALLBACK_JOINING_NETWORK tsch_rpl_callback_joining_network */ diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index a133cf34f..5707143b1 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -98,6 +98,11 @@ ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) return 0; } /*---------------------------------------------------------------------------*/ +static void +link_callback(const linkaddr_t *addr, int status, int numtx) +{ +} +/*---------------------------------------------------------------------------*/ const struct routing_driver nullrouting_driver = { "Null Routing", init, @@ -110,6 +115,7 @@ const struct routing_driver nullrouting_driver = { ext_header_hbh_update, ext_header_srh_update, ext_header_srh_get_next_hop, + link_callback, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index ec982c9ad..fa0e301af 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -110,6 +110,14 @@ struct routing_driver { * \return 1 if a next hop was found, 0 otherwise */ int (* ext_header_srh_get_next_hop)(uip_ipaddr_t *ipaddr); + /** + * Called by lower layers after every packet transmission + * + * \param addr The link-layer addrress of the packet destination + * \param status The transmission status (see os/net/mac/mac.h) + * \param numtx The total number of transmission attempts + */ + void (* link_callback)(const linkaddr_t *addr, int status, int numtx); }; #endif /* ROUTING_H_ */ diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 6ac987ebf..6fa041eba 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -383,6 +383,7 @@ const struct routing_driver rpl_classic_driver = { rpl_ext_header_hbh_update, rpl_ext_header_srh_update, rpl_ext_header_srh_get_next_hop, + rpl_link_callback, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 9a27d7262..fe4f87684 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -205,6 +205,7 @@ const struct routing_driver rpl_lite_driver = { rpl_ext_header_hbh_update, rpl_ext_header_srh_update, rpl_ext_header_srh_get_next_hop, + rpl_link_callback, }; /*---------------------------------------------------------------------------*/ From 4ffab13eeb6ab72a21557797c0343df7961a80db Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 06:55:28 -0800 Subject: [PATCH 20/43] Routing API: drop_route --- os/net/ipv6/tcpip.c | 25 +++++------------------- os/net/ipv6/uip-ds6-route.h | 1 - os/net/routing/nullrouting/nullrouting.c | 6 ++++++ os/net/routing/routing.h | 6 ++++++ os/net/routing/rpl-classic/rpl.c | 13 ++++++++++++ os/net/routing/rpl-lite/rpl.c | 7 +++++++ 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/os/net/ipv6/tcpip.c b/os/net/ipv6/tcpip.c index 903498532..eec3068ad 100644 --- a/os/net/ipv6/tcpip.c +++ b/os/net/ipv6/tcpip.c @@ -476,23 +476,6 @@ output_fallback(void) } /*---------------------------------------------------------------------------*/ static void -drop_route(uip_ds6_route_t *route) -{ -#if UIP_CONF_IPV6_RPL && (UIP_CONF_IPV6_RPL_LITE == 0) - - /* If we are running RPL, and if we are the root of the - network, we'll trigger a global repair before we remove - the route. */ - rpl_dag_t *dag; - dag = (rpl_dag_t *)route->state.dag; - if(dag != NULL && dag->instance != NULL) { - rpl_repair_root(dag->instance->instance_id); - } -#endif /* UIP_CONF_IPV6_RPL && (UIP_CONF_IPV6_RPL_LITE == 0) */ - uip_ds6_route_rm(route); -} -/*---------------------------------------------------------------------------*/ -static void annotate_transmission(uip_ipaddr_t *nexthop) { #if TCPIP_CONF_ANNOTATE_TRANSMISSIONS @@ -558,9 +541,11 @@ get_nexthop(uip_ipaddr_t *addr) never responded to link-layer acks, we drop its route. */ if(nexthop == NULL) { LOG_ERR("output: found dead route\n"); - drop_route(route); - /* We don't have a nexthop to send the packet to, so we drop - it. */ + /* Notifiy the routing protocol that we are about to remove the route */ + NETSTACK_ROUTING.drop_route(route); + /* Remove the route */ + uip_ds6_route_rm(route); + /* We don't have a nexthop to send the packet to, so we drop it. */ } else { LOG_INFO("output: found next hop from routing table: "); LOG_INFO_6ADDR(nexthop); diff --git a/os/net/ipv6/uip-ds6-route.h b/os/net/ipv6/uip-ds6-route.h index 8f2bc377d..663f0ad50 100644 --- a/os/net/ipv6/uip-ds6-route.h +++ b/os/net/ipv6/uip-ds6-route.h @@ -44,7 +44,6 @@ #include "net/nbr-table.h" #include "sys/stimer.h" #include "lib/list.h" -#include "net/routing/routing.h" #ifdef UIP_CONF_MAX_ROUTES #define UIP_MAX_ROUTES UIP_CONF_MAX_ROUTES diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 5707143b1..e341225f9 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -103,6 +103,11 @@ link_callback(const linkaddr_t *addr, int status, int numtx) { } /*---------------------------------------------------------------------------*/ +static void +drop_route(uip_ds6_route_t *route) +{ +} +/*---------------------------------------------------------------------------*/ const struct routing_driver nullrouting_driver = { "Null Routing", init, @@ -116,6 +121,7 @@ const struct routing_driver nullrouting_driver = { ext_header_srh_update, ext_header_srh_get_next_hop, link_callback, + drop_route, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index fa0e301af..330269826 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -118,6 +118,12 @@ struct routing_driver { * \param numtx The total number of transmission attempts */ void (* link_callback)(const linkaddr_t *addr, int status, int numtx); + /** + * Called by uIP if it has decided to drop a route because + * + * \param route The route that will be dropped after this function returns + */ + void (* drop_route)(uip_ds6_route_t *route); }; #endif /* ROUTING_H_ */ diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 6fa041eba..a649e247c 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -371,6 +371,18 @@ local_repair(const char *str) } } /*---------------------------------------------------------------------------*/ +static void +drop_route(uip_ds6_route_t *route) +{ + /* If we are the root of the network, trigger a global repair before + the route gets removed */ + rpl_dag_t *dag; + dag = (rpl_dag_t *)route->state.dag; + if(dag != NULL && dag->instance != NULL) { + rpl_repair_root(dag->instance->instance_id); + } +} +/*---------------------------------------------------------------------------*/ const struct routing_driver rpl_classic_driver = { "RPL Classic", init, @@ -384,6 +396,7 @@ const struct routing_driver rpl_classic_driver = { rpl_ext_header_srh_update, rpl_ext_header_srh_get_next_hop, rpl_link_callback, + drop_route, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index fe4f87684..dc1c123f2 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -193,6 +193,12 @@ init(void) rpl_ns_init(); } /*---------------------------------------------------------------------------*/ +static void +drop_route(uip_ds6_route_t *route) +{ + /* Do nothing. RPL-lite only supports non-storing mode, i.e. no routes */ +} +/*---------------------------------------------------------------------------*/ const struct routing_driver rpl_lite_driver = { "RPL Lite", init, @@ -206,6 +212,7 @@ const struct routing_driver rpl_lite_driver = { rpl_ext_header_srh_update, rpl_ext_header_srh_get_next_hop, rpl_link_callback, + drop_route, }; /*---------------------------------------------------------------------------*/ From dfa7d735ac29ce5568aa05684a8cb4797f559a50 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 07:19:27 -0800 Subject: [PATCH 21/43] Added necessary includes --- os/net/ipv6/uip-ds6-nbr.c | 2 ++ os/net/ipv6/uip-ds6.c | 1 + 2 files changed, 3 insertions(+) diff --git a/os/net/ipv6/uip-ds6-nbr.c b/os/net/ipv6/uip-ds6-nbr.c index d07f85d78..27678a2db 100644 --- a/os/net/ipv6/uip-ds6-nbr.c +++ b/os/net/ipv6/uip-ds6-nbr.c @@ -50,7 +50,9 @@ #include "net/link-stats.h" #include "net/linkaddr.h" #include "net/packetbuf.h" +#include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-ds6-nbr.h" +#include "net/ipv6/uip-nd6.h" /* Log configuration */ #include "sys/log.h" diff --git a/os/net/ipv6/uip-ds6.c b/os/net/ipv6/uip-ds6.c index 18e9d33e9..6dd178dc8 100644 --- a/os/net/ipv6/uip-ds6.c +++ b/os/net/ipv6/uip-ds6.c @@ -47,6 +47,7 @@ #include #include "lib/random.h" #include "net/ipv6/uip-nd6.h" +#include "net/ipv6/uip-ds6-nbr.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/multicast/uip-mcast6.h" #include "net/ipv6/uip-packetqueue.h" From c6f2364bd801555c33ff529367af6e22d1072a5e Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 07:32:43 -0800 Subject: [PATCH 22/43] RPL Classic: fix rpl-ext-headers.c --- os/net/routing/rpl-classic/rpl-ext-header.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/os/net/routing/rpl-classic/rpl-ext-header.c b/os/net/routing/rpl-classic/rpl-ext-header.c index 250aeb924..bb28c590d 100644 --- a/os/net/routing/rpl-classic/rpl-ext-header.c +++ b/os/net/routing/rpl-classic/rpl-ext-header.c @@ -174,10 +174,10 @@ rpl_ext_header_hbh_update(int uip_ext_opt_offset) return 1; } /*---------------------------------------------------------------------------*/ -#if RPL_WITH_NON_STORING int rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) { +#if RPL_WITH_NON_STORING uint8_t *uip_next_hdr; int last_uip_ext_len = uip_ext_len; rpl_dag_t *dag; @@ -227,11 +227,15 @@ rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) uip_ext_len = last_uip_ext_len; return 0; +#else /* RPL_WITH_NON_STORING */ + return 0; /* SRH not found */ +#endif /* RPL_WITH_NON_STORING */ } /*---------------------------------------------------------------------------*/ int rpl_ext_header_srh_update(void) { +#if RPL_WITH_NON_STORING uint8_t *uip_next_hdr; int last_uip_ext_len = uip_ext_len; @@ -308,6 +312,9 @@ rpl_ext_header_srh_update(void) uip_ext_len = last_uip_ext_len; return 0; +#else /* RPL_WITH_NON_STORING */ + return 0; /* SRH not found */ +#endif /* RPL_WITH_NON_STORING */ } /*---------------------------------------------------------------------------*/ static int @@ -461,9 +468,6 @@ insert_srh_header(void) return 1; } -#else /* RPL_WITH_NON_STORING */ -int insert_srh_header(void); -#endif /* RPL_WITH_NON_STORING */ /*---------------------------------------------------------------------------*/ static int update_hbh_header(void) From c9861b0726a8687d554406c7f3f63df80400109c Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 07:34:16 -0800 Subject: [PATCH 23/43] Routing API: added neighbor_state_changed --- os/net/ipv6/uip-ds6-nbr.c | 12 +++--------- os/net/ipv6/uip-ds6.h | 7 ------- os/net/routing/nullrouting/nullrouting.c | 6 ++++++ os/net/routing/routing.h | 9 +++++++++ os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-lite/rpl.c | 7 +++++++ 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/os/net/ipv6/uip-ds6-nbr.c b/os/net/ipv6/uip-ds6-nbr.c index 27678a2db..81c12bf96 100644 --- a/os/net/ipv6/uip-ds6-nbr.c +++ b/os/net/ipv6/uip-ds6-nbr.c @@ -53,19 +53,13 @@ #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-ds6-nbr.h" #include "net/ipv6/uip-nd6.h" +#include "net/routing/routing.h" /* Log configuration */ #include "sys/log.h" #define LOG_MODULE "IPv6 Nbr" #define LOG_LEVEL LOG_LEVEL_IPV6 -#ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED -#define NEIGHBOR_STATE_CHANGED(n) UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED(n) -void NEIGHBOR_STATE_CHANGED(uip_ds6_nbr_t *n); -#else -#define NEIGHBOR_STATE_CHANGED(n) -#endif /* UIP_DS6_CONF_NEIGHBOR_STATE_CHANGED */ - NBR_TABLE_GLOBAL(uip_ds6_nbr_t, ds6_neighbors); /*---------------------------------------------------------------------------*/ @@ -107,7 +101,7 @@ uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr, LOG_INFO_(" link addr "); LOG_INFO_LLADDR((linkaddr_t*)lladdr); LOG_INFO_(" state %u\n", state); - NEIGHBOR_STATE_CHANGED(nbr); + NETSTACK_ROUTING.neighbor_state_changed(nbr); return nbr; } else { LOG_INFO("Add drop ip addr "); @@ -127,7 +121,7 @@ uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr) #if UIP_CONF_IPV6_QUEUE_PKT uip_packetqueue_free(&nbr->packethandle); #endif /* UIP_CONF_IPV6_QUEUE_PKT */ - NEIGHBOR_STATE_CHANGED(nbr); + NETSTACK_ROUTING.neighbor_state_changed(nbr); return nbr_table_remove(ds6_neighbors, nbr); } return 0; diff --git a/os/net/ipv6/uip-ds6.h b/os/net/ipv6/uip-ds6.h index 29f9249c3..45394fec3 100644 --- a/os/net/ipv6/uip-ds6.h +++ b/os/net/ipv6/uip-ds6.h @@ -226,13 +226,6 @@ typedef struct uip_ds6_maddr { uip_ipaddr_t ipaddr; } uip_ds6_maddr_t; -/* only define the callback if RPL is active */ -#if UIP_CONF_IPV6_RPL && (UIP_CONF_IPV6_RPL_LITE == 0) -#ifndef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED -#define UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED rpl_ipv6_neighbor_callback -#endif /* UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED */ -#endif /* UIP_CONF_IPV6_RPL */ - /** \brief Interface structure (contains all the interface variables) */ typedef struct uip_ds6_netif { uint32_t link_mtu; diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index e341225f9..2d48221e2 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -104,6 +104,11 @@ link_callback(const linkaddr_t *addr, int status, int numtx) } /*---------------------------------------------------------------------------*/ static void +neighbor_state_changed(uip_ds6_nbr_t *nbr) +{ +} +/*---------------------------------------------------------------------------*/ +static void drop_route(uip_ds6_route_t *route) { } @@ -121,6 +126,7 @@ const struct routing_driver nullrouting_driver = { ext_header_srh_update, ext_header_srh_get_next_hop, link_callback, + neighbor_state_changed, drop_route, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index 330269826..dd10086a0 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -42,6 +42,7 @@ #include "contiki.h" #include "net/ipv6/uip.h" +#include "net/ipv6/uip-ds6-nbr.h" #include "net/ipv6/uip-ds6-route.h" #include "net/linkaddr.h" @@ -118,6 +119,14 @@ struct routing_driver { * \param numtx The total number of transmission attempts */ void (* link_callback)(const linkaddr_t *addr, int status, int numtx); + /** + * Called by uIP to notify addition/removal of IPv6 neighbor entries + * + * \param addr The link-layer addrress of the packet destination + * \param status The transmission status (see os/net/mac/mac.h) + * \param numtx The total number of transmission attempts + */ + void (* neighbor_state_changed)(uip_ds6_nbr_t *nbr); /** * Called by uIP if it has decided to drop a route because * diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index a649e247c..5f82cf182 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -396,6 +396,7 @@ const struct routing_driver rpl_classic_driver = { rpl_ext_header_srh_update, rpl_ext_header_srh_get_next_hop, rpl_link_callback, + rpl_ipv6_neighbor_callback, drop_route, }; /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index dc1c123f2..e45c6df42 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -194,6 +194,12 @@ init(void) } /*---------------------------------------------------------------------------*/ static void +neighbor_state_changed(uip_ds6_nbr_t *nbr) +{ + /* Nothing needs be done in non-storing mode */ +} +/*---------------------------------------------------------------------------*/ +static void drop_route(uip_ds6_route_t *route) { /* Do nothing. RPL-lite only supports non-storing mode, i.e. no routes */ @@ -212,6 +218,7 @@ const struct routing_driver rpl_lite_driver = { rpl_ext_header_srh_update, rpl_ext_header_srh_get_next_hop, rpl_link_callback, + neighbor_state_changed, drop_route, }; /*---------------------------------------------------------------------------*/ From b01c2d98024798d762b9c38a0dcb2c20ee6d8c12 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 07:51:01 -0800 Subject: [PATCH 24/43] Fix shell-commands.c --- os/services/shell/shell-commands.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index 25812eebd..3b1889189 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -60,11 +60,14 @@ #endif /* MAC_CONF_WITH_TSCH */ #include "net/routing/routing.h" #include "net/mac/llsec802154.h" -#if RPL_WITH_NON_STORING -/* For RPL non-storing specific link printout */ -#include "rpl-ns.h" -#endif +/* For RPL-specific commands */ +#if UIP_CONF_IPV6_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#elif UIP_CONF_IPV6_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-private.h" +#endif #include From fb8bf3d02d22555e786a4522d9730a55ef0d33a7 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 07:53:56 -0800 Subject: [PATCH 25/43] Remove unused define in uip6.c --- os/net/ipv6/uip6.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/os/net/ipv6/uip6.c b/os/net/ipv6/uip6.c index c491baf64..de14486b9 100644 --- a/os/net/ipv6/uip6.c +++ b/os/net/ipv6/uip6.c @@ -153,9 +153,6 @@ uint8_t uip_ext_opt_offset = 0; #define UIP_DESTO_BUF ((struct uip_desto_hdr *)&uip_buf[uip_l2_l3_hdr_len]) #define UIP_EXT_HDR_OPT_BUF ((struct uip_ext_hdr_opt *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset]) #define UIP_EXT_HDR_OPT_PADN_BUF ((struct uip_ext_hdr_opt_padn *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset]) -#if UIP_CONF_IPV6_RPL -#define UIP_EXT_HDR_OPT_RPL_BUF ((struct uip_ext_hdr_opt_rpl *)&uip_buf[uip_l2_l3_hdr_len + uip_ext_opt_offset]) -#endif /* UIP_CONF_IPV6_RPL */ #define UIP_ICMP6_ERROR_BUF ((struct uip_icmp6_error *)&uip_buf[uip_l2_l3_icmp_hdr_len]) /** @} */ /** From 15b81c0fe527e4ef37ed0b5e03294dfe351c8f51 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 10:51:05 -0800 Subject: [PATCH 26/43] Fix protocol-dependent def of UIP_MAX_ROUTES --- os/net/ipv6/uip-ds6-route.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/os/net/ipv6/uip-ds6-route.h b/os/net/ipv6/uip-ds6-route.h index 663f0ad50..9d055ec53 100644 --- a/os/net/ipv6/uip-ds6-route.h +++ b/os/net/ipv6/uip-ds6-route.h @@ -46,13 +46,26 @@ #include "lib/list.h" #ifdef UIP_CONF_MAX_ROUTES + #define UIP_MAX_ROUTES UIP_CONF_MAX_ROUTES + #else /* UIP_CONF_MAX_ROUTES */ + +#if UIP_CONF_IPV6_RPL_LITE +#define UIP_MAX_ROUTES 0 /* RPL Lite only supports non-storing, no routes */ +#elif UIP_CONF_IPV6_RPL_CLASSIC + +#include "net/routing/rpl-classic/rpl-conf.h" #if RPL_WITH_STORING #define UIP_MAX_ROUTES NETSTACK_MAX_ROUTE_ENTRIES -#else -#define UIP_MAX_ROUTES 0 +#else /* RPL_WITH_STORING */ +#define UIP_MAX_ROUTES 0 /* No storing mode, no need for routes */ +#endif /* RPL_WITH_STORING */ + +#else /* Not RPL Lite nor RPL Classic */ +#define UIP_MAX_ROUTES NETSTACK_MAX_ROUTE_ENTRIES #endif + #endif /* UIP_CONF_MAX_ROUTES */ NBR_TABLE_DECLARE(nbr_routes); From 26d51c15d792bfd324b357143f64dc2430a92097 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 11:51:26 -0800 Subject: [PATCH 27/43] Routing API: added more missing functions, homogenize configuration --- Makefile.include | 4 +- examples/6tisch/simple-node/node.c | 4 +- .../rpl-border-router/webserver/webserver.c | 10 +- os/contiki-default-conf.h | 4 + os/net/ipv6/uip-ds6-nbr.c | 6 +- os/net/mac/tsch/tsch.c | 2 +- os/net/routing/nullrouting/nullrouting.c | 27 ++++ os/net/routing/routing.h | 24 ++++ os/net/routing/rpl-classic/rpl.c | 23 ++++ os/net/routing/rpl-lite/rpl-dag.c | 10 ++ os/net/routing/rpl-lite/rpl-dag.h | 7 ++ os/net/routing/rpl-lite/rpl.c | 4 + os/services/lwm2m/lwm2m-engine.c | 5 - os/services/shell/shell-commands.c | 115 +++++++++--------- tools/doxygen/Doxyfile | 3 - 15 files changed, 168 insertions(+), 80 deletions(-) diff --git a/Makefile.include b/Makefile.include index c8110ad66..67b788af1 100644 --- a/Makefile.include +++ b/Makefile.include @@ -151,17 +151,15 @@ MAKE_ROUTING ?= MAKE_ROUTING_NONE endif ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC) - CFLAGS += -DUIP_CONF_IPV6_RPL=1 CFLAGS += -DUIP_CONF_IPV6_RPL_CLASSIC=1 CFLAGS += -DNETSTACK_ROUTING=rpl_classic_driver MODULES += os/net/routing/rpl-classic else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_LITE) - CFLAGS += -DUIP_CONF_IPV6_RPL=1 CFLAGS += -DUIP_CONF_IPV6_RPL_LITE=1 CFLAGS += -DNETSTACK_ROUTING=rpl_lite_driver MODULES += os/net/routing/rpl-lite else - CFLAGS += -DUIP_CONF_IPV6_RPL=0 + CFLAGS += -DUIP_CONF_IPV6_NULLROUTING=1 CFLAGS += -DNETSTACK_ROUTING=nullrouting_driver MODULES += os/net/routing/nullrouting endif diff --git a/examples/6tisch/simple-node/node.c b/examples/6tisch/simple-node/node.c index ce4c15093..1132ecb67 100644 --- a/examples/6tisch/simple-node/node.c +++ b/examples/6tisch/simple-node/node.c @@ -76,10 +76,10 @@ PROCESS_THREAD(node_process, ev, data) etimer_set(&et, CLOCK_SECOND * 60); while(1) { /* Used for non-regression testing */ - #if RPL_WITH_STORING + #if (UIP_MAX_ROUTES != 0) PRINTF("Routing entries: %u\n", uip_ds6_route_num_routes()); #endif - #if RPL_WITH_NON_STORING + #if UIP_CONF_IPV6_RPL PRINTF("Routing links: %u\n", rpl_ns_num_nodes()); #endif PROCESS_YIELD_UNTIL(etimer_expired(&et)); diff --git a/examples/rpl-border-router/webserver/webserver.c b/examples/rpl-border-router/webserver/webserver.c index f71b80915..4d40ea32f 100644 --- a/examples/rpl-border-router/webserver/webserver.c +++ b/examples/rpl-border-router/webserver/webserver.c @@ -32,11 +32,11 @@ #include "contiki.h" #include "net/routing/routing.h" -#if RPL_WITH_NON_STORING -/* For RPL non-storing specific link printout. - * Note that traditional DS6 routes are printed in addition, - * whenever UIP_MAX_ROUTES != 0 */ -#include "rpl-ns.h" +/* For RPL-specific data inclusion, in particular non-storing routing link */ +#if UIP_CONF_IPV6_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#elif UIP_CONF_IPV6_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" #endif #include diff --git a/os/contiki-default-conf.h b/os/contiki-default-conf.h index 0395f6ca4..81714c4df 100644 --- a/os/contiki-default-conf.h +++ b/os/contiki-default-conf.h @@ -81,6 +81,10 @@ #define UIP_CONF_ROUTER 1 #endif /* UIP_CONF_ROUTER */ +/* UIP_CONF_IPV6_RPL tells whether the RPL routing protocol is running, + whether implemented as RPL Lite or RPL Classic */ +#define UIP_CONF_IPV6_RPL (UIP_CONF_IPV6_RPL_LITE || UIP_CONF_IPV6_RPL_CLASSIC) + /* If RPL is enabled also enable the RPL NBR Policy */ #if UIP_CONF_IPV6_RPL #ifndef NBR_TABLE_FIND_REMOVABLE diff --git a/os/net/ipv6/uip-ds6-nbr.c b/os/net/ipv6/uip-ds6-nbr.c index 81c12bf96..e49125548 100644 --- a/os/net/ipv6/uip-ds6-nbr.c +++ b/os/net/ipv6/uip-ds6-nbr.c @@ -253,7 +253,7 @@ uip_ds6_neighbor_periodic(void) switch(nbr->state) { case NBR_REACHABLE: if(stimer_expired(&nbr->reachable)) { -#if UIP_CONF_IPV6_RPL +#if UIP_CONF_ROUTER /* when a neighbor leave its REACHABLE state and is a default router, instead of going to STALE state it enters DELAY state in order to force a NUD on it. Otherwise, if there is no upward traffic, the @@ -273,12 +273,12 @@ uip_ds6_neighbor_periodic(void) LOG_INFO_(")\n"); nbr->state = NBR_STALE; } -#else /* UIP_CONF_IPV6_RPL */ +#else /* UIP_CONF_ROUTER */ LOG_INFO("REACHABLE: moving to STALE ("); LOG_INFO_6ADDR(&nbr->ipaddr); LOG_INFO_(")\n"); nbr->state = NBR_STALE; -#endif /* UIP_CONF_IPV6_RPL */ +#endif /* UIP_CONF_ROUTER */ } break; case NBR_INCOMPLETE: diff --git a/os/net/mac/tsch/tsch.c b/os/net/mac/tsch/tsch.c index b5b572f40..9d0affb8a 100644 --- a/os/net/mac/tsch/tsch.c +++ b/os/net/mac/tsch/tsch.c @@ -62,7 +62,7 @@ #include "net/mac/tsch/tsch-security.h" #if UIP_CONF_IPV6_RPL #include "net/mac/tsch/tsch-rpl.h" -#endif /* #if UIP_CONF_IPV6_RPL */ +#endif /* UIP_CONF_IPV6_RPL */ #include "net/mac/mac-sequence.h" #include "lib/random.h" #include "net/routing/routing.h" diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 2d48221e2..416a4fd58 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -58,6 +58,29 @@ root_start(void) return 0; } /*---------------------------------------------------------------------------*/ +static int +node_is_root(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +static int +get_root_ipaddr(uip_ipaddr_t *ipaddr) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +static void +leave_network(void) +{ +} +/*---------------------------------------------------------------------------*/ +static int +node_is_reachable(void) +{ + return 1; +} +/*---------------------------------------------------------------------------*/ static void global_repair(const char *str) { @@ -118,6 +141,10 @@ const struct routing_driver nullrouting_driver = { init, root_set_prefix, root_start, + node_is_root, + get_root_ipaddr, + leave_network, + node_is_reachable, global_repair, local_repair, ext_header_remove, diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index dd10086a0..ca86d77f5 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -66,6 +66,30 @@ struct routing_driver { * \return 0 in case of success, -1 otherwise */ int (* root_start)(void); + /** + * Tells whether the node is a network root or not + * + * \return 1 if we are root, 0 otherwise + */ + int (* node_is_root)(void); + /** + * Returns the IPv6 address of the network root, if any + * + * \param ipaddr A pointer where to copy the IP address of the root + * \return 1 if the root address was copied, 0 otherwise + */ + int (* get_root_ipaddr)(uip_ipaddr_t *ipaddr); + /** + * Leave the network the node is part of + * + */ + void (* leave_network)(void); + /** + * Tells whether the node is currently reachable as part of the network + * + * \return 1 if we are reachable, 0 otherwise. + */ + int (* node_is_reachable)(void); /** * Triggers a global topology repair * diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 5f82cf182..0146f7a71 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -383,11 +383,34 @@ drop_route(uip_ds6_route_t *route) } } /*---------------------------------------------------------------------------*/ +static void +leave_network(void) +{ + PRINTF("RPL: leave_network not supported in RPL Classic\n"); +} +/*---------------------------------------------------------------------------*/ +static int +get_root_ipaddr(uip_ipaddr_t *ipaddr) +{ + rpl_dag_t *dag; + /* Use the DAG id as server address if no other has been specified */ + dag = rpl_get_any_dag(); + if(dag != NULL && ipaddr != NULL) { + uip_ipaddr_copy(ipaddr, &dag->dag_id); + return 1; + } + return 0; +} +/*---------------------------------------------------------------------------*/ const struct routing_driver rpl_classic_driver = { "RPL Classic", init, rpl_dag_root_set_prefix, rpl_dag_root_start, + rpl_dag_root_is_root, + get_root_ipaddr, + leave_network, + rpl_has_downward_route, global_repair, local_repair, rpl_ext_header_remove, diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index 2f89cc1ff..a43696c5b 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -78,6 +78,16 @@ rpl_dag_state_to_str(enum rpl_dag_state state) } } /*---------------------------------------------------------------------------*/ +int +rpl_dag_get_root_ipaddr(uip_ipaddr_t *ipaddr) +{ + if(curr_instance.used && ipaddr != NULL) { + uip_ipaddr_copy(ipaddr, &curr_instance.dag.dag_id); + return 1; + } + return 0; +} +/*---------------------------------------------------------------------------*/ void rpl_dag_leave(void) { diff --git a/os/net/routing/rpl-lite/rpl-dag.h b/os/net/routing/rpl-lite/rpl-dag.h index 52e14c9f3..f9ae66f5f 100644 --- a/os/net/routing/rpl-lite/rpl-dag.h +++ b/os/net/routing/rpl-lite/rpl-dag.h @@ -58,6 +58,13 @@ * \return The description string */ const char *rpl_dag_state_to_str(enum rpl_dag_state state); +/** + * Returns the IPv6 address of the RPL DAG root, if any + * + * \param ipaddr A pointer where to copy the IP address of the DAG root + * \return 1 if the root address was copied, 0 otherwise +*/ +int rpl_dag_get_root_ipaddr(uip_ipaddr_t *ipaddr); /** * Start poisoning and leave the DAG after a delay * diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index e45c6df42..1f43fab29 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -210,6 +210,10 @@ const struct routing_driver rpl_lite_driver = { init, rpl_dag_root_set_prefix, rpl_dag_root_start, + rpl_dag_root_is_root, + rpl_dag_get_root_ipaddr, + rpl_dag_poison_and_leave, + rpl_is_reachable, rpl_global_repair, rpl_local_repair, rpl_ext_header_remove, diff --git a/os/services/lwm2m/lwm2m-engine.c b/os/services/lwm2m/lwm2m-engine.c index 7f67be2c8..3a1682e95 100644 --- a/os/services/lwm2m/lwm2m-engine.c +++ b/os/services/lwm2m/lwm2m-engine.c @@ -59,11 +59,6 @@ #include #include -#if UIP_CONF_IPV6_RPL -#include "rpl.h" -#include "net/ipv6/uip-ds6.h" -#endif /* UIP_CONF_IPV6_RPL */ - /* Log configuration */ #include "coap-log.h" #define LOG_MODULE "lwm2m-engine" diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index 3b1889189..ebdc7266b 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -66,7 +66,6 @@ #include "net/routing/rpl-lite/rpl.h" #elif UIP_CONF_IPV6_RPL_CLASSIC #include "net/routing/rpl-classic/rpl.h" -#include "net/routing/rpl-classic/rpl-private.h" #endif #include @@ -149,6 +148,50 @@ rpl_ocp_to_str(int ocp) return "Unknown"; } } +/*---------------------------------------------------------------------------*/ +static +PT_THREAD(cmd_rpl_status(struct pt *pt, shell_output_func output, char *args)) +{ + PT_BEGIN(pt); + + SHELL_OUTPUT(output, "RPL status:\n"); + if(!curr_instance.used) { + SHELL_OUTPUT(output, "-- Instance: None\n"); + } else { + SHELL_OUTPUT(output, "-- Instance: %u\n", curr_instance.instance_id); + if(NETSTACK_ROUTING.node_is_root()) { + SHELL_OUTPUT(output, "-- DAG root\n"); + } else { + SHELL_OUTPUT(output, "-- DAG node\n"); + } + SHELL_OUTPUT(output, "-- DAG: "); + shell_output_6addr(output, &curr_instance.dag.dag_id); + SHELL_OUTPUT(output, ", version %u\n", curr_instance.dag.version); + SHELL_OUTPUT(output, "-- Prefix: "); + shell_output_6addr(output, &curr_instance.dag.prefix_info.prefix); + SHELL_OUTPUT(output, "/%u\n", curr_instance.dag.prefix_info.length); + SHELL_OUTPUT(output, "-- MOP: %s\n", rpl_mop_to_str(curr_instance.mop)); + SHELL_OUTPUT(output, "-- OF: %s\n", rpl_ocp_to_str(curr_instance.of->ocp)); + SHELL_OUTPUT(output, "-- Hop rank increment: %u\n", curr_instance.min_hoprankinc); + SHELL_OUTPUT(output, "-- Default lifetime: %lu seconds\n", RPL_LIFETIME(curr_instance.default_lifetime)); + + SHELL_OUTPUT(output, "-- State: %s\n", rpl_state_to_str(curr_instance.dag.state)); + SHELL_OUTPUT(output, "-- Preferred parent: "); + shell_output_6addr(output, rpl_neighbor_get_ipaddr(curr_instance.dag.preferred_parent)); + SHELL_OUTPUT(output, "\n"); + SHELL_OUTPUT(output, "-- Rank: %u\n", curr_instance.dag.rank); + SHELL_OUTPUT(output, "-- Lowest rank: %u (%u)\n", curr_instance.dag.lowest_rank, curr_instance.max_rankinc); + SHELL_OUTPUT(output, "-- DTSN out: %u\n", curr_instance.dtsn_out); + SHELL_OUTPUT(output, "-- DAO sequence: last sent %u, last acked %u\n", + curr_instance.dag.dao_last_seqno, curr_instance.dag.dao_last_acked_seqno); + SHELL_OUTPUT(output, "-- Trickle timer: current %u, min %u, max %u, redundancy %u\n", + curr_instance.dag.dio_intcurrent, curr_instance.dio_intmin, + curr_instance.dio_intmin + curr_instance.dio_intdoubl, curr_instance.dio_redundancy); + + } + + PT_END(pt); +} #endif /* UIP_CONF_IPV6_RPL_LITE */ /*---------------------------------------------------------------------------*/ static void @@ -291,7 +334,6 @@ PT_THREAD(cmd_help(struct pt *pt, shell_output_func output, char *args)) PT_END(pt); } -#if UIP_CONF_IPV6_RPL_LITE /*---------------------------------------------------------------------------*/ static PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args)) @@ -328,7 +370,7 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args)) } if(is_on) { - if(!rpl_dag_root_is_root()) { + if(!NETSTACK_ROUTING.node_is_root()) { SHELL_OUTPUT(output, "Setting as DAG root with prefix "); shell_output_6addr(output, &prefix); SHELL_OUTPUT(output, "/64\n"); @@ -338,9 +380,9 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args)) SHELL_OUTPUT(output, "Node is already a DAG root\n"); } } else { - if(rpl_dag_root_is_root()) { + if(NETSTACK_ROUTING.node_is_root()) { SHELL_OUTPUT(output, "Setting as non-root node: leaving DAG\n"); - rpl_dag_poison_and_leave(); + NETSTACK_ROUTING.leave_network(); } else { SHELL_OUTPUT(output, "Node is not a DAG root\n"); } @@ -350,50 +392,6 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args)) } /*---------------------------------------------------------------------------*/ static -PT_THREAD(cmd_rpl_status(struct pt *pt, shell_output_func output, char *args)) -{ - PT_BEGIN(pt); - - SHELL_OUTPUT(output, "RPL status:\n"); - if(!curr_instance.used) { - SHELL_OUTPUT(output, "-- Instance: None\n"); - } else { - SHELL_OUTPUT(output, "-- Instance: %u\n", curr_instance.instance_id); - if(rpl_dag_root_is_root()) { - SHELL_OUTPUT(output, "-- DAG root\n"); - } else { - SHELL_OUTPUT(output, "-- DAG node\n"); - } - SHELL_OUTPUT(output, "-- DAG: "); - shell_output_6addr(output, &curr_instance.dag.dag_id); - SHELL_OUTPUT(output, ", version %u\n", curr_instance.dag.version); - SHELL_OUTPUT(output, "-- Prefix: "); - shell_output_6addr(output, &curr_instance.dag.prefix_info.prefix); - SHELL_OUTPUT(output, "/%u\n", curr_instance.dag.prefix_info.length); - SHELL_OUTPUT(output, "-- MOP: %s\n", rpl_mop_to_str(curr_instance.mop)); - SHELL_OUTPUT(output, "-- OF: %s\n", rpl_ocp_to_str(curr_instance.of->ocp)); - SHELL_OUTPUT(output, "-- Hop rank increment: %u\n", curr_instance.min_hoprankinc); - SHELL_OUTPUT(output, "-- Default lifetime: %lu seconds\n", RPL_LIFETIME(curr_instance.default_lifetime)); - - SHELL_OUTPUT(output, "-- State: %s\n", rpl_state_to_str(curr_instance.dag.state)); - SHELL_OUTPUT(output, "-- Preferred parent: "); - shell_output_6addr(output, rpl_neighbor_get_ipaddr(curr_instance.dag.preferred_parent)); - SHELL_OUTPUT(output, "\n"); - SHELL_OUTPUT(output, "-- Rank: %u\n", curr_instance.dag.rank); - SHELL_OUTPUT(output, "-- Lowest rank: %u (%u)\n", curr_instance.dag.lowest_rank, curr_instance.max_rankinc); - SHELL_OUTPUT(output, "-- DTSN out: %u\n", curr_instance.dtsn_out); - SHELL_OUTPUT(output, "-- DAO sequence: last sent %u, last acked %u\n", - curr_instance.dag.dao_last_seqno, curr_instance.dag.dao_last_acked_seqno); - SHELL_OUTPUT(output, "-- Trickle timer: current %u, min %u, max %u, redundancy %u\n", - curr_instance.dag.dio_intcurrent, curr_instance.dio_intmin, - curr_instance.dio_intmin + curr_instance.dio_intdoubl, curr_instance.dio_redundancy); - - } - - PT_END(pt); -} -/*---------------------------------------------------------------------------*/ -static PT_THREAD(cmd_rpl_global_repair(struct pt *pt, shell_output_func output, char *args)) { PT_BEGIN(pt); @@ -414,7 +412,6 @@ PT_THREAD(cmd_rpl_local_repair(struct pt *pt, shell_output_func output, char *ar PT_END(pt); } -#endif /* UIP_CONF_IPV6_RPL_LITE */ /*---------------------------------------------------------------------------*/ static PT_THREAD(cmd_ipaddr(struct pt *pt, shell_output_func output, char *args)) @@ -557,9 +554,9 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) #if RPL_WITH_NON_STORING rpl_ns_node_t *link; #endif /* RPL_WITH_NON_STORING */ -#if RPL_WITH_STORING +#if (UIP_MAX_ROUTES != 0) uip_ds6_route_t *route; -#endif /* RPL_WITH_STORING */ +#endif /* (UIP_MAX_ROUTES != 0) */ PT_BEGIN(pt); @@ -597,7 +594,7 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) SHELL_OUTPUT(output, " to "); shell_output_6addr(output, &parent_ipaddr); } - if(link->lifetime != RPL_ROUTE_INFINITE_LIFETIME) { + if(link->lifetime != 0xFFFFFFFF) { SHELL_OUTPUT(output, " (lifetime: %lu seconds)\n", (unsigned long)link->lifetime); } else { SHELL_OUTPUT(output, " (lifetime: infinite)\n"); @@ -609,7 +606,7 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) } #endif /* RPL_WITH_NON_STORING */ -#if RPL_WITH_STORING +#if (UIP_MAX_ROUTES != 0) if(uip_ds6_route_num_routes() > 0) { /* Our routing entries */ SHELL_OUTPUT(output, "Routing entries (%u in total):\n", uip_ds6_route_num_routes()); @@ -619,7 +616,7 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) shell_output_6addr(output, &route->ipaddr); SHELL_OUTPUT(output, " via "); shell_output_6addr(output, uip_ds6_route_nexthop(route)); - if((unsigned long)route->state.lifetime != RPL_ROUTE_INFINITE_LIFETIME) { + if((unsigned long)route->state.lifetime != 0xFFFFFFFF) { SHELL_OUTPUT(output, " (lifetime: %lu seconds)\n", (unsigned long)route->state.lifetime); } else { SHELL_OUTPUT(output, " (lifetime: infinite)\n"); @@ -629,7 +626,7 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) } else { SHELL_OUTPUT(output, "No routing entries\n"); } -#endif /* RPL_WITH_STORING */ +#endif /* (UIP_MAX_ROUTES != 0) */ PT_END(pt); } @@ -724,11 +721,13 @@ struct shell_command_t shell_commands[] = { { "ip-nbr", cmd_ip_neighbors, "'> ip-nbr': Shows all IPv6 neighbors" }, { "log", cmd_log, "'> log module level': Sets log level (0--4) for a given module (or \"all\"). For module \"mac\", level 4 also enables per-slot logging." }, { "ping", cmd_ping, "'> ping addr': Pings the IPv6 address 'addr'" }, -#if UIP_CONF_IPV6_RPL_LITE +#if UIP_CONF_IPV6_RPL { "rpl-set-root", cmd_rpl_set_root, "'> rpl-set-root 0/1 [prefix]': Sets node as root (1) or not (0). A /64 prefix can be optionally specified." }, - { "rpl-status", cmd_rpl_status, "'> rpl-status': Shows a summary of the current RPL state" }, { "rpl-local-repair", cmd_rpl_local_repair, "'> rpl-local-repair': Triggers a RPL local repair" }, { "rpl-global-repair", cmd_rpl_global_repair, "'> rpl-global-repair': Triggers a RPL global repair" }, +#endif /* UIP_CONF_IPV6_RPL */ +#if UIP_CONF_IPV6_RPL_LITE + { "rpl-status", cmd_rpl_status, "'> rpl-status': Shows a summary of the current RPL state" }, #endif /* UIP_CONF_IPV6_RPL_LITE */ { "routes", cmd_routes, "'> routes': Shows the route entries" }, #if MAC_CONF_WITH_TSCH diff --git a/tools/doxygen/Doxyfile b/tools/doxygen/Doxyfile index 2c2bf5e4a..a7dc79fab 100644 --- a/tools/doxygen/Doxyfile +++ b/tools/doxygen/Doxyfile @@ -1953,10 +1953,7 @@ INCLUDE_FILE_PATTERNS = # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. PREDEFINED = CC_FUNCTION_POINTER_ARGS:=1 \ - NETSTACK_CONF_WITH_RIME:=1 \ - NETSTACK_CONF_WITH_IPV4:=1 \ NETSTACK_CONF_WITH_IPV6:=1 \ - UIP_CONF_IPV6_RPL:=1 \ UIP_TCP:=1 \ UIP_UDP:=1 \ UIP_CONF_ICMP6:=1 \ From f117770131bdbf94b27042da0cfcca07949b61a1 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 12:07:10 -0800 Subject: [PATCH 28/43] Fix inclusion paths --- os/net/ipv6/tcpip.c | 2 ++ os/net/ipv6/uip-ds6-nbr.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/os/net/ipv6/tcpip.c b/os/net/ipv6/tcpip.c index eec3068ad..41d317d17 100644 --- a/os/net/ipv6/tcpip.c +++ b/os/net/ipv6/tcpip.c @@ -38,11 +38,13 @@ * \author Julien Abeille (IPv6 related code) */ +#include "contiki.h" #include "contiki-net.h" #include "net/ipv6/uip-packetqueue.h" #include "net/ipv6/uip-nd6.h" #include "net/ipv6/uip-ds6.h" +#include "net/ipv6/uip-ds6-nbr.h" #include "net/linkaddr.h" #include "net/routing/routing.h" diff --git a/os/net/ipv6/uip-ds6-nbr.h b/os/net/ipv6/uip-ds6-nbr.h index f10a415b0..9aec47b4a 100644 --- a/os/net/ipv6/uip-ds6-nbr.h +++ b/os/net/ipv6/uip-ds6-nbr.h @@ -46,7 +46,9 @@ #ifndef UIP_DS6_NEIGHBOR_H_ #define UIP_DS6_NEIGHBOR_H_ +#include "contiki.h" #include "net/ipv6/uip.h" +#include "net/ipv6/uip-nd6.h" #include "net/nbr-table.h" #include "sys/stimer.h" #if UIP_CONF_IPV6_QUEUE_PKT From 7adfb92b63361b324148809a7314f76cd757af6d Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 12:08:03 -0800 Subject: [PATCH 29/43] Routing module configuration through netstack.h --- Makefile.include | 9 +++------ examples/6tisch/6p-packet/Makefile | 2 +- .../nrf52dk/blink-hello/Makefile | 2 +- .../platform-specific/nrf52dk/coap-demo/Makefile | 2 +- .../platform-specific/nrf52dk/mqtt-demo/Makefile | 2 +- .../nrf52dk/timer-test/Makefile | 2 +- examples/slip-radio/Makefile | 2 +- os/net/netstack.h | 16 ++++++++++++++++ 8 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Makefile.include b/Makefile.include index 67b788af1..785194092 100644 --- a/Makefile.include +++ b/Makefile.include @@ -139,7 +139,7 @@ ifeq ($(WITH_IP64),1) endif # Configure Routing protocol -MAKE_ROUTING_NONE = 0 +MAKE_ROUTING_NULLROUTING = 0 MAKE_ROUTING_RPL_CLASSIC = 1 MAKE_ROUTING_RPL_LITE = 2 @@ -147,20 +147,17 @@ MAKE_ROUTING_RPL_LITE = 2 ifeq ($(MAKE_NET),MAKE_NET_IPV6) MAKE_ROUTING ?= MAKE_ROUTING_RPL_LITE else -MAKE_ROUTING ?= MAKE_ROUTING_NONE +MAKE_ROUTING ?= MAKE_ROUTING_NULLROUTING endif ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC) CFLAGS += -DUIP_CONF_IPV6_RPL_CLASSIC=1 - CFLAGS += -DNETSTACK_ROUTING=rpl_classic_driver MODULES += os/net/routing/rpl-classic else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_LITE) CFLAGS += -DUIP_CONF_IPV6_RPL_LITE=1 - CFLAGS += -DNETSTACK_ROUTING=rpl_lite_driver MODULES += os/net/routing/rpl-lite -else +else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_NULLROUTING) CFLAGS += -DUIP_CONF_IPV6_NULLROUTING=1 - CFLAGS += -DNETSTACK_ROUTING=nullrouting_driver MODULES += os/net/routing/nullrouting endif diff --git a/examples/6tisch/6p-packet/Makefile b/examples/6tisch/6p-packet/Makefile index 1ae6e34b5..7e154f9d3 100644 --- a/examples/6tisch/6p-packet/Makefile +++ b/examples/6tisch/6p-packet/Makefile @@ -4,7 +4,7 @@ PROJECT_SOURCEFILES += test-sf.c CONTIKI = ../../../ MAKE_MAC = MAKE_MAC_TSCH -MAKE_ROUTING = MAKE_ROUTING_NONE +MAKE_ROUTING = MAKE_ROUTING_NULLROUTING MODULES += os/net/mac/tsch/sixtop include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/nrf52dk/blink-hello/Makefile b/examples/platform-specific/nrf52dk/blink-hello/Makefile index d5d2de18d..9bc1ee34f 100644 --- a/examples/platform-specific/nrf52dk/blink-hello/Makefile +++ b/examples/platform-specific/nrf52dk/blink-hello/Makefile @@ -1,6 +1,6 @@ CONTIKI_PROJECT = blink-hello -MAKE_ROUTING = MAKE_ROUTING_NONE +MAKE_ROUTING = MAKE_ROUTING_NULLROUTING MAKE_MAC=MAKE_MAC_NULLMAC NRF52_WITHOUT_SOFTDEVICE=1 diff --git a/examples/platform-specific/nrf52dk/coap-demo/Makefile b/examples/platform-specific/nrf52dk/coap-demo/Makefile index 0ad01fc57..39692524d 100644 --- a/examples/platform-specific/nrf52dk/coap-demo/Makefile +++ b/examples/platform-specific/nrf52dk/coap-demo/Makefile @@ -21,6 +21,6 @@ MODULES_REL += ./resources # REST Engine shall use Erbium CoAP implementation MODULES += os/net/app-layer/coap -MAKE_ROUTING = MAKE_ROUTING_NONE +MAKE_ROUTING = MAKE_ROUTING_NULLROUTING include $(CONTIKI)/Makefile.include diff --git a/examples/platform-specific/nrf52dk/mqtt-demo/Makefile b/examples/platform-specific/nrf52dk/mqtt-demo/Makefile index bf1b35fff..d32903531 100644 --- a/examples/platform-specific/nrf52dk/mqtt-demo/Makefile +++ b/examples/platform-specific/nrf52dk/mqtt-demo/Makefile @@ -1,6 +1,6 @@ all: mqtt-demo -MAKE_ROUTING = MAKE_ROUTING_NONE +MAKE_ROUTING = MAKE_ROUTING_NULLROUTING MODULES += os/net/app-layer/mqtt diff --git a/examples/platform-specific/nrf52dk/timer-test/Makefile b/examples/platform-specific/nrf52dk/timer-test/Makefile index de851dcf1..c5ddcfbd2 100644 --- a/examples/platform-specific/nrf52dk/timer-test/Makefile +++ b/examples/platform-specific/nrf52dk/timer-test/Makefile @@ -1,6 +1,6 @@ CONTIKI_PROJECT = timer-test -MAKE_ROUTING = MAKE_ROUTING_NONE +MAKE_ROUTING = MAKE_ROUTING_NULLROUTING MAKE_MAC=MAKE_MAC_NULLMAC NRF52_WITHOUT_SOFTDEVICE=1 diff --git a/examples/slip-radio/Makefile b/examples/slip-radio/Makefile index 3ab7bffa3..6b30b2d13 100644 --- a/examples/slip-radio/Makefile +++ b/examples/slip-radio/Makefile @@ -10,5 +10,5 @@ PROJECT_SOURCEFILES += slip-net.c # custom net layer, but with IPv6 enabled MAKE_NET = MAKE_NET_IPV6 -MAKE_ROUTING = MAKE_ROUTING_NONE +MAKE_ROUTING = MAKE_ROUTING_NULLROUTING include $(CONTIKI)/Makefile.include diff --git a/os/net/netstack.h b/os/net/netstack.h index 963b40c42..c32bfbce8 100644 --- a/os/net/netstack.h +++ b/os/net/netstack.h @@ -43,6 +43,22 @@ #include "contiki.h" +/* Routing protocol configuration. The Routing protocol is configured through the Makefile, + via the flag MAC_ROUTING */ +#ifdef NETSTACK_CONF_ROUTING +#define NETSTACK_ROUTING NETSTACK_CONF_ROUTING +#else /* NETSTACK_CONF_ROUTING */ +#if UIP_CONF_IPV6_RPL_LITE +#define NETSTACK_ROUTING rpl_lite_driver +#elif UIP_CONF_IPV6_RPL_CLASSIC +#define NETSTACK_ROUTING rpl_classic_driver +#elif UIP_CONF_IPV6_NULLROUTING +#define NETSTACK_ROUTING nullrouting_driver +#else +#error Unknown ROUTING configuration +#endif +#endif /* NETSTACK_CONF_ROUTING */ + /* Network layer configuration. The NET layer is configured through the Makefile, via the flag MAC_NET */ #ifdef NETSTACK_CONF_NETWORK From 5f4ad6d657a67b9a1e82aea6851a9d3adea3f997 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 12:13:47 -0800 Subject: [PATCH 30/43] Fix compilation of multicast engines smrf and esmrf --- os/net/ipv6/multicast/esmrf.c | 6 ++++++ os/net/ipv6/multicast/smrf.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/os/net/ipv6/multicast/esmrf.c b/os/net/ipv6/multicast/esmrf.c index bc8415a24..d66b15836 100644 --- a/os/net/ipv6/multicast/esmrf.c +++ b/os/net/ipv6/multicast/esmrf.c @@ -50,6 +50,12 @@ #include "net/ipv6/uip.h" #include "net/netstack.h" #include "net/packetbuf.h" +#if UIP_CONF_IPV6_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#endif /* UIP_CONF_IPV6_RPL_LITE */ +#if UIP_CONF_IPV6_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" +#endif /* UIP_CONF_IPV6_RPL_CLASSIC */ #include extern uint16_t uip_slen; diff --git a/os/net/ipv6/multicast/smrf.c b/os/net/ipv6/multicast/smrf.c index d6f86615b..fc6f3286b 100644 --- a/os/net/ipv6/multicast/smrf.c +++ b/os/net/ipv6/multicast/smrf.c @@ -50,6 +50,12 @@ #include "net/routing/routing.h" #include "net/netstack.h" #include "net/packetbuf.h" +#if UIP_CONF_IPV6_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#endif /* UIP_CONF_IPV6_RPL_LITE */ +#if UIP_CONF_IPV6_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" +#endif /* UIP_CONF_IPV6_RPL_CLASSIC */ #include #define DEBUG DEBUG_NONE From 0fc93b6d37c0b2b7e3cff92ae379f8f8a56e396b Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 12:17:42 -0800 Subject: [PATCH 31/43] Fix udp-client example, now using NETSTACK_ROUTING --- examples/rpl-udp/udp-client.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/examples/rpl-udp/udp-client.c b/examples/rpl-udp/udp-client.c index dec64b61e..a10d188ac 100644 --- a/examples/rpl-udp/udp-client.c +++ b/examples/rpl-udp/udp-client.c @@ -45,6 +45,7 @@ PROCESS_THREAD(udp_client_process, ev, data) { static struct etimer periodic_timer; static unsigned count; + uip_ipaddr_t dest_ipaddr; PROCESS_BEGIN(); @@ -56,25 +57,21 @@ PROCESS_THREAD(udp_client_process, ev, data) while(1) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer)); - if(rpl_is_reachable()) { + if(NETSTACK_ROUTING.node_is_reachable() && NETSTACK_ROUTING.get_root_ipaddr(&dest_ipaddr)) { /* Send to DAG root */ - rpl_dag_t *dag = rpl_get_any_dag(); - if(dag != NULL) { /* Only a sanity check. Should never be NULL - as rpl_is_reachable() is true */ - LOG_INFO("Sending request %u to ", count); - LOG_INFO_6ADDR(&dag->dag_id); - LOG_INFO_("\n"); - /* Set the number of transmissions to use for this packet - - this can be used to create more reliable transmissions or - less reliable than the default. Works end-to-end if - UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS is set to 1. - */ - uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, 1 + count % 5); - simple_udp_sendto(&udp_conn, &count, sizeof(count), &dag->dag_id); - count++; - } + LOG_INFO("Sending request %u to ", count); + LOG_INFO_6ADDR(&dest_ipaddr); + LOG_INFO_("\n"); + /* Set the number of transmissions to use for this packet - + this can be used to create more reliable transmissions or + less reliable than the default. Works end-to-end if + UIP_CONF_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS is set to 1. + */ + uipbuf_set_attr(UIPBUF_ATTR_MAX_MAC_TRANSMISSIONS, 1 + count % 5); + simple_udp_sendto(&udp_conn, &count, sizeof(count), &dest_ipaddr); + count++; } else { - LOG_INFO("Not reachable yet %p\n", rpl_get_any_dag()); + LOG_INFO("Not reachable yet\n"); } /* Add some jitter */ From 65cbc45145ca4c430fb9d5082bbd3a997d10229b Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 12:20:24 -0800 Subject: [PATCH 32/43] Rename routing module flags --- Makefile.include | 6 +++--- examples/rpl-border-router/webserver/webserver.c | 4 ++-- os/contiki-default-conf.h | 2 +- os/net/ipv6/multicast/esmrf.c | 8 ++++---- os/net/ipv6/multicast/smrf.c | 8 ++++---- os/net/ipv6/uip-ds6-route.h | 4 ++-- os/net/mac/tsch/tsch-rpl.c | 2 +- os/net/netstack.h | 6 +++--- os/services/shell/shell-commands.c | 12 ++++++------ 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Makefile.include b/Makefile.include index 785194092..0a013f84a 100644 --- a/Makefile.include +++ b/Makefile.include @@ -151,13 +151,13 @@ MAKE_ROUTING ?= MAKE_ROUTING_NULLROUTING endif ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_CLASSIC) - CFLAGS += -DUIP_CONF_IPV6_RPL_CLASSIC=1 + CFLAGS += -DROUTING_CONF_RPL_CLASSIC=1 MODULES += os/net/routing/rpl-classic else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_RPL_LITE) - CFLAGS += -DUIP_CONF_IPV6_RPL_LITE=1 + CFLAGS += -DROUTING_CONF_RPL_LITE=1 MODULES += os/net/routing/rpl-lite else ifeq ($(MAKE_ROUTING),MAKE_ROUTING_NULLROUTING) - CFLAGS += -DUIP_CONF_IPV6_NULLROUTING=1 + CFLAGS += -DROUTING_CONF_NULLROUTING=1 MODULES += os/net/routing/nullrouting endif diff --git a/examples/rpl-border-router/webserver/webserver.c b/examples/rpl-border-router/webserver/webserver.c index 4d40ea32f..5a40644e3 100644 --- a/examples/rpl-border-router/webserver/webserver.c +++ b/examples/rpl-border-router/webserver/webserver.c @@ -33,9 +33,9 @@ #include "contiki.h" #include "net/routing/routing.h" /* For RPL-specific data inclusion, in particular non-storing routing link */ -#if UIP_CONF_IPV6_RPL_LITE +#if ROUTING_CONF_RPL_LITE #include "net/routing/rpl-lite/rpl.h" -#elif UIP_CONF_IPV6_RPL_CLASSIC +#elif ROUTING_CONF_RPL_CLASSIC #include "net/routing/rpl-classic/rpl.h" #endif diff --git a/os/contiki-default-conf.h b/os/contiki-default-conf.h index 81714c4df..8ec1a41f7 100644 --- a/os/contiki-default-conf.h +++ b/os/contiki-default-conf.h @@ -83,7 +83,7 @@ /* UIP_CONF_IPV6_RPL tells whether the RPL routing protocol is running, whether implemented as RPL Lite or RPL Classic */ -#define UIP_CONF_IPV6_RPL (UIP_CONF_IPV6_RPL_LITE || UIP_CONF_IPV6_RPL_CLASSIC) +#define UIP_CONF_IPV6_RPL (ROUTING_CONF_RPL_LITE || ROUTING_CONF_RPL_CLASSIC) /* If RPL is enabled also enable the RPL NBR Policy */ #if UIP_CONF_IPV6_RPL diff --git a/os/net/ipv6/multicast/esmrf.c b/os/net/ipv6/multicast/esmrf.c index d66b15836..00619c354 100644 --- a/os/net/ipv6/multicast/esmrf.c +++ b/os/net/ipv6/multicast/esmrf.c @@ -50,12 +50,12 @@ #include "net/ipv6/uip.h" #include "net/netstack.h" #include "net/packetbuf.h" -#if UIP_CONF_IPV6_RPL_LITE +#if ROUTING_CONF_RPL_LITE #include "net/routing/rpl-lite/rpl.h" -#endif /* UIP_CONF_IPV6_RPL_LITE */ -#if UIP_CONF_IPV6_RPL_CLASSIC +#endif /* ROUTING_CONF_RPL_LITE */ +#if ROUTING_CONF_RPL_CLASSIC #include "net/routing/rpl-classic/rpl.h" -#endif /* UIP_CONF_IPV6_RPL_CLASSIC */ +#endif /* ROUTING_CONF_RPL_CLASSIC */ #include extern uint16_t uip_slen; diff --git a/os/net/ipv6/multicast/smrf.c b/os/net/ipv6/multicast/smrf.c index fc6f3286b..86a053648 100644 --- a/os/net/ipv6/multicast/smrf.c +++ b/os/net/ipv6/multicast/smrf.c @@ -50,12 +50,12 @@ #include "net/routing/routing.h" #include "net/netstack.h" #include "net/packetbuf.h" -#if UIP_CONF_IPV6_RPL_LITE +#if ROUTING_CONF_RPL_LITE #include "net/routing/rpl-lite/rpl.h" -#endif /* UIP_CONF_IPV6_RPL_LITE */ -#if UIP_CONF_IPV6_RPL_CLASSIC +#endif /* ROUTING_CONF_RPL_LITE */ +#if ROUTING_CONF_RPL_CLASSIC #include "net/routing/rpl-classic/rpl.h" -#endif /* UIP_CONF_IPV6_RPL_CLASSIC */ +#endif /* ROUTING_CONF_RPL_CLASSIC */ #include #define DEBUG DEBUG_NONE diff --git a/os/net/ipv6/uip-ds6-route.h b/os/net/ipv6/uip-ds6-route.h index 9d055ec53..9f435824c 100644 --- a/os/net/ipv6/uip-ds6-route.h +++ b/os/net/ipv6/uip-ds6-route.h @@ -51,9 +51,9 @@ #else /* UIP_CONF_MAX_ROUTES */ -#if UIP_CONF_IPV6_RPL_LITE +#if ROUTING_CONF_RPL_LITE #define UIP_MAX_ROUTES 0 /* RPL Lite only supports non-storing, no routes */ -#elif UIP_CONF_IPV6_RPL_CLASSIC +#elif ROUTING_CONF_RPL_CLASSIC #include "net/routing/rpl-classic/rpl-conf.h" #if RPL_WITH_STORING diff --git a/os/net/mac/tsch/tsch-rpl.c b/os/net/mac/tsch/tsch-rpl.c index f603c0e60..8ca942d4c 100644 --- a/os/net/mac/tsch/tsch-rpl.c +++ b/os/net/mac/tsch/tsch-rpl.c @@ -87,7 +87,7 @@ tsch_rpl_callback_new_dio_interval(clock_time_t dio_interval) rpl_dag_t *dag; rpl_rank_t root_rank; rpl_rank_t dag_rank; -#if UIP_CONF_IPV6_RPL_LITE +#if ROUTING_CONF_RPL_LITE dag = &curr_instance.dag; root_rank = ROOT_RANK; dag_rank = DAG_RANK(dag->rank); diff --git a/os/net/netstack.h b/os/net/netstack.h index c32bfbce8..b55319356 100644 --- a/os/net/netstack.h +++ b/os/net/netstack.h @@ -48,11 +48,11 @@ #ifdef NETSTACK_CONF_ROUTING #define NETSTACK_ROUTING NETSTACK_CONF_ROUTING #else /* NETSTACK_CONF_ROUTING */ -#if UIP_CONF_IPV6_RPL_LITE +#if ROUTING_CONF_RPL_LITE #define NETSTACK_ROUTING rpl_lite_driver -#elif UIP_CONF_IPV6_RPL_CLASSIC +#elif ROUTING_CONF_RPL_CLASSIC #define NETSTACK_ROUTING rpl_classic_driver -#elif UIP_CONF_IPV6_NULLROUTING +#elif ROUTING_CONF_NULLROUTING #define NETSTACK_ROUTING nullrouting_driver #else #error Unknown ROUTING configuration diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index ebdc7266b..cf242d320 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -62,9 +62,9 @@ #include "net/mac/llsec802154.h" /* For RPL-specific commands */ -#if UIP_CONF_IPV6_RPL_LITE +#if ROUTING_CONF_RPL_LITE #include "net/routing/rpl-lite/rpl.h" -#elif UIP_CONF_IPV6_RPL_CLASSIC +#elif ROUTING_CONF_RPL_CLASSIC #include "net/routing/rpl-classic/rpl.h" #endif @@ -100,7 +100,7 @@ ds6_nbr_state_to_str(uint8_t state) return "Unknown"; } } -#if UIP_CONF_IPV6_RPL_LITE +#if ROUTING_CONF_RPL_LITE /*---------------------------------------------------------------------------*/ static const char * rpl_state_to_str(enum rpl_dag_state state) @@ -192,7 +192,7 @@ PT_THREAD(cmd_rpl_status(struct pt *pt, shell_output_func output, char *args)) PT_END(pt); } -#endif /* UIP_CONF_IPV6_RPL_LITE */ +#endif /* ROUTING_CONF_RPL_LITE */ /*---------------------------------------------------------------------------*/ static void echo_reply_handler(uip_ipaddr_t *source, uint8_t ttl, uint8_t *data, uint16_t datalen) @@ -726,9 +726,9 @@ struct shell_command_t shell_commands[] = { { "rpl-local-repair", cmd_rpl_local_repair, "'> rpl-local-repair': Triggers a RPL local repair" }, { "rpl-global-repair", cmd_rpl_global_repair, "'> rpl-global-repair': Triggers a RPL global repair" }, #endif /* UIP_CONF_IPV6_RPL */ -#if UIP_CONF_IPV6_RPL_LITE +#if ROUTING_CONF_RPL_LITE { "rpl-status", cmd_rpl_status, "'> rpl-status': Shows a summary of the current RPL state" }, -#endif /* UIP_CONF_IPV6_RPL_LITE */ +#endif /* ROUTING_CONF_RPL_LITE */ { "routes", cmd_routes, "'> routes': Shows the route entries" }, #if MAC_CONF_WITH_TSCH { "tsch-set-coordinator", cmd_tsch_set_coordinator, "'> tsch-set-coordinator 0/1 [0/1]': Sets node as coordinator (1) or not (0). Second, optional parameter: enable (1) or disable (0) security." }, From e1088e59d766b354b1316d862f1759dd524dcf42 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 12:34:46 -0800 Subject: [PATCH 33/43] Fix includes for tsch-rpl module --- os/net/mac/tsch/tsch-rpl.c | 3 ++- os/net/mac/tsch/tsch-rpl.h | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/os/net/mac/tsch/tsch-rpl.c b/os/net/mac/tsch/tsch-rpl.c index 8ca942d4c..c01c0ea67 100644 --- a/os/net/mac/tsch/tsch-rpl.c +++ b/os/net/mac/tsch/tsch-rpl.c @@ -40,9 +40,10 @@ * @{ */ +#include "contiki.h" + #if UIP_CONF_IPV6_RPL -#include "contiki.h" #include "net/routing/routing.h" #include "net/mac/tsch/tsch.h" #include "net/mac/tsch/tsch-private.h" diff --git a/os/net/mac/tsch/tsch-rpl.h b/os/net/mac/tsch/tsch-rpl.h index fd71c6437..41fa17e91 100644 --- a/os/net/mac/tsch/tsch-rpl.h +++ b/os/net/mac/tsch/tsch-rpl.h @@ -40,6 +40,11 @@ #include "net/routing/routing.h" #include "net/mac/tsch/tsch-queue.h" +#if ROUTING_CONF_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#elif ROUTING_CONF_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" +#endif /********** Functions *********/ From 627cb3de9cf965d6a97f116f877edf148e5f2d35 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 12:59:00 -0800 Subject: [PATCH 34/43] Homogenize access to RPL non-storing links from external modules --- examples/rpl-border-router/webserver/webserver.c | 6 +++--- os/services/shell/shell-commands.c | 12 ++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/examples/rpl-border-router/webserver/webserver.c b/examples/rpl-border-router/webserver/webserver.c index 5a40644e3..a4946b6e7 100644 --- a/examples/rpl-border-router/webserver/webserver.c +++ b/examples/rpl-border-router/webserver/webserver.c @@ -124,8 +124,8 @@ PT_THREAD(generate_routes(struct httpd_state *s)) } #endif /* UIP_MAX_ROUTES != 0 */ -#if RPL_WITH_NON_STORING - { +#if UIP_CONF_IPV6_RPL + if(rpl_ns_num_nodes() > 0) { static rpl_ns_node_t *link; ADD(" Routing links\n
    \n"); SEND(&s->sout); @@ -151,7 +151,7 @@ PT_THREAD(generate_routes(struct httpd_state *s)) ADD("
"); SEND(&s->sout); } -#endif /* RPL_WITH_NON_STORING */ +#endif /* UIP_CONF_IPV6_RPL */ SEND_STRING(&s->sout, BOTTOM); diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index cf242d320..266b67b21 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -551,12 +551,6 @@ static PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) { uip_ds6_defrt_t *default_route; -#if RPL_WITH_NON_STORING - rpl_ns_node_t *link; -#endif /* RPL_WITH_NON_STORING */ -#if (UIP_MAX_ROUTES != 0) - uip_ds6_route_t *route; -#endif /* (UIP_MAX_ROUTES != 0) */ PT_BEGIN(pt); @@ -575,8 +569,9 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) SHELL_OUTPUT(output, "-- None\n"); } -#if RPL_WITH_NON_STORING +#if UIP_CONF_IPV6_RPL if(rpl_ns_num_nodes() > 0) { + rpl_ns_node_t *link; /* Our routing links */ SHELL_OUTPUT(output, "Routing links (%u in total):\n", rpl_ns_num_nodes()); link = rpl_ns_node_head(); @@ -604,10 +599,11 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) } else { SHELL_OUTPUT(output, "No routing links\n"); } -#endif /* RPL_WITH_NON_STORING */ +#endif /* UIP_CONF_IPV6_RPL */ #if (UIP_MAX_ROUTES != 0) if(uip_ds6_route_num_routes() > 0) { + uip_ds6_route_t *route; /* Our routing entries */ SHELL_OUTPUT(output, "Routing entries (%u in total):\n", uip_ds6_route_num_routes()); route = uip_ds6_route_head(); From 229cec630ca188b34921c4be65103219b7899df7 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 12:59:17 -0800 Subject: [PATCH 35/43] RPL Classic: use full inclusion paths --- os/net/routing/rpl-classic/rpl-dag-root.c | 4 ++-- os/net/routing/rpl-classic/rpl-dag.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/os/net/routing/rpl-classic/rpl-dag-root.c b/os/net/routing/rpl-classic/rpl-dag-root.c index 684b3c8ab..05adff4de 100644 --- a/os/net/routing/rpl-classic/rpl-dag-root.c +++ b/os/net/routing/rpl-classic/rpl-dag-root.c @@ -32,8 +32,8 @@ #include "contiki.h" #include "contiki-net.h" -#include "rpl.h" -#include "rpl-private.h" +#include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-private.h" #include "net/ipv6/uip-ds6-route.h" #include diff --git a/os/net/routing/rpl-classic/rpl-dag.c b/os/net/routing/rpl-classic/rpl-dag.c index 074485f67..ee3475250 100644 --- a/os/net/routing/rpl-classic/rpl-dag.c +++ b/os/net/routing/rpl-classic/rpl-dag.c @@ -45,8 +45,8 @@ #include "contiki.h" #include "net/link-stats.h" -#include "rpl.h" -#include "rpl-private.h" +#include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-private.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-nd6.h" #include "net/ipv6/uip-ds6-nbr.h" From f8ddf8c816dd600b34259dbf9b3712cc4c4102b2 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 13:06:53 -0800 Subject: [PATCH 36/43] Added missing includes for modules that rely on RPL --- examples/6tisch/simple-node/node.c | 7 +++++++ .../cc26xx/cc26xx-web-demo/cetic-6lbr-client.c | 5 +++++ .../jn516x/rpl/coap-dongle-node/dongle-node.c | 1 + .../jn516x/rpl/coap-dr1175-node/dr1175-node.c | 1 + .../jn516x/rpl/coap-dr1199-node/dr1199-node.c | 1 + .../jn516x/tsch/tx-power-verification/node/node.c | 1 + .../jn516x/tsch/uart1-test-node/uart1-test-node.c | 1 + examples/rpl-border-router/webserver/webserver.c | 1 + os/net/mac/tsch/tsch-rpl.c | 7 +++++++ os/services/orchestra/orchestra.c | 5 +++++ tests/07-simulation-base/code-slip-radio/wait-dag.c | 6 ++++++ 11 files changed, 36 insertions(+) diff --git a/examples/6tisch/simple-node/node.c b/examples/6tisch/simple-node/node.c index 1132ecb67..f26049d15 100644 --- a/examples/6tisch/simple-node/node.c +++ b/examples/6tisch/simple-node/node.c @@ -44,6 +44,13 @@ #include "net/mac/tsch/tsch-log.h" #include "net/routing/routing.h" +#if ROUTING_CONF_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#elif ROUTING_CONF_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-ns.h" +#endif + #define DEBUG DEBUG_PRINT #include "net/ipv6/uip-debug.h" diff --git a/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c b/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c index 11171e51e..d3042bf81 100644 --- a/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c +++ b/examples/platform-specific/cc26xx/cc26xx-web-demo/cetic-6lbr-client.c @@ -37,6 +37,11 @@ #include "contiki-net.h" #include "net/routing/routing.h" #include "net/ipv6/uip.h" +#if ROUTING_CONF_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#elif ROUTING_CONF_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" +#endif #include #include diff --git a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c index 5e8c3cca1..2fb2d7761 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dongle-node/dongle-node.c @@ -34,6 +34,7 @@ #include "contiki.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" +#include "net/routing/routing.h" #include "coap-engine.h" #include "sys/ctimer.h" #include diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c index 75d654a1e..443cf4fbe 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1175-node/dr1175-node.c @@ -35,6 +35,7 @@ #include "contiki.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" +#include "net/routing/routing.h" #include "coap-engine.h" #include "light-sensor.h" #include "ht-sensor.h" diff --git a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c index b901414d6..d341170ad 100644 --- a/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c +++ b/examples/platform-specific/jn516x/rpl/coap-dr1199-node/dr1199-node.c @@ -34,6 +34,7 @@ #include "contiki.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" +#include "net/routing/routing.h" #include "coap-engine.h" #include "dev/leds.h" #include "button-sensor.h" diff --git a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c index 45a2f191a..995dc3304 100644 --- a/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c +++ b/examples/platform-specific/jn516x/tsch/tx-power-verification/node/node.c @@ -33,6 +33,7 @@ */ #include "contiki.h" #include "net/ipv6/uip-ds6.h" +#include "net/routing/routing.h" #include "net/netstack.h" #include "net/ipv6/uip.h" #include "net/linkaddr.h" diff --git a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c index 0d96527bc..dd647fa21 100644 --- a/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c +++ b/examples/platform-specific/jn516x/tsch/uart1-test-node/uart1-test-node.c @@ -34,6 +34,7 @@ #include "contiki.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip.h" +#include "net/routing/routing.h" #include "net/linkaddr.h" #include "coap-engine.h" #include "sys/ctimer.h" diff --git a/examples/rpl-border-router/webserver/webserver.c b/examples/rpl-border-router/webserver/webserver.c index a4946b6e7..9e47065b6 100644 --- a/examples/rpl-border-router/webserver/webserver.c +++ b/examples/rpl-border-router/webserver/webserver.c @@ -37,6 +37,7 @@ #include "net/routing/rpl-lite/rpl.h" #elif ROUTING_CONF_RPL_CLASSIC #include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-ns.h" #endif #include diff --git a/os/net/mac/tsch/tsch-rpl.c b/os/net/mac/tsch/tsch-rpl.c index c01c0ea67..bc54de99c 100644 --- a/os/net/mac/tsch/tsch-rpl.c +++ b/os/net/mac/tsch/tsch-rpl.c @@ -51,6 +51,13 @@ #include "net/mac/tsch/tsch-log.h" #include "net/mac/tsch/tsch-rpl.h" +#if ROUTING_CONF_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#elif ROUTING_CONF_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" +#include "net/routing/rpl-classic/rpl-private.h" +#endif + /* Log configuration */ #include "sys/log.h" #define LOG_MODULE "TSCH RPL" diff --git a/os/services/orchestra/orchestra.c b/os/services/orchestra/orchestra.c index efd5b9f5d..8b9929c03 100644 --- a/os/services/orchestra/orchestra.c +++ b/os/services/orchestra/orchestra.c @@ -41,6 +41,11 @@ #include "net/packetbuf.h" #include "net/ipv6/uip-icmp6.h" #include "net/routing/routing.h" +#if ROUTING_CONF_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#elif ROUTING_CONF_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" +#endif #define DEBUG DEBUG_PRINT #include "net/ipv6/uip-debug.h" diff --git a/tests/07-simulation-base/code-slip-radio/wait-dag.c b/tests/07-simulation-base/code-slip-radio/wait-dag.c index e824ea55b..b349204b9 100644 --- a/tests/07-simulation-base/code-slip-radio/wait-dag.c +++ b/tests/07-simulation-base/code-slip-radio/wait-dag.c @@ -37,6 +37,12 @@ #include "net/ipv6/uip.h" #include +#if ROUTING_CONF_RPL_LITE +#include "net/routing/rpl-lite/rpl.h" +#elif ROUTING_CONF_RPL_CLASSIC +#include "net/routing/rpl-classic/rpl.h" +#endif + #define DEBUG DEBUG_FULL #include "net/ipv6/uip-debug.h" From 62d128f5c7466392da327e06725eb4e327c8e7eb Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Sun, 10 Dec 2017 13:21:16 -0800 Subject: [PATCH 37/43] RPL Classic: added stub implementations of NS functions when NS is disabled --- os/net/routing/rpl-classic/rpl-ns.c | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/os/net/routing/rpl-classic/rpl-ns.c b/os/net/routing/rpl-classic/rpl-ns.c index b28a7c002..1cb6de4ff 100644 --- a/os/net/routing/rpl-classic/rpl-ns.c +++ b/os/net/routing/rpl-classic/rpl-ns.c @@ -225,5 +225,45 @@ rpl_ns_periodic(void) } } } +/*---------------------------------------------------------------------------*/ + +#else /* RPL_WITH_NON_STORING */ + +/*---------------------------------------------------------------------------*/ +int +rpl_ns_num_nodes(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +rpl_ns_node_t * +rpl_ns_node_head(void) +{ + return NULL; +} +/*---------------------------------------------------------------------------*/ +rpl_ns_node_t * +rpl_ns_node_next(rpl_ns_node_t *item) +{ + return NULL; +} +/*---------------------------------------------------------------------------*/ +void +rpl_ns_get_node_global_addr(uip_ipaddr_t *addr, rpl_ns_node_t *node) +{ +} +/*---------------------------------------------------------------------------*/ +rpl_ns_node_t * +rpl_ns_get_node(const rpl_dag_t *dag, const uip_ipaddr_t *addr) +{ + return NULL; +} +/*---------------------------------------------------------------------------*/ +int +rpl_ns_is_node_reachable(const rpl_dag_t *dag, const uip_ipaddr_t *addr) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ #endif /* RPL_WITH_NON_STORING */ From 123105ab2040f8459bbef5fce294c5f7bf49fb6e Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 13 Dec 2017 12:00:33 -0800 Subject: [PATCH 38/43] Move source routing state management from RPL Lite and RPL Classic to uip. --- examples/6tisch/simple-node/node.c | 12 +- .../rpl-border-router/webserver/webserver.c | 23 +- .../rpl-lite/rpl-ns.c => ipv6/uip-sr.c} | 117 ++++---- .../rpl-lite/rpl-ns.h => ipv6/uip-sr.h} | 105 ++++--- os/net/routing/nullrouting/nullrouting.c | 7 + os/net/routing/routing.h | 9 + os/net/routing/rpl-classic/rpl-dag.c | 4 + os/net/routing/rpl-classic/rpl-ext-header.c | 29 +- os/net/routing/rpl-classic/rpl-icmp6.c | 6 +- os/net/routing/rpl-classic/rpl-ns.c | 269 ------------------ os/net/routing/rpl-classic/rpl-ns.h | 76 ----- os/net/routing/rpl-classic/rpl-private.h | 1 - os/net/routing/rpl-classic/rpl-timers.c | 4 +- os/net/routing/rpl-classic/rpl.c | 17 +- os/net/routing/rpl-lite/rpl-conf.h | 7 - os/net/routing/rpl-lite/rpl-dag.c | 7 +- os/net/routing/rpl-lite/rpl-ext-header.c | 30 +- os/net/routing/rpl-lite/rpl-timers.c | 3 +- os/net/routing/rpl-lite/rpl.c | 15 +- os/net/routing/rpl-lite/rpl.h | 1 - os/services/shell/shell-commands.c | 16 +- .../code-slip-radio/wait-dag.c | 11 +- 22 files changed, 240 insertions(+), 529 deletions(-) rename os/net/{routing/rpl-lite/rpl-ns.c => ipv6/uip-sr.c} (72%) rename os/net/{routing/rpl-lite/rpl-ns.h => ipv6/uip-sr.h} (57%) delete mode 100644 os/net/routing/rpl-classic/rpl-ns.c delete mode 100644 os/net/routing/rpl-classic/rpl-ns.h diff --git a/examples/6tisch/simple-node/node.c b/examples/6tisch/simple-node/node.c index f26049d15..4fa416290 100644 --- a/examples/6tisch/simple-node/node.c +++ b/examples/6tisch/simple-node/node.c @@ -40,17 +40,11 @@ #include "node-id.h" #include "sys/log.h" #include "net/ipv6/uip-ds6-route.h" +#include "net/ipv6/uip-sr.h" #include "net/mac/tsch/tsch.h" #include "net/mac/tsch/tsch-log.h" #include "net/routing/routing.h" -#if ROUTING_CONF_RPL_LITE -#include "net/routing/rpl-lite/rpl.h" -#elif ROUTING_CONF_RPL_CLASSIC -#include "net/routing/rpl-classic/rpl.h" -#include "net/routing/rpl-classic/rpl-ns.h" -#endif - #define DEBUG DEBUG_PRINT #include "net/ipv6/uip-debug.h" @@ -86,8 +80,8 @@ PROCESS_THREAD(node_process, ev, data) #if (UIP_MAX_ROUTES != 0) PRINTF("Routing entries: %u\n", uip_ds6_route_num_routes()); #endif - #if UIP_CONF_IPV6_RPL - PRINTF("Routing links: %u\n", rpl_ns_num_nodes()); + #if (UIP_SR_LINK_NUM != 0) + PRINTF("Routing links: %u\n", uip_sr_num_nodes()); #endif PROCESS_YIELD_UNTIL(etimer_expired(&et)); etimer_reset(&et); diff --git a/examples/rpl-border-router/webserver/webserver.c b/examples/rpl-border-router/webserver/webserver.c index 9e47065b6..3658381bf 100644 --- a/examples/rpl-border-router/webserver/webserver.c +++ b/examples/rpl-border-router/webserver/webserver.c @@ -32,13 +32,8 @@ #include "contiki.h" #include "net/routing/routing.h" -/* For RPL-specific data inclusion, in particular non-storing routing link */ -#if ROUTING_CONF_RPL_LITE -#include "net/routing/rpl-lite/rpl.h" -#elif ROUTING_CONF_RPL_CLASSIC -#include "net/routing/rpl-classic/rpl.h" -#include "net/routing/rpl-classic/rpl-ns.h" -#endif +#include "net/ipv6/uip-ds6-route.h" +#include "net/ipv6/uip-sr.h" #include #include @@ -125,18 +120,18 @@ PT_THREAD(generate_routes(struct httpd_state *s)) } #endif /* UIP_MAX_ROUTES != 0 */ -#if UIP_CONF_IPV6_RPL - if(rpl_ns_num_nodes() > 0) { - static rpl_ns_node_t *link; +#if (UIP_SR_LINK_NUM != 0) + if(uip_sr_num_nodes() > 0) { + static uip_sr_node_t *link; ADD(" Routing links\n
    \n"); SEND(&s->sout); - for(link = rpl_ns_node_head(); link != NULL; link = rpl_ns_node_next(link)) { + for(link = uip_sr_node_head(); link != NULL; link = uip_sr_node_next(link)) { if(link->parent != NULL) { uip_ipaddr_t child_ipaddr; uip_ipaddr_t parent_ipaddr; - rpl_ns_get_node_global_addr(&child_ipaddr, link); - rpl_ns_get_node_global_addr(&parent_ipaddr, link->parent); + NETSTACK_ROUTING.get_sr_node_ipaddr(&child_ipaddr, link); + NETSTACK_ROUTING.get_sr_node_ipaddr(&parent_ipaddr, link->parent); ADD("
  • "); ipaddr_add(&child_ipaddr); @@ -152,7 +147,7 @@ PT_THREAD(generate_routes(struct httpd_state *s)) ADD("
"); SEND(&s->sout); } -#endif /* UIP_CONF_IPV6_RPL */ +#endif /* UIP_SR_LINK_NUM != 0 */ SEND_STRING(&s->sout, BOTTOM); diff --git a/os/net/routing/rpl-lite/rpl-ns.c b/os/net/ipv6/uip-sr.c similarity index 72% rename from os/net/routing/rpl-lite/rpl-ns.c rename to os/net/ipv6/uip-sr.c index 12c23ff30..9b859fb3a 100644 --- a/os/net/routing/rpl-lite/rpl-ns.c +++ b/os/net/ipv6/uip-sr.c @@ -30,55 +30,59 @@ */ /** - * \addtogroup rpl-lite + * \addtogroup uip * @{ * * \file - * RPL non-storing mode specific functions. Includes support for - * source routing. + * Source routing support * * \author Simon Duquennoy */ -#include "net/routing/rpl-lite/rpl.h" +#include "contiki.h" +#include "net/ipv6/uip-sr.h" +#include "net/routing/routing.h" #include "lib/list.h" #include "lib/memb.h" /* Log configuration */ #include "sys/log.h" -#define LOG_MODULE "RPL" -#define LOG_LEVEL LOG_LEVEL_RPL +#define LOG_MODULE "IPv6 SR" +#define LOG_LEVEL LOG_LEVEL_IPV6 /* Total number of nodes */ static int num_nodes; /* Every known node in the network */ LIST(nodelist); -MEMB(nodememb, rpl_ns_node_t, RPL_NS_LINK_NUM); +MEMB(nodememb, uip_sr_node_t, UIP_SR_LINK_NUM); /*---------------------------------------------------------------------------*/ int -rpl_ns_num_nodes(void) +uip_sr_num_nodes(void) { return num_nodes; } /*---------------------------------------------------------------------------*/ static int -node_matches_address(const rpl_ns_node_t *node, const uip_ipaddr_t *addr) +node_matches_address(void *graph, const uip_sr_node_t *node, const uip_ipaddr_t *addr) { - return addr != NULL - && node != NULL - && !memcmp(addr, &curr_instance.dag.dag_id, 8) - && !memcmp(((const unsigned char *)addr) + 8, node->link_identifier, 8); + if(node == NULL || addr == NULL || graph != node->graph) { + return 0; + } else { + uip_ipaddr_t node_ipaddr; + NETSTACK_ROUTING.get_sr_node_ipaddr(&node_ipaddr, node); + return uip_ipaddr_cmp(&node_ipaddr, addr); + } } /*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_get_node(const uip_ipaddr_t *addr) +uip_sr_node_t * +uip_sr_get_node(void *graph, const uip_ipaddr_t *addr) { - rpl_ns_node_t *l; + uip_sr_node_t *l; for(l = list_head(nodelist); l != NULL; l = list_item_next(l)) { /* Compare prefix and node identifier */ - if(node_matches_address(l, addr)) { + if(node_matches_address(graph, l, addr)) { return l; } } @@ -86,11 +90,17 @@ rpl_ns_get_node(const uip_ipaddr_t *addr) } /*---------------------------------------------------------------------------*/ int -rpl_ns_is_addr_reachable(const uip_ipaddr_t *addr) +uip_sr_is_addr_reachable(void *graph, const uip_ipaddr_t *addr) { - int max_depth = RPL_NS_LINK_NUM; - rpl_ns_node_t *node = rpl_ns_get_node(addr); - rpl_ns_node_t *root_node = rpl_ns_get_node(&curr_instance.dag.dag_id); + int max_depth = UIP_SR_LINK_NUM; + uip_ipaddr_t root_ipaddr; + uip_sr_node_t *node; + uip_sr_node_t *root_node; + + NETSTACK_ROUTING.get_root_ipaddr(&root_ipaddr); + node = uip_sr_get_node(graph, addr); + root_node = uip_sr_get_node(graph, &root_ipaddr); + while(node != NULL && node != root_node && max_depth > 0) { node = node->parent; max_depth--; @@ -99,26 +109,26 @@ rpl_ns_is_addr_reachable(const uip_ipaddr_t *addr) } /*---------------------------------------------------------------------------*/ void -rpl_ns_expire_parent(const uip_ipaddr_t *child, const uip_ipaddr_t *parent) +uip_sr_expire_parent(void *graph, const uip_ipaddr_t *child, const uip_ipaddr_t *parent) { - rpl_ns_node_t *l = rpl_ns_get_node(child); + uip_sr_node_t *l = uip_sr_get_node(graph, child); /* Check if parent matches */ - if(l != NULL && node_matches_address(l->parent, parent)) { - l->lifetime = RPL_NOPATH_REMOVAL_DELAY; + if(l != NULL && node_matches_address(graph, l->parent, parent)) { + l->lifetime = UIP_SR_REMOVAL_DELAY; } } /*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_update_node(const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32_t lifetime) +uip_sr_node_t * +uip_sr_update_node(void *graph, const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32_t lifetime) { - rpl_ns_node_t *child_node = rpl_ns_get_node(child); - rpl_ns_node_t *parent_node = rpl_ns_get_node(parent); - rpl_ns_node_t *old_parent_node; + uip_sr_node_t *child_node = uip_sr_get_node(graph, child); + uip_sr_node_t *parent_node = uip_sr_get_node(graph, parent); + uip_sr_node_t *old_parent_node; if(parent != NULL) { /* No node for the parent, add one with infinite lifetime */ if(parent_node == NULL) { - parent_node = rpl_ns_update_node(parent, NULL, RPL_ROUTE_INFINITE_LIFETIME); + parent_node = uip_sr_update_node(graph, parent, NULL, UIP_SR_INFINITE_LIFETIME); if(parent_node == NULL) { LOG_ERR("NS: no space left for root node!\n"); return NULL; @@ -142,16 +152,17 @@ rpl_ns_update_node(const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32 } /* Initialize node */ + child_node->graph = graph; child_node->lifetime = lifetime; memcpy(child_node->link_identifier, ((const unsigned char *)child) + 8, 8); /* Is the node reachable before the update? */ - if(rpl_ns_is_addr_reachable(child)) { + if(uip_sr_is_addr_reachable(graph, child)) { old_parent_node = child_node->parent; /* Update node */ child_node->parent = parent_node; /* Has the node become unreachable? May happen if we create a loop. */ - if(!rpl_ns_is_addr_reachable(child)) { + if(!uip_sr_is_addr_reachable(graph, child)) { /* The new parent makes the node unreachable, restore old parent. * We will take the update next time, with chances we know more of * the topology and the loop is gone. */ @@ -171,48 +182,36 @@ rpl_ns_update_node(const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32 } /*---------------------------------------------------------------------------*/ void -rpl_ns_init(void) +uip_sr_init(void) { num_nodes = 0; memb_init(&nodememb); list_init(nodelist); } /*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_node_head(void) +uip_sr_node_t * +uip_sr_node_head(void) { return list_head(nodelist); } /*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_node_next(rpl_ns_node_t *item) +uip_sr_node_t * +uip_sr_node_next(uip_sr_node_t *item) { return list_item_next(item); } /*---------------------------------------------------------------------------*/ -int -rpl_ns_get_node_global_addr(uip_ipaddr_t *addr, rpl_ns_node_t *node) -{ - if(addr != NULL && node != NULL) { - memcpy(addr, &curr_instance.dag.dag_id, 8); - memcpy(((unsigned char *)addr) + 8, &node->link_identifier, 8); - return 1; - } else { - return 0; - } -} -/*---------------------------------------------------------------------------*/ void -rpl_ns_periodic(unsigned seconds) +uip_sr_periodic(unsigned seconds) { - rpl_ns_node_t *l; - rpl_ns_node_t *next; + uip_sr_node_t *l; + uip_sr_node_t *next; /* First pass, for all expired nodes, deallocate them iff no child points to them */ for(l = list_head(nodelist); l != NULL; l = next) { next = list_item_next(l); if(l->lifetime == 0) { - rpl_ns_node_t *l2; + uip_sr_node_t *l2; for(l2 = list_head(nodelist); l2 != NULL; l2 = list_item_next(l2)) { if(l2->parent == l) { break; @@ -220,7 +219,7 @@ rpl_ns_periodic(unsigned seconds) } #if LOG_INFO_ENABLED uip_ipaddr_t node_addr; - rpl_ns_get_node_global_addr(&node_addr, l); + NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, l); LOG_INFO("NS: removing expired node "); LOG_INFO_6ADDR(&node_addr); LOG_INFO_("\n"); @@ -229,17 +228,17 @@ rpl_ns_periodic(unsigned seconds) list_remove(nodelist, l); memb_free(&nodememb, l); num_nodes--; - } else if(l->lifetime != RPL_ROUTE_INFINITE_LIFETIME) { + } else if(l->lifetime != UIP_SR_INFINITE_LIFETIME) { l->lifetime = l->lifetime > seconds ? l->lifetime - seconds : 0; } } } /*---------------------------------------------------------------------------*/ void -rpl_ns_free_all(void) +uip_sr_free_all(void) { - rpl_ns_node_t *l; - rpl_ns_node_t *next; + uip_sr_node_t *l; + uip_sr_node_t *next; for(l = list_head(nodelist); l != NULL; l = next) { next = list_item_next(l); list_remove(nodelist, l); diff --git a/os/net/routing/rpl-lite/rpl-ns.h b/os/net/ipv6/uip-sr.h similarity index 57% rename from os/net/routing/rpl-lite/rpl-ns.h rename to os/net/ipv6/uip-sr.h index 6e4a1e471..7224cea14 100644 --- a/os/net/routing/rpl-lite/rpl-ns.h +++ b/os/net/ipv6/uip-sr.h @@ -30,37 +30,75 @@ */ /** - * \addtogroup rpl-lite + * \addtogroup uip * @{ * * \file - * RPL non-storing mode specific functions. Includes support for - * source routing. + * Source routing support * * \author Simon Duquennoy */ -#ifndef RPL_NS_H -#define RPL_NS_H +#ifndef UIP_SR_H +#define UIP_SR_H /********** Includes **********/ +#include "contiki.h" #include "net/ipv6/uip.h" -#include "net/routing/rpl-lite/rpl.h" + +/********** Configuration **********/ + +/* The number of source routing nodes, i.e. the maximum netwrok size at the root */ +#ifdef UIP_SR_CONF_LINK_NUM + +#define UIP_SR_LINK_NUM UIP_SR_CONF_LINK_NUM + +#else /* UIP_SR_CONF_LINK_NUM */ + +#if ROUTING_CONF_RPL_LITE +#define UIP_SR_LINK_NUM NETSTACK_MAX_ROUTE_ENTRIES +#elif ROUTING_CONF_RPL_CLASSIC + +#include "net/routing/rpl-classic/rpl-conf.h" +#if RPL_WITH_NON_STORING +#define UIP_SR_LINK_NUM NETSTACK_MAX_ROUTE_ENTRIES +#else /* RPL_WITH_NON_STORING */ +#define UIP_SR_LINK_NUM 0 +#endif /* RPL_WITH_NON_STORING */ + +#else + +#define UIP_SR_LINK_NUM 0 + +#endif + +#endif /* UIP_SR_CONF_LINK_NUM */ + +/* Delay between between expiration order and actual node removal */ +#ifdef UIP_SR_CONF_REMOVAL_DELAY +#define UIP_SR_REMOVAL_DELAY UIP_SR_CONF_REMOVAL_DELAY +#else /* UIP_SR_CONF_REMOVAL_DELAY */ +#define UIP_SR_REMOVAL_DELAY 60 +#endif /* UIP_SR_CONF_REMOVAL_DELAY */ + +#define UIP_SR_INFINITE_LIFETIME 0xFFFFFFFF /********** Data Structures **********/ -/* A node in a RPL Non-storing graph, stored at the root and representing +/** \brief A node in a source routing graph, stored at the root and representing * all child-parent relationship. Used to build source routes */ -typedef struct rpl_ns_node { - struct rpl_ns_node *next; +typedef struct uip_sr_node { + struct uip_sr_node *next; uint32_t lifetime; - rpl_dag_t *dag; - /* Store only IPv6 link identifiers as all nodes in the DAG share the same prefix */ + /* Protocol-specific graph structure */ + void *graph; + /* Store only IPv6 link identifiers, the routing protocol will provide + us with the prefix */ unsigned char link_identifier[8]; - struct rpl_ns_node *parent; -} rpl_ns_node_t; + struct uip_sr_node *parent; +} uip_sr_node_t; /********** Public functions **********/ @@ -69,31 +107,33 @@ typedef struct rpl_ns_node { * * \return The number of nodes */ -int rpl_ns_num_nodes(void); +int uip_sr_num_nodes(void); /** * Expires a given child-parent link * + * \param graph The graph the link belongs to * \param child The IPv6 address of the child * \param parent The IPv6 address of the parent */ -void rpl_ns_expire_parent(const uip_ipaddr_t *child, const uip_ipaddr_t *parent); +void uip_sr_expire_parent(void *graph, const uip_ipaddr_t *child, const uip_ipaddr_t *parent); /** * Updates a child-parent link * + * \param graph The graph the link belongs to * \param child The IPv6 address of the child * \param parent The IPv6 address of the parent * \param lifetime The link lifetime in seconds */ -rpl_ns_node_t *rpl_ns_update_node(const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32_t lifetime); +uip_sr_node_t *uip_sr_update_node(void *graph, const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32_t lifetime); /** * Returns the head of the non-storing node list * * \return The head of the list */ -rpl_ns_node_t *rpl_ns_node_head(void); +uip_sr_node_t *uip_sr_node_head(void); /** * Returns the next element of the non-storing node list @@ -101,33 +141,26 @@ rpl_ns_node_t *rpl_ns_node_head(void); * \param item The current element in the list * \return The next element of the list */ -rpl_ns_node_t *rpl_ns_node_next(rpl_ns_node_t *item); +uip_sr_node_t *uip_sr_node_next(uip_sr_node_t *item); /** - * Looks up for a RPL NS node from its IPv6 global address + * Looks up for a source routing node from its IPv6 global address * + * \param graph The graph where to look up for the node * \param addr The target address * \return A pointer to the node */ -rpl_ns_node_t *rpl_ns_get_node(const uip_ipaddr_t *addr); +uip_sr_node_t *uip_sr_get_node(void *graph, const uip_ipaddr_t *addr); /** * Telle whether an address is reachable, i.e. if there exists a path from - * the root to the node in the current RPL NS graph + * the root to the node in the current source routing graph * + * \param graph The graph where to look up for the node * \param addr The target IPv6 global address * \return 1 if the node is reachable, 0 otherwise */ -int rpl_ns_is_addr_reachable(const uip_ipaddr_t *addr); - -/** - * Finds the global address of a given node - * - * \param addr A pointer to the address to be written - * \param node The target node - * \return 1 if success, 0 otherwise -*/ -int rpl_ns_get_node_global_addr(uip_ipaddr_t *addr, rpl_ns_node_t *node); +int uip_sr_is_addr_reachable(void *graph, const uip_ipaddr_t *addr); /** * A function called periodically. Used to age the links (decrease lifetime @@ -135,18 +168,18 @@ int rpl_ns_get_node_global_addr(uip_ipaddr_t *addr, rpl_ns_node_t *node); * * \param seconds The number of seconds elapsted since last call */ -void rpl_ns_periodic(unsigned seconds); +void uip_sr_periodic(unsigned seconds); /** - * Initialize rpl-ns module + * Initialize this module */ -void rpl_ns_init(void); +void uip_sr_init(void); /** * Deallocate all neighbors */ -void rpl_ns_free_all(void); +void uip_sr_free_all(void); /** @} */ -#endif /* RPL_NS_H */ +#endif /* UIP_SR_H */ diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index 416a4fd58..fc788d58a 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -70,6 +70,12 @@ get_root_ipaddr(uip_ipaddr_t *ipaddr) return 0; } /*---------------------------------------------------------------------------*/ +static int +get_sr_node_ipaddr(uip_ipaddr_t *addr, const uip_sr_node_t *node) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ static void leave_network(void) { @@ -143,6 +149,7 @@ const struct routing_driver nullrouting_driver = { root_start, node_is_root, get_root_ipaddr, + get_sr_node_ipaddr, leave_network, node_is_reachable, global_repair, diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index ca86d77f5..94cb874fd 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -44,6 +44,7 @@ #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6-nbr.h" #include "net/ipv6/uip-ds6-route.h" +#include "net/ipv6/uip-sr.h" #include "net/linkaddr.h" /** @@ -79,6 +80,14 @@ struct routing_driver { * \return 1 if the root address was copied, 0 otherwise */ int (* get_root_ipaddr)(uip_ipaddr_t *ipaddr); + /** + * Returns the global IPv6 address of a source routing node + * + * \param ipaddr A pointer where to copy the IP address of the node + * \param node The source routing node + * \return 1 if the global node address was copied, 0 otherwise + */ + int (* get_sr_node_ipaddr)(uip_ipaddr_t *addr, const uip_sr_node_t *node); /** * Leave the network the node is part of * diff --git a/os/net/routing/rpl-classic/rpl-dag.c b/os/net/routing/rpl-classic/rpl-dag.c index ee3475250..a8ec7b3f4 100644 --- a/os/net/routing/rpl-classic/rpl-dag.c +++ b/os/net/routing/rpl-classic/rpl-dag.c @@ -47,6 +47,7 @@ #include "net/link-stats.h" #include "net/routing/rpl-classic/rpl.h" #include "net/routing/rpl-classic/rpl-private.h" +#include "net/routing/rpl-classic/rpl-dag-root.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-nd6.h" #include "net/ipv6/uip-ds6-nbr.h" @@ -1008,6 +1009,9 @@ int rpl_has_downward_route(void) { int i; + if(rpl_dag_root_is_root()) { + return 1; /* We are the root, and know the route to ourself */ + } for(i = 0; i < RPL_MAX_INSTANCES; ++i) { if(instance_table[i].used && instance_table[i].has_downward_route) { return 1; diff --git a/os/net/routing/rpl-classic/rpl-ext-header.c b/os/net/routing/rpl-classic/rpl-ext-header.c index bb28c590d..e6498b993 100644 --- a/os/net/routing/rpl-classic/rpl-ext-header.c +++ b/os/net/routing/rpl-classic/rpl-ext-header.c @@ -44,11 +44,12 @@ * @{ */ +#include "net/routing/routing.h" #include "net/ipv6/uip.h" #include "net/ipv6/tcpip.h" #include "net/ipv6/uip-ds6.h" +#include "net/ipv6/uip-sr.h" #include "net/routing/rpl-classic/rpl-private.h" -#include "net/routing/rpl-classic/rpl-ns.h" #include "net/packetbuf.h" #define DEBUG DEBUG_NONE @@ -181,8 +182,8 @@ rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) uint8_t *uip_next_hdr; int last_uip_ext_len = uip_ext_len; rpl_dag_t *dag; - rpl_ns_node_t *dest_node; - rpl_ns_node_t *root_node; + uip_sr_node_t *dest_node; + uip_sr_node_t *root_node; uip_ext_len = 0; uip_next_hdr = &UIP_IP_BUF->proto; @@ -208,8 +209,8 @@ rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) } dag = rpl_get_dag(&UIP_IP_BUF->destipaddr); - root_node = rpl_ns_get_node(dag, &dag->dag_id); - dest_node = rpl_ns_get_node(dag, &UIP_IP_BUF->destipaddr); + root_node = uip_sr_get_node(dag, &dag->dag_id); + dest_node = uip_sr_get_node(dag, &UIP_IP_BUF->destipaddr); if((uip_next_hdr != NULL && *uip_next_hdr == UIP_PROTO_ROUTING && UIP_RH_BUF->routing_type == RPL_RH_TYPE_SRH) || @@ -339,9 +340,9 @@ insert_srh_header(void) uint8_t cmpri, cmpre; /* ComprI and ComprE fields of the RPL Source Routing Header */ uint8_t *hop_ptr; uint8_t padding; - rpl_ns_node_t *dest_node; - rpl_ns_node_t *root_node; - rpl_ns_node_t *node; + uip_sr_node_t *dest_node; + uip_sr_node_t *root_node; + uip_sr_node_t *node; rpl_dag_t *dag; uip_ipaddr_t node_addr; @@ -359,19 +360,19 @@ insert_srh_header(void) return 0; } - dest_node = rpl_ns_get_node(dag, &UIP_IP_BUF->destipaddr); + dest_node = uip_sr_get_node(dag, &UIP_IP_BUF->destipaddr); if(dest_node == NULL) { /* The destination is not found, skip SRH insertion */ return 1; } - root_node = rpl_ns_get_node(dag, &dag->dag_id); + root_node = uip_sr_get_node(dag, &dag->dag_id); if(root_node == NULL) { PRINTF("RPL: SRH root node not found\n"); return 0; } - if(!rpl_ns_is_node_reachable(dag, &UIP_IP_BUF->destipaddr)) { + if(!uip_sr_is_addr_reachable(dag, &UIP_IP_BUF->destipaddr)) { PRINTF("RPL: SRH no path found to destination\n"); return 0; } @@ -390,7 +391,7 @@ insert_srh_header(void) while(node != NULL && node != root_node) { - rpl_ns_get_node_global_addr(&node_addr, node); + NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, node); /* How many bytes in common between all nodes in the path? */ cmpri = MIN(cmpri, count_matching_bytes(&node_addr, &UIP_IP_BUF->destipaddr, 16)); @@ -444,7 +445,7 @@ insert_srh_header(void) hop_ptr = ((uint8_t *)UIP_RH_BUF) + ext_len - padding; /* Pointer where to write the next hop compressed address */ while(node != NULL && node->parent != root_node) { - rpl_ns_get_node_global_addr(&node_addr, node); + NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, node); hop_ptr -= (16 - cmpri); memcpy(hop_ptr, ((uint8_t*)&node_addr) + cmpri, 16 - cmpri); @@ -453,7 +454,7 @@ insert_srh_header(void) } /* The next hop (i.e. node whose parent is the root) is placed as the current IPv6 destination */ - rpl_ns_get_node_global_addr(&node_addr, node); + NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, node); uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &node_addr); /* In-place update of IPv6 length field */ diff --git a/os/net/routing/rpl-classic/rpl-icmp6.c b/os/net/routing/rpl-classic/rpl-icmp6.c index 2e121b5e2..914575dbf 100644 --- a/os/net/routing/rpl-classic/rpl-icmp6.c +++ b/os/net/routing/rpl-classic/rpl-icmp6.c @@ -49,9 +49,9 @@ #include "net/ipv6/uip.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-nd6.h" +#include "net/ipv6/uip-sr.h" #include "net/ipv6/uip-icmp6.h" #include "net/routing/rpl-classic/rpl-private.h" -#include "net/routing/rpl-classic/rpl-ns.h" #include "net/packetbuf.h" #include "net/ipv6/multicast/uip-mcast6.h" #include "random.h" @@ -993,9 +993,9 @@ dao_input_nonstoring(void) if(lifetime == RPL_ZERO_LIFETIME) { PRINTF("RPL: No-Path DAO received\n"); - rpl_ns_expire_parent(dag, &prefix, &dao_parent_addr); + uip_sr_expire_parent(dag, &prefix, &dao_parent_addr); } else { - if(rpl_ns_update_node(dag, &prefix, &dao_parent_addr, RPL_LIFETIME(instance, lifetime)) == NULL) { + if(uip_sr_update_node(dag, &prefix, &dao_parent_addr, RPL_LIFETIME(instance, lifetime)) == NULL) { PRINTF("RPL: failed to add link\n"); return; } diff --git a/os/net/routing/rpl-classic/rpl-ns.c b/os/net/routing/rpl-classic/rpl-ns.c deleted file mode 100644 index 1cb6de4ff..000000000 --- a/os/net/routing/rpl-classic/rpl-ns.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (c) 2016, Inria. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - */ - -/** - * \file - * RPL non-storing mode specific functions. Includes support for - * source routing. - * - * \author Simon Duquennoy - */ - -#include "net/routing/rpl-classic/rpl-conf.h" - -#include "net/ipv6/uip.h" -#include "net/ipv6/tcpip.h" -#include "net/ipv6/uip-ds6.h" -#include "net/ipv6/uip-icmp6.h" -#include "net/routing/rpl-classic/rpl-private.h" -#include "net/routing/rpl-classic/rpl-ns.h" -#include "lib/list.h" -#include "lib/memb.h" - -#if RPL_WITH_NON_STORING - -#define DEBUG DEBUG_NONE -#include "net/ipv6/uip-debug.h" - -#include -#include - -/* Total number of nodes */ -static int num_nodes; - -/* Every known node in the network */ -LIST(nodelist); -MEMB(nodememb, rpl_ns_node_t, RPL_NS_LINK_NUM); - -/*---------------------------------------------------------------------------*/ -int -rpl_ns_num_nodes(void) -{ - return num_nodes; -} -/*---------------------------------------------------------------------------*/ -static int -node_matches_address(const rpl_dag_t *dag, const rpl_ns_node_t *node, const uip_ipaddr_t *addr) -{ - return addr != NULL - && node != NULL - && dag != NULL - && dag == node->dag - && !memcmp(addr, &node->dag->dag_id, 8) - && !memcmp(((const unsigned char *)addr) + 8, node->link_identifier, 8); -} -/*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_get_node(const rpl_dag_t *dag, const uip_ipaddr_t *addr) -{ - rpl_ns_node_t *l; - for(l = list_head(nodelist); l != NULL; l = list_item_next(l)) { - /* Compare prefix and node identifier */ - if(node_matches_address(dag, l, addr)) { - return l; - } - } - return NULL; -} -/*---------------------------------------------------------------------------*/ -int -rpl_ns_is_node_reachable(const rpl_dag_t *dag, const uip_ipaddr_t *addr) -{ - int max_depth = RPL_NS_LINK_NUM; - rpl_ns_node_t *node = rpl_ns_get_node(dag, addr); - rpl_ns_node_t *root_node = rpl_ns_get_node(dag, dag != NULL ? &dag->dag_id : NULL); - while(node != NULL && node != root_node && max_depth > 0) { - node = node->parent; - max_depth--; - } - return node != NULL && node == root_node; -} -/*---------------------------------------------------------------------------*/ -void -rpl_ns_expire_parent(rpl_dag_t *dag, const uip_ipaddr_t *child, const uip_ipaddr_t *parent) -{ - rpl_ns_node_t *l = rpl_ns_get_node(dag, child); - /* Check if parent matches */ - if(l != NULL && node_matches_address(dag, l->parent, parent)) { - l->lifetime = RPL_NOPATH_REMOVAL_DELAY; - } -} -/*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_update_node(rpl_dag_t *dag, const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32_t lifetime) -{ - rpl_ns_node_t *child_node = rpl_ns_get_node(dag, child); - rpl_ns_node_t *parent_node = rpl_ns_get_node(dag, parent); - rpl_ns_node_t *old_parent_node; - - if(parent != NULL) { - /* No node for the parent, add one with infinite lifetime */ - if(parent_node == NULL) { - parent_node = rpl_ns_update_node(dag, parent, NULL, 0xffffffff); - if(parent_node == NULL) { - return NULL; - } - } - } - - /* No node for this child, add one */ - if(child_node == NULL) { - child_node = memb_alloc(&nodememb); - /* No space left, abort */ - if(child_node == NULL) { - return NULL; - } - child_node->parent = NULL; - list_add(nodelist, child_node); - num_nodes++; - } - - /* Initialize node */ - child_node->dag = dag; - child_node->lifetime = lifetime; - memcpy(child_node->link_identifier, ((const unsigned char *)child) + 8, 8); - - /* Is the node reachable before the update? */ - if(rpl_ns_is_node_reachable(dag, child)) { - old_parent_node = child_node->parent; - /* Update node */ - child_node->parent = parent_node; - /* Has the node become unreachable? May happen if we create a loop. */ - if(!rpl_ns_is_node_reachable(dag, child)) { - /* The new parent makes the node unreachable, restore old parent. - * We will take the update next time, with chances we know more of - * the topology and the loop is gone. */ - child_node->parent = old_parent_node; - } - } else { - child_node->parent = parent_node; - } - - return child_node; -} -/*---------------------------------------------------------------------------*/ -void -rpl_ns_init(void) -{ - num_nodes = 0; - memb_init(&nodememb); - list_init(nodelist); -} -/*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_node_head(void) -{ - return list_head(nodelist); -} -/*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_node_next(rpl_ns_node_t *item) -{ - return list_item_next(item); -} -/*---------------------------------------------------------------------------*/ -void -rpl_ns_get_node_global_addr(uip_ipaddr_t *addr, rpl_ns_node_t *node) -{ - if(addr != NULL && node != NULL && node->dag != NULL) { - memcpy(addr, &node->dag->dag_id, 8); - memcpy(((unsigned char *)addr) + 8, &node->link_identifier, 8); - } -} -/*---------------------------------------------------------------------------*/ -void -rpl_ns_periodic(void) -{ - rpl_ns_node_t *l; - rpl_ns_node_t *next; - - /* First pass, for all expired nodes, deallocate them iff no child points to them */ - for(l = list_head(nodelist); l != NULL; l = next) { - next = list_item_next(l); - if(l->lifetime == 0) { - rpl_ns_node_t *l2; - for(l2 = list_head(nodelist); l2 != NULL; l2 = list_item_next(l2)) { - if(l2->parent == l) { - break; - } - } - /* No child found, deallocate node */ - list_remove(nodelist, l); - memb_free(&nodememb, l); - num_nodes--; - } else if(l->lifetime != 0xffffffff) { - /* Decrement lifetime for all nodes with non-infinite lifetime */ - l->lifetime--; - } - } -} -/*---------------------------------------------------------------------------*/ - -#else /* RPL_WITH_NON_STORING */ - -/*---------------------------------------------------------------------------*/ -int -rpl_ns_num_nodes(void) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_node_head(void) -{ - return NULL; -} -/*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_node_next(rpl_ns_node_t *item) -{ - return NULL; -} -/*---------------------------------------------------------------------------*/ -void -rpl_ns_get_node_global_addr(uip_ipaddr_t *addr, rpl_ns_node_t *node) -{ -} -/*---------------------------------------------------------------------------*/ -rpl_ns_node_t * -rpl_ns_get_node(const rpl_dag_t *dag, const uip_ipaddr_t *addr) -{ - return NULL; -} -/*---------------------------------------------------------------------------*/ -int -rpl_ns_is_node_reachable(const rpl_dag_t *dag, const uip_ipaddr_t *addr) -{ - return 0; -} -/*---------------------------------------------------------------------------*/ - -#endif /* RPL_WITH_NON_STORING */ diff --git a/os/net/routing/rpl-classic/rpl-ns.h b/os/net/routing/rpl-classic/rpl-ns.h deleted file mode 100644 index 83f2621b8..000000000 --- a/os/net/routing/rpl-classic/rpl-ns.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2016, Inria. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file is part of the Contiki operating system. - */ - -/** - * \file - * RPL non-storing mode specific functions. Includes support for - * source routing. - * - * \author Simon Duquennoy - */ - - -#ifndef RPL_NS_H -#define RPL_NS_H - -#include "net/routing/rpl-classic/rpl-conf.h" - -#ifdef RPL_NS_CONF_LINK_NUM -#define RPL_NS_LINK_NUM RPL_NS_CONF_LINK_NUM -#else /* RPL_NS_CONF_LINK_NUM */ -#if RPL_WITH_NON_STORING -#define RPL_NS_LINK_NUM NETSTACK_MAX_ROUTE_ENTRIES -#else -#define RPL_NS_LINK_NUM 0 -#endif -#endif /* RPL_NS_CONF_LINK_NUM */ - -typedef struct rpl_ns_node { - struct rpl_ns_node *next; - uint32_t lifetime; - rpl_dag_t *dag; - /* Store only IPv6 link identifiers as all nodes in the DAG share the same prefix */ - unsigned char link_identifier[8]; - struct rpl_ns_node *parent; -} rpl_ns_node_t; - -int rpl_ns_num_nodes(void); -void rpl_ns_expire_parent(rpl_dag_t *dag, const uip_ipaddr_t *child, const uip_ipaddr_t *parent); -rpl_ns_node_t *rpl_ns_update_node(rpl_dag_t *dag, const uip_ipaddr_t *child, const uip_ipaddr_t *parent, uint32_t lifetime); -void rpl_ns_init(void); -rpl_ns_node_t *rpl_ns_node_head(void); -rpl_ns_node_t *rpl_ns_node_next(rpl_ns_node_t *item); -rpl_ns_node_t *rpl_ns_get_node(const rpl_dag_t *dag, const uip_ipaddr_t *addr); -int rpl_ns_is_node_reachable(const rpl_dag_t *dag, const uip_ipaddr_t *addr); -void rpl_ns_get_node_global_addr(uip_ipaddr_t *addr, rpl_ns_node_t *node); -void rpl_ns_periodic(void); - -#endif /* RPL_NS_H */ diff --git a/os/net/routing/rpl-classic/rpl-private.h b/os/net/routing/rpl-classic/rpl-private.h index ab77329a0..1259fffeb 100644 --- a/os/net/routing/rpl-classic/rpl-private.h +++ b/os/net/routing/rpl-classic/rpl-private.h @@ -45,7 +45,6 @@ #include "sys/ctimer.h" #include "net/ipv6/uip-ds6.h" #include "net/ipv6/uip-ds6-route.h" -#include "net/routing/rpl-classic/rpl-ns.h" #include "net/ipv6/multicast/uip-mcast6.h" /*---------------------------------------------------------------------------*/ diff --git a/os/net/routing/rpl-classic/rpl-timers.c b/os/net/routing/rpl-classic/rpl-timers.c index dd61c5ff4..c812a8897 100644 --- a/os/net/routing/rpl-classic/rpl-timers.c +++ b/os/net/routing/rpl-classic/rpl-timers.c @@ -43,9 +43,9 @@ #include "contiki.h" #include "net/routing/rpl-classic/rpl-private.h" -#include "net/routing/rpl-classic/rpl-ns.h" #include "net/link-stats.h" #include "net/ipv6/multicast/uip-mcast6.h" +#include "net/ipv6/uip-sr.h" #include "lib/random.h" #include "sys/ctimer.h" @@ -89,7 +89,7 @@ handle_periodic_timer(void *ptr) rpl_purge_routes(); } if(RPL_IS_NON_STORING(dag->instance)) { - rpl_ns_periodic(); + uip_sr_periodic(1); } } rpl_recalculate_ranks(); diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 0146f7a71..4b90165f0 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -45,10 +45,10 @@ #include "net/ipv6/uip.h" #include "net/ipv6/tcpip.h" #include "net/ipv6/uip-ds6.h" +#include "net/ipv6/uip-sr.h" #include "net/ipv6/uip-icmp6.h" #include "net/routing/routing.h" #include "net/routing/rpl-classic/rpl-private.h" -#include "net/routing/rpl-classic/rpl-ns.h" #include "net/routing/rpl-classic/rpl-dag-root.h" #include "net/ipv6/multicast/uip-mcast6.h" @@ -349,10 +349,22 @@ init(void) #endif #if RPL_WITH_NON_STORING - rpl_ns_init(); + uip_sr_init(); #endif /* RPL_WITH_NON_STORING */ } /*---------------------------------------------------------------------------*/ +static int +get_sr_node_ipaddr(uip_ipaddr_t *addr, const uip_sr_node_t *node) +{ + if(addr != NULL && node != NULL) { + memcpy(addr, &((rpl_dag_t *)node->graph)->dag_id, 8); + memcpy(((unsigned char *)addr) + 8, &node->link_identifier, 8); + return 1; + } else { + return 0; + } +} +/*---------------------------------------------------------------------------*/ static void global_repair(const char *str) { @@ -409,6 +421,7 @@ const struct routing_driver rpl_classic_driver = { rpl_dag_root_start, rpl_dag_root_is_root, get_root_ipaddr, + get_sr_node_ipaddr, leave_network, rpl_has_downward_route, global_repair, diff --git a/os/net/routing/rpl-lite/rpl-conf.h b/os/net/routing/rpl-lite/rpl-conf.h index eceb2843c..aa08a1db8 100644 --- a/os/net/routing/rpl-lite/rpl-conf.h +++ b/os/net/routing/rpl-lite/rpl-conf.h @@ -318,13 +318,6 @@ #define RPL_DAO_DELAY (CLOCK_SECOND * 4) #endif /* RPL_CONF_DAO_DELAY */ -/* Delay between reception of a no-path DAO and actual route removal */ -#ifdef RPL_CONF_NOPATH_REMOVAL_DELAY -#define RPL_NOPATH_REMOVAL_DELAY RPL_CONF_NOPATH_REMOVAL_DELAY -#else /* RPL_CONF_NOPATH_REMOVAL_DELAY */ -#define RPL_NOPATH_REMOVAL_DELAY 60 -#endif /* RPL_CONF_NOPATH_REMOVAL_DELAY */ - #ifdef RPL_CONF_DAO_MAX_RETRANSMISSIONS #define RPL_DAO_MAX_RETRANSMISSIONS RPL_CONF_DAO_MAX_RETRANSMISSIONS #else diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index a43696c5b..fed488013 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -43,6 +43,7 @@ */ #include "net/routing/rpl-lite/rpl.h" +#include "net/ipv6/uip-sr.h" #include "net/nbr-table.h" #include "net/link-stats.h" @@ -106,7 +107,7 @@ rpl_dag_leave(void) /* Remove all neighbors and lnks */ rpl_neighbor_remove_all(); - rpl_ns_free_all(); + uip_sr_free_all(); /* Stop all timers */ rpl_timers_stop_dag_timers(); @@ -589,9 +590,9 @@ void rpl_process_dao(uip_ipaddr_t *from, rpl_dao_t *dao) { if(dao->lifetime == 0) { - rpl_ns_expire_parent(from, &dao->parent_addr); + uip_sr_expire_parent(NULL, from, &dao->parent_addr); } else { - if(!rpl_ns_update_node(from, &dao->parent_addr, RPL_LIFETIME(dao->lifetime))) { + if(!uip_sr_update_node(NULL, from, &dao->parent_addr, RPL_LIFETIME(dao->lifetime))) { LOG_ERR("failed to add link on incoming DAO\n"); return; } diff --git a/os/net/routing/rpl-lite/rpl-ext-header.c b/os/net/routing/rpl-lite/rpl-ext-header.c index eda59a744..af67cdaff 100644 --- a/os/net/routing/rpl-lite/rpl-ext-header.c +++ b/os/net/routing/rpl-lite/rpl-ext-header.c @@ -42,8 +42,10 @@ * Nicolas Tsiftes , * Simon Duquennoy */ - + +#include "net/routing/routing.h" #include "net/routing/rpl-lite/rpl.h" +#include "net/ipv6/uip-sr.h" #include "net/packetbuf.h" /* Log configuration */ @@ -68,8 +70,8 @@ rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) { uint8_t *uip_next_hdr; int last_uip_ext_len = uip_ext_len; - rpl_ns_node_t *dest_node; - rpl_ns_node_t *root_node; + uip_sr_node_t *dest_node; + uip_sr_node_t *root_node; uip_ext_len = 0; uip_next_hdr = &UIP_IP_BUF->proto; @@ -96,8 +98,8 @@ rpl_ext_header_srh_get_next_hop(uip_ipaddr_t *ipaddr) return 0; } - root_node = rpl_ns_get_node(&curr_instance.dag.dag_id); - dest_node = rpl_ns_get_node(&UIP_IP_BUF->destipaddr); + root_node = uip_sr_get_node(NULL, &curr_instance.dag.dag_id); + dest_node = uip_sr_get_node(NULL, &UIP_IP_BUF->destipaddr); if((uip_next_hdr != NULL && *uip_next_hdr == UIP_PROTO_ROUTING && UIP_RH_BUF->routing_type == RPL_RH_TYPE_SRH) || @@ -227,9 +229,9 @@ insert_srh_header(void) uint8_t cmpri, cmpre; /* ComprI and ComprE fields of the RPL Source Routing Header */ uint8_t *hop_ptr; uint8_t padding; - rpl_ns_node_t *dest_node; - rpl_ns_node_t *root_node; - rpl_ns_node_t *node; + uip_sr_node_t *dest_node; + uip_sr_node_t *root_node; + uip_sr_node_t *node; uip_ipaddr_t node_addr; LOG_INFO("SRH creating source routing header with destination "); @@ -246,20 +248,20 @@ insert_srh_header(void) return 1; } - dest_node = rpl_ns_get_node(&UIP_IP_BUF->destipaddr); + dest_node = uip_sr_get_node(NULL, &UIP_IP_BUF->destipaddr); if(dest_node == NULL) { /* The destination is not found, skip SRH insertion */ LOG_INFO("SRH node not found, skip SRH insertion\n"); return 1; } - root_node = rpl_ns_get_node(&curr_instance.dag.dag_id); + root_node = uip_sr_get_node(NULL, &curr_instance.dag.dag_id); if(root_node == NULL) { LOG_ERR("SRH root node not found\n"); return 0; } - if(!rpl_ns_is_addr_reachable(&UIP_IP_BUF->destipaddr)) { + if(!uip_sr_is_addr_reachable(NULL, &UIP_IP_BUF->destipaddr)) { LOG_ERR("SRH no path found to destination\n"); return 0; } @@ -277,7 +279,7 @@ insert_srh_header(void) while(node != NULL && node != root_node) { - rpl_ns_get_node_global_addr(&node_addr, node); + NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, node); /* How many bytes in common between all nodes in the path? */ cmpri = MIN(cmpri, count_matching_bytes(&node_addr, &UIP_IP_BUF->destipaddr, 16)); @@ -331,7 +333,7 @@ insert_srh_header(void) hop_ptr = ((uint8_t *)UIP_RH_BUF) + ext_len - padding; /* Pointer where to write the next hop compressed address */ while(node != NULL && node->parent != root_node) { - rpl_ns_get_node_global_addr(&node_addr, node); + NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, node); hop_ptr -= (16 - cmpri); memcpy(hop_ptr, ((uint8_t*)&node_addr) + cmpri, 16 - cmpri); @@ -340,7 +342,7 @@ insert_srh_header(void) } /* The next hop (i.e. node whose parent is the root) is placed as the current IPv6 destination */ - rpl_ns_get_node_global_addr(&node_addr, node); + NETSTACK_ROUTING.get_sr_node_ipaddr(&node_addr, node); uip_ipaddr_copy(&UIP_IP_BUF->destipaddr, &node_addr); /* In-place update of IPv6 length field */ diff --git a/os/net/routing/rpl-lite/rpl-timers.c b/os/net/routing/rpl-lite/rpl-timers.c index 0925c8f6b..5da6edc67 100644 --- a/os/net/routing/rpl-lite/rpl-timers.c +++ b/os/net/routing/rpl-lite/rpl-timers.c @@ -42,6 +42,7 @@ #include "contiki.h" #include "net/routing/rpl-lite/rpl.h" +#include "net/ipv6/uip-sr.h" #include "net/link-stats.h" #include "lib/random.h" #include "sys/ctimer.h" @@ -500,7 +501,7 @@ handle_periodic_timer(void *ptr) { if(curr_instance.used) { rpl_dag_periodic(PERIODIC_DELAY_SECONDS); - rpl_ns_periodic(PERIODIC_DELAY_SECONDS); + uip_sr_periodic(PERIODIC_DELAY_SECONDS); } if(!curr_instance.used || diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 1f43fab29..07c8cf344 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -190,7 +190,19 @@ init(void) rpl_timers_init(); rpl_icmp6_init(); - rpl_ns_init(); + uip_sr_init(); +} +/*---------------------------------------------------------------------------*/ +static int +get_sr_node_ipaddr(uip_ipaddr_t *addr, const uip_sr_node_t *node) +{ + if(addr != NULL && node != NULL) { + memcpy(addr, &curr_instance.dag.dag_id, 8); + memcpy(((unsigned char *)addr) + 8, &node->link_identifier, 8); + return 1; + } else { + return 0; + } } /*---------------------------------------------------------------------------*/ static void @@ -212,6 +224,7 @@ const struct routing_driver rpl_lite_driver = { rpl_dag_root_start, rpl_dag_root_is_root, rpl_dag_get_root_ipaddr, + get_sr_node_ipaddr, rpl_dag_poison_and_leave, rpl_is_reachable, rpl_global_repair, diff --git a/os/net/routing/rpl-lite/rpl.h b/os/net/routing/rpl-lite/rpl.h index cb43f4f79..7fb4c8718 100644 --- a/os/net/routing/rpl-lite/rpl.h +++ b/os/net/routing/rpl-lite/rpl.h @@ -53,7 +53,6 @@ #include "net/routing/rpl-lite/rpl-types.h" #include "net/routing/rpl-lite/rpl-icmp6.h" #include "net/routing/rpl-lite/rpl-dag.h" -#include "net/routing/rpl-lite/rpl-ns.h" #include "net/routing/rpl-lite/rpl-dag-root.h" #include "net/routing/rpl-lite/rpl-neighbor.h" #include "net/routing/rpl-lite/rpl-ext-header.h" diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index 266b67b21..5e19a0dc8 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -570,16 +570,16 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) } #if UIP_CONF_IPV6_RPL - if(rpl_ns_num_nodes() > 0) { - rpl_ns_node_t *link; + if(uip_sr_num_nodes() > 0) { + uip_sr_node_t *link; /* Our routing links */ - SHELL_OUTPUT(output, "Routing links (%u in total):\n", rpl_ns_num_nodes()); - link = rpl_ns_node_head(); + SHELL_OUTPUT(output, "Routing links (%u in total):\n", uip_sr_num_nodes()); + link = uip_sr_node_head(); while(link != NULL) { uip_ipaddr_t child_ipaddr; uip_ipaddr_t parent_ipaddr; - rpl_ns_get_node_global_addr(&child_ipaddr, link); - rpl_ns_get_node_global_addr(&parent_ipaddr, link->parent); + NETSTACK_ROUTING.get_sr_node_ipaddr(&child_ipaddr, link); + NETSTACK_ROUTING.get_sr_node_ipaddr(&parent_ipaddr, link->parent); SHELL_OUTPUT(output, "-- "); shell_output_6addr(output, &child_ipaddr); if(link->parent == NULL) { @@ -589,12 +589,12 @@ PT_THREAD(cmd_routes(struct pt *pt, shell_output_func output, char *args)) SHELL_OUTPUT(output, " to "); shell_output_6addr(output, &parent_ipaddr); } - if(link->lifetime != 0xFFFFFFFF) { + if(link->lifetime != UIP_SR_INFINITE_LIFETIME) { SHELL_OUTPUT(output, " (lifetime: %lu seconds)\n", (unsigned long)link->lifetime); } else { SHELL_OUTPUT(output, " (lifetime: infinite)\n"); } - link = rpl_ns_node_next(link); + link = uip_sr_node_next(link); } } else { SHELL_OUTPUT(output, "No routing links\n"); diff --git a/tests/07-simulation-base/code-slip-radio/wait-dag.c b/tests/07-simulation-base/code-slip-radio/wait-dag.c index b349204b9..06fa80250 100644 --- a/tests/07-simulation-base/code-slip-radio/wait-dag.c +++ b/tests/07-simulation-base/code-slip-radio/wait-dag.c @@ -37,12 +37,6 @@ #include "net/ipv6/uip.h" #include -#if ROUTING_CONF_RPL_LITE -#include "net/routing/rpl-lite/rpl.h" -#elif ROUTING_CONF_RPL_CLASSIC -#include "net/routing/rpl-classic/rpl.h" -#endif - #define DEBUG DEBUG_FULL #include "net/ipv6/uip-debug.h" @@ -55,8 +49,7 @@ AUTOSTART_PROCESSES(&wait_for_dag); static void timeout_handler(void) { - rpl_dag_t *dag = rpl_get_any_dag(); - if (dag != NULL) { + if(NETSTACK_ROUTING.node_is_reachable()) { PRINTF("DAG Found\n"); } } @@ -73,7 +66,7 @@ PROCESS_THREAD(wait_for_dag, ev, data) if(etimer_expired(&et)) { timeout_handler(); etimer_restart(&et); - } + } } PROCESS_END(); } From 30d12fd994e98c1a1feda88e2150ef7ab059412c Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 13 Dec 2017 12:24:04 -0800 Subject: [PATCH 39/43] Fix potential compilation error for example multicast --- examples/multicast/sink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/multicast/sink.c b/examples/multicast/sink.c index e15d0f695..34ad6009d 100644 --- a/examples/multicast/sink.c +++ b/examples/multicast/sink.c @@ -71,7 +71,7 @@ tcpip_handler(void) if(uip_newdata()) { count++; PRINTF("In: [0x%08lx], TTL %u, total %u\n", - uip_ntohl((unsigned long) *((uint32_t *)(uip_appdata))), + (unsigned long)uip_ntohl((unsigned long) *((uint32_t *)(uip_appdata))), UIP_IP_BUF->ttl, count); } return; From ca13d2c3efb515129242a26eb127fe37bd92f879 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 13 Dec 2017 12:24:29 -0800 Subject: [PATCH 40/43] CI: added more compile tests for RPL Classic --- tests/01-compile-base/Makefile | 1 + tests/02-compile-arm-ports-01/Makefile | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/01-compile-base/Makefile b/tests/01-compile-base/Makefile index 748837c50..d043c9d6e 100644 --- a/tests/01-compile-base/Makefile +++ b/tests/01-compile-base/Makefile @@ -4,6 +4,7 @@ TOOLSDIR=../../tools EXAMPLES = \ hello-world/native \ hello-world/native:MAKE_NET=MAKE_NET_NULLNET \ +hello-world/native:MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC \ hello-world/sky \ storage/eeprom-test/native \ multicast/sky \ diff --git a/tests/02-compile-arm-ports-01/Makefile b/tests/02-compile-arm-ports-01/Makefile index 854d138b1..4d20fe5d8 100644 --- a/tests/02-compile-arm-ports-01/Makefile +++ b/tests/02-compile-arm-ports-01/Makefile @@ -28,6 +28,7 @@ platform-specific/cc2538-common/crypto/cc2538dk \ platform-specific/cc2538-common/pka/cc2538dk \ hello-world/cc2538dk \ rpl-border-router/cc2538dk \ +rpl-border-router/cc2538dk:MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC \ hello-world/nrf52dk \ platform-specific/nrf52dk/coap-demo/nrf52dk:coap-server \ platform-specific/nrf52dk/coap-demo/nrf52dk:coap-client:SERVER_IPV6_EP=ffff \ From 177a68db53eefef40c7730800336cdf55c2df875 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 13 Dec 2017 12:24:53 -0800 Subject: [PATCH 41/43] CI: added a simulation test for RPL Classic in non-storing mode --- .../05-rpl-up-and-down-routes-non-storing.csc | 341 ++++++++++++++++++ tests/15-rpl-classic/code/receiver-node.c | 8 + 2 files changed, 349 insertions(+) create mode 100644 tests/15-rpl-classic/05-rpl-up-and-down-routes-non-storing.csc diff --git a/tests/15-rpl-classic/05-rpl-up-and-down-routes-non-storing.csc b/tests/15-rpl-classic/05-rpl-up-and-down-routes-non-storing.csc new file mode 100644 index 000000000..aa412586b --- /dev/null +++ b/tests/15-rpl-classic/05-rpl-up-and-down-routes-non-storing.csc @@ -0,0 +1,341 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/collect-view + [APPS_DIR]/powertracker + + My simulation + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 50.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype743 + Sender + [CONFIG_DIR]/code/sender-node.c + make clean TARGET=cooja +make -j sender-node.cooja TARGET=cooja DEFINES=RPL_CONF_MOP=RPL_MOP_NON_STORING + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype452 + RPL root + [CONFIG_DIR]/code/root-node.c + make clean TARGET=cooja +make -j root-node.cooja TARGET=cooja DEFINES=RPL_CONF_MOP=RPL_MOP_NON_STORING + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype782 + Receiver + [CONFIG_DIR]/code/receiver-node.c + make clean TARGET=cooja +make -j receiver-node.cooja TARGET=cooja DEFINES=RPL_CONF_MOP=RPL_MOP_NON_STORING + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + -22.5728586847096 + 123.9358664968653 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + mtype782 + + + + org.contikios.cooja.interfaces.Position + 116.13379149678028 + 88.36698920455684 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + mtype743 + + + + org.contikios.cooja.interfaces.Position + -1.39303771455413 + 100.21446701029119 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 4 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + mtype782 + + + + org.contikios.cooja.interfaces.Position + 95.25095618820441 + 63.14998053005015 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 5 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + mtype782 + + + + org.contikios.cooja.interfaces.Position + 66.09378990830604 + 38.32698761608261 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 6 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + mtype782 + + + + org.contikios.cooja.interfaces.Position + 29.05630841762433 + 30.840688165838436 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 7 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + mtype782 + + + + org.contikios.cooja.interfaces.Position + 10.931583432822638 + 69.848248459216 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 8 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + mtype782 + + + + org.contikios.cooja.interfaces.Position + 0.0 + 0.0 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 3 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + mtype452 + + + + org.contikios.cooja.plugins.SimControl + 280 + 1 + 160 + 400 + 0 + + + org.contikios.cooja.plugins.Visualizer + + org.contikios.cooja.plugins.skins.IDVisualizerSkin + org.contikios.cooja.plugins.skins.UDGMVisualizerSkin + org.contikios.cooja.plugins.skins.GridVisualizerSkin + org.contikios.cooja.plugins.skins.MoteTypeVisualizerSkin + 2.5379695437350276 0.0 0.0 2.5379695437350276 75.2726010197627 15.727272727272757 + + 400 + 2 + 400 + 1 + 1 + + + org.contikios.cooja.plugins.LogListener + + + + 1184 + 3 + 240 + 402 + 162 + + + org.contikios.cooja.plugins.Notes + + Enter notes here + true + + 904 + 4 + 160 + 680 + 0 + + + org.contikios.cooja.plugins.ScriptRunner + + + true + + 962 + 0 + 596 + 603 + 43 + + diff --git a/tests/15-rpl-classic/code/receiver-node.c b/tests/15-rpl-classic/code/receiver-node.c index 02142c317..20bf165f8 100644 --- a/tests/15-rpl-classic/code/receiver-node.c +++ b/tests/15-rpl-classic/code/receiver-node.c @@ -91,6 +91,7 @@ set_global_address(void) return &ipaddr; } /*---------------------------------------------------------------------------*/ +#if RPL_WITH_STORING uint8_t should_blink = 1; static void route_callback(int event, uip_ipaddr_t *route, uip_ipaddr_t *ipaddr, int num_routes) @@ -101,17 +102,22 @@ route_callback(int event, uip_ipaddr_t *route, uip_ipaddr_t *ipaddr, int num_rou should_blink = 1; } } +#endif /* #if RPL_WITH_STORING */ /*---------------------------------------------------------------------------*/ PROCESS_THREAD(receiver_node_process, ev, data) { static struct etimer et; +#if RPL_WITH_STORING static struct uip_ds6_notification n; +#endif /* #if RPL_WITH_STORING */ PROCESS_BEGIN(); set_global_address(); +#if RPL_WITH_STORING uip_ds6_notification_add(&n, route_callback); +#endif /* #if RPL_WITH_STORING */ simple_udp_register(&unicast_connection, UDP_PORT, NULL, UDP_PORT, receiver); @@ -120,12 +126,14 @@ PROCESS_THREAD(receiver_node_process, ev, data) while(1) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); etimer_reset(&et); +#if RPL_WITH_STORING if(should_blink) { leds_on(LEDS_ALL); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); etimer_reset(&et); leds_off(LEDS_ALL); } +#endif /* #if RPL_WITH_STORING */ } PROCESS_END(); } From fe7ded0762f8861d06cb0a5990e0770f1e658e73 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 13 Dec 2017 12:55:22 -0800 Subject: [PATCH 42/43] Routing API: add function node_has_joined --- os/net/routing/nullrouting/nullrouting.c | 7 +++++++ os/net/routing/routing.h | 6 ++++++ os/net/routing/rpl-classic/rpl-dag.c | 6 ++++++ os/net/routing/rpl-classic/rpl.c | 1 + os/net/routing/rpl-classic/rpl.h | 6 ++++++ os/net/routing/rpl-lite/rpl.c | 7 +++++++ tests/07-simulation-base/code-slip-radio/wait-dag.c | 2 +- 7 files changed, 34 insertions(+), 1 deletion(-) diff --git a/os/net/routing/nullrouting/nullrouting.c b/os/net/routing/nullrouting/nullrouting.c index fc788d58a..14c328b0c 100644 --- a/os/net/routing/nullrouting/nullrouting.c +++ b/os/net/routing/nullrouting/nullrouting.c @@ -82,6 +82,12 @@ leave_network(void) } /*---------------------------------------------------------------------------*/ static int +node_has_joined(void) +{ + return 1; +} +/*---------------------------------------------------------------------------*/ +static int node_is_reachable(void) { return 1; @@ -151,6 +157,7 @@ const struct routing_driver nullrouting_driver = { get_root_ipaddr, get_sr_node_ipaddr, leave_network, + node_has_joined, node_is_reachable, global_repair, local_repair, diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index 94cb874fd..7fe6e7ca8 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -93,6 +93,12 @@ struct routing_driver { * */ void (* leave_network)(void); + /** + * Tells whether the node is currently part of a network + * + * \return 1 if we have joined a network, 0 otherwise. + */ + int (* node_has_joined)(void); /** * Tells whether the node is currently reachable as part of the network * diff --git a/os/net/routing/rpl-classic/rpl-dag.c b/os/net/routing/rpl-classic/rpl-dag.c index a8ec7b3f4..899322264 100644 --- a/os/net/routing/rpl-classic/rpl-dag.c +++ b/os/net/routing/rpl-classic/rpl-dag.c @@ -1006,6 +1006,12 @@ rpl_move_parent(rpl_dag_t *dag_src, rpl_dag_t *dag_dst, rpl_parent_t *parent) } /*---------------------------------------------------------------------------*/ int +rpl_has_joined(void) +{ + return rpl_get_any_dag() != NULL; +} +/*---------------------------------------------------------------------------*/ +int rpl_has_downward_route(void) { int i; diff --git a/os/net/routing/rpl-classic/rpl.c b/os/net/routing/rpl-classic/rpl.c index 4b90165f0..b1905d611 100644 --- a/os/net/routing/rpl-classic/rpl.c +++ b/os/net/routing/rpl-classic/rpl.c @@ -423,6 +423,7 @@ const struct routing_driver rpl_classic_driver = { get_root_ipaddr, get_sr_node_ipaddr, leave_network, + rpl_has_joined, rpl_has_downward_route, global_repair, local_repair, diff --git a/os/net/routing/rpl-classic/rpl.h b/os/net/routing/rpl-classic/rpl.h index 85f092606..db87cc824 100644 --- a/os/net/routing/rpl-classic/rpl.h +++ b/os/net/routing/rpl-classic/rpl.h @@ -327,6 +327,12 @@ enum rpl_mode rpl_set_mode(enum rpl_mode mode); */ enum rpl_mode rpl_get_mode(void); +/** + * Tells whether the node has joined a network or not + * + * \retval 1 if we have joined a network, 0 if not. + */ +int rpl_has_joined(void); /** * Get the RPL's best guess on if we have downward route or not. diff --git a/os/net/routing/rpl-lite/rpl.c b/os/net/routing/rpl-lite/rpl.c index 07c8cf344..acfe94c37 100644 --- a/os/net/routing/rpl-lite/rpl.c +++ b/os/net/routing/rpl-lite/rpl.c @@ -109,6 +109,12 @@ rpl_link_callback(const linkaddr_t *addr, int status, int numtx) } /*---------------------------------------------------------------------------*/ int +rpl_has_joined(void) +{ + return curr_instance.used && curr_instance.dag.state >= DAG_JOINED; +} +/*---------------------------------------------------------------------------*/ +int rpl_is_reachable(void) { return curr_instance.used && curr_instance.dag.state == DAG_REACHABLE; @@ -226,6 +232,7 @@ const struct routing_driver rpl_lite_driver = { rpl_dag_get_root_ipaddr, get_sr_node_ipaddr, rpl_dag_poison_and_leave, + rpl_has_joined, rpl_is_reachable, rpl_global_repair, rpl_local_repair, diff --git a/tests/07-simulation-base/code-slip-radio/wait-dag.c b/tests/07-simulation-base/code-slip-radio/wait-dag.c index 06fa80250..a059661b4 100644 --- a/tests/07-simulation-base/code-slip-radio/wait-dag.c +++ b/tests/07-simulation-base/code-slip-radio/wait-dag.c @@ -49,7 +49,7 @@ AUTOSTART_PROCESSES(&wait_for_dag); static void timeout_handler(void) { - if(NETSTACK_ROUTING.node_is_reachable()) { + if(NETSTACK_ROUTING.node_has_joined()) { PRINTF("DAG Found\n"); } } From 8aec2ac03033d1c2b402cd979d8678262241b43d Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 2 Feb 2018 09:42:05 -0800 Subject: [PATCH 43/43] Fix lwm2m header inclusions --- os/services/lwm2m/lwm2m-engine.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/os/services/lwm2m/lwm2m-engine.c b/os/services/lwm2m/lwm2m-engine.c index 3a1682e95..cdd82af89 100644 --- a/os/services/lwm2m/lwm2m-engine.c +++ b/os/services/lwm2m/lwm2m-engine.c @@ -53,12 +53,14 @@ #include "lwm2m-tlv-writer.h" #include "lib/list.h" #include "sys/cc.h" -#include "net/ipv6/uip-ds6.h" -#include "net/routing/routing.h" #include #include #include +#ifndef LWM2M_ENGINE_CLIENT_ENDPOINT_NAME +#include "net/ipv6/uip-ds6.h" +#endif /* LWM2M_ENGINE_CLIENT_ENDPOINT_NAME */ + /* Log configuration */ #include "coap-log.h" #define LOG_MODULE "lwm2m-engine"