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.
This commit is contained in:
parent
333ad36a4a
commit
e991edc24d
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $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
|
||||
|
|
Loading…
Reference in a new issue