aboutsummaryrefslogtreecommitdiff
path: root/route.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-12-22 18:55:49 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2005-12-22 18:55:49 +0000
commit6215931bffed74b6e02062f28b0f22f4090da727 (patch)
tree60f1d8a6de1c759f13838773816992f35fc5e1d6 /route.c
parent--ip-win32 adaptive is now the default. (diff)
downloadopenvpn-6215931bffed74b6e02062f28b0f22f4090da727.tar.xz
Added new option --route-method adaptive (Win32)
which tries IP helper API first, then falls back to route.exe. Made --route-method adaptive the default. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@858 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'route.c')
-rw-r--r--route.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/route.c b/route.c
index 06e1fac..5ca48bc 100644
--- a/route.c
+++ b/route.c
@@ -22,8 +22,6 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* JYFIXME WIN32 todo: add adaptive route-method */
-
/*
* Support routines for adding/deleting network routes.
*/
@@ -812,6 +810,18 @@ add_route (struct route *r, const struct tuntap *tt, unsigned int flags, const s
status = system_check (BSTR (&buf), es, 0, "ERROR: Windows route add command failed");
netcmd_semaphore_release ();
}
+ else if ((flags & ROUTE_METHOD_MASK) == ROUTE_METHOD_ADAPTIVE)
+ {
+ status = add_route_ipapi (r, tt);
+ msg (D_ROUTE, "Route addition via IPAPI %s [adaptive]", status ? "succeeded" : "failed");
+ if (!status)
+ {
+ msg (D_ROUTE, "Route addition fallback to route.exe");
+ netcmd_semaphore_lock ();
+ status = system_check (BSTR (&buf), es, 0, "ERROR: Windows route add command failed [adaptive]");
+ netcmd_semaphore_release ();
+ }
+ }
else
{
ASSERT (0);
@@ -949,6 +959,18 @@ delete_route (const struct route *r, const struct tuntap *tt, unsigned int flags
system_check (BSTR (&buf), es, 0, "ERROR: Windows route delete command failed");
netcmd_semaphore_release ();
}
+ else if ((flags & ROUTE_METHOD_MASK) == ROUTE_METHOD_ADAPTIVE)
+ {
+ const bool status = del_route_ipapi (r, tt);
+ msg (D_ROUTE, "Route deletion via IPAPI %s [adaptive]", status ? "succeeded" : "failed");
+ if (!status)
+ {
+ msg (D_ROUTE, "Route deletion fallback to route.exe");
+ netcmd_semaphore_lock ();
+ system_check (BSTR (&buf), es, 0, "ERROR: Windows route delete command failed [adaptive]");
+ netcmd_semaphore_release ();
+ }
+ }
else
{
ASSERT (0);