Removed automatic refresh of routes from the route_lookup() function and moved it into an explicit route_refresh() function. The previous behaviour was dangerous, since it meant that even bad routes that someone was looking for were considered fresh. Now such routes time out if they are not explictily refreshed (e.g., on a packet reception)
This commit is contained in:
parent
f5a57a4e54
commit
c83c5c4c55
2 changed files with 13 additions and 5 deletions
|
@ -33,7 +33,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: route.c,v 1.13 2009/03/23 16:22:02 adamdunkels Exp $
|
||||
* $Id: route.c,v 1.14 2009/05/04 11:23:30 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -135,9 +135,6 @@ route_lookup(const rimeaddr_t *dest)
|
|||
uip_ipaddr_to_quad(dest), uip_ipaddr_to_quad(&e->dest));*/
|
||||
|
||||
if(rimeaddr_cmp(dest, &e->dest)) {
|
||||
/* Refresh age of route so that used routes do not get thrown
|
||||
out. */
|
||||
e->time = 0;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
@ -145,6 +142,16 @@ route_lookup(const rimeaddr_t *dest)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
route_refresh(struct route_entry *e)
|
||||
{
|
||||
if(e != NULL) {
|
||||
/* Refresh age of route so that used routes do not get thrown
|
||||
out. */
|
||||
e->time = 0;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
route_remove(struct route_entry *e)
|
||||
{
|
||||
list_remove(route_table, e);
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: route.h,v 1.9 2009/03/23 16:22:02 adamdunkels Exp $
|
||||
* $Id: route.h,v 1.10 2009/05/04 11:23:30 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -67,6 +67,7 @@ void route_init(void);
|
|||
int route_add(const rimeaddr_t *dest, const rimeaddr_t *nexthop,
|
||||
uint8_t hop_count, uint8_t seqno);
|
||||
struct route_entry *route_lookup(const rimeaddr_t *dest);
|
||||
void route_refresh(struct route_entry *e);
|
||||
void route_remove(struct route_entry *e);
|
||||
void route_flush_all(void);
|
||||
void route_set_lifetime(int seconds);
|
||||
|
|
Loading…
Reference in a new issue