]> 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:44:45 +0000 (18:44 +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>
doc/openvpn.8
src/openvpn/init.c
src/openvpn/misc.c
src/openvpn/misc.h

index 3c0d70bf1a84bef20f9e3f36fb5ff0998ebd9976..94b5222095417ef7ffa02b2c876ee034735f6305 100644 (file)
@@ -5954,6 +5954,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 e7e9532efbf3352468f86302a4c3d0f1c675445a..2beec72203f7c14a9d1ca8aa30dc192d2612a2e7 100644 (file)
@@ -1485,6 +1485,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),
@@ -1535,6 +1538,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),
@@ -1573,6 +1579,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;
 
@@ -1596,6 +1605,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),
@@ -1621,6 +1633,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),
@@ -1652,6 +1667,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 bc411bf12eed4f934851491a984d3253f31ce770..05ed0738d1ff5e9e100b292d9ceb07b7d861621c 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 dbe899e9b7848e10c653dc0637674687c1d2ff4a..65a6e55a00bc34a058c08adc9f3ff6459f96ab0f 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,