From b7b23b712f35c4d5d2d4cdb860c81f02889bfe7e Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 7 Feb 2017 23:11:36 +0100 Subject: [PATCH 1/3] RPL: fix indentation (rpl-icmp6.c) --- core/net/rpl/rpl-icmp6.c | 310 +++++++++++++++++++-------------------- 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index 733b4e6a4..7763cb18d 100644 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -79,7 +79,7 @@ static void dao_input(void); static void dao_ack_input(void); static void dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix, - uint8_t lifetime, uint8_t seq_no); + uint8_t lifetime, uint8_t seq_no); /* some debug callbacks useful when debugging RPL networks */ #ifdef RPL_DEBUG_DIO_INPUT @@ -158,8 +158,8 @@ get_global_addr(uip_ipaddr_t *addr) static uint32_t get32(uint8_t *buffer, int pos) { - return (uint32_t)buffer[pos] << 24 | (uint32_t)buffer[pos + 1] << 16 | - (uint32_t)buffer[pos + 2] << 8 | buffer[pos + 3]; + return ((uint32_t)buffer[pos] << 24 | (uint32_t)buffer[pos + 1] << 16 | + (uint32_t)buffer[pos + 2] << 8 | buffer[pos + 3]); } /*---------------------------------------------------------------------------*/ static void @@ -202,7 +202,7 @@ rpl_icmp6_update_nbr_table(uip_ipaddr_t *from, nbr_table_reason_t reason, void * } return nbr; - } +} /*---------------------------------------------------------------------------*/ static void dis_input(void) @@ -238,7 +238,7 @@ dis_input(void) PRINTF("RPL: Unicast DIS, reply to sender\n"); dio_output(instance, &UIP_IP_BUF->srcipaddr); } - /* } */ + /* } */ } } } @@ -355,103 +355,103 @@ dio_input(void) PRINTF("RPL: DIO option %u, length: %u\n", subopt_type, len - 2); switch(subopt_type) { - case RPL_OPTION_DAG_METRIC_CONTAINER: - if(len < 6) { - PRINTF("RPL: Invalid DAG MC, len = %d\n", len); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } - dio.mc.type = buffer[i + 2]; - dio.mc.flags = buffer[i + 3] << 1; - dio.mc.flags |= buffer[i + 4] >> 7; - dio.mc.aggr = (buffer[i + 4] >> 4) & 0x3; - dio.mc.prec = buffer[i + 4] & 0xf; - dio.mc.length = buffer[i + 5]; + case RPL_OPTION_DAG_METRIC_CONTAINER: + if(len < 6) { + PRINTF("RPL: Invalid DAG MC, len = %d\n", len); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } + dio.mc.type = buffer[i + 2]; + dio.mc.flags = buffer[i + 3] << 1; + dio.mc.flags |= buffer[i + 4] >> 7; + dio.mc.aggr = (buffer[i + 4] >> 4) & 0x3; + dio.mc.prec = buffer[i + 4] & 0xf; + dio.mc.length = buffer[i + 5]; - if(dio.mc.type == RPL_DAG_MC_NONE) { - /* No metric container: do nothing */ - } else if(dio.mc.type == RPL_DAG_MC_ETX) { - dio.mc.obj.etx = get16(buffer, i + 6); + if(dio.mc.type == RPL_DAG_MC_NONE) { + /* No metric container: do nothing */ + } else if(dio.mc.type == RPL_DAG_MC_ETX) { + dio.mc.obj.etx = get16(buffer, i + 6); - PRINTF("RPL: DAG MC: type %u, flags %u, aggr %u, prec %u, length %u, ETX %u\n", - (unsigned)dio.mc.type, - (unsigned)dio.mc.flags, - (unsigned)dio.mc.aggr, - (unsigned)dio.mc.prec, - (unsigned)dio.mc.length, - (unsigned)dio.mc.obj.etx); - } else if(dio.mc.type == RPL_DAG_MC_ENERGY) { - dio.mc.obj.energy.flags = buffer[i + 6]; - dio.mc.obj.energy.energy_est = buffer[i + 7]; - } else { - PRINTF("RPL: Unhandled DAG MC type: %u\n", (unsigned)dio.mc.type); - goto discard; - } - break; - case RPL_OPTION_ROUTE_INFO: - if(len < 9) { - PRINTF("RPL: Invalid destination prefix option, len = %d\n", len); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } + PRINTF("RPL: DAG MC: type %u, flags %u, aggr %u, prec %u, length %u, ETX %u\n", + (unsigned)dio.mc.type, + (unsigned)dio.mc.flags, + (unsigned)dio.mc.aggr, + (unsigned)dio.mc.prec, + (unsigned)dio.mc.length, + (unsigned)dio.mc.obj.etx); + } else if(dio.mc.type == RPL_DAG_MC_ENERGY) { + dio.mc.obj.energy.flags = buffer[i + 6]; + dio.mc.obj.energy.energy_est = buffer[i + 7]; + } else { + PRINTF("RPL: Unhandled DAG MC type: %u\n", (unsigned)dio.mc.type); + goto discard; + } + break; + case RPL_OPTION_ROUTE_INFO: + if(len < 9) { + PRINTF("RPL: Invalid destination prefix option, len = %d\n", len); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } - /* The flags field includes the preference value. */ - dio.destination_prefix.length = buffer[i + 2]; - dio.destination_prefix.flags = buffer[i + 3]; - dio.destination_prefix.lifetime = get32(buffer, i + 4); + /* The flags field includes the preference value. */ + dio.destination_prefix.length = buffer[i + 2]; + dio.destination_prefix.flags = buffer[i + 3]; + dio.destination_prefix.lifetime = get32(buffer, i + 4); - if(((dio.destination_prefix.length + 7) / 8) + 8 <= len && - dio.destination_prefix.length <= 128) { - PRINTF("RPL: Copying destination prefix\n"); - memcpy(&dio.destination_prefix.prefix, &buffer[i + 8], - (dio.destination_prefix.length + 7) / 8); - } else { - PRINTF("RPL: Invalid route info option, len = %d\n", len); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } + if(((dio.destination_prefix.length + 7) / 8) + 8 <= len && + dio.destination_prefix.length <= 128) { + PRINTF("RPL: Copying destination prefix\n"); + memcpy(&dio.destination_prefix.prefix, &buffer[i + 8], + (dio.destination_prefix.length + 7) / 8); + } else { + PRINTF("RPL: Invalid route info option, len = %d\n", len); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } - break; - case RPL_OPTION_DAG_CONF: - if(len != 16) { - PRINTF("RPL: Invalid DAG configuration option, len = %d\n", len); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } + break; + case RPL_OPTION_DAG_CONF: + if(len != 16) { + PRINTF("RPL: Invalid DAG configuration option, len = %d\n", len); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } - /* Path control field not yet implemented - at i + 2 */ - dio.dag_intdoubl = buffer[i + 3]; - dio.dag_intmin = buffer[i + 4]; - dio.dag_redund = buffer[i + 5]; - dio.dag_max_rankinc = get16(buffer, i + 6); - dio.dag_min_hoprankinc = get16(buffer, i + 8); - dio.ocp = get16(buffer, i + 10); - /* buffer + 12 is reserved */ - dio.default_lifetime = buffer[i + 13]; - dio.lifetime_unit = get16(buffer, i + 14); - PRINTF("RPL: DAG conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n", - dio.dag_intdoubl, dio.dag_intmin, dio.dag_redund, - dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp, - dio.default_lifetime, dio.lifetime_unit); - break; - case RPL_OPTION_PREFIX_INFO: - if(len != 32) { - PRINTF("RPL: Invalid DAG prefix info, len != 32\n"); - RPL_STAT(rpl_stats.malformed_msgs++); - goto discard; - } - dio.prefix_info.length = buffer[i + 2]; - dio.prefix_info.flags = buffer[i + 3]; - /* valid lifetime is ingnored for now - at i + 4 */ - /* preferred lifetime stored in lifetime */ - dio.prefix_info.lifetime = get32(buffer, i + 8); - /* 32-bit reserved at i + 12 */ - PRINTF("RPL: Copying prefix information\n"); - memcpy(&dio.prefix_info.prefix, &buffer[i + 16], 16); - break; - default: - PRINTF("RPL: Unsupported suboption type in DIO: %u\n", - (unsigned)subopt_type); + /* Path control field not yet implemented - at i + 2 */ + dio.dag_intdoubl = buffer[i + 3]; + dio.dag_intmin = buffer[i + 4]; + dio.dag_redund = buffer[i + 5]; + dio.dag_max_rankinc = get16(buffer, i + 6); + dio.dag_min_hoprankinc = get16(buffer, i + 8); + dio.ocp = get16(buffer, i + 10); + /* buffer + 12 is reserved */ + dio.default_lifetime = buffer[i + 13]; + dio.lifetime_unit = get16(buffer, i + 14); + PRINTF("RPL: DAG conf:dbl=%d, min=%d red=%d maxinc=%d mininc=%d ocp=%d d_l=%u l_u=%u\n", + dio.dag_intdoubl, dio.dag_intmin, dio.dag_redund, + dio.dag_max_rankinc, dio.dag_min_hoprankinc, dio.ocp, + dio.default_lifetime, dio.lifetime_unit); + break; + case RPL_OPTION_PREFIX_INFO: + if(len != 32) { + PRINTF("RPL: Invalid DAG prefix info, len != 32\n"); + RPL_STAT(rpl_stats.malformed_msgs++); + goto discard; + } + dio.prefix_info.length = buffer[i + 2]; + dio.prefix_info.flags = buffer[i + 3]; + /* valid lifetime is ingnored for now - at i + 4 */ + /* preferred lifetime stored in lifetime */ + dio.prefix_info.lifetime = get32(buffer, i + 8); + /* 32-bit reserved at i + 12 */ + PRINTF("RPL: Copying prefix information\n"); + memcpy(&dio.prefix_info.prefix, &buffer[i + 16], 16); + break; + default: + PRINTF("RPL: Unsupported suboption type in DIO: %u\n", + (unsigned)subopt_type); } } @@ -461,7 +461,7 @@ dio_input(void) rpl_process_dio(&from, &dio); - discard: +discard: uip_clear_buf(); } /*---------------------------------------------------------------------------*/ @@ -546,7 +546,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr) buffer[pos++] = instance->mc.obj.energy.energy_est; } else { PRINTF("RPL: Unable to send DIO because of unhandled DAG MC type %u\n", - (unsigned)instance->mc.type); + (unsigned)instance->mc.type); return; } } @@ -600,7 +600,7 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr) } #endif /* DEBUG_PRINT */ PRINTF("RPL: Sending unicast-DIO with rank %u to ", - (unsigned)dag->rank); + (unsigned)dag->rank); PRINT6ADDR(uc_addr); PRINTF("\n"); uip_icmp6_send(uc_addr, ICMP6_RPL, RPL_CODE_DIO, pos); @@ -608,12 +608,12 @@ dio_output(rpl_instance_t *instance, uip_ipaddr_t *uc_addr) /* Unicast requests get unicast replies! */ if(uc_addr == NULL) { PRINTF("RPL: Sending a multicast-DIO with rank %u\n", - (unsigned)instance->current_dag->rank); + (unsigned)instance->current_dag->rank); uip_create_linklocal_rplnodes_mcast(&addr); uip_icmp6_send(&addr, ICMP6_RPL, RPL_CODE_DIO, pos); } else { PRINTF("RPL: Sending unicast-DIO with rank %u to ", - (unsigned)instance->current_dag->rank); + (unsigned)instance->current_dag->rank); PRINT6ADDR(uc_addr); PRINTF("\n"); uip_icmp6_send(uc_addr, ICMP6_RPL, RPL_CODE_DIO, pos); @@ -636,8 +636,8 @@ dao_input_storing(void) uint8_t flags; uint8_t subopt_type; /* - uint8_t pathcontrol; - uint8_t pathsequence; + uint8_t pathcontrol; + uint8_t pathsequence; */ uip_ipaddr_t prefix; uip_ds6_route_t *rep; @@ -683,11 +683,11 @@ dao_input_storing(void) } learned_from = uip_is_addr_mcast(&dao_sender_addr) ? - RPL_ROUTE_FROM_MULTICAST_DAO : RPL_ROUTE_FROM_UNICAST_DAO; + RPL_ROUTE_FROM_MULTICAST_DAO : RPL_ROUTE_FROM_UNICAST_DAO; /* Destination Advertisement Object */ PRINTF("RPL: Received a (%s) DAO with sequence number %u from ", - learned_from == RPL_ROUTE_FROM_UNICAST_DAO? "unicast": "multicast", sequence); + learned_from == RPL_ROUTE_FROM_UNICAST_DAO? "unicast": "multicast", sequence); PRINT6ADDR(&dao_sender_addr); PRINTF("\n"); @@ -699,7 +699,7 @@ dao_input_storing(void) if(parent != NULL && DAG_RANK(parent->rank, instance) < DAG_RANK(dag->rank, instance)) { PRINTF("RPL: Loop detected when receiving a unicast DAO from a node with a lower rank! (%u < %u)\n", - DAG_RANK(parent->rank, instance), DAG_RANK(dag->rank, instance)); + DAG_RANK(parent->rank, instance), DAG_RANK(dag->rank, instance)); parent->rank = INFINITE_RANK; parent->flags |= RPL_PARENT_FLAG_UPDATED; return; @@ -725,24 +725,24 @@ dao_input_storing(void) } switch(subopt_type) { - case RPL_OPTION_TARGET: - /* Handle the target option. */ - prefixlen = buffer[i + 3]; - memset(&prefix, 0, sizeof(prefix)); - memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT); - break; - case RPL_OPTION_TRANSIT: - /* The path sequence and control are ignored. */ - /* pathcontrol = buffer[i + 3]; - pathsequence = buffer[i + 4];*/ - lifetime = buffer[i + 5]; - /* The parent address is also ignored. */ - break; + case RPL_OPTION_TARGET: + /* Handle the target option. */ + prefixlen = buffer[i + 3]; + memset(&prefix, 0, sizeof(prefix)); + memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT); + break; + case RPL_OPTION_TRANSIT: + /* The path sequence and control are ignored. */ + /* pathcontrol = buffer[i + 3]; + pathsequence = buffer[i + 4];*/ + lifetime = buffer[i + 5]; + /* The parent address is also ignored. */ + break; } } PRINTF("RPL: DAO lifetime: %u, prefix length: %u prefix: ", - (unsigned)lifetime, (unsigned)prefixlen); + (unsigned)lifetime, (unsigned)prefixlen); PRINT6ADDR(&prefix); PRINTF("\n"); @@ -781,7 +781,7 @@ dao_input_storing(void) out_seq = prepare_for_dao_fwd(sequence, rep); PRINTF("RPL: Forwarding No-path DAO to parent - out_seq:%d", - out_seq); + out_seq); PRINT6ADDR(rpl_get_parent_ipaddr(dag->preferred_parent)); PRINTF("\n"); @@ -813,8 +813,8 @@ dao_input_storing(void) if(flags & RPL_DAO_K_FLAG) { /* signal the failure to add the node */ dao_ack_output(instance, &dao_sender_addr, sequence, - is_root ? RPL_DAO_ACK_UNABLE_TO_ADD_ROUTE_AT_ROOT : - RPL_DAO_ACK_UNABLE_TO_ACCEPT); + is_root ? RPL_DAO_ACK_UNABLE_TO_ADD_ROUTE_AT_ROOT : + RPL_DAO_ACK_UNABLE_TO_ACCEPT); } return; } @@ -826,8 +826,8 @@ dao_input_storing(void) if(flags & RPL_DAO_K_FLAG) { /* signal the failure to add the node */ dao_ack_output(instance, &dao_sender_addr, sequence, - is_root ? RPL_DAO_ACK_UNABLE_TO_ADD_ROUTE_AT_ROOT : - RPL_DAO_ACK_UNABLE_TO_ACCEPT); + is_root ? RPL_DAO_ACK_UNABLE_TO_ADD_ROUTE_AT_ROOT : + RPL_DAO_ACK_UNABLE_TO_ACCEPT); } return; } @@ -852,7 +852,7 @@ fwd_dao: */ if((!RPL_ROUTE_IS_DAO_PENDING(rep) && rep->state.dao_seqno_in == sequence) || - dag->rank == ROOT_RANK(instance)) { + dag->rank == ROOT_RANK(instance)) { should_ack = 1; } } @@ -948,26 +948,26 @@ dao_input_nonstoring(void) } switch(subopt_type) { - case RPL_OPTION_TARGET: - /* Handle the target option. */ - prefixlen = buffer[i + 3]; - memset(&prefix, 0, sizeof(prefix)); - memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT); - break; - case RPL_OPTION_TRANSIT: - /* The path sequence and control are ignored. */ - /* pathcontrol = buffer[i + 3]; - pathsequence = buffer[i + 4];*/ - lifetime = buffer[i + 5]; - if(len >= 20) { - memcpy(&dao_parent_addr, buffer + i + 6, 16); - } - break; + case RPL_OPTION_TARGET: + /* Handle the target option. */ + prefixlen = buffer[i + 3]; + memset(&prefix, 0, sizeof(prefix)); + memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT); + break; + case RPL_OPTION_TRANSIT: + /* The path sequence and control are ignored. */ + /* pathcontrol = buffer[i + 3]; + pathsequence = buffer[i + 4];*/ + lifetime = buffer[i + 5]; + if(len >= 20) { + memcpy(&dao_parent_addr, buffer + i + 6, 16); + } + break; } } PRINTF("RPL: DAO lifetime: %u, prefix length: %u prefix: ", - (unsigned)lifetime, (unsigned)prefixlen); + (unsigned)lifetime, (unsigned)prefixlen); PRINT6ADDR(&prefix); PRINTF(", parent: "); PRINT6ADDR(&dao_parent_addr); @@ -987,7 +987,7 @@ dao_input_nonstoring(void) PRINTF("RPL: Sending DAO ACK\n"); uip_clear_buf(); dao_ack_output(instance, &dao_sender_addr, sequence, - RPL_DAO_ACK_UNCONDITIONAL_ACCEPT); + RPL_DAO_ACK_UNCONDITIONAL_ACCEPT); } #endif /* RPL_WITH_NON_STORING */ } @@ -1017,7 +1017,7 @@ dao_input(void) dao_input_nonstoring(); } - discard: +discard: uip_clear_buf(); } /*---------------------------------------------------------------------------*/ @@ -1059,7 +1059,7 @@ handle_dao_retransmission(void *ptr) } PRINTF("RPL: will retransmit DAO - seq:%d trans:%d\n", instance->my_dao_seqno, - instance->my_dao_transmissions); + instance->my_dao_transmissions); if(get_global_addr(&prefix) == 0) { return; @@ -1068,11 +1068,11 @@ handle_dao_retransmission(void *ptr) ctimer_set(&instance->dao_retransmit_timer, RPL_DAO_RETRANSMISSION_TIMEOUT / 2 + (random_rand() % (RPL_DAO_RETRANSMISSION_TIMEOUT / 2)), - handle_dao_retransmission, parent); + handle_dao_retransmission, parent); instance->my_dao_transmissions++; dao_output_target_seq(parent, &prefix, - instance->default_lifetime, instance->my_dao_seqno); + instance->default_lifetime, instance->my_dao_seqno); } #endif /* RPL_WITH_DAO_ACK */ /*---------------------------------------------------------------------------*/ @@ -1103,11 +1103,11 @@ dao_output(rpl_parent_t *parent, uint8_t lifetime) instance->my_dao_seqno = dao_sequence; instance->my_dao_transmissions = 1; ctimer_set(&instance->dao_retransmit_timer, RPL_DAO_RETRANSMISSION_TIMEOUT, - handle_dao_retransmission, parent); + handle_dao_retransmission, parent); } #else - /* We know that we have tried to register so now we are assuming - that we have a down-link - unless this is a zero lifetime one */ + /* We know that we have tried to register so now we are assuming + that we have a down-link - unless this is a zero lifetime one */ parent->dag->instance->has_downward_route = lifetime != RPL_ZERO_LIFETIME; #endif /* RPL_WITH_DAO_ACK */ @@ -1123,7 +1123,7 @@ dao_output_target(rpl_parent_t *parent, uip_ipaddr_t *prefix, uint8_t lifetime) /*---------------------------------------------------------------------------*/ static void dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix, - uint8_t lifetime, uint8_t seq_no) + uint8_t lifetime, uint8_t seq_no) { rpl_dag_t *dag; rpl_instance_t *instance; @@ -1223,7 +1223,7 @@ dao_output_target_seq(rpl_parent_t *parent, uip_ipaddr_t *prefix, } PRINTF("RPL: Sending a %sDAO with sequence number %u, lifetime %u, prefix ", - lifetime == RPL_ZERO_LIFETIME ? "No-Path " : "", seq_no, lifetime); + lifetime == RPL_ZERO_LIFETIME ? "No-Path " : "", seq_no, lifetime); PRINT6ADDR(prefix); PRINTF(" to "); @@ -1273,8 +1273,8 @@ dao_ack_input(void) } PRINTF("RPL: Received a DAO %s with sequence number %d (%d) and status %d from ", - status < 128 ? "ACK" : "NACK", - sequence, instance->my_dao_seqno, status); + status < 128 ? "ACK" : "NACK", + sequence, instance->my_dao_seqno, status); PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINTF("\n"); @@ -1333,7 +1333,7 @@ dao_ack_input(void) /*---------------------------------------------------------------------------*/ void dao_ack_output(rpl_instance_t *instance, uip_ipaddr_t *dest, uint8_t sequence, - uint8_t status) + uint8_t status) { #if RPL_WITH_DAO_ACK unsigned char *buffer; From 3559402781e65909585cfdb973562ab826c686a3 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 7 Feb 2017 23:55:01 +0100 Subject: [PATCH 2/3] RPL: add regression test for multicast This test aims to reproduce the issue #2031: https://github.com/contiki-os/contiki/issues/2031 Test nodes are built from the code under example/ipv6/multicast with WITH_SMRF=1 and WITH_DAO_ACK=1. If the simulation runs through for one hour, the test is regarded as success. Otherwise, when it crashes, the test fails. --- regression-tests/12-rpl/11-rpl-multicast.csc | 263 +++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 regression-tests/12-rpl/11-rpl-multicast.csc diff --git a/regression-tests/12-rpl/11-rpl-multicast.csc b/regression-tests/12-rpl/11-rpl-multicast.csc new file mode 100644 index 000000000..cd985d9d1 --- /dev/null +++ b/regression-tests/12-rpl/11-rpl-multicast.csc @@ -0,0 +1,263 @@ + + + [APPS_DIR]/mrm + [APPS_DIR]/mspsim + [APPS_DIR]/avrora + [APPS_DIR]/serial_socket + [APPS_DIR]/collect-view + [APPS_DIR]/powertracker + [APPS_DIR]/radiologger-headless + + My simulation + 123456 + 1000000 + + org.contikios.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + 40000 + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype442 + Cooja Mote Type #1 + [CONTIKI_DIR]/examples/ipv6/multicast/root.c + make clean TARGET=cooja + make DEFINES=RPL_CONF_WITH_DAO_ACK=1,UIP_MCAST6_CONF_ENGINE=UIP_MCAST6_ENGINE_SMRF root.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype774 + Cooja Mote Type #2 + [CONTIKI_DIR]/examples/ipv6/multicast/sink.c + make clean TARGET=cooja + make DEFINES=RPL_CONF_WITH_DAO_ACK=1,UIP_MCAST6_CONF_ENGINE=UIP_MCAST6_ENGINE_SMRF sink.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + org.contikios.cooja.contikimote.ContikiMoteType + mtype224 + Cooja Mote Type #3 + [CONTIKI_DIR]/examples/ipv6/multicast/intermediate.c + make clean TARGET=cooja + make DEFINES=RPL_CONF_WITH_DAO_ACK=1,UIP_MCAST6_CONF_ENGINE=UIP_MCAST6_ENGINE_SMRF intermediate.cooja TARGET=cooja + org.contikios.cooja.interfaces.Position + org.contikios.cooja.interfaces.Battery + org.contikios.cooja.contikimote.interfaces.ContikiVib + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + org.contikios.cooja.contikimote.interfaces.ContikiRS232 + org.contikios.cooja.contikimote.interfaces.ContikiBeeper + org.contikios.cooja.interfaces.RimeAddress + org.contikios.cooja.contikimote.interfaces.ContikiIPAddress + org.contikios.cooja.contikimote.interfaces.ContikiRadio + org.contikios.cooja.contikimote.interfaces.ContikiButton + org.contikios.cooja.contikimote.interfaces.ContikiPIR + org.contikios.cooja.contikimote.interfaces.ContikiClock + org.contikios.cooja.contikimote.interfaces.ContikiLED + org.contikios.cooja.contikimote.interfaces.ContikiCFS + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + org.contikios.cooja.interfaces.Mote2MoteRelations + org.contikios.cooja.interfaces.MoteAttributes + false + + + + org.contikios.cooja.interfaces.Position + 85.56533190308505 + 53.562395364420965 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 1 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiE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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype442 + + + + org.contikios.cooja.interfaces.Position + 43.952924225580446 + 106.6875691603427 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 2 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype774 + + + + org.contikios.cooja.interfaces.Position + 64.1616459084996 + 81.13076965805963 + 0.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiMoteID + 3 + + + org.contikios.cooja.contikimote.interfaces.ContikiRadio + 250.0 + + + org.contikios.cooja.contikimote.interfaces.ContikiEEPROM + AAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== + + mtype224 + + + + org.contikios.cooja.plugins.SimControl + 280 + 2 + 160 + 400 + 0 + + + org.contikios.cooja.plugins.Visualizer + + true + org.contikios.cooja.plugins.skins.IDVisualizerSkin + org.contikios.cooja.plugins.skins.GridVisualizerSkin + org.contikios.cooja.plugins.skins.TrafficVisualizerSkin + org.contikios.cooja.plugins.skins.UDGMVisualizerSkin + 3.699424669235615 0.0 0.0 3.699424669235615 -45.57151591938098 -64.4098979798254 + + 400 + 1 + 400 + 1 + 1 + + + org.contikios.cooja.plugins.LogListener + + + + + + 1320 + 6 + 240 + 400 + 160 + + + org.contikios.cooja.plugins.TimeLine + + 0 + 1 + 2 + + + + 500.0 + + 1720 + 5 + 166 + 0 + 957 + + + org.contikios.cooja.plugins.Notes + + Enter notes here + true + + 1040 + 4 + 160 + 680 + 0 + + + org.contikios.cooja.plugins.RadioLogger + + 150 + + false + false + + + 500 + 3 + 300 + 710 + 30 + + + org.contikios.cooja.plugins.ScriptRunner + + + true + + 600 + 0 + 700 + 430 + 30 + + + From faeb71de008e227bd8d957ef218c0120c458dc98 Mon Sep 17 00:00:00 2001 From: Yasuyuki Tanaka Date: Tue, 7 Feb 2017 23:59:17 +0100 Subject: [PATCH 3/3] RPL: fix a bug accessing an uninitialized pointer This bug is uncovered when RPL_WITH_MULTICAST is enabled. --- core/net/rpl/rpl-icmp6.c | 43 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/core/net/rpl/rpl-icmp6.c b/core/net/rpl/rpl-icmp6.c index 7763cb18d..94361cf04 100644 --- a/core/net/rpl/rpl-icmp6.c +++ b/core/net/rpl/rpl-icmp6.c @@ -748,6 +748,11 @@ dao_input_storing(void) #if RPL_WITH_MULTICAST if(uip_is_addr_mcast_global(&prefix)) { + /* + * "rep" is used for a unicast route which we don't need now; so set NULL so + * that operations on "rep" will be skipped. + */ + rep = NULL; mcast_group = uip_mcast6_route_add(&prefix); if(mcast_group) { mcast_group->dag = dag; @@ -844,29 +849,33 @@ fwd_dao: int should_ack = 0; if(flags & RPL_DAO_K_FLAG) { - /* - * check if this route is already installed and we can ack now! - * not pending - and same seq-no means that we can ack. - * (e.g. the route is installed already so it will not take any - * more room that it already takes - so should be ok!) - */ - if((!RPL_ROUTE_IS_DAO_PENDING(rep) && - rep->state.dao_seqno_in == sequence) || - dag->rank == ROOT_RANK(instance)) { - should_ack = 1; + if(rep != NULL) { + /* + * check if this route is already installed and we can ack now! + * not pending - and same seq-no means that we can ack. + * (e.g. the route is installed already so it will not take any + * more room that it already takes - so should be ok!) + */ + if((!RPL_ROUTE_IS_DAO_PENDING(rep) && + rep->state.dao_seqno_in == sequence) || + dag->rank == ROOT_RANK(instance)) { + should_ack = 1; + } } } if(dag->preferred_parent != NULL && rpl_get_parent_ipaddr(dag->preferred_parent) != NULL) { uint8_t out_seq = 0; - /* if this is pending and we get the same seq no it is a retrans */ - if(RPL_ROUTE_IS_DAO_PENDING(rep) && - rep->state.dao_seqno_in == sequence) { - /* keep the same seq-no as before for parent also */ - out_seq = rep->state.dao_seqno_out; - } else { - out_seq = prepare_for_dao_fwd(sequence, rep); + if(rep != NULL) { + /* if this is pending and we get the same seq no it is a retrans */ + if(RPL_ROUTE_IS_DAO_PENDING(rep) && + rep->state.dao_seqno_in == sequence) { + /* keep the same seq-no as before for parent also */ + out_seq = rep->state.dao_seqno_out; + } else { + out_seq = prepare_for_dao_fwd(sequence, rep); + } } PRINTF("RPL: Forwarding DAO to parent ");