aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--options.c8
-rw-r--r--route.c26
-rw-r--r--route.h9
4 files changed, 38 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index e8c2005..ac0dbc4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,6 +36,10 @@ $Id$
* --ip-win32 netsh (or --ip-win32 adaptive when in netsh
mode) can now set DNS/WINS addresses on the TAP-Win32
adapter.
+* 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.
2005.11.12 -- Version 2.1-beta7
diff --git a/options.c b/options.c
index 75c8825..6614c3e 100644
--- a/options.c
+++ b/options.c
@@ -644,7 +644,7 @@ init_options (struct options *o)
#endif
o->tuntap_options.dhcp_lease_time = 31536000; /* one year */
o->tuntap_options.dhcp_masq_offset = 0; /* use network address as internal DHCP server address */
- o->route_method = ROUTE_METHOD_IPAPI;
+ o->route_method = ROUTE_METHOD_ADAPTIVE;
#endif
#ifdef USE_PTHREAD
o->n_threads = 1;
@@ -4318,13 +4318,15 @@ add_option (struct options *options,
else if (streq (p[0], "route-method") && p[1])
{
VERIFY_PERMISSION (OPT_P_ROUTE_EXTRAS);
- if (streq (p[1], "ipapi"))
+ if (streq (p[1], "adaptive"))
+ options->route_method = ROUTE_METHOD_ADAPTIVE;
+ else if (streq (p[1], "ipapi"))
options->route_method = ROUTE_METHOD_IPAPI;
else if (streq (p[1], "exe"))
options->route_method = ROUTE_METHOD_EXE;
else
{
- msg (msglevel, "--route method must be 'ipapi' or 'exe'");
+ msg (msglevel, "--route method must be 'adaptive', 'ipapi', or 'exe'");
goto err;
}
}
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);
diff --git a/route.h b/route.h
index c2da533..9cbc773 100644
--- a/route.h
+++ b/route.h
@@ -38,15 +38,16 @@
/*
* Windows route methods
*/
-#define ROUTE_METHOD_IPAPI 0 /* use IP helper API */
-#define ROUTE_METHOD_EXE 1 /* use route.exe */
-#define ROUTE_METHOD_MASK 1
+#define ROUTE_METHOD_ADAPTIVE 0 /* try IP helper first then route.exe */
+#define ROUTE_METHOD_IPAPI 1 /* use IP helper API */
+#define ROUTE_METHOD_EXE 2 /* use route.exe */
+#define ROUTE_METHOD_MASK 3
#endif
/*
* Route add flags (must stay clear of ROUTE_METHOD bits)
*/
-#define ROUTE_DELETE_FIRST 2
+#define ROUTE_DELETE_FIRST 4
struct route_bypass
{