From 9c84cd90b8776c1bd87bfbc6095bcc2e18550876 Mon Sep 17 00:00:00 2001
From: Martine Lenders <m.lenders@fu-berlin.de>
Date: Wed, 21 Feb 2018 20:23:36 +0100
Subject: [PATCH] gnrc_rpl: allow for non-router operation (as leaf)

---
 Makefile.dep                              | 2 +-
 sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Makefile.dep b/Makefile.dep
index ce01d0bb1f..a13d98801a 100644
--- a/Makefile.dep
+++ b/Makefile.dep
@@ -122,7 +122,7 @@ ifneq (,$(filter gnrc_rpl_p2p,$(USEMODULE)))
 endif
 
 ifneq (,$(filter gnrc_rpl,$(USEMODULE)))
-  USEMODULE += gnrc_ipv6_router_default
+  USEMODULE += gnrc_icmpv6
   USEMODULE += trickle
   USEMODULE += xtimer
 endif
diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
index 4b4021a2ef..87d055a4fe 100644
--- a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
+++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
@@ -132,6 +132,7 @@ bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, k
     assert(instance && (instance->state > 0));
 
     gnrc_rpl_dodag_t *dodag = &instance->dodag;
+    gnrc_netif_t *netif = gnrc_netif_get_by_pid(iface);
 
     dodag->dodag_id = *dodag_id;
     dodag->my_rank = GNRC_RPL_INFINITE_RANK;
@@ -150,6 +151,9 @@ bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, k
     dodag->instance = instance;
     dodag->iface = iface;
 
+    if ((netif != NULL) && !(netif->flags & GNRC_NETIF_FLAGS_IPV6_FORWARDING)) {
+        gnrc_rpl_leaf_operation(dodag);
+    }
 #ifdef MODULE_GNRC_RPL_P2P
     if ((instance->mop == GNRC_RPL_P2P_MOP) && (gnrc_rpl_p2p_ext_new(dodag) == NULL)) {
         DEBUG("RPL: could not allocate new P2P-RPL DODAG extension. Remove DODAG\n");
-- 
GitLab