]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Pass adapter index to up/down scripts
authorLev Stipakov <lstipakov@gmail.com>
Sat, 12 Dec 2015 12:34:20 +0000 (14:34 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 14 Dec 2015 17:46:37 +0000 (18:46 +0100)
Trac #637

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1449923660-27363-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10762
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 9dff2c1f106865a72a1d505076751dde170e88dc)

doc/openvpn.8
src/openvpn/init.c
src/openvpn/misc.c
src/openvpn/misc.h

index 9e4b01ec334c23f68f889f3985cedb2994123c61..d302baaf19e838fb14c59889ae4888f57b72a7b5 100644 (file)
@@ -5821,6 +5821,17 @@ or
 script execution.
 .\"*********************************************************
 .TP
+.B dev_idx
+On Windows, the device index of the TUN/TAP adapter (to
+be used in netsh.exe calls which sometimes just do not work
+right with interface names).
+Set prior to
+.B \-\-up
+or
+.B \-\-down
+script execution.
+.\"*********************************************************
+.TP
 .B foreign_option_{n}
 An option pushed via
 .B \-\-push
index e8a96c2c66c59bff0d12c109ad6930e8cfaa47ef..294b52068f4d2d87061f4b05d803aa6bba410645 100644 (file)
@@ -1458,6 +1458,9 @@ do_open_tun (struct context *c)
                   c->plugins,
                   OPENVPN_PLUGIN_UP,
                   c->c1.tuntap->actual_name,
+#ifdef WIN32
+                  c->c1.tuntap->adapter_index,
+#endif
                   dev_type_string (c->options.dev, c->options.dev_type),
                   TUN_MTU_SIZE (&c->c2.frame),
                   EXPANDED_SIZE (&c->c2.frame),
@@ -1507,6 +1510,9 @@ do_open_tun (struct context *c)
                     c->plugins,
                     OPENVPN_PLUGIN_UP,
                     c->c1.tuntap->actual_name,
+#ifdef WIN32
+                    c->c1.tuntap->adapter_index,
+#endif
                     dev_type_string (c->options.dev, c->options.dev_type),
                     TUN_MTU_SIZE (&c->c2.frame),
                     EXPANDED_SIZE (&c->c2.frame),
@@ -1544,6 +1550,9 @@ do_close_tun (struct context *c, bool force)
   if (c->c1.tuntap && c->c1.tuntap_owned)
     {
       const char *tuntap_actual = string_alloc (c->c1.tuntap->actual_name, &gc);
+#ifdef WIN32
+      DWORD adapter_index = c->c1.tuntap->adapter_index;
+#endif
       const in_addr_t local = c->c1.tuntap->local;
       const in_addr_t remote_netmask = c->c1.tuntap->remote_netmask;
 
@@ -1567,6 +1576,9 @@ do_close_tun (struct context *c, bool force)
                            c->plugins,
                            OPENVPN_PLUGIN_ROUTE_PREDOWN,
                            tuntap_actual,
+#ifdef WIN32
+                           adapter_index,
+#endif
                            NULL,
                            TUN_MTU_SIZE (&c->c2.frame),
                            EXPANDED_SIZE (&c->c2.frame),
@@ -1592,6 +1604,9 @@ do_close_tun (struct context *c, bool force)
                       c->plugins,
                       OPENVPN_PLUGIN_DOWN,
                       tuntap_actual,
+#ifdef WIN32
+                      adapter_index,
+#endif
                       NULL,
                       TUN_MTU_SIZE (&c->c2.frame),
                       EXPANDED_SIZE (&c->c2.frame),
@@ -1623,6 +1638,9 @@ do_close_tun (struct context *c, bool force)
                         c->plugins,
                         OPENVPN_PLUGIN_DOWN,
                         tuntap_actual,
+#ifdef WIN32
+                        adapter_index,
+#endif
                         NULL,
                         TUN_MTU_SIZE (&c->c2.frame),
                         EXPANDED_SIZE (&c->c2.frame),
index 9fd4a369c2bf35edbc33079f3ede1f7344d919bb..04a5b5f59ab3da764bd674c55c596bdffb794741 100644 (file)
@@ -62,6 +62,9 @@ run_up_down (const char *command,
             const struct plugin_list *plugins,
             int plugin_type,
             const char *arg,
+#ifdef WIN32
+            DWORD adapter_index,
+#endif
             const char *dev_type,
             int tun_mtu,
             int link_mtu,
@@ -82,6 +85,9 @@ run_up_down (const char *command,
   setenv_str (es, "dev", arg);
   if (dev_type)
     setenv_str (es, "dev_type", dev_type);
+#ifdef WIN32
+  setenv_int (es, "dev_idx", adapter_index);
+#endif
 
   if (!ifconfig_local)
     ifconfig_local = "";
index 59267b824983d3c90daa04009cc00662a5c27723..c1942b60c1663023842703e37e6ef99bd230f4ba 100644 (file)
@@ -63,6 +63,9 @@ void run_up_down (const char *command,
                  const struct plugin_list *plugins,
                  int plugin_type,
                  const char *arg,
+#ifdef WIN32
+                 DWORD adapter_index,
+#endif
                  const char *dev_type,
                  int tun_mtu,
                  int link_mtu,