From 3d819ce70728c721d34e63868dfe67248cd4f971 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 18 Feb 2022 16:42:08 +0100 Subject: [PATCH] gnrc_netif: make auto-config of compression context optional --- sys/include/net/gnrc/netif/conf.h | 10 ++++++++++ sys/net/gnrc/netif/Kconfig | 7 +++++++ sys/net/gnrc/netif/gnrc_netif.c | 10 ++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/sys/include/net/gnrc/netif/conf.h b/sys/include/net/gnrc/netif/conf.h index 6156028010c0..4d679c23d4bf 100644 --- a/sys/include/net/gnrc/netif/conf.h +++ b/sys/include/net/gnrc/netif/conf.h @@ -194,6 +194,16 @@ extern "C" { #define CONFIG_GNRC_NETIF_NONSTANDARD_6LO_MTU 0 #endif +/** + * @brief Automatically add 6LoWPAN compression at border router + * + * When set, 6LoWPAN compression context 0 will be automatically set for the prefix configured by + * prefix deligation at the border router. + */ +#ifndef CONFIG_GNRC_NETIF_IPV6_BR_AUTO_6CTX +#define CONFIG_GNRC_NETIF_IPV6_BR_AUTO_6CTX 1 +#endif + #ifdef __cplusplus } #endif diff --git a/sys/net/gnrc/netif/Kconfig b/sys/net/gnrc/netif/Kconfig index 213d64c57bb8..481e425e94cc 100644 --- a/sys/net/gnrc/netif/Kconfig +++ b/sys/net/gnrc/netif/Kconfig @@ -74,5 +74,12 @@ config GNRC_NETIF_LORAWAN_NETIF_HDR GNRC LoRaWAN packets will include the GNRC Netif header. Therefore this parameter will be removed +config GNRC_NETIF_IPV6_BR_AUTO_6CTX + bool "Automatically add 6LoWPAN compression at border router" + default y + depends on USEMODULE_GNRC_IPV6_NIB_6LBR && USEMODULE_GNRC_SIXLOWPAN_IPHC && USEMODULE_GNRC_SIXLOWPAN_CTX + help + When set, 6LoWPAN compression context 0 will be automatically set for the prefix configured + by prefix deligation at the border router. endif # KCONFIG_USEMODULE_GNRC_NETIF diff --git a/sys/net/gnrc/netif/gnrc_netif.c b/sys/net/gnrc/netif/gnrc_netif.c index 4c197e999e23..94e3fe5ead4d 100644 --- a/sys/net/gnrc/netif/gnrc_netif.c +++ b/sys/net/gnrc/netif/gnrc_netif.c @@ -1287,10 +1287,12 @@ int gnrc_netif_ipv6_add_prefix(gnrc_netif_t *netif, IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_P6C) && gnrc_netif_is_6ln(netif)) { - /* configure compression context */ - if (gnrc_sixlowpan_ctx_update_6ctx(pfx, pfx_len, valid)) { - DEBUG("gnrc_netif: add compression context for prefix %s/%u\n", - ipv6_addr_to_str(addr_str, pfx, sizeof(addr_str)), pfx_len); + if (IS_ACTIVE(CONFIG_GNRC_NETIF_IPV6_BR_AUTO_6CTX)) { + /* configure compression context */ + if (gnrc_sixlowpan_ctx_update_6ctx(pfx, pfx_len, valid)) { + DEBUG("gnrc_netif: add compression context for prefix %s/%u\n", + ipv6_addr_to_str(addr_str, pfx, sizeof(addr_str)), pfx_len); + } } (void)gnrc_ipv6_nib_abr_add(&addr);