aboutsummaryrefslogtreecommitdiff
path: root/tun.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-12-05 01:21:49 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-12-05 01:21:49 +0000
commit6d5d1010bcab428391d0c33dd753a31def29f972 (patch)
treefd232610fef9624d555dfa1876a2908de37e8454 /tun.c
parentsvn merge -r 780:820 $SO/trunk/openvpn . (diff)
downloadopenvpn-6d5d1010bcab428391d0c33dd753a31def29f972.tar.xz
Patch to support --topology subnet on Mac OS X (Mathias Sundman).
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@832 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'tun.c')
-rw-r--r--tun.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/tun.c b/tun.c
index 0420817..eafa8d6 100644
--- a/tun.c
+++ b/tun.c
@@ -44,6 +44,7 @@
#include "misc.h"
#include "socket.h"
#include "manage.h"
+#include "route.h"
#include "memdbg.h"
@@ -746,18 +747,41 @@ do_ifconfig (struct tuntap *tt,
tun_mtu
);
else
- openvpn_snprintf (command_line, sizeof (command_line),
- IFCONFIG_PATH " %s %s netmask %s mtu %d up",
- actual,
- ifconfig_local,
- ifconfig_remote_netmask,
- tun_mtu
- );
-
+ {
+ if (tt->topology == TOP_SUBNET)
+ openvpn_snprintf (command_line, sizeof (command_line),
+ IFCONFIG_PATH " %s %s %s netmask %s mtu %d up",
+ actual,
+ ifconfig_local,
+ ifconfig_local,
+ ifconfig_remote_netmask,
+ tun_mtu
+ );
+ else
+ openvpn_snprintf (command_line, sizeof (command_line),
+ IFCONFIG_PATH " %s %s netmask %s mtu %d up",
+ actual,
+ ifconfig_local,
+ ifconfig_remote_netmask,
+ tun_mtu
+ );
+ }
msg (M_INFO, "%s", command_line);
system_check (command_line, es, S_FATAL, "Mac OS X ifconfig failed");
tt->did_ifconfig = true;
+ /* Add a network route for the local tun interface */
+ if (!tun && tt->topology == TOP_SUBNET)
+ {
+ struct route r;
+ CLEAR (r);
+ r.defined = true;
+ r.network = tt->local & tt->remote_netmask;
+ r.netmask = tt->remote_netmask;
+ r.gateway = tt->local;
+ add_route (&r, tt, 0, es);
+ }
+
#elif defined(TARGET_FREEBSD)
/* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */