summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2015-09-15 11:23:35 +0200
committerGert Doering <gert@greenie.muc.de>2015-09-15 13:23:21 +0200
commit429f0560e3a908ffa00f18ba1a81af03ba05751e (patch)
tree139938c1c6736f7d63363eaf3cc179744bb0553f
parentd967ec289df5c5196f68a3708a9f36a5ba354833 (diff)
downloadopenvpn-429f0560e3a908ffa00f18ba1a81af03ba05751e.zip
openvpn-429f0560e3a908ffa00f18ba1a81af03ba05751e.tar.gz
openvpn-429f0560e3a908ffa00f18ba1a81af03ba05751e.tar.xz
Use pseudo gw as default gw on Android as a workaround for not being able to read /proc/net/route
Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1442309019-7586-5-git-send-email-arne@rfc2549.org> URL: http://article.gmane.org/gmane.network.openvpn.devel/10111 Signed-off-by: Gert Doering <gert@greenie.muc.de>
-rw-r--r--src/openvpn/route.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index d7d2eee..baa4a23 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -2509,6 +2509,7 @@ get_default_gateway (struct route_gateway_info *rgi)
CLEAR(*rgi);
+#ifndef TARGET_ANDROID
/* get default gateway IP addr */
{
FILE *fp = fopen ("/proc/net/route", "r");
@@ -2565,6 +2566,19 @@ get_default_gateway (struct route_gateway_info *rgi)
}
}
}
+#else
+ /* Android, set some pseudo GW, addr is in host byte order,
+ * Determining the default GW on Android 5.0+ is non trivial
+ * and serves almost no purpose since OpenVPN only uses the
+ * default GW address to add routes for networks that should
+ * NOT be routed over the VPN. Using a well known address
+ * (127.'d'.'g'.'w') for the default GW make detecting
+ * these routes easier from the controlling app.
+ */
+ rgi->gateway.addr = 127 << 24 | 'd' << 16 | 'g' << 8 | 'w';
+ rgi->flags |= RGI_ADDR_DEFINED;
+ strcpy(best_name, "android-gw");
+#endif
/* scan adapter list */
if (rgi->flags & RGI_ADDR_DEFINED)