gnrc_rpl: minor fixes and enhancements
This commit is contained in:
parent
5b5810ab7b
commit
fc75ff9b29
@ -385,6 +385,11 @@ static inline bool GNRC_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
|
|||||||
*/
|
*/
|
||||||
extern kernel_pid_t gnrc_rpl_pid;
|
extern kernel_pid_t gnrc_rpl_pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief @see @ref GNRC_RPL_ALL_NODES_ADDR
|
||||||
|
*/
|
||||||
|
extern const ipv6_addr_t ipv6_addr_all_rpl_nodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialization of the RPL thread.
|
* @brief Initialization of the RPL thread.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
static char _stack[GNRC_RPL_STACK_SIZE];
|
static char _stack[GNRC_RPL_STACK_SIZE];
|
||||||
kernel_pid_t gnrc_rpl_pid = KERNEL_PID_UNDEF;
|
kernel_pid_t gnrc_rpl_pid = KERNEL_PID_UNDEF;
|
||||||
|
const ipv6_addr_t ipv6_addr_all_rpl_nodes = GNRC_RPL_ALL_NODES_ADDR;
|
||||||
static uint32_t _lt_time = GNRC_RPL_LIFETIME_UPDATE_STEP * SEC_IN_USEC;
|
static uint32_t _lt_time = GNRC_RPL_LIFETIME_UPDATE_STEP * SEC_IN_USEC;
|
||||||
static xtimer_t _lt_timer;
|
static xtimer_t _lt_timer;
|
||||||
static msg_t _lt_msg = { .type = GNRC_RPL_MSG_TYPE_LIFETIME_UPDATE };
|
static msg_t _lt_msg = { .type = GNRC_RPL_MSG_TYPE_LIFETIME_UPDATE };
|
||||||
@ -68,10 +69,9 @@ kernel_pid_t gnrc_rpl_init(kernel_pid_t if_pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* register all_RPL_nodes multicast address */
|
/* register all_RPL_nodes multicast address */
|
||||||
ipv6_addr_t all_RPL_nodes = GNRC_RPL_ALL_NODES_ADDR;
|
gnrc_ipv6_netif_add_addr(if_pid, &ipv6_addr_all_rpl_nodes, IPV6_ADDR_BIT_LEN, 0);
|
||||||
gnrc_ipv6_netif_add_addr(if_pid, &all_RPL_nodes, IPV6_ADDR_BIT_LEN, 0);
|
|
||||||
|
|
||||||
gnrc_rpl_send_DIS(NULL, &all_RPL_nodes);
|
gnrc_rpl_send_DIS(NULL, (ipv6_addr_t *) &ipv6_addr_all_rpl_nodes);
|
||||||
return gnrc_rpl_pid;
|
return gnrc_rpl_pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,8 +51,8 @@ void gnrc_rpl_send(gnrc_pktsnip_t *pkt, ipv6_addr_t *src, ipv6_addr_t *dst, ipv6
|
|||||||
{
|
{
|
||||||
(void) dodag_id;
|
(void) dodag_id;
|
||||||
gnrc_pktsnip_t *hdr;
|
gnrc_pktsnip_t *hdr;
|
||||||
ipv6_addr_t all_RPL_nodes = GNRC_RPL_ALL_NODES_ADDR, ll_addr;
|
ipv6_addr_t ll_addr;
|
||||||
kernel_pid_t iface = gnrc_ipv6_netif_find_by_addr(NULL, &all_RPL_nodes);
|
kernel_pid_t iface = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes);
|
||||||
if (iface == KERNEL_PID_UNDEF) {
|
if (iface == KERNEL_PID_UNDEF) {
|
||||||
DEBUG("RPL: no suitable interface found for this destination address\n");
|
DEBUG("RPL: no suitable interface found for this destination address\n");
|
||||||
gnrc_pktbuf_release(pkt);
|
gnrc_pktbuf_release(pkt);
|
||||||
@ -71,11 +71,11 @@ void gnrc_rpl_send(gnrc_pktsnip_t *pkt, ipv6_addr_t *src, ipv6_addr_t *dst, ipv6
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dst == NULL) {
|
if (dst == NULL) {
|
||||||
dst = &all_RPL_nodes;
|
dst = (ipv6_addr_t *) &ipv6_addr_all_rpl_nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
hdr = gnrc_ipv6_hdr_build(pkt, (uint8_t *)src, sizeof(ipv6_addr_t), (uint8_t *)dst,
|
hdr = gnrc_ipv6_hdr_build(pkt, (uint8_t *)src, sizeof(ipv6_addr_t), (uint8_t *)dst,
|
||||||
sizeof(ipv6_addr_t));
|
sizeof(ipv6_addr_t));
|
||||||
|
|
||||||
if (hdr == NULL) {
|
if (hdr == NULL) {
|
||||||
DEBUG("RPL: Send - no space left in packet buffer\n");
|
DEBUG("RPL: Send - no space left in packet buffer\n");
|
||||||
@ -151,7 +151,7 @@ void gnrc_rpl_send_DIO(gnrc_rpl_instance_t *inst, ipv6_addr_t *destination)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gnrc_rpl_dodag_t *dodag = &inst->dodag;
|
gnrc_rpl_dodag_t *dodag = &inst->dodag;
|
||||||
gnrc_pktsnip_t *pkt = NULL, *tmp = NULL;
|
gnrc_pktsnip_t *pkt = NULL, *tmp;
|
||||||
gnrc_rpl_dio_t *dio;
|
gnrc_rpl_dio_t *dio;
|
||||||
|
|
||||||
#ifndef GNRC_RPL_WITHOUT_PIO
|
#ifndef GNRC_RPL_WITHOUT_PIO
|
||||||
@ -419,8 +419,7 @@ 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;
|
dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO;
|
||||||
#endif
|
#endif
|
||||||
gnrc_rpl_opt_prefix_info_t *pi = (gnrc_rpl_opt_prefix_info_t *) opt;
|
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, &ipv6_addr_all_rpl_nodes);
|
||||||
if_id = gnrc_ipv6_netif_find_by_addr(NULL, &all_RPL_nodes);
|
|
||||||
/* check for the auto address-configuration flag */
|
/* check for the auto address-configuration flag */
|
||||||
if ((gnrc_netapi_get(if_id, NETOPT_IPV6_IID, 0, &iid, sizeof(eui64_t)) < 0) &&
|
if ((gnrc_netapi_get(if_id, NETOPT_IPV6_IID, 0, &iid, sizeof(eui64_t)) < 0) &&
|
||||||
!(pi->LAR_flags & GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT)) {
|
!(pi->LAR_flags & GNRC_RPL_PREFIX_AUTO_ADDRESS_BIT)) {
|
||||||
@ -469,8 +468,8 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
|
|||||||
*included_opts |= ((uint32_t) 1) << GNRC_RPL_OPT_TRANSIT;
|
*included_opts |= ((uint32_t) 1) << GNRC_RPL_OPT_TRANSIT;
|
||||||
gnrc_rpl_opt_transit_t *transit = (gnrc_rpl_opt_transit_t *) opt;
|
gnrc_rpl_opt_transit_t *transit = (gnrc_rpl_opt_transit_t *) opt;
|
||||||
if (first_target == NULL) {
|
if (first_target == NULL) {
|
||||||
DEBUG("RPL: Encountered a RPL TRANSIT DAO option without \
|
DEBUG("RPL: Encountered a RPL TRANSIT DAO option without "
|
||||||
a preceding RPL TARGET DAO option\n");
|
"a preceding RPL TARGET DAO option\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,7 +559,7 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, ipv6_addr_t *src, uint16_t len)
|
|||||||
|
|
||||||
uint32_t included_opts = 0;
|
uint32_t included_opts = 0;
|
||||||
if(!_parse_options(GNRC_RPL_ICMPV6_CODE_DIO, inst, (gnrc_rpl_opt_t *)(dio + 1), len,
|
if(!_parse_options(GNRC_RPL_ICMPV6_CODE_DIO, inst, (gnrc_rpl_opt_t *)(dio + 1), len,
|
||||||
NULL, &included_opts)) {
|
src, &included_opts)) {
|
||||||
DEBUG("RPL: Error encountered during DIO option parsing - remove DODAG\n");
|
DEBUG("RPL: Error encountered during DIO option parsing - remove DODAG\n");
|
||||||
gnrc_rpl_instance_remove(inst);
|
gnrc_rpl_instance_remove(inst);
|
||||||
return;
|
return;
|
||||||
@ -670,7 +669,7 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, ipv6_addr_t *src, uint16_t len)
|
|||||||
dodag->prf = dio->g_mop_prf & GNRC_RPL_PRF_MASK;
|
dodag->prf = dio->g_mop_prf & GNRC_RPL_PRF_MASK;
|
||||||
uint32_t included_opts = 0;
|
uint32_t included_opts = 0;
|
||||||
if(!_parse_options(GNRC_RPL_ICMPV6_CODE_DIO, inst, (gnrc_rpl_opt_t *)(dio + 1), len,
|
if(!_parse_options(GNRC_RPL_ICMPV6_CODE_DIO, inst, (gnrc_rpl_opt_t *)(dio + 1), len,
|
||||||
NULL, &included_opts)) {
|
src, &included_opts)) {
|
||||||
DEBUG("RPL: Error encountered during DIO option parsing - remove DODAG\n");
|
DEBUG("RPL: Error encountered during DIO option parsing - remove DODAG\n");
|
||||||
gnrc_rpl_instance_remove(inst);
|
gnrc_rpl_instance_remove(inst);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -39,7 +39,6 @@ static void _rpl_trickle_send_dio(void *args)
|
|||||||
{
|
{
|
||||||
gnrc_rpl_instance_t *inst = (gnrc_rpl_instance_t *) args;
|
gnrc_rpl_instance_t *inst = (gnrc_rpl_instance_t *) args;
|
||||||
gnrc_rpl_dodag_t *dodag = &inst->dodag;
|
gnrc_rpl_dodag_t *dodag = &inst->dodag;
|
||||||
ipv6_addr_t all_RPL_nodes = GNRC_RPL_ALL_NODES_ADDR;
|
|
||||||
|
|
||||||
/* a leaf node does not send DIOs periodically */
|
/* a leaf node does not send DIOs periodically */
|
||||||
if (dodag->node_status == GNRC_RPL_LEAF_NODE) {
|
if (dodag->node_status == GNRC_RPL_LEAF_NODE) {
|
||||||
@ -47,7 +46,7 @@ static void _rpl_trickle_send_dio(void *args)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gnrc_rpl_send_DIO(inst, &all_RPL_nodes);
|
gnrc_rpl_send_DIO(inst, (ipv6_addr_t *) &ipv6_addr_all_rpl_nodes);
|
||||||
DEBUG("trickle callback: Instance (%d) | DODAG: (%s)\n", inst->id,
|
DEBUG("trickle callback: Instance (%d) | DODAG: (%s)\n", inst->id,
|
||||||
ipv6_addr_to_str(addr_str,&dodag->dodag_id, sizeof(addr_str)));
|
ipv6_addr_to_str(addr_str,&dodag->dodag_id, sizeof(addr_str)));
|
||||||
}
|
}
|
||||||
@ -231,14 +230,13 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent)
|
|||||||
if (parent != NULL) {
|
if (parent != NULL) {
|
||||||
parent->lifetime = (now / SEC_IN_USEC) + ((dodag->default_lifetime * dodag->lifetime_unit));
|
parent->lifetime = (now / SEC_IN_USEC) + ((dodag->default_lifetime * dodag->lifetime_unit));
|
||||||
if (parent == dodag->parents) {
|
if (parent == dodag->parents) {
|
||||||
ipv6_addr_t all_RPL_nodes = GNRC_RPL_ALL_NODES_ADDR;
|
|
||||||
kernel_pid_t if_id;
|
kernel_pid_t if_id;
|
||||||
if ((if_id = gnrc_ipv6_netif_find_by_addr(NULL, &all_RPL_nodes)) != KERNEL_PID_UNDEF) {
|
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,
|
fib_add_entry(&gnrc_ipv6_fib_table,
|
||||||
if_id,
|
if_id,
|
||||||
(uint8_t *) ipv6_addr_unspecified.u8,
|
(uint8_t *) ipv6_addr_unspecified.u8,
|
||||||
sizeof(ipv6_addr_t),
|
sizeof(ipv6_addr_t),
|
||||||
(FIB_FLAG_NET_PREFIX | 0x0),
|
FIB_FLAG_NET_PREFIX,
|
||||||
parent->addr.u8,
|
parent->addr.u8,
|
||||||
sizeof(ipv6_addr_t),
|
sizeof(ipv6_addr_t),
|
||||||
FIB_FLAG_RPL_ROUTE,
|
FIB_FLAG_RPL_ROUTE,
|
||||||
@ -269,13 +267,14 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
|
|||||||
gnrc_rpl_parent_t *old_best = dodag->parents;
|
gnrc_rpl_parent_t *old_best = dodag->parents;
|
||||||
gnrc_rpl_parent_t *new_best = old_best;
|
gnrc_rpl_parent_t *new_best = old_best;
|
||||||
uint16_t old_rank = dodag->my_rank;
|
uint16_t old_rank = dodag->my_rank;
|
||||||
gnrc_rpl_parent_t *elt = NULL, *tmp = NULL;
|
gnrc_rpl_parent_t *elt, *tmp;
|
||||||
|
kernel_pid_t if_id;
|
||||||
|
|
||||||
if (dodag->parents == NULL) {
|
if (dodag->parents == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LL_FOREACH_SAFE(dodag->parents, elt, tmp) {
|
LL_FOREACH(dodag->parents, elt) {
|
||||||
new_best = dodag->instance->of->which_parent(new_best, elt);
|
new_best = dodag->instance->of->which_parent(new_best, elt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,12 +289,8 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
|
|||||||
gnrc_rpl_send_DAO(dodag->instance, &old_best->addr, 0);
|
gnrc_rpl_send_DAO(dodag->instance, &old_best->addr, 0);
|
||||||
gnrc_rpl_delay_dao(dodag);
|
gnrc_rpl_delay_dao(dodag);
|
||||||
}
|
}
|
||||||
fib_remove_entry(&gnrc_ipv6_fib_table,
|
|
||||||
(uint8_t *) ipv6_addr_unspecified.u8,
|
|
||||||
sizeof(ipv6_addr_t));
|
|
||||||
ipv6_addr_t all_RPL_nodes = GNRC_RPL_ALL_NODES_ADDR;
|
|
||||||
|
|
||||||
kernel_pid_t if_id = gnrc_ipv6_netif_find_by_addr(NULL, &all_RPL_nodes);
|
if_id = gnrc_ipv6_netif_find_by_addr(NULL, &ipv6_addr_all_rpl_nodes);
|
||||||
|
|
||||||
if (if_id == KERNEL_PID_UNDEF) {
|
if (if_id == KERNEL_PID_UNDEF) {
|
||||||
DEBUG("RPL: no interface found for the parent address\n");
|
DEBUG("RPL: no interface found for the parent address\n");
|
||||||
@ -306,7 +301,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
|
|||||||
if_id,
|
if_id,
|
||||||
(uint8_t *) ipv6_addr_unspecified.u8,
|
(uint8_t *) ipv6_addr_unspecified.u8,
|
||||||
sizeof(ipv6_addr_t),
|
sizeof(ipv6_addr_t),
|
||||||
(FIB_FLAG_NET_PREFIX | 0x0),
|
FIB_FLAG_NET_PREFIX,
|
||||||
dodag->parents->addr.u8,
|
dodag->parents->addr.u8,
|
||||||
sizeof(ipv6_addr_t),
|
sizeof(ipv6_addr_t),
|
||||||
FIB_FLAG_RPL_ROUTE,
|
FIB_FLAG_RPL_ROUTE,
|
||||||
@ -318,7 +313,6 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
|
|||||||
trickle_reset_timer(&dodag->trickle);
|
trickle_reset_timer(&dodag->trickle);
|
||||||
}
|
}
|
||||||
|
|
||||||
elt = NULL; tmp = NULL;
|
|
||||||
LL_FOREACH_SAFE(dodag->parents, elt, tmp) {
|
LL_FOREACH_SAFE(dodag->parents, elt, tmp) {
|
||||||
if (DAGRANK(dodag->my_rank, dodag->instance->min_hop_rank_inc)
|
if (DAGRANK(dodag->my_rank, dodag->instance->min_hop_rank_inc)
|
||||||
<= DAGRANK(elt->rank, dodag->instance->min_hop_rank_inc)) {
|
<= DAGRANK(elt->rank, dodag->instance->min_hop_rank_inc)) {
|
||||||
@ -355,8 +349,8 @@ gnrc_rpl_instance_t *gnrc_rpl_root_instance_init(uint8_t instance_id, ipv6_addr_
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((netif_addr = gnrc_ipv6_netif_addr_get(configured_addr)) == NULL) {
|
if ((netif_addr = gnrc_ipv6_netif_addr_get(configured_addr)) == NULL) {
|
||||||
DEBUG("RPL: no netif address found for %s\n", ipv6_addr_to_str(addr_str, configured_addr,
|
DEBUG("RPL: no netif address found for %s\n",
|
||||||
sizeof(addr_str)));
|
ipv6_addr_to_str(addr_str, configured_addr, sizeof(addr_str)));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,8 +142,7 @@ int _gnrc_rpl_trickle_start(char *arg1)
|
|||||||
|
|
||||||
int _gnrc_rpl_send_dis(void)
|
int _gnrc_rpl_send_dis(void)
|
||||||
{
|
{
|
||||||
ipv6_addr_t all_RPL_nodes = GNRC_RPL_ALL_NODES_ADDR;
|
gnrc_rpl_send_DIS(NULL, (ipv6_addr_t *) &ipv6_addr_all_rpl_nodes);
|
||||||
gnrc_rpl_send_DIS(NULL, &all_RPL_nodes);
|
|
||||||
|
|
||||||
puts("success: send a DIS\n");
|
puts("success: send a DIS\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user