From e4ca09fad0338001e8c45265660a204d19c2959e Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Mon, 31 Aug 2015 02:36:12 +0200 Subject: [PATCH] gnrc: adapt for gnrc_sixlowpan_nd_border_router --- .../ipv6/netif/gnrc_ipv6_netif.c | 21 +++++++++++++++++++ .../sixlowpan/ctx/gnrc_sixlowpan_ctx.c | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/net/gnrc/network_layer/ipv6/netif/gnrc_ipv6_netif.c b/sys/net/gnrc/network_layer/ipv6/netif/gnrc_ipv6_netif.c index a8fc2a773531c..63154ff772757 100644 --- a/sys/net/gnrc/network_layer/ipv6/netif/gnrc_ipv6_netif.c +++ b/sys/net/gnrc/network_layer/ipv6/netif/gnrc_ipv6_netif.c @@ -111,6 +111,12 @@ static ipv6_addr_t *_add_addr_to_entry(gnrc_ipv6_netif_t *entry, const ipv6_addr gnrc_ndp_router_retrans_rtr_adv(entry); mutex_lock(&entry->mutex); /* relock mutex */ } +#endif +#ifdef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER + gnrc_sixlowpan_nd_router_abr_t *abr = gnrc_sixlowpan_nd_router_abr_get(); + if (gnrc_sixlowpan_nd_router_abr_add_prf(abr, entry, tmp_addr) < 0) { + DEBUG("ipv6_netif: error adding prefix to 6LoWPAN-ND management\n"); + } #endif } else { @@ -303,6 +309,10 @@ static void _remove_addr_from_entry(gnrc_ipv6_netif_t *entry, ipv6_addr_t *addr) return; } #endif +#ifdef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER + gnrc_sixlowpan_nd_router_abr_t *abr = gnrc_sixlowpan_nd_router_abr_get(); + gnrc_sixlowpan_nd_router_abr_rem_prf(abr, entry, &entry->addrs[i]); +#endif mutex_unlock(&entry->mutex); return; @@ -752,6 +762,9 @@ void gnrc_ipv6_netif_init_by_dev(void) { kernel_pid_t ifs[GNRC_NETIF_NUMOF]; size_t ifnum = gnrc_netif_get(ifs); +#ifdef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER + bool abr_init = false; +#endif for (size_t i = 0; i < ifnum; i++) { ipv6_addr_t addr; @@ -826,6 +839,14 @@ void gnrc_ipv6_netif_init_by_dev(void) #endif #ifdef MODULE_GNRC_SIXLOWPAN_ND if (ipv6_if->flags & GNRC_IPV6_NETIF_FLAGS_SIXLOWPAN) { +#ifdef MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER + /* first interface wins */ + if (!abr_init) { + gnrc_sixlowpan_nd_router_abr_create(&addr, 0); + gnrc_ipv6_netif_set_rtr_adv(ipv6_if, true); + abr_init = true; + } +#endif gnrc_sixlowpan_nd_init(ipv6_if); continue; /* skip gnrc_ndp_host_init() */ } diff --git a/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c b/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c index 5c3ff30aeb5bd..c1a186da2d893 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c +++ b/sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c @@ -127,7 +127,6 @@ gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *p _ctx_inval_times[id] = ltime + _current_minute(); mutex_unlock(&_ctx_mutex); - return &(_ctxs[id]); }