diff --git a/arch/platform/native/platform.c b/arch/platform/native/platform.c index d00efaac1..b2c25e223 100644 --- a/arch/platform/native/platform.c +++ b/arch/platform/native/platform.c @@ -196,16 +196,13 @@ set_lladdr(void) static void set_global_address(void) { - static uip_ipaddr_t ipaddr; - static uip_ipaddr_t *prefix = NULL; + uip_ipaddr_t ipaddr; + const uip_ipaddr_t *default_prefix = uip_ds6_default_prefix(); /* Assign a unique local address (RFC4193, http://tools.ietf.org/html/rfc4193). */ - if(prefix == NULL) { - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); - } else { - memcpy(&ipaddr, prefix, 8); - } + uip_ip6addr_copy(&ipaddr, default_prefix); + /* Assumes that the uip_lladdr is set */ uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); @@ -215,7 +212,8 @@ set_global_address(void) LOG_INFO_("\n"); /* set the PREFIX::1 address to the IF */ - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 1); + uip_ip6addr_copy(&ipaddr, default_prefix); + ipaddr.u8[15] = 1; uip_ds6_defrt_add(&ipaddr, 0); } #endif diff --git a/examples/multicast/sink.c b/examples/multicast/sink.c index 49180b69a..2b6f48846 100644 --- a/examples/multicast/sink.c +++ b/examples/multicast/sink.c @@ -80,9 +80,10 @@ join_mcast_group(void) { uip_ipaddr_t addr; uip_ds6_maddr_t *rv; + const uip_ipaddr_t *default_prefix = uip_ds6_default_prefix(); /* First, set our v6 global */ - uip_ip6addr(&addr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + uip_ip6addr_copy(&addr, default_prefix); uip_ds6_set_addr_iid(&addr, &uip_lladdr); uip_ds6_addr_add(&addr, 0, ADDR_AUTOCONF); diff --git a/os/net/ipv6/uip-ds6.c b/os/net/ipv6/uip-ds6.c index 4e82b3745..bcfb9b0c8 100644 --- a/os/net/ipv6/uip-ds6.c +++ b/os/net/ipv6/uip-ds6.c @@ -95,10 +95,29 @@ static uip_ds6_prefix_t *locprefix; static const uint8_t iid_prefix[] = { 0x00, 0x00 , 0x00 , 0xff , 0xfe , 0x00 }; #endif /* (UIP_LLADDR_LEN == 2) */ +/* The default prefix */ +static uip_ip6addr_t default_prefix = { + .u16 = { 0, 0, 0, 0, 0, 0, 0, 0 } +}; +/*---------------------------------------------------------------------------*/ +const uip_ip6addr_t * +uip_ds6_default_prefix() +{ + return &default_prefix; +} +/*---------------------------------------------------------------------------*/ +void +uip_ds6_set_default_prefix(const uip_ip6addr_t *prefix) +{ + uip_ip6addr_copy(&default_prefix, prefix); +} /*---------------------------------------------------------------------------*/ void uip_ds6_init(void) { + if(uip_is_addr_unspecified(&default_prefix)) { + uip_ip6addr(&default_prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + } uip_ds6_neighbors_init(); uip_ds6_route_init(); diff --git a/os/net/ipv6/uip-ds6.h b/os/net/ipv6/uip-ds6.h index 45394fec3..0edc1fd6d 100644 --- a/os/net/ipv6/uip-ds6.h +++ b/os/net/ipv6/uip-ds6.h @@ -296,6 +296,22 @@ uip_ds6_prefix_t *uip_ds6_prefix_lookup(uip_ipaddr_t *ipaddr, uint8_t ipaddrlen); uint8_t uip_ds6_is_addr_onlink(uip_ipaddr_t *ipaddr); +/** + * \brief Retrieve the Default IPv6 prefix + * \retval A pointer to the default prefix + */ +const uip_ip6addr_t *uip_ds6_default_prefix(void); + +/** + * \brief Set the Default IPv6 prefix + * \param prefix A pointer to the new default prefix + * + * uip_ds6_init() will set the default prefix to UIP_DS6_DEFAULT_PREFIX + * unless this function here has been called beforehand to set a new default + * prefix. + */ +void uip_ds6_set_default_prefix(const uip_ip6addr_t *prefix); + /** @} */ /** \name Unicast address list basic routines */ diff --git a/os/net/mac/tsch/tsch-rpl.c b/os/net/mac/tsch/tsch-rpl.c index 951648d91..e8db94b57 100644 --- a/os/net/mac/tsch/tsch-rpl.c +++ b/os/net/mac/tsch/tsch-rpl.c @@ -136,5 +136,13 @@ tsch_rpl_callback_parent_switch(rpl_parent_t *old, rpl_parent_t *new) rpl_parent_get_ipaddr(new))); } } +/*---------------------------------------------------------------------------*/ +/* Check RPL has joined DODAG. + * To use, set #define TSCH_RPL_CHECK_DODAG_JOINED tsch_rpl_check_dodag_joined */ +int +tsch_rpl_check_dodag_joined(void) +{ + return NETSTACK_ROUTING.node_has_joined(); +} #endif /* UIP_CONF_IPV6_RPL */ /** @} */ diff --git a/os/net/mac/tsch/tsch-rpl.h b/os/net/mac/tsch/tsch-rpl.h index 23a148db8..95412e3d2 100644 --- a/os/net/mac/tsch/tsch-rpl.h +++ b/os/net/mac/tsch/tsch-rpl.h @@ -79,6 +79,12 @@ void tsch_rpl_callback_new_dio_interval(clock_time_t dio_interval); * \param new The new RPL parent */ void tsch_rpl_callback_parent_switch(rpl_parent_t *old, rpl_parent_t *new); +/** + * \brief Check RPL has joined DODAG. + * To use, set TSCH_RPL_CHECK_DODAG_JOINED tsch_rpl_check_dodag_joined + * \return 1 if joined, 0 otherwise + */ +int tsch_rpl_check_dodag_joined(void); #endif /* __TSCH_RPL_H__ */ /** @} */ diff --git a/os/net/mac/tsch/tsch.c b/os/net/mac/tsch/tsch.c index a33feeef1..6278ce0dc 100644 --- a/os/net/mac/tsch/tsch.c +++ b/os/net/mac/tsch/tsch.c @@ -861,7 +861,12 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data) while(1) { unsigned long delay; - if(tsch_is_associated && tsch_current_eb_period > 0) { + if(tsch_is_associated && tsch_current_eb_period > 0 +#ifdef TSCH_RPL_CHECK_DODAG_JOINED + /* Implementation section 6.3 of RFC 8180 */ + && TSCH_RPL_CHECK_DODAG_JOINED() +#endif /* TSCH_RPL_CHECK_DODAG_JOINED */ + ) { /* Enqueue EB only if there isn't already one in queue */ if(tsch_queue_packet_count(&tsch_eb_address) == 0) { uint8_t hdr_len = 0; diff --git a/os/net/mac/tsch/tsch.h b/os/net/mac/tsch/tsch.h index 8674ee31a..ba2926341 100644 --- a/os/net/mac/tsch/tsch.h +++ b/os/net/mac/tsch/tsch.h @@ -88,6 +88,10 @@ frequency hopping for enhanced reliability. #define TSCH_CALLBACK_KA_SENT tsch_rpl_callback_ka_sent #endif /* TSCH_CALLBACK_KA_SENT */ +#ifndef TSCH_RPL_CHECK_DODAG_JOINED +#define TSCH_RPL_CHECK_DODAG_JOINED tsch_rpl_check_dodag_joined +#endif /* TSCH_RPL_CHECK_DODAG_JOINED */ + #endif /* UIP_CONF_IPV6_RPL */ #if BUILD_WITH_ORCHESTRA @@ -117,6 +121,11 @@ void TSCH_CALLBACK_LEAVING_NETWORK(); void TSCH_CALLBACK_KA_SENT(); #endif +/* Called by TSCH before sending a EB */ +#ifdef TSCH_RPL_CHECK_DODAG_JOINED +int TSCH_RPL_CHECK_DODAG_JOINED(); +#endif + /* Called by TSCH form interrupt after receiving a frame, enabled upper-layer to decide * whether to ACK or NACK */ #ifdef TSCH_CALLBACK_DO_NACK diff --git a/os/net/routing/routing.h b/os/net/routing/routing.h index 4508f0c4e..3cee3d9b2 100644 --- a/os/net/routing/routing.h +++ b/os/net/routing/routing.h @@ -57,7 +57,7 @@ struct routing_driver { /** * Set the prefix, for nodes that will operate as root * - * \param prefix The prefix. If NULL, UIP_DS6_DEFAULT_PREFIX is used instead + * \param prefix The prefix. If NULL, uip_ds6_default_prefix() is used instead * \param iid The IID. If NULL, it will be built from uip_ds6_set_addr_iid. */ void (* root_set_prefix)(uip_ipaddr_t *prefix, uip_ipaddr_t *iid); diff --git a/os/net/routing/rpl-classic/rpl-dag-root.c b/os/net/routing/rpl-classic/rpl-dag-root.c index 3a0162627..f45c2d317 100644 --- a/os/net/routing/rpl-classic/rpl-dag-root.c +++ b/os/net/routing/rpl-classic/rpl-dag-root.c @@ -48,12 +48,15 @@ static void set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) { static uip_ipaddr_t root_ipaddr; + const uip_ipaddr_t *default_prefix; int i; + default_prefix = uip_ds6_default_prefix(); + /* Assign a unique local address (RFC4193, http://tools.ietf.org/html/rfc4193). */ if(prefix == NULL) { - uip_ip6addr(&root_ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + uip_ip6addr_copy(&root_ipaddr, default_prefix); } else { memcpy(&root_ipaddr, prefix, 8); } @@ -115,9 +118,11 @@ rpl_dag_root_start(void) if(root_if != NULL) { rpl_dag_t *dag; uip_ipaddr_t prefix; + const uip_ipaddr_t *default_prefix; rpl_set_root(RPL_DEFAULT_INSTANCE, ipaddr); dag = rpl_get_any_dag(); + default_prefix = uip_ds6_default_prefix(); /* If there are routes in this dag, we remove them all as we are from now on the new dag root and the old routes are wrong */ @@ -129,7 +134,7 @@ rpl_dag_root_start(void) dag->instance->def_route = NULL; } - uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + uip_ip6addr_copy(&prefix, default_prefix); rpl_set_prefix(dag, &prefix, 64); LOG_INFO("root_set_prefix: created a new RPL dag\n"); return 0; diff --git a/os/net/routing/rpl-lite/rpl-dag-root.c b/os/net/routing/rpl-lite/rpl-dag-root.c index c3e356828..38f5697e7 100644 --- a/os/net/routing/rpl-lite/rpl-dag-root.c +++ b/os/net/routing/rpl-lite/rpl-dag-root.c @@ -76,13 +76,16 @@ static void set_global_address(uip_ipaddr_t *prefix, uip_ipaddr_t *iid) { static uip_ipaddr_t root_ipaddr; + const uip_ipaddr_t *default_prefix; int i; uint8_t state; + default_prefix = uip_ds6_default_prefix(); + /* Assign a unique local address (RFC4193, http://tools.ietf.org/html/rfc4193). */ if(prefix == NULL) { - uip_ip6addr(&root_ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + uip_ip6addr_copy(&root_ipaddr, default_prefix); } else { memcpy(&root_ipaddr, prefix, 8); } diff --git a/os/net/routing/rpl-lite/rpl-dag-root.h b/os/net/routing/rpl-lite/rpl-dag-root.h index 71b999765..f035e8595 100644 --- a/os/net/routing/rpl-lite/rpl-dag-root.h +++ b/os/net/routing/rpl-lite/rpl-dag-root.h @@ -45,7 +45,7 @@ /** * Set a prefix in case the node is later set as dag root. * - * \param prefix The prefix. If NULL, UIP_DS6_DEFAULT_PREFIX is used instead + * \param prefix The prefix. If NULL, uip_ds6_default_prefix() is used instead * \param iid The IID. If NULL, it will be built from uip_ds6_set_addr_iid. */ void rpl_dag_root_set_prefix(uip_ipaddr_t *prefix, uip_ipaddr_t *iid); diff --git a/os/net/routing/rpl-lite/rpl-dag.c b/os/net/routing/rpl-lite/rpl-dag.c index 09caa9625..5ec080c15 100644 --- a/os/net/routing/rpl-lite/rpl-dag.c +++ b/os/net/routing/rpl-lite/rpl-dag.c @@ -104,7 +104,7 @@ rpl_dag_leave(void) /* Issue a no-path DAO */ if(!rpl_dag_root_is_root()) { - RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_curr_seqno); + RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_last_seqno); rpl_icmp6_dao_output(0); } @@ -507,7 +507,7 @@ init_dag(uint8_t instance_id, uip_ipaddr_t *dag_id, rpl_ocp_t ocp, curr_instance.dag.lowest_rank = RPL_INFINITE_RANK; curr_instance.dag.dao_last_seqno = RPL_LOLLIPOP_INIT; curr_instance.dag.dao_last_acked_seqno = RPL_LOLLIPOP_INIT; - curr_instance.dag.dao_curr_seqno = RPL_LOLLIPOP_INIT; + curr_instance.dag.dao_last_seqno = RPL_LOLLIPOP_INIT; memcpy(&curr_instance.dag.dag_id, dag_id, sizeof(curr_instance.dag.dag_id)); return 1; @@ -657,6 +657,8 @@ rpl_process_dao_ack(uint8_t sequence, uint8_t status) curr_instance.dag.state = DAG_REACHABLE; rpl_timers_dio_reset("Reachable"); } + /* Let the rpl-timers module know that we got an ACK for the last DAO */ + rpl_timers_notify_dao_ack(); if(!status_ok) { /* We got a NACK, start poisoning and leave */ diff --git a/os/net/routing/rpl-lite/rpl-icmp6.c b/os/net/routing/rpl-lite/rpl-icmp6.c index d376ff5e8..335c640d9 100644 --- a/os/net/routing/rpl-lite/rpl-icmp6.c +++ b/os/net/routing/rpl-lite/rpl-icmp6.c @@ -579,7 +579,7 @@ rpl_icmp6_dao_output(uint8_t lifetime) #endif /* RPL_WITH_DAO_ACK */ ++pos; buffer[pos++] = 0; /* reserved */ - buffer[pos++] = curr_instance.dag.dao_curr_seqno; + buffer[pos++] = curr_instance.dag.dao_last_seqno; /* create target subopt */ prefixlen = sizeof(*prefix) * CHAR_BIT; @@ -606,7 +606,7 @@ rpl_icmp6_dao_output(uint8_t lifetime) LOG_INFO("sending a %sDAO seqno %u, tx count %u, lifetime %u, prefix ", lifetime == 0 ? "No-path " : "", - curr_instance.dag.dao_curr_seqno, curr_instance.dag.dao_transmissions, lifetime); + curr_instance.dag.dao_last_seqno, curr_instance.dag.dao_transmissions, lifetime); LOG_INFO_6ADDR(prefix); LOG_INFO_(" to "); LOG_INFO_6ADDR(&curr_instance.dag.dag_id); @@ -640,7 +640,7 @@ dao_ack_input(void) LOG_INFO("received a DAO-%s with seqno %d (%d %d) and status %d from ", status < RPL_DAO_ACK_UNABLE_TO_ACCEPT ? "ACK" : "NACK", sequence, - curr_instance.dag.dao_curr_seqno, curr_instance.dag.dao_curr_seqno, status); + curr_instance.dag.dao_last_seqno, curr_instance.dag.dao_last_seqno, status); LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr); LOG_INFO_("\n"); diff --git a/os/net/routing/rpl-lite/rpl-timers.c b/os/net/routing/rpl-lite/rpl-timers.c index c41b92948..169226fd5 100644 --- a/os/net/routing/rpl-lite/rpl-timers.c +++ b/os/net/routing/rpl-lite/rpl-timers.c @@ -71,8 +71,9 @@ clock_time_t RPL_PROBING_DELAY_FUNC(void); static void handle_dis_timer(void *ptr); static void handle_dio_timer(void *ptr); static void handle_unicast_dio_timer(void *ptr); -static void handle_dao_timer(void *ptr); +static void send_new_dao(void *ptr); #if RPL_WITH_DAO_ACK +static void resend_dao(void *ptr); static void handle_dao_ack_timer(void *ptr); #endif /* RPL_WITH_DAO_ACK */ #if RPL_WITH_PROBING @@ -224,7 +225,7 @@ static void schedule_dao_retransmission(void) { clock_time_t expiration_time = RPL_DAO_RETRANSMISSION_TIMEOUT / 2 + (random_rand() % (RPL_DAO_RETRANSMISSION_TIMEOUT)); - ctimer_set(&curr_instance.dag.dao_timer, expiration_time, handle_dao_timer, NULL); + ctimer_set(&curr_instance.dag.dao_timer, expiration_time, resend_dao, NULL); } #endif /* RPL_WITH_DAO_ACK */ /*---------------------------------------------------------------------------*/ @@ -247,9 +248,8 @@ schedule_dao_refresh(void) target_refresh -= safety_margin; } - /* Increment next sequno */ - RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_curr_seqno); - ctimer_set(&curr_instance.dag.dao_timer, target_refresh, handle_dao_timer, NULL); + /* Schedule transmission */ + ctimer_set(&curr_instance.dag.dao_timer, target_refresh, send_new_dao, NULL); } } /*---------------------------------------------------------------------------*/ @@ -261,36 +261,16 @@ rpl_timers_schedule_dao(void) * only serves storing mode. Use simple delay instead, with the only purpose * to reduce congestion. */ clock_time_t expiration_time = RPL_DAO_DELAY / 2 + (random_rand() % (RPL_DAO_DELAY)); - /* Increment next seqno */ - RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_curr_seqno); - ctimer_set(&curr_instance.dag.dao_timer, expiration_time, handle_dao_timer, NULL); + ctimer_set(&curr_instance.dag.dao_timer, expiration_time, send_new_dao, NULL); } } /*---------------------------------------------------------------------------*/ static void -handle_dao_timer(void *ptr) +send_new_dao(void *ptr) { #if RPL_WITH_DAO_ACK - if(rpl_lollipop_greater_than(curr_instance.dag.dao_curr_seqno, - curr_instance.dag.dao_last_seqno)) { - /* We are sending a new DAO here. Prepare retransmissions */ - curr_instance.dag.dao_transmissions = 0; - } else { - /* We are called for the same DAO again */ - if(curr_instance.dag.dao_last_acked_seqno == curr_instance.dag.dao_last_seqno) { - /* The last seqno sent is ACKed! Schedule refresh to avoid route expiration */ - schedule_dao_refresh(); - return; - } - /* We need to re-send the last DAO */ - if(curr_instance.dag.dao_transmissions >= RPL_DAO_MAX_RETRANSMISSIONS) { - /* No more retransmissions. Perform local repair and hope to find another . */ - rpl_local_repair("DAO max rtx"); - return; - } - } - /* Increment transmission counter before sending */ - curr_instance.dag.dao_transmissions++; + /* We are sending a new DAO here. Prepare retransmissions */ + curr_instance.dag.dao_transmissions = 1; /* Schedule next retransmission */ schedule_dao_retransmission(); #else /* RPL_WITH_DAO_ACK */ @@ -299,19 +279,14 @@ handle_dao_timer(void *ptr) curr_instance.dag.state = DAG_REACHABLE; } rpl_timers_dio_reset("Reachable"); -#endif /* !RPL_WITH_DAO_ACK */ - - curr_instance.dag.dao_last_seqno = curr_instance.dag.dao_curr_seqno; - /* Send a DAO with own prefix as target and default lifetime */ - rpl_icmp6_dao_output(curr_instance.default_lifetime); - -#if !RPL_WITH_DAO_ACK - /* There is no DAO-ACK, schedule a refresh. Must be done after rpl_icmp6_dao_output, - because we increment curr_instance.dag.dao_curr_seqno for the next DAO (refresh). - Where there is DAO-ACK, the refresh is scheduled after reception of the ACK. - Happens when handle_dao_timer is called again next. */ + /* There is no DAO-ACK, schedule a refresh. */ schedule_dao_refresh(); #endif /* !RPL_WITH_DAO_ACK */ + + /* Increment seqno */ + RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_last_seqno); + /* Send a DAO with own prefix as target and default lifetime */ + rpl_icmp6_dao_output(curr_instance.default_lifetime); } #if RPL_WITH_DAO_ACK /*---------------------------------------------------------------------------*/ @@ -334,6 +309,32 @@ handle_dao_ack_timer(void *ptr) rpl_icmp6_dao_ack_output(&curr_instance.dag.dao_ack_target, curr_instance.dag.dao_ack_sequence, RPL_DAO_ACK_UNCONDITIONAL_ACCEPT); } +/*---------------------------------------------------------------------------*/ +void +rpl_timers_notify_dao_ack(void) +{ + /* The last DAO was ACKed. Schedule refresh to avoid route expiration. This + implicitly de-schedules resend_dao, as both share curr_instance.dag.dao_timer */ + schedule_dao_refresh(); +} +/*---------------------------------------------------------------------------*/ +static void +resend_dao(void *ptr) +{ + /* Increment transmission counter before sending */ + curr_instance.dag.dao_transmissions++; + /* Send a DAO with own prefix as target and default lifetime */ + rpl_icmp6_dao_output(curr_instance.default_lifetime); + + /* Schedule next retransmission, or abort */ + if(curr_instance.dag.dao_transmissions < RPL_DAO_MAX_RETRANSMISSIONS) { + schedule_dao_retransmission(); + } else { + /* No more retransmissions. Perform local repair. */ + rpl_local_repair("DAO max rtx"); + return; + } +} #endif /* RPL_WITH_DAO_ACK */ /*---------------------------------------------------------------------------*/ /*------------------------------- Probing----------------------------------- */ diff --git a/os/net/routing/rpl-lite/rpl-timers.h b/os/net/routing/rpl-lite/rpl-timers.h index e153858fc..5d9498b97 100644 --- a/os/net/routing/rpl-lite/rpl-timers.h +++ b/os/net/routing/rpl-lite/rpl-timers.h @@ -99,6 +99,11 @@ void rpl_timers_schedule_dao(void); */ void rpl_timers_schedule_dao_ack(uip_ipaddr_t *target, uint16_t sequence); +/** + * Let the rpl-timers module know that the last DAO was ACKed +*/ +void rpl_timers_notify_dao_ack(void); + /** * Schedule probing with delay RPL_PROBING_DELAY_FUNC() */ diff --git a/os/net/routing/rpl-lite/rpl-types.h b/os/net/routing/rpl-lite/rpl-types.h index 16dfa057e..2c57bf664 100644 --- a/os/net/routing/rpl-lite/rpl-types.h +++ b/os/net/routing/rpl-lite/rpl-types.h @@ -198,7 +198,6 @@ struct rpl_dag { uint8_t dio_counter; /* internal trickle timer state: redundancy counter */ uint8_t dao_last_seqno; /* the node's last sent DAO seqno */ uint8_t dao_last_acked_seqno; /* the last seqno we got an ACK for */ - uint8_t dao_curr_seqno; /* the node's current DAO seqno (sent or to be sent) */ uint8_t dao_transmissions; /* the number of transmissions for the current DAO */ enum rpl_dag_state state; diff --git a/os/services/shell/shell-commands.c b/os/services/shell/shell-commands.c index 32827e4b3..0a48f7ce9 100644 --- a/os/services/shell/shell-commands.c +++ b/os/services/shell/shell-commands.c @@ -413,7 +413,8 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args)) PT_EXIT(pt); } } else { - uip_ip6addr(&prefix, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + const uip_ipaddr_t *default_prefix = uip_ds6_default_prefix(); + uip_ip6addr_copy(&prefix, default_prefix); } if(is_on) { diff --git a/tests/07-simulation-base/23-rpl-tsch-z1.csc b/tests/07-simulation-base/23-rpl-tsch-z1.csc index f5a182ecd..170300f55 100644 --- a/tests/07-simulation-base/23-rpl-tsch-z1.csc +++ b/tests/07-simulation-base/23-rpl-tsch-z1.csc @@ -7,7 +7,7 @@ [APPS_DIR]/powertracker RPL+TSCH (Z1) - 123456 + 1 1000000 org.contikios.cooja.radiomediums.UDGM @@ -108,20 +108,6 @@ z11 - - - - org.contikios.cooja.interfaces.Position - 10.622284947035123 - 109.81862399725188 - 0.0 - - - org.contikios.cooja.mspmote.interfaces.MspMoteID - 6 - - z11 - org.contikios.cooja.plugins.SimControl @@ -168,7 +154,6 @@ 2 3 4 - 5 diff --git a/tests/07-simulation-base/code-ipv6/receiver/udp-receiver.c b/tests/07-simulation-base/code-ipv6/receiver/udp-receiver.c index e84c57637..0a3b16b15 100644 --- a/tests/07-simulation-base/code-ipv6/receiver/udp-receiver.c +++ b/tests/07-simulation-base/code-ipv6/receiver/udp-receiver.c @@ -36,10 +36,13 @@ PROCESS_THREAD(udp_process, ev, data) static struct etimer send_timer; uip_ipaddr_t addr; static int alive; + const uip_ipaddr_t *default_prefix; PROCESS_BEGIN(); - uip_ip6addr(&addr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 2); + default_prefix = uip_ds6_default_prefix(); + uip_ip6addr_copy(&addr, default_prefix); + addr.u16[7] = UIP_HTONS(2); uip_ds6_addr_add(&addr, 0, ADDR_AUTOCONF); simple_udp_register(&broadcast_connection, UDP_PORT, diff --git a/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c b/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c index 4e2e664b3..e56daa342 100644 --- a/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c +++ b/tests/07-simulation-base/code-ipv6/sender/unicast-sender.c @@ -51,12 +51,15 @@ PROCESS_THREAD(udp_process, ev, data) etimer_set(&periodic_timer, SEND_INTERVAL); while(1) { + const uip_ipaddr_t *default_prefix; uint8_t buf[SIZE]; PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&periodic_timer)); etimer_reset(&periodic_timer); printf("Sending unicast\n"); - uip_ip6addr(&addr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 2); + default_prefix = uip_ds6_default_prefix(); + uip_ip6addr_copy(&addr, default_prefix); + addr.u16[7] = UIP_HTONS(2); simple_udp_sendto(&broadcast_connection, buf, sizeof(buf), &addr); } diff --git a/tests/09-ipv6/code/node.c b/tests/09-ipv6/code/node.c index f465e2642..a99261865 100644 --- a/tests/09-ipv6/code/node.c +++ b/tests/09-ipv6/code/node.c @@ -44,6 +44,7 @@ PROCESS_THREAD(node_process, ev, data) static struct etimer et; #if WITH_ULA static uip_ipaddr_t ipaddr; + const uip_ipaddr_t *default_prefix; #endif /* WITH_ULA */ #if WITH_TSCH @@ -60,7 +61,8 @@ PROCESS_THREAD(node_process, ev, data) #endif /* WITH_TSCH */ #if WITH_ULA - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + default_prefix = uip_ds6_default_prefix(); + uip_ip6addr_copy(&ipaddr, default_prefix); uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); diff --git a/tests/14-rpl-lite/code/receiver-node.c b/tests/14-rpl-lite/code/receiver-node.c index b5265d3f7..b5cd26a15 100644 --- a/tests/14-rpl-lite/code/receiver-node.c +++ b/tests/14-rpl-lite/code/receiver-node.c @@ -73,8 +73,9 @@ set_global_address(void) static uip_ipaddr_t ipaddr; int i; uint8_t state; + const uip_ipaddr_t *default_prefix = uip_ds6_default_prefix(); - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + uip_ip6addr_copy(&ipaddr, default_prefix); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); diff --git a/tests/14-rpl-lite/code/sender-node.c b/tests/14-rpl-lite/code/sender-node.c index 350758110..00bd6d5c5 100644 --- a/tests/14-rpl-lite/code/sender-node.c +++ b/tests/14-rpl-lite/code/sender-node.c @@ -71,8 +71,9 @@ set_global_address(void) uip_ipaddr_t ipaddr; int i; uint8_t state; + const uip_ipaddr_t *default_prefix = uip_ds6_default_prefix(); - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + uip_ip6addr_copy(&ipaddr, default_prefix); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); @@ -92,6 +93,7 @@ PROCESS_THREAD(sender_node_process, ev, data) static struct etimer periodic_timer; static struct etimer send_timer; uip_ipaddr_t addr; + const uip_ipaddr_t *default_prefix; PROCESS_BEGIN(); @@ -109,7 +111,13 @@ PROCESS_THREAD(sender_node_process, ev, data) PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer)); - uip_ip6addr(&addr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0x0201, 0x001, 0x001, 0x001); + default_prefix = uip_ds6_default_prefix(); + uip_ip6addr_copy(&addr, default_prefix); + + addr.u16[4] = UIP_HTONS(0x0201); + addr.u16[5] = UIP_HTONS(0x0001); + addr.u16[6] = UIP_HTONS(0x0001); + addr.u16[7] = UIP_HTONS(0x0001); { static unsigned int message_number; diff --git a/tests/15-rpl-classic/code/receiver-node.c b/tests/15-rpl-classic/code/receiver-node.c index 798aea84d..3854784d0 100644 --- a/tests/15-rpl-classic/code/receiver-node.c +++ b/tests/15-rpl-classic/code/receiver-node.c @@ -73,8 +73,9 @@ set_global_address(void) static uip_ipaddr_t ipaddr; int i; uint8_t state; + const uip_ipaddr_t *default_prefix = uip_ds6_default_prefix(); - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + uip_ip6addr_copy(&ipaddr, default_prefix); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); diff --git a/tests/15-rpl-classic/code/sender-node.c b/tests/15-rpl-classic/code/sender-node.c index 350758110..00bd6d5c5 100644 --- a/tests/15-rpl-classic/code/sender-node.c +++ b/tests/15-rpl-classic/code/sender-node.c @@ -71,8 +71,9 @@ set_global_address(void) uip_ipaddr_t ipaddr; int i; uint8_t state; + const uip_ipaddr_t *default_prefix = uip_ds6_default_prefix(); - uip_ip6addr(&ipaddr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0, 0, 0, 0); + uip_ip6addr_copy(&ipaddr, default_prefix); uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr); uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); @@ -92,6 +93,7 @@ PROCESS_THREAD(sender_node_process, ev, data) static struct etimer periodic_timer; static struct etimer send_timer; uip_ipaddr_t addr; + const uip_ipaddr_t *default_prefix; PROCESS_BEGIN(); @@ -109,7 +111,13 @@ PROCESS_THREAD(sender_node_process, ev, data) PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&send_timer)); - uip_ip6addr(&addr, UIP_DS6_DEFAULT_PREFIX, 0, 0, 0, 0x0201, 0x001, 0x001, 0x001); + default_prefix = uip_ds6_default_prefix(); + uip_ip6addr_copy(&addr, default_prefix); + + addr.u16[4] = UIP_HTONS(0x0201); + addr.u16[5] = UIP_HTONS(0x0001); + addr.u16[6] = UIP_HTONS(0x0001); + addr.u16[7] = UIP_HTONS(0x0001); { static unsigned int message_number;