summaryrefslogtreecommitdiff
path: root/vpn
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-11-12 14:07:32 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-11-23 12:58:51 +0200
commita7851eb04e67a6c046c1665157a97fd6b2d42462 (patch)
tree4aa967541050e34f42f9f1f593af01ba5e0b1133 /vpn
parentf9603194e91e48ce1badc1378a7b973a7e925013 (diff)
downloadconnman-a7851eb04e67a6c046c1665157a97fd6b2d42462.tar.gz
connman-a7851eb04e67a6c046c1665157a97fd6b2d42462.tar.bz2
connman-a7851eb04e67a6c046c1665157a97fd6b2d42462.zip
vpnd: Add -r option which enables route handling in vpnd
By default routes are handled by connman daemon.
Diffstat (limited to 'vpn')
-rw-r--r--vpn/main.c5
-rw-r--r--vpn/vpn-provider.c30
-rw-r--r--vpn/vpn.h2
3 files changed, 29 insertions, 8 deletions
diff --git a/vpn/main.c b/vpn/main.c
index 35daca77..dcf3a78c 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 5dfd0106..982b2809 100644
--- a/vpn/vpn-provider.c
+++ b/vpn/vpn-provider.c
@@ -46,6 +46,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;
@@ -316,7 +317,8 @@ static void del_routes(struct vpn_provider *provider)
gpointer value, key;
g_hash_table_iter_init(&hash, provider->user_routes);
- while (g_hash_table_iter_next(&hash, &key, &value) == TRUE) {
+ while (handle_routes == TRUE && g_hash_table_iter_next(&hash,
+ &key, &value) == TRUE) {
struct vpn_route *route = value;
if (route->family == AF_INET6) {
unsigned char prefixlen = atoi(route->netmask);
@@ -398,8 +400,9 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
provider->user_networks = networks;
set_user_networks(provider, provider->user_networks);
- provider_schedule_changed(provider, USER_ROUTES_CHANGED);
- provider_property_changed(provider, name);
+ if (handle_routes == FALSE)
+ provider_schedule_changed(provider,
+ USER_ROUTES_CHANGED);
}
} else
return __connman_error_invalid_property(msg);
@@ -421,7 +424,8 @@ static DBusMessage *clear_property(DBusConnection *conn, DBusMessage *msg,
if (g_str_equal(name, "UserRoutes") == TRUE) {
del_routes(provider);
- provider_property_changed(provider, name);
+ if (handle_routes == FALSE)
+ provider_property_changed(provider, name);
} else {
return __connman_error_invalid_property(msg);
}
@@ -1241,6 +1245,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
@@ -1280,7 +1287,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);
@@ -2004,6 +2013,13 @@ int vpn_provider_append_route(struct vpn_provider *provider,
break;
}
+ if (handle_routes == FALSE) {
+ if (route->netmask != NULL && route->gateway != NULL &&
+ route->network != NULL)
+ provider_schedule_changed(provider,
+ SERVER_ROUTES_CHANGED);
+ }
+
return 0;
}
@@ -2052,10 +2068,12 @@ void 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 10672e02..93894d12 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"