v3: * Use interface=<idx> syntax. * Add forward declaration of get_adapter_index_flexible to get rid of warning.
v2: * Remove netsh call which uses adapter name. After thoughtful testing turns out that "adapter name" code branch is never used. 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 <olmanni...@gmail.com> Signed-off-by: Lev Stipakov <lstipa...@gmail.com> --- src/openvpn/tun.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 24a61ec..070fd18 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -67,6 +67,8 @@ static void netsh_command (const struct argv *a, int n); static const char *netsh_get_id (const char *dev_node, struct gc_arena *gc); +static DWORD get_adapter_index_flexible (const char *name); + #endif #ifdef TARGET_SOLARIS @@ -1301,18 +1303,20 @@ do_ifconfig (struct tuntap *tt, if ( do_ipv6 ) { char * saved_actual; + char iface[64]; 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 */ + openvpn_snprintf(iface, sizeof(iface), "interface=%lu", get_adapter_index_flexible(actual)); + + /* example: netsh interface ipv6 set address interface=42 2001:608:8003::d store=active */ argv_printf (&argv, - "%s%sc interface ipv6 set address %s %s store=active", + "%s%sc interface ipv6 set address %s %s store=active", get_win_sys_path(), NETSH_PATH_SUFFIX, - actual, - ifconfig_ipv6_local ); - + iface, + ifconfig_ipv6_local); netsh_command (&argv, 4); /* explicit route needed */ -- 1.9.1