mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-09 23:54:32 +00:00
Make route lifetime dynamically configurable
This commit is contained in:
parent
4a2f71c3ef
commit
f3872aac48
@ -28,7 +28,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: route.c,v 1.4 2007/03/24 13:57:04 oliverschmidt Exp $
|
||||
* $Id: route.c,v 1.5 2007/03/25 12:03:59 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ MEMB(route_mem, struct route_entry, NUM_RT_ENTRIES);
|
||||
|
||||
static struct ctimer t;
|
||||
|
||||
#define MAX_TIME 10
|
||||
static int max_time = 10;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
@ -62,7 +62,7 @@ periodic(void *ptr)
|
||||
|
||||
for(e = list_head(route_table); e != NULL; e = e->next) {
|
||||
e->time++;
|
||||
if(e->time >= MAX_TIME) {
|
||||
if(e->time >= max_time) {
|
||||
printf("Route to %d.%d bropped\n",
|
||||
e->dest.u8[0], e->dest.u8[1]);
|
||||
list_remove(route_table, e);
|
||||
@ -70,7 +70,7 @@ periodic(void *ptr)
|
||||
}
|
||||
}
|
||||
|
||||
ctimer_set(&t, CLOCK_SECOND * 2, periodic, NULL);
|
||||
ctimer_set(&t, CLOCK_SECOND, periodic, NULL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
@ -79,7 +79,7 @@ route_init(void)
|
||||
list_init(route_table);
|
||||
memb_init(&route_mem);
|
||||
|
||||
ctimer_set(&t, CLOCK_SECOND * 2, periodic, NULL);
|
||||
ctimer_set(&t, CLOCK_SECOND, periodic, NULL);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
@ -157,3 +157,9 @@ route_flush_all(void)
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
route_set_lifetime(int seconds)
|
||||
{
|
||||
max_time = seconds;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: route.h,v 1.3 2007/03/24 13:54:05 oliverschmidt Exp $
|
||||
* $Id: route.h,v 1.4 2007/03/25 12:03:59 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -59,5 +59,6 @@ int route_add(rimeaddr_t *dest, rimeaddr_t *nexthop,
|
||||
struct route_entry *route_lookup(rimeaddr_t *dest);
|
||||
void route_remove(struct route_entry *e);
|
||||
void route_flush_all(void);
|
||||
void route_set_lifetime(int seconds);
|
||||
|
||||
#endif /* __ROUTE_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user