diff --git a/sys/net/routing/aodvv2/aodv.c b/sys/net/routing/aodvv2/aodv.c index fbe8dbbc5a..81099941c9 100644 --- a/sys/net/routing/aodvv2/aodv.c +++ b/sys/net/routing/aodvv2/aodv.c @@ -338,7 +338,7 @@ ipv6_addr_t *aodv_get_next_hop(ipv6_addr_t *dest) /* Case 2: Broken Link (detected by lower layer) */ int link_broken = (ndp_nc_entry->state == NDP_NCE_STATUS_INCOMPLETE || ndp_nc_entry->state == NDP_NCE_STATUS_PROBE) && - (rt_entry != NULL && rt_entry->state != ROUTE_STATE_BROKEN); + (rt_entry != NULL && rt_entry->state != ROUTE_STATE_INVALID); if (link_broken) { DEBUG("\tNeighbor Cache entry found, but invalid (state: %i). Sending RERR.\n", @@ -360,8 +360,7 @@ ipv6_addr_t *aodv_get_next_hop(ipv6_addr_t *dest) ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, dest)); if (rt_entry) { /* Case 1: Undeliverable Packet */ - int packet_indeliverable = rt_entry->state == ROUTE_STATE_BROKEN || - rt_entry->state == ROUTE_STATE_EXPIRED; + int packet_indeliverable = rt_entry->state == ROUTE_STATE_INVALID; if (packet_indeliverable) { DEBUG("\tRouting table entry found, but invalid (state %i). Sending RERR.\n", rt_entry->state); diff --git a/sys/net/routing/aodvv2/reader.c b/sys/net/routing/aodvv2/reader.c index 0b88ffbf6f..7bd01ac4a7 100644 --- a/sys/net/routing/aodvv2/reader.c +++ b/sys/net/routing/aodvv2/reader.c @@ -646,7 +646,7 @@ static enum rfc5444_result _cb_rerr_blocktlv_addresstlvs_okay(struct rfc5444_rea /* check if route to unreachable node has to be marked as broken and RERR has to be forwarded */ if (netaddr_cmp(&unreachable_entry->nextHopAddr, &packet_data.sender) == 0 && (!tlv || seqnum_cmp(unreachable_entry->seqnum, packet_data.origNode.seqnum) == 0)) { - unreachable_entry->state = ROUTE_STATE_BROKEN; + unreachable_entry->state = ROUTE_STATE_INVALID; unreachable_nodes[num_unreachable_nodes].addr = packet_data.origNode.addr; unreachable_nodes[num_unreachable_nodes].seqnum = packet_data.origNode.seqnum; num_unreachable_nodes++; diff --git a/sys/net/routing/aodvv2/routingtable.c b/sys/net/routing/aodvv2/routingtable.c index 45f8f12898..d392bd1c8d 100644 --- a/sys/net/routing/aodvv2/routingtable.c +++ b/sys/net/routing/aodvv2/routingtable.c @@ -120,7 +120,7 @@ void routingtable_break_and_get_all_hopping_over(struct netaddr *hop, (*len)++; DEBUG("\t[routing] unreachable node found: %s\n", netaddr_to_string(&nbuf, &routing_table[i].nextHopAddr)); } - routing_table[i].state = ROUTE_STATE_BROKEN; + routing_table[i].state = ROUTE_STATE_INVALID; DEBUG("\t[routing] number of unreachable nodes: %i\n", *len); } } @@ -159,30 +159,33 @@ static void _reset_entry_if_stale(uint8_t i) routing_table[i].lastUsed = now; /* mark the time entry was set to Idle */ } - /* After an idle route remains Idle for MAX_IDLETIME, it becomes an Expired route. - A route MUST be considered Expired if Current_Time >= Route.ExpirationTime - */ + /* After an Idle route remains Idle for MAX_IDLETIME, it becomes an Invalid route. */ /* if the node is younger than the expiration time, don't bother */ if (timex_cmp(now, expirationTime) < 0) { return; } + /* If Current_Time > Route.ExpirationTime, set Route.State := Invalid. */ if ((state == ROUTE_STATE_IDLE) && - (timex_cmp(expirationTime, now) < 1)) { - DEBUG("\t[routing] route towards %s Expired\n", + (timex_cmp(now, expirationTime) > 0)) { + DEBUG("\t[routing] route towards %s became Invalid\n", netaddr_to_string(&nbuf, &routing_table[i].addr)); - DEBUG("\t expirationTime: %"PRIu32":%"PRIu32" , now: %"PRIu32":%"PRIu32"\n", - expirationTime.seconds, expirationTime.microseconds, - now.seconds, now.microseconds); - routing_table[i].state = ROUTE_STATE_EXPIRED; - routing_table[i].lastUsed = now; /* mark the time entry was set to Expired */ + routing_table[i].state = ROUTE_STATE_INVALID; + routing_table[i].lastUsed = now; /* mark the time entry was set to Invalid */ + } + + /* If (Current_Time - Route.LastUsed) > (ACTIVE_INTERVAL + MAX_IDLETIME), + * and if (Route.Timed == FALSE), set Route.State := Invalid. */ + if ((timex_cmp(timex_sub(now, lastUsed), timex_add(active_interval, max_idletime)) > 0) && + (state != ROUTE_STATE_TIMED)) { + routing_table[i].state = ROUTE_STATE_INVALID; } /* After that time, old sequence number information is considered no longer - * valuable and the Expired route MUST BE expunged */ + * valid and the Invalid route MUST BE expunged */ if (timex_cmp(timex_sub(now, lastUsed), max_seqnum_lifetime) >= 0) { - DEBUG("\t[routing] reset routing table entry for %s at %i\n", + DEBUG("\t[routing] Expunged routing table entry for %s at %i\n", netaddr_to_string(&nbuf, &routing_table[i].addr), i); memset(&routing_table[i], 0, sizeof(routing_table[i])); } @@ -197,11 +200,11 @@ bool routingtable_offers_improvement(struct aodvv2_routing_entry_t *rt_entry, } /* Check if new info is more costly */ if ((node_data->metric >= rt_entry->metric) - && !(rt_entry->state != ROUTE_STATE_BROKEN)) { + && !(rt_entry->state != ROUTE_STATE_INVALID)) { return false; } - /* Check if new info repairs a broken route */ - if (!(rt_entry->state != ROUTE_STATE_BROKEN)) { + /* Check if new info repairs an invalid route */ + if (!(rt_entry->state != ROUTE_STATE_INVALID)) { return false; } return true; diff --git a/sys/net/routing/aodvv2/routingtable.h b/sys/net/routing/aodvv2/routingtable.h index 5e1e533aaa..87e4421585 100644 --- a/sys/net/routing/aodvv2/routingtable.h +++ b/sys/net/routing/aodvv2/routingtable.h @@ -39,8 +39,7 @@ enum aodvv2_routing_states { ROUTE_STATE_ACTIVE, ROUTE_STATE_IDLE, - ROUTE_STATE_EXPIRED, - ROUTE_STATE_BROKEN, + ROUTE_STATE_INVALID, ROUTE_STATE_TIMED };