2010-10-28 12:37:42 +00:00
|
|
|
/*
|
|
|
|
* static-routing.c
|
|
|
|
*
|
|
|
|
* Created on: Oct 12, 2010
|
|
|
|
* Author: dogan
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "static-routing.h"
|
|
|
|
|
2011-04-11 22:09:15 +00:00
|
|
|
#if !defined (CONTIKI_TARGET_MINIMAL_NET) /* Any other targets will be added here (&& ! defined (OTHER))*/
|
|
|
|
|
2010-10-28 12:37:42 +00:00
|
|
|
#define DEBUG 0
|
|
|
|
#if DEBUG
|
|
|
|
#include <stdio.h>
|
|
|
|
#define PRINTF(...) printf(__VA_ARGS__)
|
2012-02-20 19:13:50 +00:00
|
|
|
#define PRINT6ADDR(addr) PRINTF(" %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x ", ((uint8_t *)addr)[0], ((uint8_t *)addr)[1], ((uint8_t *)addr)[2], ((uint8_t *)addr)[3], ((uint8_t *)addr)[4], ((uint8_t *)addr)[5], ((uint8_t *)addr)[6], ((uint8_t *)addr)[7], ((uint8_t *)addr)[8], ((uint8_t *)addr)[9], ((uint8_t *)addr)[10], ((uint8_t *)addr)[11], ((uint8_t *)addr)[12], ((uint8_t *)addr)[13], ((uint8_t *)addr)[14], ((uint8_t *)addr)[15])
|
2010-10-28 12:37:42 +00:00
|
|
|
#define PRINTLLADDR(lladdr) PRINTF(" %02x:%02x:%02x:%02x:%02x:%02x ",(lladdr)->addr[0], (lladdr)->addr[1], (lladdr)->addr[2], (lladdr)->addr[3],(lladdr)->addr[4], (lladdr)->addr[5])
|
|
|
|
#else
|
|
|
|
#define PRINTF(...)
|
|
|
|
#define PRINT6ADDR(addr)
|
|
|
|
#define PRINTLLADDR(addr)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if !UIP_CONF_IPV6_RPL
|
|
|
|
#include "contiki-net.h"
|
2012-11-20 18:57:20 +00:00
|
|
|
#include "sys/node-id.h"
|
2010-10-28 12:37:42 +00:00
|
|
|
|
|
|
|
void set_global_address(void)
|
|
|
|
{
|
|
|
|
uip_ipaddr_t ipaddr;
|
|
|
|
|
|
|
|
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
|
|
|
|
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
|
|
|
|
}
|
|
|
|
|
|
|
|
void configure_routing(void)
|
|
|
|
{
|
|
|
|
PRINTF("configure_routing\n");
|
|
|
|
|
2010-11-24 10:16:45 +00:00
|
|
|
if (node_id < 10) { /*COOJA*/
|
|
|
|
/*Go to desktop machine over border router*/
|
|
|
|
ADD_ROUTE(DESKTOP_MACHINE_ID, COOJA_BORDER_ROUTER_ID);
|
|
|
|
} else { /*SKY*/
|
|
|
|
if (node_id < 20) { /*First hops (ids between 10-20)*/
|
|
|
|
/*Go to desktop machine over border router*/
|
2010-10-28 12:37:42 +00:00
|
|
|
ADD_ROUTE(DESKTOP_MACHINE_ID, BORDER_ROUTER_ID);
|
|
|
|
}
|
|
|
|
|
2010-11-24 10:16:45 +00:00
|
|
|
switch(node_id) {
|
2010-10-28 12:37:42 +00:00
|
|
|
case 12:
|
2010-11-24 10:16:45 +00:00
|
|
|
ADD_ROUTE(22, 22); /*Go to next hop over the local address of next hop*/
|
2010-10-28 12:37:42 +00:00
|
|
|
break;
|
|
|
|
case 13:
|
2010-11-24 10:16:45 +00:00
|
|
|
ADD_ROUTE(23, 23); /*Go to next hop over the local address of next hop*/
|
2010-10-28 12:37:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 22:
|
2010-11-24 10:16:45 +00:00
|
|
|
ADD_ROUTE(0, 12); /*Go to desktop machine over the corresponding first hop*/
|
2010-10-28 12:37:42 +00:00
|
|
|
break;
|
|
|
|
case 23:
|
2010-11-24 10:16:45 +00:00
|
|
|
ADD_ROUTE(0, 13); /*Go to desktop machine over the corresponding first hop*/
|
2010-10-28 12:37:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /*!UIP_CONF_IPV6_RPL*/
|
2011-04-11 22:09:15 +00:00
|
|
|
#endif /*CONTIKI_TARGET_MINIMAL_NET*/
|