By default routes are handled by connman daemon.
---
vpn/main.c | 5 ++++-
vpn/vpn-provider.c | 26 ++++++++++++++++++++++----
vpn/vpn.h | 2 +-
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/vpn/main.c b/vpn/main.c
index e89d29b..e22a46c 100644
--- a/vpn/main.c
+++ b/vpn/main.c
@@ -126,6 +126,7 @@ static gchar *option_plugin = NULL;
static gchar *option_noplugin = NULL;
static gboolean option_detach = TRUE;
static gboolean option_version = FALSE;
+static gboolean option_routes = FALSE;
static gboolean parse_debug(const char *key, const char *value,
gpointer user_data, GError **error)
@@ -149,6 +150,8 @@ static GOptionEntry options[] = {
{ "nodaemon", 'n', G_OPTION_FLAG_REVERSE,
G_OPTION_ARG_NONE, &option_detach,
"Don't fork daemon to background" },
+ { "routes", 'r', 0, G_OPTION_ARG_NONE, &option_routes,
+ "Create/delete VPN routes" },
{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
"Show version information and exit" },
{ NULL },
@@ -223,7 +226,7 @@ int main(int argc, char *argv[])
__connman_log_init(argv[0], option_debug, option_detach, FALSE,
"Connection Manager VPN daemon", VERSION);
__connman_dbus_init(conn);
- __vpn_provider_init();
+ __vpn_provider_init(option_routes);
__vpn_manager_init();
__vpn_ipconfig_init();
__vpn_rtnl_init();
diff --git a/vpn/vpn-provider.c b/vpn/vpn-provider.c
index eeb1eea..41d7e87 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -40,6 +40,7 @@ static DBusConnection *connection;
static GHashTable *provider_hash;
static GSList *driver_list;
static int configuration_count;
+static gboolean handle_routes;
struct vpn_route {
int family;
@@ -312,7 +313,9 @@ static DBusMessage *set_property(DBusConnection *conn,
DBusMessage *msg,
provider->num_user_networks = count;
set_user_networks(provider, provider->user_networks);
- provider_property_changed(provider, name, NULL);
+ if (handle_routes == FALSE)
+ provider_property_changed(provider, name,
+ NULL);
}
} else
return __connman_error_invalid_property(msg);
@@ -334,7 +337,8 @@ static DBusMessage *clear_property(DBusConnection *conn,
DBusMessage *msg,
if (g_str_equal(name, "UserRoutes") == TRUE) {
del_routes(provider);
- provider_property_changed(provider, name, NULL);
+ if (handle_routes == FALSE)
+ provider_property_changed(provider, name, NULL);
} else {
return __connman_error_invalid_property(msg);
}
@@ -989,6 +993,9 @@ static void provider_append_routes(gpointer key, gpointer
value,
struct vpn_provider *provider = user_data;
int index = provider->index;
+ if (handle_routes == FALSE)
+ return;
+
/*
* If the VPN administrator/user has given a route to
* VPN server, then we must discard that because the
@@ -1028,7 +1035,9 @@ static int set_connected(struct vpn_provider *provider,
ipconfig = provider->ipconfig_ipv4;
__vpn_ipconfig_address_add(ipconfig, provider->family);
- __vpn_ipconfig_gateway_add(ipconfig, provider->family);
+
+ if (handle_routes == TRUE)
+ __vpn_ipconfig_gateway_add(ipconfig, provider->family);
provider_indicate_state(provider,
VPN_PROVIDER_STATE_READY);
@@ -1765,6 +1774,13 @@ int vpn_provider_append_route(struct vpn_provider
*provider,
break;
}
+ if (handle_routes == FALSE) {
+ if (route->netmask != NULL && route->gateway != NULL &&
+ route->host != NULL)
+ provider_property_changed(provider, "ServerRoute",
+ route);
+ }
+
return 0;
}
@@ -1816,10 +1832,12 @@ vpn_provider_driver_unregister(struct
vpn_provider_driver *driver)
driver_list = g_slist_remove(driver_list, driver);
}
-int __vpn_provider_init(void)
+int __vpn_provider_init(gboolean do_routes)
{
DBG("");
+ handle_routes = do_routes;
+
connection = connman_dbus_get_connection();
provider_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
diff --git a/vpn/vpn.h b/vpn/vpn.h
index 10672e0..93894d1 100644
--- a/vpn/vpn.h
+++ b/vpn/vpn.h
@@ -84,7 +84,7 @@ int __vpn_provider_connect_path(const char *path);
int __vpn_provider_disconnect(struct vpn_provider *provider);
int __vpn_provider_remove(const char *path);
void __vpn_provider_cleanup(void);
-int __vpn_provider_init(void);
+int __vpn_provider_init(gboolean handle_routes);
#include "vpn-rtnl.h"
--
1.7.11.4
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman