mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 14:03:55 +01:00
gnrc_rpl: new default route when old one was deleted
This commit is contained in:
parent
095e4558df
commit
eae0e4c724
@ -192,12 +192,30 @@ bool gnrc_rpl_parent_add_by_addr(gnrc_rpl_dodag_t *dodag, ipv6_addr_t *addr,
|
||||
|
||||
bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent)
|
||||
{
|
||||
if (parent == parent->dodag->parents) {
|
||||
assert(parent != NULL);
|
||||
|
||||
gnrc_rpl_dodag_t *dodag = parent->dodag;
|
||||
|
||||
if (parent == dodag->parents) {
|
||||
fib_remove_entry(&gnrc_ipv6_fib_table,
|
||||
(uint8_t *) ipv6_addr_unspecified.u8,
|
||||
sizeof(ipv6_addr_t));
|
||||
|
||||
/* set the default route to the next parent for now */
|
||||
if (parent->next) {
|
||||
uint32_t now = xtimer_now() / SEC_IN_USEC;
|
||||
fib_add_entry(&gnrc_ipv6_fib_table,
|
||||
dodag->iface,
|
||||
(uint8_t *) ipv6_addr_unspecified.u8,
|
||||
sizeof(ipv6_addr_t),
|
||||
FIB_FLAG_NET_PREFIX,
|
||||
parent->next->addr.u8,
|
||||
sizeof(ipv6_addr_t),
|
||||
FIB_FLAG_RPL_ROUTE,
|
||||
(parent->next->lifetime - now) * SEC_IN_MS);
|
||||
}
|
||||
}
|
||||
LL_DELETE(parent->dodag->parents, parent);
|
||||
LL_DELETE(dodag->parents, parent);
|
||||
memset(parent, 0, sizeof(gnrc_rpl_parent_t));
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user