From 73fac82b58a0b4bc42b3bf1b8b70b1af723a20b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Wed, 3 Feb 2016 08:37:59 +0100 Subject: [PATCH] rpl: shell: don't compile PIO code dependent on CFLAGS --- sys/include/net/gnrc/rpl.h | 3 +++ sys/net/gnrc/routing/rpl/gnrc_rpl.c | 2 ++ sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c | 6 ++++++ sys/shell/commands/sc_gnrc_rpl.c | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/sys/include/net/gnrc/rpl.h b/sys/include/net/gnrc/rpl.h index 74acf762e0..dd54dc738c 100644 --- a/sys/include/net/gnrc/rpl.h +++ b/sys/include/net/gnrc/rpl.h @@ -483,6 +483,7 @@ void gnrc_rpl_send(gnrc_pktsnip_t *pkt, ipv6_addr_t *src, ipv6_addr_t *dst, ipv6 */ 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 @@ -495,6 +496,8 @@ static inline void gnrc_rpl_config_pio(gnrc_rpl_dodag_t *dodag, bool status) dodag->req_opts = (dodag->req_opts & ~GNRC_RPL_REQ_OPT_PREFIX_INFO) | (status << GNRC_RPL_REQ_OPT_PREFIX_INFO_SHIFT); } +#endif + #ifdef __cplusplus } #endif diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl.c b/sys/net/gnrc/routing/rpl/gnrc_rpl.c index ece5ed87b5..fbc9d0f302 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl.c @@ -104,7 +104,9 @@ 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->req_opts |= GNRC_RPL_REQ_OPT_DODAG_CONF; +#ifndef GNRC_RPL_WITHOUT_PIO dodag->req_opts |= GNRC_RPL_REQ_OPT_PREFIX_INFO; +#endif trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL, GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min), 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 b8c2233ee1..ee5f46804c 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c @@ -116,6 +116,7 @@ gnrc_pktsnip_t *_dio_dodag_conf_build(gnrc_pktsnip_t *pkt, gnrc_rpl_dodag_t *dod return opt_snip; } +#ifndef GNRC_RPL_WITHOUT_PIO gnrc_pktsnip_t *_dio_prefix_info_build(gnrc_pktsnip_t *pkt, gnrc_rpl_dodag_t *dodag) { gnrc_rpl_opt_prefix_info_t *prefix_info; @@ -140,6 +141,7 @@ gnrc_pktsnip_t *_dio_prefix_info_build(gnrc_pktsnip_t *pkt, gnrc_rpl_dodag_t *do ipv6_addr_init_prefix(&prefix_info->prefix, &dodag->dodag_id, dodag->prefix_len); return opt_snip; } +#endif void gnrc_rpl_send_DIO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination) { @@ -152,11 +154,13 @@ void gnrc_rpl_send_DIO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination) gnrc_pktsnip_t *pkt = NULL, *tmp = NULL; gnrc_rpl_dio_t *dio; +#ifndef GNRC_RPL_WITHOUT_PIO if (dodag->req_opts & GNRC_RPL_REQ_OPT_PREFIX_INFO) { if ((pkt = _dio_prefix_info_build(pkt, dodag)) == NULL) { return; } } +#endif if (dodag->req_opts & GNRC_RPL_REQ_OPT_DODAG_CONF) { if ((pkt = _dio_dodag_conf_build(pkt, dodag)) == NULL) { @@ -411,7 +415,9 @@ 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->req_opts |= GNRC_RPL_REQ_OPT_PREFIX_INFO; +#endif gnrc_rpl_opt_prefix_info_t *pi = (gnrc_rpl_opt_prefix_info_t *) opt; ipv6_addr_t all_RPL_nodes = GNRC_RPL_ALL_NODES_ADDR; if_id = gnrc_ipv6_netif_find_by_addr(NULL, &all_RPL_nodes); diff --git a/sys/shell/commands/sc_gnrc_rpl.c b/sys/shell/commands/sc_gnrc_rpl.c index 9422532888..fb7163a5d7 100644 --- a/sys/shell/commands/sc_gnrc_rpl.c +++ b/sys/shell/commands/sc_gnrc_rpl.c @@ -241,6 +241,7 @@ 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 = (uint8_t) atoi(inst_id); @@ -256,6 +257,7 @@ 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) { @@ -301,6 +303,7 @@ int _gnrc_rpl(int argc, char **argv) } else if (strcmp(argv[1], "set") == 0) { if (argc > 2) { +#ifndef 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); @@ -309,6 +312,7 @@ int _gnrc_rpl(int argc, char **argv) return _gnrc_rpl_set_pio(argv[4], false); } } +#endif } } @@ -322,7 +326,9 @@ int _gnrc_rpl(int argc, char **argv) puts("* root \t- add a dodag to a new or existing instance"); puts("* router \t\t- operate as router in the instance"); puts("* send dis\t\t\t- send a multicast DIS"); +#ifndef GNRC_RPL_WITHOUT_PIO puts("* set pio - (de-)activate PIO transmissions in DIOs"); +#endif puts("* show\t\t\t\t- show instance and dodag tables"); return 0; }