]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Use adapter index for add/delete_route_ipv6
authorLev Stipakov <lstipakov@gmail.com>
Fri, 11 Dec 2015 23:10:30 +0000 (01:10 +0200)
committerGert Doering <gert@greenie.muc.de>
Sun, 13 Dec 2015 20:34:19 +0000 (21:34 +0100)
Trac #637

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1449875430-15579-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10760

Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/route.c
src/openvpn/tun.c

index 1775a9c0f47658aa3259c6c774765bbcc5ba4080..cf5a0671414a3f44b891e828c82981e29db2058f 100644 (file)
@@ -1623,6 +1623,10 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
 
 #elif defined (WIN32)
 
+  struct buffer out = alloc_buf_gc (64, &gc);
+  buf_printf (&out, "interface=%d", tt->adapter_index );
+  device = buf_bptr(&out);
+
   /* netsh interface ipv6 add route 2001:db8::/32 MyTunDevice */
   argv_printf (&argv, "%s%sc interface ipv6 add route %s/%d %s",
               get_win_sys_path(),
@@ -1954,6 +1958,10 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne
 
 #elif defined (WIN32)
 
+  struct buffer out = alloc_buf_gc (64, &gc);
+  buf_printf (&out, "interface=%d", tt->adapter_index );
+  device = buf_bptr(&out);
+
   /* netsh interface ipv6 delete route 2001:db8::/32 MyTunDevice */
   argv_printf (&argv, "%s%sc interface ipv6 delete route %s/%d %s",
               get_win_sys_path(),
index b4223b1fef98af22ca9a2c8774e993550dbc157d..b08c8276111453925bf901b5df362d451e6095f3 100644 (file)
@@ -1231,11 +1231,13 @@ do_ifconfig (struct tuntap *tt,
       {
        char * saved_actual;
        char iface[64];
+       DWORD idx;
 
        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");
 
-       openvpn_snprintf(iface, sizeof(iface), "interface=%lu", get_adapter_index_flexible(actual));
+       idx = get_adapter_index_flexible(actual);
+       openvpn_snprintf(iface, sizeof(iface), "interface=%lu", idx);
 
        /* example: netsh interface ipv6 set address interface=42 2001:608:8003::d store=active */
        argv_printf (&argv,
@@ -1253,6 +1255,8 @@ do_ifconfig (struct tuntap *tt,
         */
        saved_actual = tt->actual_name;
        tt->actual_name = (char*) actual;
+       /* we use adapter_index in add_route_ipv6 */
+       tt->adapter_index = idx;
        add_route_connected_v6_net(tt, es);
        tt->actual_name = saved_actual;
       }