Pass adapter index to up/down scripts
PATCH 1/1 Pass adapter index to up/down scripts
Trac #637
Signed-off-by Lev Stipakov <[email protected]...>
--- src/openvpn/init.c | 18 ++++++++++++++++++ src/openvpn/misc.c | 6 ++++++ src/openvpn/misc.h | 3 +++ 3 files changed, 27 insertions(+)
src/openvpn/init.c +18 -0
@@ -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, +#endifdev_type_string (c->options.dev, c->options.dev_type),TUN_MTU_SIZE (&c->c2.frame), EXPANDED_SIZE (&c->c2.frame),
@@ -1526,6 +1529,9 @@ do_open_tun (struct context *c) c->plugins,OPENVPN_PLUGIN_UP , c->c1.tuntap->actual_name, +#ifdef WIN32 + c->c1.tuntap->adapter_index, +#endifdev_type_string (c->options.dev, c->options.dev_type),TUN_MTU_SIZE (&c->c2.frame), EXPANDED_SIZE (&c->c2.frame),
@@ -1564,6 +1570,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;
@@ -1587,6 +1596,9 @@ do_close_tun (struct context *c, bool force) c->plugins,OPENVPN_PLUGIN_ROUTE_PREDOWN , tuntap_actual, +#ifdef WIN32 + adapter_index, +#endifNULL ,TUN_MTU_SIZE (&c->c2.frame), EXPANDED_SIZE (&c->c2.frame),
@@ -1612,6 +1624,9 @@ do_close_tun (struct context *c, bool force) c->plugins,OPENVPN_PLUGIN_DOWN , tuntap_actual, +#ifdef WIN32 + adapter_index, +#endifNULL ,TUN_MTU_SIZE (&c->c2.frame), EXPANDED_SIZE (&c->c2.frame),
@@ -1635,6 +1650,9 @@ do_close_tun (struct context *c, bool force) c->plugins,OPENVPN_PLUGIN_DOWN , tuntap_actual, +#ifdef WIN32 + adapter_index, +#endifNULL ,TUN_MTU_SIZE (&c->c2.frame), EXPANDED_SIZE (&c->c2.frame),
src/openvpn/misc.c +6 -0
@@ -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 ="" ;
src/openvpn/misc.h +3 -0
@@ -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,
Signature · 1 line
1.9.1
ACK. I have not actually compile-tested this (buildbot will :-) ) but it looks reasonable and since we've decided to use idx for netsh.exe, it should be available to scripts too.
Your patch has been applied to the master and release/2.3 branch.
I've taken the liberty of actually documenting $env_idx in doc/openvpn.8
commit 9dff2c1f106865a72a1d505076751dde170e88dc (master) commit 9fe2ac8d51b8182f5e8e41ce7c875f451de10191 (release/2.3)
Author: Lev Stipakov Date: Sat Dec 12 14:34:20 2015 +0200
Pass adapter index to up/down scripts
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10762
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering