]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Patch to support --topology subnet on Mac OS X (Mathias Sundman).
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Mon, 5 Dec 2005 01:21:49 +0000 (01:21 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Mon, 5 Dec 2005 01:21:49 +0000 (01:21 +0000)
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@832 e7ae566f-a301-0410-adde-c780ea21d3b5

ChangeLog
route.c
route.h
tun.c

index f12b94505fff37077cc31608d85db465f1316dda..1fe18e7fd0f534f9c0998f9e4709f7dee1273d49 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,7 @@ $Id$
   (David Stipp).
 * Fixed typo in manage.c where inline function declaration
   was declared without the "static" keyword (David Stipp).
+* Patch to support --topology subnet on Mac OS X (Mathias Sundman).
 
 2005.11.12 -- Version 2.1-beta7
 
diff --git a/route.c b/route.c
index 1db0b36c5c70eb1d7dd483f34c42f5c8d0dd7246..06e1facd641838cc58d96fa0d23a56fd9ecf4dcc 100644 (file)
--- a/route.c
+++ b/route.c
@@ -45,7 +45,6 @@
 
 #include "memdbg.h"
 
-static void add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const struct env_set *es);
 static void delete_route (const struct route *r, const struct tuntap *tt, unsigned int flags, const struct env_set *es);
 static bool get_default_gateway (in_addr_t *ret);
 static void get_bypass_addresses (struct route_bypass *rb, const unsigned int flags);
@@ -741,7 +740,7 @@ setenv_routes (struct env_set *es, const struct route_list *rl)
     setenv_route (es, &rl->routes[i], i + 1);
 }
 
-static void
+void
 add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
 {
   struct gc_arena gc;
diff --git a/route.h b/route.h
index 21f546576f88071c98ea25f6ce3db870a140e927..c2da5331bc4ee90049216261f8846ab37fcc9cc2 100644 (file)
--- a/route.h
+++ b/route.h
@@ -118,6 +118,8 @@ struct route_option_list *new_route_option_list (struct gc_arena *a);
 
 struct route_list *new_route_list (struct gc_arena *a);
 
+void add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const struct env_set *es);
+
 void add_route_to_option_list (struct route_option_list *l,
                               const char *network,
                               const char *netmask,
diff --git a/tun.c b/tun.c
index 042081750e5a96d899bc1c450ef87ea7e022f4c6..eafa8d6e1ba59c409a602773e39299e035aa6979 100644 (file)
--- 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 */