Added route addition and removal when starting and exiting
This commit is contained in:
parent
78043e4d24
commit
3abd973edb
@ -31,7 +31,7 @@
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: tapdev.c,v 1.3 2007/03/27 21:47:18 oliverschmidt Exp $
|
||||
* $Id: tapdev.c,v 1.4 2007/03/29 22:26:17 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
@ -70,6 +70,16 @@ static unsigned long lasttime;
|
||||
|
||||
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
remove_route(void)
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "route delete -net 172.16.0.0");
|
||||
system(buf);
|
||||
printf("%s\n", buf);
|
||||
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
tapdev_init(void)
|
||||
@ -94,9 +104,13 @@ tapdev_init(void)
|
||||
}
|
||||
#endif /* Linux */
|
||||
|
||||
snprintf(buf, sizeof(buf), "ifconfig tap0 inet 192.168.2.1");
|
||||
snprintf(buf, sizeof(buf), "ifconfig tap0 inet 192.168.1.1");
|
||||
system(buf);
|
||||
printf("%s\n", buf);
|
||||
snprintf(buf, sizeof(buf), "route add -net 172.16.0.0 192.168.1.2");
|
||||
system(buf);
|
||||
printf("%s\n", buf);
|
||||
atexit(remove_route);
|
||||
|
||||
lasttime = 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user