diff --git a/sys/include/net/gnrc/rpl.h b/sys/include/net/gnrc/rpl.h index 845b4ddcec49486bae171fb504a7a9a01572ca24..7ca26b7e1e4faf1305d3f91d1bff85c10b3cdecd 100644 --- a/sys/include/net/gnrc/rpl.h +++ b/sys/include/net/gnrc/rpl.h @@ -455,37 +455,42 @@ void gnrc_rpl_send_DAO_ACK(gnrc_rpl_instance_t *instance, ipv6_addr_t *destinati * @brief Parse a DIS. * * @param[in] dis Pointer to the DIS message. + * @param[in] iface Interface PID of the incoming DIS. * @param[in] src Pointer to the source address of the IPv6 packet. * @param[in] dst Pointer to the destination address of the IPv6 packet. * @param[in] len Length of the IPv6 packet. */ -void gnrc_rpl_recv_DIS(gnrc_rpl_dis_t *dis, ipv6_addr_t *src, ipv6_addr_t *dst, uint16_t len); +void gnrc_rpl_recv_DIS(gnrc_rpl_dis_t *dis, kernel_pid_t iface, ipv6_addr_t *src, + ipv6_addr_t *dst, uint16_t len); /** * @brief Parse a DIO. * * @param[in] dio Pointer to the DIO message. + * @param[in] iface Interface PID of the incoming DIO. * @param[in] src Pointer to the source address of the IPv6 packet. * @param[in] len Length of the IPv6 packet. */ -void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, ipv6_addr_t *src, uint16_t len); +void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src, uint16_t len); /** * @brief Parse a DAO. * * @param[in] dao Pointer to the DAO message. + * @param[in] iface Interface PID of the incoming DIO. * @param[in] src Pointer to the source address of the IPv6 packet. * @param[in] len Length of the IPv6 packet. */ -void gnrc_rpl_recv_DAO(gnrc_rpl_dao_t *dao, ipv6_addr_t *src, uint16_t len); +void gnrc_rpl_recv_DAO(gnrc_rpl_dao_t *dao, kernel_pid_t iface, ipv6_addr_t *src, uint16_t len); /** * @brief Parse a DAO-ACK. * * @param[in] dao_ack Pointer to the DAO-ACK message. + * @param[in] iface Interface PID of the incoming DIO. * @param[in] len Length of the IPv6 packet. */ -void gnrc_rpl_recv_DAO_ACK(gnrc_rpl_dao_ack_t *dao_ack, uint16_t len); +void gnrc_rpl_recv_DAO_ACK(gnrc_rpl_dao_ack_t *dao_ack, kernel_pid_t iface, uint16_t len); /** * @brief Delay the DAO sending interval @@ -518,11 +523,13 @@ gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_ * @brief Send a control message * * @param[in] pkt gnrc_pktnsip_t to send + * @param[in] iface Interface PID to send this pkt to * @param[in] src Source address of the packet * @param[in] dst Destination address of the packet * @param[in] dodag_id Id of the DODAG */ -void gnrc_rpl_send(gnrc_pktsnip_t *pkt, ipv6_addr_t *src, ipv6_addr_t *dst, ipv6_addr_t *dodag_id); +void gnrc_rpl_send(gnrc_pktsnip_t *pkt, kernel_pid_t iface, ipv6_addr_t *src, ipv6_addr_t *dst, + ipv6_addr_t *dodag_id); /** * @brief Generate a local or global instance id diff --git a/sys/include/net/gnrc/rpl/dodag.h b/sys/include/net/gnrc/rpl/dodag.h index db84de3c479c72937c8df8d51f72f49654f78d33..3621cacd7f0792fc36ecd3e6ac26b4967e5f4414 100644 --- a/sys/include/net/gnrc/rpl/dodag.h +++ b/sys/include/net/gnrc/rpl/dodag.h @@ -102,11 +102,12 @@ gnrc_rpl_instance_t *gnrc_rpl_instance_get(uint8_t instance_id); * * @param[in] instance Pointer to the instance to add the DODAG to * @param[in] dodag_id The DODAG-ID of the new DODAG + * @param[in] iface Interface PID where the DODAG operates * * @return true, if DODAG could be created. * @return false, if DODAG could not be created or exists already. */ -bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id); +bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, kernel_pid_t iface); /** * @brief Remove all parents from the @p dodag. diff --git a/sys/include/net/gnrc/rpl/structs.h b/sys/include/net/gnrc/rpl/structs.h index 73ed19d783f2edf3bb6c3ec1b4316d6b3465b9cd..325db5b64d13dc07c62e71594ee869af310a65e8 100644 --- a/sys/include/net/gnrc/rpl/structs.h +++ b/sys/include/net/gnrc/rpl/structs.h @@ -224,6 +224,7 @@ struct gnrc_rpl_dodag { uint8_t dio_redun; /**< trickle k parameter */ uint8_t default_lifetime; /**< lifetime of routes (lifetime * unit) */ uint16_t lifetime_unit; /**< unit in seconds of the lifetime */ + kernel_pid_t iface; /**< interface PID this DODAG operates on */ uint8_t version; /**< version of this DODAG */ uint8_t grounded; /**< grounded flag */ uint16_t my_rank; /**< rank/position in the DODAG */ diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl.c b/sys/net/gnrc/routing/rpl/gnrc_rpl.c index 52aa7d17a24998b23ef58f5687f00de9231190dc..8da5ee211649a9cd5eb55c9c1682739bfdf5bc4c 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl.c @@ -117,37 +117,45 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_ static void _receive(gnrc_pktsnip_t *icmpv6) { - gnrc_pktsnip_t *ipv6 = NULL; - ipv6_hdr_t *ipv6_hdr = NULL; - icmpv6_hdr_t *icmpv6_hdr = NULL; + gnrc_pktsnip_t *ipv6, *netif; + ipv6_hdr_t *ipv6_hdr; + icmpv6_hdr_t *icmpv6_hdr; + kernel_pid_t iface = KERNEL_PID_UNDEF; + + assert(icmpv6 != NULL); ipv6 = gnrc_pktsnip_search_type(icmpv6, GNRC_NETTYPE_IPV6); + netif = gnrc_pktsnip_search_type(icmpv6, GNRC_NETTYPE_NETIF); assert(ipv6 != NULL); + if (netif) { + iface = ((gnrc_netif_hdr_t *)netif->data)->if_pid; + } + ipv6_hdr = (ipv6_hdr_t *)ipv6->data; icmpv6_hdr = (icmpv6_hdr_t *)icmpv6->data; switch (icmpv6_hdr->code) { case GNRC_RPL_ICMPV6_CODE_DIS: DEBUG("RPL: DIS received\n"); - gnrc_rpl_recv_DIS((gnrc_rpl_dis_t *)(icmpv6_hdr + 1), &ipv6_hdr->src, &ipv6_hdr->dst, - byteorder_ntohs(ipv6_hdr->len)); + gnrc_rpl_recv_DIS((gnrc_rpl_dis_t *)(icmpv6_hdr + 1), iface, &ipv6_hdr->src, + &ipv6_hdr->dst, byteorder_ntohs(ipv6_hdr->len)); break; case GNRC_RPL_ICMPV6_CODE_DIO: DEBUG("RPL: DIO received\n"); - gnrc_rpl_recv_DIO((gnrc_rpl_dio_t *)(icmpv6_hdr + 1), &ipv6_hdr->src, - byteorder_ntohs(ipv6_hdr->len)); + gnrc_rpl_recv_DIO((gnrc_rpl_dio_t *)(icmpv6_hdr + 1), iface, &ipv6_hdr->src, + byteorder_ntohs(ipv6_hdr->len)); break; case GNRC_RPL_ICMPV6_CODE_DAO: DEBUG("RPL: DAO received\n"); - gnrc_rpl_recv_DAO((gnrc_rpl_dao_t *)(icmpv6_hdr + 1), &ipv6_hdr->src, - byteorder_ntohs(ipv6_hdr->len)); + gnrc_rpl_recv_DAO((gnrc_rpl_dao_t *)(icmpv6_hdr + 1), iface, &ipv6_hdr->src, + byteorder_ntohs(ipv6_hdr->len)); break; case GNRC_RPL_ICMPV6_CODE_DAO_ACK: DEBUG("RPL: DAO-ACK received\n"); - gnrc_rpl_recv_DAO_ACK((gnrc_rpl_dao_ack_t *)(icmpv6_hdr + 1), - byteorder_ntohs(ipv6_hdr->len)); + gnrc_rpl_recv_DAO_ACK((gnrc_rpl_dao_ack_t *)(icmpv6_hdr + 1), iface, + byteorder_ntohs(ipv6_hdr->len)); break; default: DEBUG("RPL: Unknown ICMPV6 code received\n"); 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 fbe7a885f8341b555cdbc3cdf5f5bbd8f2b82db8..a47ba29db6de3c4bf69a1df3208da869418c7058 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c @@ -47,16 +47,19 @@ static char addr_str[IPV6_ADDR_MAX_STR_LEN]; #define GNRC_RPL_DAO_K_BIT (1 << 7) #define GNRC_RPL_DAO_ACK_D_BIT (1 << 7) -void gnrc_rpl_send(gnrc_pktsnip_t *pkt, ipv6_addr_t *src, ipv6_addr_t *dst, ipv6_addr_t *dodag_id) +void gnrc_rpl_send(gnrc_pktsnip_t *pkt, kernel_pid_t iface, ipv6_addr_t *src, ipv6_addr_t *dst, + ipv6_addr_t *dodag_id) { - (void) dodag_id; + (void)dodag_id; gnrc_pktsnip_t *hdr; ipv6_addr_t ll_addr; - kernel_pid_t iface = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes); if (iface == KERNEL_PID_UNDEF) { - DEBUG("RPL: no suitable interface found for this destination address\n"); - gnrc_pktbuf_release(pkt); - return; + if ((iface = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes)) + == KERNEL_PID_UNDEF) { + DEBUG("RPL: no suitable interface found for this destination address\n"); + gnrc_pktbuf_release(pkt); + return; + } } if (src == NULL) { @@ -83,11 +86,16 @@ void gnrc_rpl_send(gnrc_pktsnip_t *pkt, ipv6_addr_t *src, ipv6_addr_t *dst, ipv6 return; } - if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_IPV6, GNRC_NETREG_DEMUX_CTX_ALL,hdr)) { + pkt = hdr; + + hdr = gnrc_netif_hdr_build(NULL, 0, NULL, 0); + ((gnrc_netif_hdr_t *)hdr->data)->if_pid = iface; + LL_PREPEND(pkt, hdr); + + if (!gnrc_netapi_dispatch_send(GNRC_NETTYPE_IPV6, GNRC_NETREG_DEMUX_CTX_ALL, pkt)) { DEBUG("RPL: cannot send packet: no subscribers found.\n"); - gnrc_pktbuf_release(hdr); + gnrc_pktbuf_release(pkt); } - } gnrc_pktsnip_t *_dio_dodag_conf_build(gnrc_pktsnip_t *pkt, gnrc_rpl_dodag_t *dodag) @@ -196,7 +204,7 @@ void gnrc_rpl_send_DIO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination) } pkt = tmp; - gnrc_rpl_send(pkt, NULL, destination, &dodag->dodag_id); + gnrc_rpl_send(pkt, dodag->iface, NULL, destination, &dodag->dodag_id); } void gnrc_rpl_send_DIS(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination) @@ -227,7 +235,7 @@ void gnrc_rpl_send_DIS(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination) /* TODO add padding may be removed if packet size grows */ memcpy((dis + 1), padding, sizeof(padding)); - gnrc_rpl_send(pkt, NULL, destination, (inst? &(inst->dodag.dodag_id) : NULL)); + gnrc_rpl_send(pkt, KERNEL_PID_UNDEF, NULL, destination, (inst? &(inst->dodag.dodag_id) : NULL)); } static bool _gnrc_rpl_check_DIS_validity(gnrc_rpl_dis_t *dis, uint16_t len) @@ -243,11 +251,11 @@ static bool _gnrc_rpl_check_DIS_validity(gnrc_rpl_dis_t *dis, uint16_t len) return false; } -void gnrc_rpl_recv_DIS(gnrc_rpl_dis_t *dis, ipv6_addr_t *src, ipv6_addr_t *dst, uint16_t len) +void gnrc_rpl_recv_DIS(gnrc_rpl_dis_t *dis, kernel_pid_t iface, ipv6_addr_t *src, + ipv6_addr_t *dst, uint16_t len) { /* TODO handle Solicited Information Option */ - (void) dis; - (void) len; + (void)iface; if (!_gnrc_rpl_check_DIS_validity(dis, len)) { return; @@ -366,7 +374,6 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt gnrc_rpl_opt_target_t *first_target = NULL; gnrc_rpl_dodag_t *dodag = &inst->dodag; eui64_t iid; - kernel_pid_t if_id = KERNEL_PID_UNDEF; *included_opts = 0; if (!_gnrc_rpl_check_options_validity(msg_type, inst, opt, len)) { @@ -419,26 +426,19 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO; #endif gnrc_rpl_opt_prefix_info_t *pi = (gnrc_rpl_opt_prefix_info_t *) opt; - if_id = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes); /* check for the auto address-configuration flag */ - if ((gnrc_netapi_get(if_id, NETOPT_IPV6_IID, 0, &iid, sizeof(eui64_t)) < 0) && - !(pi->LAR_flags & GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT)) { + if ((gnrc_netapi_get(dodag->iface, NETOPT_IPV6_IID, 0, &iid, sizeof(eui64_t)) < 0) + && !(pi->LAR_flags & GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT)) { break; } ipv6_addr_set_aiid(&pi->prefix, iid.uint8); - gnrc_ipv6_netif_add_addr(if_id, &pi->prefix, pi->prefix_len, 0); + gnrc_ipv6_netif_add_addr(dodag->iface, &pi->prefix, pi->prefix_len, 0); break; case (GNRC_RPL_OPT_TARGET): DEBUG("RPL: RPL TARGET DAO option parsed\n"); *included_opts |= ((uint32_t) 1) << GNRC_RPL_OPT_TARGET; - ipv6_addr_t *prefix = NULL; - if_id = gnrc_ipv6_netif_find_by_prefix(&prefix, &dodag->dodag_id); - if (if_id == KERNEL_PID_UNDEF) { - DEBUG("RPL: no interface found for the configured DODAG id\n"); - return false; - } gnrc_rpl_opt_target_t *target = (gnrc_rpl_opt_target_t *) opt; if (first_target == NULL) { @@ -456,7 +456,7 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt target->prefix_length, fib_dst_flags); - fib_add_entry(&gnrc_ipv6_fib_table, if_id, target->target.u8, + fib_add_entry(&gnrc_ipv6_fib_table, dodag->iface, target->target.u8, sizeof(ipv6_addr_t), fib_dst_flags, src->u8, sizeof(ipv6_addr_t), FIB_FLAG_RPL_ROUTE, (dodag->default_lifetime * dodag->lifetime_unit) * @@ -514,7 +514,7 @@ static bool _gnrc_rpl_check_DIO_validity(gnrc_rpl_dio_t *dio, uint16_t len) return false; } -void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, ipv6_addr_t *src, uint16_t len) +void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src, uint16_t len) { gnrc_rpl_instance_t *inst = NULL; gnrc_rpl_dodag_t *dodag = NULL; @@ -536,7 +536,13 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, ipv6_addr_t *src, uint16_t len) inst->mop = (dio->g_mop_prf >> GNRC_RPL_MOP_SHIFT) & GNRC_RPL_SHIFTED_MOP_MASK; inst->of = gnrc_rpl_get_of_for_ocp(GNRC_RPL_DEFAULT_OCP); - gnrc_rpl_dodag_init(inst, &dio->dodag_id); + + if (iface == KERNEL_PID_UNDEF) { + iface = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes); + assert(iface != KERNEL_PID_UNDEF); + } + + gnrc_rpl_dodag_init(inst, &dio->dodag_id, iface); dodag = &inst->dodag; @@ -870,7 +876,7 @@ void gnrc_rpl_send_DAO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination, uint } pkt = tmp; - gnrc_rpl_send(pkt, NULL, destination, &dodag->dodag_id); + gnrc_rpl_send(pkt, dodag->iface, NULL, destination, &dodag->dodag_id); GNRC_RPL_COUNTER_INCREMENT(dodag->dao_seq); } @@ -917,7 +923,7 @@ void gnrc_rpl_send_DAO_ACK(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination, dao_ack->dao_sequence = seq; dao_ack->status = 0; - gnrc_rpl_send(pkt, NULL, destination, &dodag->dodag_id); + gnrc_rpl_send(pkt, dodag->iface, NULL, destination, &dodag->dodag_id); } static bool _gnrc_rpl_check_DAO_validity(gnrc_rpl_dao_t *dao, uint16_t len) @@ -937,8 +943,10 @@ static bool _gnrc_rpl_check_DAO_validity(gnrc_rpl_dao_t *dao, uint16_t len) return false; } -void gnrc_rpl_recv_DAO(gnrc_rpl_dao_t *dao, ipv6_addr_t *src, uint16_t len) +void gnrc_rpl_recv_DAO(gnrc_rpl_dao_t *dao, kernel_pid_t iface, ipv6_addr_t *src, uint16_t len) { + (void)iface; + gnrc_rpl_instance_t *inst = NULL; gnrc_rpl_dodag_t *dodag = NULL; @@ -1004,8 +1012,10 @@ static bool _gnrc_rpl_check_DAO_ACK_validity(gnrc_rpl_dao_ack_t *dao_ack, uint16 return false; } -void gnrc_rpl_recv_DAO_ACK(gnrc_rpl_dao_ack_t *dao_ack, uint16_t len) +void gnrc_rpl_recv_DAO_ACK(gnrc_rpl_dao_ack_t *dao_ack, kernel_pid_t iface, uint16_t len) { + (void)iface; + gnrc_rpl_instance_t *inst = NULL; gnrc_rpl_dodag_t *dodag = NULL; diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c index c04b43f84d05ea39e81fd27b4f8a4954448e334f..f827659e4c0ebb72510167fe204201936fe65309 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c @@ -113,7 +113,7 @@ gnrc_rpl_instance_t *gnrc_rpl_instance_get(uint8_t instance_id) return NULL; } -bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id) +bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id, kernel_pid_t iface) { gnrc_rpl_dodag_t *dodag = NULL; @@ -142,6 +142,7 @@ bool gnrc_rpl_dodag_init(gnrc_rpl_instance_t *instance, ipv6_addr_t *dodag_id) dodag->dao_ack_received = false; dodag->dao_counter = 0; dodag->instance = instance; + dodag->iface = iface; return true; } @@ -230,18 +231,15 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent) if (parent != NULL) { parent->lifetime = (now / SEC_IN_USEC) + ((dodag->default_lifetime * dodag->lifetime_unit)); if (parent == dodag->parents) { - kernel_pid_t if_id; - if ((if_id = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes)) != KERNEL_PID_UNDEF) { - fib_add_entry(&gnrc_ipv6_fib_table, - if_id, - (uint8_t *) ipv6_addr_unspecified.u8, - sizeof(ipv6_addr_t), - FIB_FLAG_NET_PREFIX, - parent->addr.u8, - sizeof(ipv6_addr_t), - FIB_FLAG_RPL_ROUTE, - (dodag->default_lifetime * dodag->lifetime_unit) * SEC_IN_MS); - } + fib_add_entry(&gnrc_ipv6_fib_table, + dodag->iface, + (uint8_t *) ipv6_addr_unspecified.u8, + sizeof(ipv6_addr_t), + FIB_FLAG_NET_PREFIX, + parent->addr.u8, + sizeof(ipv6_addr_t), + FIB_FLAG_RPL_ROUTE, + (dodag->default_lifetime * dodag->lifetime_unit) * SEC_IN_MS); } } @@ -268,7 +266,6 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda gnrc_rpl_parent_t *new_best = old_best; uint16_t old_rank = dodag->my_rank; gnrc_rpl_parent_t *elt, *tmp; - kernel_pid_t if_id; if (dodag->parents == NULL) { return NULL; @@ -290,15 +287,8 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda gnrc_rpl_delay_dao(dodag); } - if_id = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes); - - if (if_id == KERNEL_PID_UNDEF) { - DEBUG("RPL: no interface found for the parent address\n"); - return NULL; - } - fib_add_entry(&gnrc_ipv6_fib_table, - if_id, + dodag->iface, (uint8_t *) ipv6_addr_unspecified.u8, sizeof(ipv6_addr_t), FIB_FLAG_NET_PREFIX, @@ -335,6 +325,7 @@ gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_ gnrc_ipv6_netif_addr_t *netif_addr = NULL; gnrc_rpl_instance_t *inst = NULL; gnrc_rpl_dodag_t *dodag = NULL; + kernel_pid_t iface; if (!(ipv6_addr_is_global(dodag_id) || ipv6_addr_is_unique_local_unicast(dodag_id))) { DEBUG("RPL: dodag id (%s) must be a global or unique local IPv6 address\n", @@ -342,7 +333,7 @@ gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_ return NULL; } - if (gnrc_ipv6_netif_find_by_addr(&configured_addr, dodag_id) == KERNEL_PID_UNDEF) { + if ((iface = gnrc_ipv6_netif_find_by_addr(&configured_addr, dodag_id)) == KERNEL_PID_UNDEF) { DEBUG("RPL: no IPv6 address configured to match the given dodag id: %s\n", ipv6_addr_to_str(addr_str, dodag_id, sizeof(addr_str))); return NULL; @@ -369,7 +360,7 @@ gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_ return NULL; } - if (!gnrc_rpl_dodag_init(inst, dodag_id)) { + if (!gnrc_rpl_dodag_init(inst, dodag_id, iface)) { DEBUG("RPL: could not initialize DODAG"); return NULL; } diff --git a/sys/shell/commands/sc_gnrc_rpl.c b/sys/shell/commands/sc_gnrc_rpl.c index 244c931387ce66e1939eb0f205f4ae0d6ae04b29..33252d500a15f428ca8db4d92eb9a50bd906376d 100644 --- a/sys/shell/commands/sc_gnrc_rpl.c +++ b/sys/shell/commands/sc_gnrc_rpl.c @@ -185,12 +185,14 @@ int _gnrc_rpl_dodag_show(void) if (gnrc_rpl_instances[i].state == 0) { continue; } - printf("instance [%d | mop: %d | ocp: %d | mhri: %d | mri %d]\n", gnrc_rpl_instances[i].id, - gnrc_rpl_instances[i].mop, gnrc_rpl_instances[i].of->ocp, - gnrc_rpl_instances[i].min_hop_rank_inc, gnrc_rpl_instances[i].max_rank_inc); dodag = &gnrc_rpl_instances[i].dodag; + printf("instance [%d | Iface: %" PRIkernel_pid " | mop: %d | ocp: %d | mhri: %d | mri %d]\n", + gnrc_rpl_instances[i].id, dodag->iface, + gnrc_rpl_instances[i].mop, gnrc_rpl_instances[i].of->ocp, + gnrc_rpl_instances[i].min_hop_rank_inc, gnrc_rpl_instances[i].max_rank_inc); + tc = (((uint64_t) dodag->trickle.msg_callback_timer.long_target << 32) | dodag->trickle.msg_callback_timer.target) - xnow; tc = (int64_t) tc < 0 ? 0 : tc / SEC_IN_USEC;