Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Lev Stipakov <lstipakov <at> gmail.com>
Subject: [PATCH] Use adapter index instead of name
Newsgroups: gmane.network.openvpn.devel
Date: Thursday 22nd October 2015 13:09:20 UTC (over 2 years ago)
From: Olli Mannisto 

Some windows machines get weird issues with netsh when using
adapter name on "netsh.exe interface ipv6 set address" command.

Changed logic to get adapter index and use it instead of adapter
name for netsh set address command. if unable to get adapter index,
try with adapter name.

Signed-off-by: Olli Mannisto 
Signed-off-by: Lev Stipakov 
---
 src/openvpn/tun.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 24a61ec..aa0278d 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -1301,18 +1301,30 @@ do_ifconfig (struct tuntap *tt,
     if ( do_ipv6 )
       {
 	char * saved_actual;
+	const DWORD idx = get_adapter_index_flexible(actual);
 
 	if (!strcmp (actual, "NULL"))
 	  msg (M_FATAL, "Error: When using --tun-ipv6, if you have more than one
TAP-Windows adapter, you must also specify --dev-node");
 
 	/* example: netsh interface ipv6 set address MyTap 2001:608:8003::d
store=active */
-	argv_printf (&argv,
-		    "%s%sc interface ipv6 set address %s %s store=active",
-		     get_win_sys_path(),
-		     NETSH_PATH_SUFFIX,
-		     actual,
-		     ifconfig_ipv6_local );
-
+    if (idx != TUN_ADAPTER_INDEX_INVALID)
+    {
+        argv_printf (&argv,
+            "%s%sc interface ipv6 set address %u %s store=active",
+             get_win_sys_path(),
+             NETSH_PATH_SUFFIX,
+             idx,
+             ifconfig_ipv6_local);
+    }
+    else
+    {
+        argv_printf (&argv,
+            "%s%sc interface ipv6 set address %s %s store=active",
+             get_win_sys_path(),
+             NETSH_PATH_SUFFIX,
+             actual,
+             ifconfig_ipv6_local);
+    }
 	netsh_command (&argv, 4);
 
 	/* explicit route needed */
-- 
1.9.1


------------------------------------------------------------------------------
 
CD: 46ms