mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-11 03:29:51 +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.
|
* 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;
|
static struct ctimer t;
|
||||||
|
|
||||||
#define MAX_TIME 10
|
static int max_time = 10;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
@ -62,7 +62,7 @@ periodic(void *ptr)
|
|||||||
|
|
||||||
for(e = list_head(route_table); e != NULL; e = e->next) {
|
for(e = list_head(route_table); e != NULL; e = e->next) {
|
||||||
e->time++;
|
e->time++;
|
||||||
if(e->time >= MAX_TIME) {
|
if(e->time >= max_time) {
|
||||||
printf("Route to %d.%d bropped\n",
|
printf("Route to %d.%d bropped\n",
|
||||||
e->dest.u8[0], e->dest.u8[1]);
|
e->dest.u8[0], e->dest.u8[1]);
|
||||||
list_remove(route_table, e);
|
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
|
void
|
||||||
@ -79,7 +79,7 @@ route_init(void)
|
|||||||
list_init(route_table);
|
list_init(route_table);
|
||||||
memb_init(&route_mem);
|
memb_init(&route_mem);
|
||||||
|
|
||||||
ctimer_set(&t, CLOCK_SECOND * 2, periodic, NULL);
|
ctimer_set(&t, CLOCK_SECOND, periodic, NULL);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
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.
|
* 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);
|
struct route_entry *route_lookup(rimeaddr_t *dest);
|
||||||
void route_remove(struct route_entry *e);
|
void route_remove(struct route_entry *e);
|
||||||
void route_flush_all(void);
|
void route_flush_all(void);
|
||||||
|
void route_set_lifetime(int seconds);
|
||||||
|
|
||||||
#endif /* __ROUTE_H__ */
|
#endif /* __ROUTE_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user