From 46dc908fcb1d394762d98a048fe4c39e04408339 Mon Sep 17 00:00:00 2001 From: Oleg Hahm Date: Mon, 16 Nov 2015 19:05:54 +0100 Subject: [PATCH] gnrc 6lowpan: exclude CTX if not part of the app This removes dependencies to 6LoWPAN context module if an application is built without support for it. Also, includes a missing header. --- sys/include/net/gnrc/sixlowpan/ctx.h | 2 ++ sys/include/net/gnrc/sixlowpan/nd/router.h | 2 ++ sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c | 3 +++ sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c | 2 ++ 4 files changed, 9 insertions(+) diff --git a/sys/include/net/gnrc/sixlowpan/ctx.h b/sys/include/net/gnrc/sixlowpan/ctx.h index cae1e3e1c6..6d5aa86216 100644 --- a/sys/include/net/gnrc/sixlowpan/ctx.h +++ b/sys/include/net/gnrc/sixlowpan/ctx.h @@ -113,6 +113,7 @@ gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *p uint8_t prefix_len, uint16_t ltime, bool comp); +#ifdef MODULE_GNRC_SIXLOWPAN_CTX /** * @brief Removes context. * @@ -122,6 +123,7 @@ static inline void gnrc_sixlowpan_ctx_remove(uint8_t id) { gnrc_sixlowpan_ctx_lookup_id(id)->prefix_len = 0; } +#endif #ifdef TEST_SUITES /** diff --git a/sys/include/net/gnrc/sixlowpan/nd/router.h b/sys/include/net/gnrc/sixlowpan/nd/router.h index 8971f40803..551f732abd 100644 --- a/sys/include/net/gnrc/sixlowpan/nd/router.h +++ b/sys/include/net/gnrc/sixlowpan/nd/router.h @@ -68,7 +68,9 @@ typedef struct { uint32_t version; /**< version of the information dissiminated by the * BR */ uint16_t ltime; /**< the time in minutes until deletion */ +#ifdef MODULE_GNRC_SIXLOWPAN_CTX BITFIELD(ctxs, GNRC_SIXLOWPAN_CTX_SIZE);/**< contexts associated with BR */ +#endif gnrc_sixlowpan_nd_router_prf_t *prfs; /**< prefixes associated with BR */ xtimer_t ltimer; /**< timer for deletion */ msg_t ltimer_msg; /**< msg_t for gnrc_sixlowpan_nd_router_abr_t::ltimer */ diff --git a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c index 4297cfdd40..7e25b00330 100644 --- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c +++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c @@ -24,6 +24,7 @@ #include "net/gnrc/ndp.h" #include "net/gnrc/sixlowpan/ctx.h" #include "net/gnrc/sixlowpan/nd.h" +#include "net/gnrc/sixlowpan/nd/router.h" #include "net/protnum.h" #include "thread.h" #include "utlist.h" @@ -241,11 +242,13 @@ static void *_event_loop(void *args) DEBUG("ipv6: Unicast router solicitation event received\n"); gnrc_sixlowpan_nd_uc_rtr_sol((gnrc_ipv6_nc_t *)msg.content.ptr); break; +# ifdef MODULE_GNRC_SIXLOWPAN_CTX case GNRC_SIXLOWPAN_ND_MSG_DELETE_CTX: DEBUG("ipv6: Delete 6LoWPAN context event received\n"); gnrc_sixlowpan_ctx_remove(((((gnrc_sixlowpan_ctx_t *)msg.content.ptr)->flags_id) & GNRC_SIXLOWPAN_CTX_FLAGS_CID_MASK)); break; +# endif #endif #ifdef MODULE_GNRC_SIXLOWPAN_ND_ROUTER case GNRC_SIXLOWPAN_ND_MSG_ABR_TIMEOUT: diff --git a/sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c b/sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c index 22d0674301..08c5e3d93e 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c +++ b/sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c @@ -372,6 +372,7 @@ uint8_t gnrc_sixlowpan_nd_opt_ar_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6, bool gnrc_sixlowpan_nd_opt_6ctx_handle(uint8_t icmpv6_type, sixlowpan_nd_opt_6ctx_t *ctx_opt) { +#ifdef MODULE_GNRC_SIXLOWPAN_CTX if (((ctx_opt->ctx_len <= 64) && (ctx_opt->len != 2)) || ((ctx_opt->ctx_len > 64) && (ctx_opt->len != 3))) { DEBUG("6lo nd: invalid 6LoWPAN context option received\n"); @@ -385,6 +386,7 @@ bool gnrc_sixlowpan_nd_opt_6ctx_handle(uint8_t icmpv6_type, sixlowpan_nd_opt_6ct gnrc_sixlowpan_ctx_update(sixlowpan_nd_opt_6ctx_get_cid(ctx_opt), (ipv6_addr_t *)(ctx_opt + 1), ctx_opt->ctx_len, byteorder_ntohs(ctx_opt->ltime), sixlowpan_nd_opt_6ctx_is_comp(ctx_opt)); +#endif return true; }