platform/minimal-net: Better, more seamless support for OS X.
This patch enables automatic route setup and cleanup when starting and stopping the minimal-net target on OS X. Both IPv4 and IPv6 are supported. Using the minimal-net target on OS X was absolute hell before I came up with this patch. Now it is painless.
This commit is contained in:
parent
092b6f3baa
commit
a571b663b0
4 changed files with 191 additions and 11 deletions
|
@ -81,7 +81,7 @@ static void
|
|||
remove_route(void)
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "route delete -net 172.16.0.0");
|
||||
snprintf(buf, sizeof(buf), "route delete -net 172.18.0.0");
|
||||
system(buf);
|
||||
printf("%s\n", buf);
|
||||
|
||||
|
@ -110,15 +110,15 @@ tapdev_init(void)
|
|||
}
|
||||
#endif /* Linux */
|
||||
|
||||
snprintf(buf, sizeof(buf), "ifconfig tap0 inet 192.168.1.1");
|
||||
snprintf(buf, sizeof(buf), "ifconfig tap0 inet 172.18.0.1/16");
|
||||
system(buf);
|
||||
printf("%s\n", buf);
|
||||
#ifdef linux
|
||||
/* route add for linux */
|
||||
snprintf(buf, sizeof(buf), "route add -net 172.16.0.0/16 gw 192.168.1.2");
|
||||
snprintf(buf, sizeof(buf), "route add -net 172.18.0.0/16 dev tap0");
|
||||
#else /* linux */
|
||||
/* route add for freebsd */
|
||||
snprintf(buf, sizeof(buf), "route add -net 172.16.0.0/16 192.168.1.2");
|
||||
snprintf(buf, sizeof(buf), "route add -net 172.18.0.0/16 -iface tap0");
|
||||
#endif /* linux */
|
||||
|
||||
system(buf);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue