Added API for reading the routing table

This commit is contained in:
adamdunkels 2008-01-08 07:58:23 +00:00
parent 601560b1eb
commit 40d6216ec9
2 changed files with 32 additions and 2 deletions

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: route.c,v 1.10 2008/01/04 23:33:09 oliverschmidt Exp $
* $Id: route.c,v 1.11 2008/01/08 07:58:23 adamdunkels Exp $
*/
/**
@ -172,4 +172,31 @@ route_set_lifetime(int seconds)
max_time = seconds;
}
/*---------------------------------------------------------------------------*/
int
route_num(void)
{
struct route_entry *e;
int i = 0;
for(e = list_head(route_table); e != NULL; e = e->next) {
i++;
}
return i;
}
/*---------------------------------------------------------------------------*/
struct route_entry *
route_get(int num)
{
struct route_entry *e;
int i = 0;
for(e = list_head(route_table); e != NULL; e = e->next) {
if(i == num) {
return e;
}
i++;
}
return NULL;
}
/*---------------------------------------------------------------------------*/
/** @} */

View file

@ -39,7 +39,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: route.h,v 1.6 2007/12/17 09:14:08 adamdunkels Exp $
* $Id: route.h,v 1.7 2008/01/08 07:58:23 adamdunkels Exp $
*/
/**
@ -71,6 +71,9 @@ void route_remove(struct route_entry *e);
void route_flush_all(void);
void route_set_lifetime(int seconds);
int route_num(void);
struct route_entry *route_get(int num);
#endif /* __ROUTE_H__ */
/** @} */
/** @} */