38 #include <sys/select.h>
43 #include "contiki-net.h"
49 #include "net/wpcap-drv.h"
51 #include "net/tapdev-drv.h"
55 PROCINIT(&etimer_process, &tcpip_process, &wpcap_process, &serial_line_process);
57 PROCINIT(&etimer_process, &tapdev_process, &tcpip_process, &serial_line_process);
61 #include "net/rpl/rpl.h"
63 uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011};
65 PROCESS(border_router_process,
"RPL Border Router");
74 char buf[
sizeof(dag_id)];
75 memcpy(buf,dag_id,
sizeof(dag_id));
76 dag = rpl_set_root((uip_ip6addr_t *)buf);
83 printf(
"Created a new RPL dag\n");
85 #if UIP_CONF_ROUTER_RECEIVE_RA
90 void sprint_ip6(uip_ip6addr_t addr);
93 #ifdef HARD_CODED_ADDRESS
96 uip_ip6addr(&ipaddr, 0xbbbb, 0, 0, 0, 0, 0, 0, 0x1);
99 uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
100 rpl_set_prefix(dag, &ipaddr, 64);
102 for (i=0;i<UIP_DS6_ADDR_NB;i++) {
103 if (uip_ds6_if.addr_list[i].isused) {
104 printf(
"IPV6 Address: ");sprint_ip6(uip_ds6_if.addr_list[i].ipaddr);printf(
"\n");
129 sprint_ip6(uip_ip6addr_t addr)
132 unsigned char zerocnt = 0;
133 unsigned char numprinted = 0;
135 char * result = thestring;
138 while (numprinted < 8) {
139 if ((addr.u16[i] == 0) && (zerocnt == 0)) {
140 while(addr.u16[zerocnt + i] == 0) zerocnt++;
147 numprinted += zerocnt;
149 result += sprintf(result,
"%x", (
unsigned int)(uip_ntohs(addr.u16[i])));
153 if (numprinted != 8) *result++ =
':';
157 printf(
"%s",thestring);
178 #ifdef HARD_CODED_ADDRESS
182 if ((ipaddr.u8[13]!=0) || (ipaddr.u8[14]!=0) || (ipaddr.u8[15]!=0)) {
201 autostart_start(autostart_processes);
203 #if RPL_BORDER_ROUTER
205 printf(
"Border Router Process started\n");
206 #elif UIP_CONF_IPV6_RPL
207 printf(
"RPL enabled\n");
237 #if !UIP_CONF_IPV6_RPL
239 #ifdef HARD_CODED_ADDRESS
244 if ((ipaddr.u16[0]!=0) || (ipaddr.u16[1]!=0) || (ipaddr.u16[2]!=0) || (ipaddr.u16[3]!=0)) {
246 uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);
248 uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0);
250 #if !UIP_CONF_IPV6_RPL
252 uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
257 #if !RPL_BORDER_ROUTER //Border router process prints addresses later
259 for (i=0;i<UIP_DS6_ADDR_NB;i++) {
260 if (uip_ds6_if.addr_list[i].isused) {
261 printf(
"IPV6 Addresss: ");sprint_ip6(uip_ds6_if.addr_list[i].ipaddr);printf(
"\n");
269 setvbuf(stdout, (
char *)
NULL, _IONBF, 0);
271 printf(
"\n*******%s online*******\n",CONTIKI_VERSION_STRING);
286 FD_SET(STDIN_FILENO, &fds);
289 if(FD_ISSET(STDIN_FILENO, &fds)) {
291 if(read(STDIN_FILENO, &c, 1) > 0) {
292 serial_line_input_byte(c);
301 void log_message(
char *m1,
char *m2)
303 printf(
"%s%s\n", m1, m2);
309 printf(
"uIP: '%s'\n", m);
315 static unsigned short count;