diff --git a/sys/include/net/gnrc/rpl.h b/sys/include/net/gnrc/rpl.h index c722e6f49a..2b613c8702 100644 --- a/sys/include/net/gnrc/rpl.h +++ b/sys/include/net/gnrc/rpl.h @@ -49,7 +49,7 @@ * * - Exclude Prefix Information Options from DIOs * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.mk} - * CFLAGS += -DGNRC_RPL_WITHOUT_PIO + * CFLAGS += -DCONFIG_GNRC_RPL_WITHOUT_PIO * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * - Modify trickle parameters @@ -667,20 +667,21 @@ void gnrc_rpl_send(gnrc_pktsnip_t *pkt, kernel_pid_t iface, ipv6_addr_t *src, ip */ uint8_t gnrc_rpl_gen_instance_id(bool local); -#ifndef GNRC_RPL_WITHOUT_PIO /** * @brief (De-)Activate the transmission of Prefix Information Options within DIOs - * for a particular DODAG + * for a particular DODAG. This function has no effect if + * CONFIG_GNRC_RPL_WITHOUT_PIO is set. * * @param[in] dodag Pointer to the DODAG * @param[in] status true for activating PIOs and false for deactivating them */ static inline void gnrc_rpl_config_pio(gnrc_rpl_dodag_t *dodag, bool status) { - dodag->dio_opts = (dodag->dio_opts & ~GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO) | - (status << GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT); + if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) { + dodag->dio_opts = (dodag->dio_opts & ~GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO) | + (status << GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT); + } } -#endif #ifdef __cplusplus } diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl.c b/sys/net/gnrc/routing/rpl/gnrc_rpl.c index f37aed2a57..16f2704a8e 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl.c @@ -16,6 +16,7 @@ */ #include +#include "kernel_defines.h" #include "net/icmpv6.h" #include "net/ipv6.h" @@ -132,9 +133,10 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_ dodag->node_status = GNRC_RPL_ROOT_NODE; dodag->my_rank = GNRC_RPL_ROOT_RANK; dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_DODAG_CONF; -#ifndef GNRC_RPL_WITHOUT_PIO - dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO; -#endif + + if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) { + dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO; + } trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_MSG, (1 << dodag->dio_min), dodag->dio_interval_doubl, diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c b/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c index b985388418..3b1f31d972 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c @@ -17,6 +17,7 @@ */ #include +#include "kernel_defines.h" #include "net/af.h" #include "net/icmpv6.h" @@ -285,7 +286,6 @@ gnrc_pktsnip_t *_dis_solicited_opt_build(gnrc_pktsnip_t *pkt, gnrc_rpl_internal_ return opt_snip; } -#ifndef GNRC_RPL_WITHOUT_PIO static bool _get_pl_entry(unsigned iface, ipv6_addr_t *pfx, unsigned pfx_len, gnrc_ipv6_nib_pl_t *ple) { @@ -340,7 +340,6 @@ gnrc_pktsnip_t *_dio_prefix_info_build(gnrc_pktsnip_t *pkt, gnrc_rpl_dodag_t *do prefix_info->prefix_len); return opt_snip; } -#endif void gnrc_rpl_send_DIO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination) { @@ -365,13 +364,12 @@ void gnrc_rpl_send_DIO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination) } #endif -#ifndef GNRC_RPL_WITHOUT_PIO - if (dodag->dio_opts & GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO) { + if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO) && + dodag->dio_opts & GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO) { if ((pkt = _dio_prefix_info_build(pkt, dodag)) == NULL) { return; } } -#endif if (dodag->dio_opts & GNRC_RPL_REQ_DIO_OPT_DODAG_CONF) { if ((pkt = _dio_dodag_conf_build(pkt, dodag)) == NULL) { @@ -556,9 +554,11 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt case (GNRC_RPL_OPT_PREFIX_INFO): DEBUG("RPL: Prefix Information DIO option parsed\n"); *included_opts |= ((uint32_t) 1) << GNRC_RPL_OPT_PREFIX_INFO; -#ifndef GNRC_RPL_WITHOUT_PIO - dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO; -#endif + + if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) { + dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO; + } + gnrc_rpl_opt_prefix_info_t *pi = (gnrc_rpl_opt_prefix_info_t *) opt; /* check for the auto address-configuration flag */ gnrc_netif_t *netif = gnrc_netif_get_by_pid(dodag->iface); diff --git a/sys/shell/commands/sc_gnrc_rpl.c b/sys/shell/commands/sc_gnrc_rpl.c index 7ec290639f..93184417e8 100644 --- a/sys/shell/commands/sc_gnrc_rpl.c +++ b/sys/shell/commands/sc_gnrc_rpl.c @@ -344,7 +344,6 @@ int _gnrc_rpl_operation(bool leaf, char *arg1) return 0; } -#ifndef GNRC_RPL_WITHOUT_PIO int _gnrc_rpl_set_pio(char *inst_id, bool status) { uint8_t instance_id = atoi(inst_id); @@ -360,7 +359,6 @@ int _gnrc_rpl_set_pio(char *inst_id, bool status) printf("success: %sactivated PIO transmissions\n", status ? "" : "de"); return 0; } -#endif int _gnrc_rpl(int argc, char **argv) { @@ -408,8 +406,7 @@ int _gnrc_rpl(int argc, char **argv) } } else if (strcmp(argv[1], "set") == 0) { - if (argc > 2) { -#ifndef GNRC_RPL_WITHOUT_PIO + if ((argc > 2) && !IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) { if (strcmp(argv[2], "pio") == 0) { if ((argc == 5) && (strcmp(argv[3], "on") == 0)) { return _gnrc_rpl_set_pio(argv[4], true); @@ -418,7 +415,6 @@ int _gnrc_rpl(int argc, char **argv) return _gnrc_rpl_set_pio(argv[4], false); } } -#endif } } #ifdef MODULE_GNRC_RPL_P2P @@ -448,9 +444,11 @@ int _gnrc_rpl(int argc, char **argv) puts("* router \t\t\t- operate as router in the instance"); puts("* send dis\t\t\t\t- send a multicast DIS"); puts("* send dis - send a multicast DIS with SOL option"); -#ifndef GNRC_RPL_WITHOUT_PIO - puts("* set pio \t- (de-)activate PIO transmissions in DIOs"); -#endif + + if (!IS_ACTIVE(CONFIG_GNRC_RPL_WITHOUT_PIO)) { + puts("* set pio \t- (de-)activate PIO transmissions in DIOs"); + } + puts("* show\t\t\t\t\t- show instance and dodag tables"); return 0; }