added route_rm_by_nexthop and small code cleanup

This commit is contained in:
joxe 2010-03-23 14:21:04 +00:00
parent 6197ac9c54
commit 4a6c6b0534
2 changed files with 56 additions and 49 deletions

View file

@ -389,9 +389,8 @@ uip_ds6_defrt_rm(uip_ds6_defrt_t * defrt)
uip_ds6_defrt_t *
uip_ds6_defrt_lookup(uip_ipaddr_t * ipaddr)
{
if(uip_ds6_list_loop
((uip_ds6_element_t *) uip_ds6_defrt_list, UIP_DS6_DEFRT_NB,
sizeof(uip_ds6_defrt_t), ipaddr, 128,
if(uip_ds6_list_loop((uip_ds6_element_t *) uip_ds6_defrt_list,
UIP_DS6_DEFRT_NB, sizeof(uip_ds6_defrt_t), ipaddr, 128,
(uip_ds6_element_t **) & locdefrt) == FOUND) {
return locdefrt;
}
@ -500,9 +499,9 @@ uip_ds6_prefix_rm(uip_ds6_prefix_t * prefix)
uip_ds6_prefix_t *
uip_ds6_prefix_lookup(uip_ipaddr_t * ipaddr, uint8_t ipaddrlen)
{
if(uip_ds6_list_loop
((uip_ds6_element_t *) uip_ds6_prefix_list, UIP_DS6_PREFIX_NB,
sizeof(uip_ds6_prefix_t), ipaddr, ipaddrlen,
if(uip_ds6_list_loop((uip_ds6_element_t *)uip_ds6_prefix_list,
UIP_DS6_PREFIX_NB, sizeof(uip_ds6_prefix_t),
ipaddr, ipaddrlen,
(uip_ds6_element_t **)&locprefix) == FOUND) {
return locprefix;
}
@ -515,10 +514,8 @@ uip_ds6_is_addr_onlink(uip_ipaddr_t * ipaddr)
{
for(locprefix = uip_ds6_prefix_list;
locprefix < uip_ds6_prefix_list + UIP_DS6_PREFIX_NB; locprefix++) {
if((locprefix->isused)
&&
(uip_ipaddr_prefixcmp(&locprefix->ipaddr, ipaddr, locprefix->length)))
{
if(locprefix->isused &&
uip_ipaddr_prefixcmp(&locprefix->ipaddr, ipaddr, locprefix->length)) {
return 1;
}
}
@ -649,9 +646,8 @@ uip_ds6_aaddr_rm(uip_ds6_aaddr_t * aaddr)
uip_ds6_aaddr_t *
uip_ds6_aaddr_lookup(uip_ipaddr_t * ipaddr)
{
if(uip_ds6_list_loop
((uip_ds6_element_t *) uip_ds6_if.aaddr_list, UIP_DS6_AADDR_NB,
sizeof(uip_ds6_aaddr_t), ipaddr, 128,
if(uip_ds6_list_loop((uip_ds6_element_t *) uip_ds6_if.aaddr_list,
UIP_DS6_AADDR_NB, sizeof(uip_ds6_aaddr_t), ipaddr, 128,
(uip_ds6_element_t **)&locaaddr) == FOUND) {
return locaaddr;
}
@ -725,7 +721,17 @@ void
uip_ds6_route_rm(uip_ds6_route_t *route)
{
route->isused = 0;
return;
}
/*---------------------------------------------------------------------------*/
void
uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop)
{
for(locroute = uip_ds6_routing_table;
locroute < uip_ds6_routing_table + UIP_DS6_ROUTE_NB; locroute++) {
if((locroute->isused) && uip_ipaddr_cmp(&locroute->nexthop, nexthop)) {
locroute->isused = 0;
}
}
}
/*---------------------------------------------------------------------------*/

View file

@ -346,6 +346,7 @@ uip_ds6_route_t *uip_ds6_route_lookup(uip_ipaddr_t * destipaddr);
uip_ds6_route_t *uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length,
uip_ipaddr_t *next_hop, u8_t metric);
void uip_ds6_route_rm(uip_ds6_route_t *route);
void uip_ds6_route_rm_by_nexthop(uip_ipaddr_t *nexthop);
/** @} */