]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
add IPv6 route add / route delete code for windows (using "netsh")
authorGert Doering <gert@greenie.muc.de>
Sun, 28 Feb 2010 21:50:41 +0000 (22:50 +0100)
committerGert Doering <gert@greenie.muc.de>
Sun, 24 Apr 2011 15:22:39 +0000 (17:22 +0200)
 - somewhat preliminary, as the next-hop setting requirements of tun/tap
   driver are not decided yet, and "route add" might need to be adapted

route.c

diff --git a/route.c b/route.c
index 4b8e5e421db2c25b33e32351b12983bc54bc02a2..1604e9eb50fbc4c639ba029cd112c6760e967033 100644 (file)
--- a/route.c
+++ b/route.c
@@ -1340,7 +1340,24 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
 
 #elif defined (WIN32)
 
-  msg( M_FATAL, "no idea how to set IPv6 routes on windows (unimplemented)" );
+  /* 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(),
+              NETSH_PATH_SUFFIX,
+              network,
+              r6->netbits,
+              device);
+
+#if 0
+  if (r->metric_defined)
+    argv_printf_cat (&argv, "METRIC %d", r->metric);
+#endif
+
+  argv_msg (D_ROUTE, &argv);
+
+  netcmd_semaphore_lock ();
+  status = openvpn_execve_check (&argv, es, 0, "ERROR: Windows route add ipv6 command failed");
+  netcmd_semaphore_release ();
 
 #elif defined (TARGET_SOLARIS)
 
@@ -1586,7 +1603,24 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne
 
 #elif defined (WIN32)
 
-  msg( M_FATAL, "no idea how to delete IPv6 routes on windows (unimplemented)" );
+  /* 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(),
+              NETSH_PATH_SUFFIX,
+              network,
+              r6->netbits,
+              device);
+
+#if 0
+  if (r->metric_defined)
+    argv_printf_cat (&argv, "METRIC %d", r->metric);
+#endif
+
+  argv_msg (D_ROUTE, &argv);
+
+  netcmd_semaphore_lock ();
+  openvpn_execve_check (&argv, es, 0, "ERROR: Windows route add ipv6 command failed");
+  netcmd_semaphore_release ();
 
 #elif defined (TARGET_SOLARIS)