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)
{ "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 },
__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();
static GHashTable *provider_hash;
static GSList *driver_list;
static int configuration_count;
+static gboolean handle_routes;
struct vpn_route {
int family;
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);
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);
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);
}
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
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);
break;
}
+ if (handle_routes == FALSE) {
+ if (route->netmask != NULL && route->gateway != NULL &&
+ route->network != NULL)
+ provider_schedule_changed(provider,
+ SERVER_ROUTES_CHANGED);
+ }
+
return 0;
}
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,