From 3abd973edbea39ad90e027420ec3ec90c88e42f7 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Thu, 29 Mar 2007 22:26:17 +0000 Subject: [PATCH] Added route addition and removal when starting and exiting --- platform/netsim/net/tapdev.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/platform/netsim/net/tapdev.c b/platform/netsim/net/tapdev.c index ef40a4a0c..0e80be379 100644 --- a/platform/netsim/net/tapdev.c +++ b/platform/netsim/net/tapdev.c @@ -31,7 +31,7 @@ * * Author: Adam Dunkels * - * $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 @@ -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; }