From e991edc24d3203b7c8bf8bcee6ececd6b9372442 Mon Sep 17 00:00:00 2001 From: oliverschmidt Date: Mon, 17 Dec 2007 01:12:09 +0000 Subject: [PATCH] Added route handling to the Cygwin build. It is done similiar to the other builds by simply shelling out to 'route'. However the coding isn't placed in the driver but in the netsim node main method - and it is fully parametrized. Cygwin doesn't seem to call exit functions on SIGTERM so I needed to go for a signal handler in order to delete the route. --- platform/netsim/contiki-main.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/platform/netsim/contiki-main.c b/platform/netsim/contiki-main.c index 12bdc0a29..794e6af9b 100644 --- a/platform/netsim/contiki-main.c +++ b/platform/netsim/contiki-main.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: contiki-main.c,v 1.21 2007/11/28 12:54:42 adamdunkels Exp $ + * $Id: contiki-main.c,v 1.22 2007/12/17 01:12:09 oliverschmidt Exp $ */ #include "contiki.h" @@ -84,6 +84,20 @@ PROCINIT(&sensors_process, &etimer_process, &tcpip_process, /* ðernode_uip_process,*/ &uip_fw_process); +/*---------------------------------------------------------------------------*/ +#ifdef __CYGWIN__ +static void +remove_route(int s) +{ + char buf[1024]; + + snprintf(buf, sizeof(buf), "route delete %d.%d.%d.%d", + uip_ipaddr_to_quad(&meshif.ipaddr)); + printf("%s\n", buf); + system(buf); + _exit(0); +} +#endif /*---------------------------------------------------------------------------*/ void contiki_main(int flag) @@ -107,6 +121,17 @@ contiki_main(int flag) if(flag == 1) { #ifdef __CYGWIN__ process_start(&wpcap_process, NULL); + { + char buf[1024]; + + snprintf(buf, sizeof(buf), "route add %d.%d.%d.%d mask %d.%d.%d.%d %d.%d.%d.%d", + uip_ipaddr_to_quad(&meshif.ipaddr), + uip_ipaddr_to_quad(&meshif.netmask), + uip_ipaddr_to_quad(&uip_hostaddr)); + printf("%s\n", buf); + system(buf); + signal(SIGTERM, remove_route); + } #else process_start(&tapdev_process, NULL); #endif