Cleanup: removed the old routing table management functions that had previously been removed from compilation with #if 0

This commit is contained in:
Adam Dunkels 2012-11-27 23:02:34 +01:00
parent edf141046b
commit 83eb9a4ec3

View file

@ -400,91 +400,6 @@ uip_ds6_nbr_ll_lookup(uip_lladdr_t *lladdr)
}
/*---------------------------------------------------------------------------*/
#if 0
uip_ds6_defrt_t *
uip_ds6_defrt_add(uip_ipaddr_t *ipaddr, unsigned long interval)
{
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) == FREESPACE) {
locdefrt->isused = 1;
uip_ipaddr_copy(&locdefrt->ipaddr, ipaddr);
if(interval != 0) {
stimer_set(&locdefrt->lifetime, interval);
locdefrt->isinfinite = 0;
} else {
locdefrt->isinfinite = 1;
}
PRINTF("Adding defrouter with ip addr ");
PRINT6ADDR(&locdefrt->ipaddr);
PRINTF("\n");
ANNOTATE("#L %u 1\n", ipaddr->u8[sizeof(uip_ipaddr_t) - 1]);
call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_ADD, ipaddr, ipaddr);
return locdefrt;
}
return NULL;
}
/*---------------------------------------------------------------------------*/
void
uip_ds6_defrt_rm(uip_ds6_defrt_t *defrt)
{
if(defrt != NULL) {
defrt->isused = 0;
ANNOTATE("#L %u 0\n", defrt->ipaddr.u8[sizeof(uip_ipaddr_t) - 1]);
call_route_callback(UIP_DS6_NOTIFICATION_DEFRT_RM,
&defrt->ipaddr, &defrt->ipaddr);
}
return;
}
/*---------------------------------------------------------------------------*/
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,
(uip_ds6_element_t **)&locdefrt) == FOUND) {
return locdefrt;
}
return NULL;
}
/*---------------------------------------------------------------------------*/
uip_ipaddr_t *
uip_ds6_defrt_choose(void)
{
uip_ds6_nbr_t *bestnbr;
locipaddr = NULL;
for(locdefrt = uip_ds6_defrt_list;
locdefrt < uip_ds6_defrt_list + UIP_DS6_DEFRT_NB; locdefrt++) {
if(locdefrt->isused) {
PRINTF("Defrt, IP address ");
PRINT6ADDR(&locdefrt->ipaddr);
PRINTF("\n");
bestnbr = uip_ds6_nbr_lookup(&locdefrt->ipaddr);
if(bestnbr != NULL && bestnbr->state != NBR_INCOMPLETE) {
PRINTF("Defrt found, IP address ");
PRINT6ADDR(&locdefrt->ipaddr);
PRINTF("\n");
return &locdefrt->ipaddr;
} else {
locipaddr = &locdefrt->ipaddr;
PRINTF("Defrt INCOMPLETE found, IP address ");
PRINT6ADDR(&locdefrt->ipaddr);
PRINTF("\n");
}
}
}
return locipaddr;
}
#endif /* 0 */
#if UIP_CONF_ROUTER
/*---------------------------------------------------------------------------*/
uip_ds6_prefix_t *
@ -751,112 +666,6 @@ uip_ds6_aaddr_lookup(uip_ipaddr_t *ipaddr)
return NULL;
}
/*---------------------------------------------------------------------------*/
#if 0
uip_ds6_route_t *
uip_ds6_route_lookup(uip_ipaddr_t *destipaddr)
{
uip_ds6_route_t *locrt = NULL;
uint8_t longestmatch = 0;
PRINTF("DS6: Looking up route for ");
PRINT6ADDR(destipaddr);
PRINTF("\n");
for(locroute = uip_ds6_routing_table;
locroute < uip_ds6_routing_table + UIP_DS6_ROUTE_NB; locroute++) {
if((locroute->isused) && (locroute->length >= longestmatch)
&&
(uip_ipaddr_prefixcmp
(destipaddr, &locroute->ipaddr, locroute->length))) {
longestmatch = locroute->length;
locrt = locroute;
}
}
if(locrt != NULL) {
PRINTF("DS6: Found route:");
PRINT6ADDR(destipaddr);
PRINTF(" via ");
PRINT6ADDR(&locrt->nexthop);
PRINTF("\n");
} else {
PRINTF("DS6: No route found\n");
}
return locrt;
}
/*---------------------------------------------------------------------------*/
uip_ds6_route_t *
uip_ds6_route_add(uip_ipaddr_t *ipaddr, uint8_t length, uip_ipaddr_t *nexthop,
uint8_t metric)
{
if(uip_ds6_list_loop
((uip_ds6_element_t *)uip_ds6_routing_table, UIP_DS6_ROUTE_NB,
sizeof(uip_ds6_route_t), ipaddr, length,
(uip_ds6_element_t **)&locroute) == FREESPACE) {
locroute->isused = 1;
uip_ipaddr_copy(&(locroute->ipaddr), ipaddr);
locroute->length = length;
uip_ipaddr_copy(&(locroute->nexthop), nexthop);
locroute->metric = metric;
#ifdef UIP_DS6_ROUTE_STATE_TYPE
memset(&locroute->state, 0, sizeof(UIP_DS6_ROUTE_STATE_TYPE));
#endif
PRINTF("DS6: adding route: ");
PRINT6ADDR(ipaddr);
PRINTF(" via ");
PRINT6ADDR(nexthop);
PRINTF("\n");
ANNOTATE("#L %u 1;blue\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_ADD, ipaddr, nexthop);
}
return locroute;
}
/*---------------------------------------------------------------------------*/
void
uip_ds6_route_rm(uip_ds6_route_t *route)
{
route->isused = 0;
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_RM,
&route->ipaddr, &route->nexthop);
#if (DEBUG & DEBUG_ANNOTATE) == DEBUG_ANNOTATE
/* we need to check if this was the last route towards "nexthop" */
/* if so - remove that link (annotation) */
for(locroute = uip_ds6_routing_table;
locroute < uip_ds6_routing_table + UIP_DS6_ROUTE_NB;
locroute++) {
if(locroute->isused && uip_ipaddr_cmp(&locroute->nexthop, &route->nexthop)) {
/* we found another link using the specific nexthop, so keep the #L */
return;
}
}
ANNOTATE("#L %u 0\n", route->nexthop.u8[sizeof(uip_ipaddr_t) - 1]);
#endif
}
/*---------------------------------------------------------------------------*/
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;
}
}
call_route_callback(UIP_DS6_NOTIFICATION_ROUTE_RM,
&locroute->ipaddr, &locroute->nexthop);
ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
}
#endif /* 0 */
/*---------------------------------------------------------------------------*/
void
uip_ds6_select_src(uip_ipaddr_t *src, uip_ipaddr_t *dst)