1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 22:13:52 +01:00

Merge pull request #371 from OlegHahm/rpl_null_pointer

RPL null pointer handling
This commit is contained in:
Oleg Hahm 2013-11-22 18:47:39 -08:00
commit 0e9b6cc1a9
2 changed files with 16 additions and 2 deletions

View File

@ -526,6 +526,9 @@ void recv_rpl_dio(void)
return;
}
}
else if (my_inst == NULL) {
DEBUG("Not joined an instance yet\n");
}
else if (my_inst->id != dio_inst->id) {
/* TODO: Add support support for several instances. */
@ -953,7 +956,7 @@ ipv6_addr_t *rpl_get_next_hop(ipv6_addr_t *addr)
}
}
return NULL;
return (rpl_get_my_preferred_parent());
}
void rpl_add_routing_entry(ipv6_addr_t *addr, ipv6_addr_t *next_hop, uint16_t lifetime)

View File

@ -210,7 +210,9 @@ void rpl_delete_worst_parent(void)
void rpl_delete_all_parents(void)
{
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
my_dodag->my_preferred_parent = NULL;
if (my_dodag != NULL) {
my_dodag->my_preferred_parent = NULL;
}
for (int i = 0; i < RPL_MAX_PARENTS; i++) {
memset(&parents[i], 0, sizeof(parents[i]));
@ -222,6 +224,11 @@ rpl_parent_t *rpl_find_preferred_parent(void)
rpl_parent_t *best = NULL;
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
if (my_dodag == NULL) {
DEBUG("Not part of a dodag\n");
return NULL;
}
for (uint8_t i = 0; i < RPL_MAX_PARENTS; i++) {
if (parents[i].used) {
if ((parents[i].rank == INFINITE_RANK) || (parents[i].lifetime <= 1)) {
@ -265,6 +272,10 @@ void rpl_parent_update(rpl_parent_t *parent)
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
uint16_t old_rank = my_dodag->my_rank;
if (my_dodag == NULL) {
DEBUG("Not part of a dodag - this should not happen");
return;
}
/* update Parent lifetime */
if (parent != NULL) {
parent->lifetime = my_dodag->default_lifetime * my_dodag->lifetime_unit;