summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Wagner <daniel.wagner@bmw-carit.de>2010-12-17 15:52:02 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2010-12-21 01:33:14 +0100
commit0159e2d07b2934d3229b9510f0ab5ba9c6711617 (patch)
tree8133e3e4259e73a51a2d5a62a376a8816c520b4b
parent756ac7134faf93c05b1d4b639123d785cddfa164 (diff)
downloadconnman-0159e2d07b2934d3229b9510f0ab5ba9c6711617.tar.gz
connman-0159e2d07b2934d3229b9510f0ab5ba9c6711617.tar.bz2
connman-0159e2d07b2934d3229b9510f0ab5ba9c6711617.zip
openvpn: Add pushed routes
We should add the routing entries pushed by the OpenVPN server.
-rw-r--r--include/provider.h4
-rw-r--r--src/provider.c47
2 files changed, 51 insertions, 0 deletions
diff --git a/include/provider.h b/include/provider.h
index dde37fba..569d47ff 100644
--- a/include/provider.h
+++ b/include/provider.h
@@ -83,6 +83,10 @@ void connman_provider_set_dns(struct connman_provider *provider,
void connman_provider_set_domain(struct connman_provider *provider,
const char *domain);
+int connman_provider_append_route(struct connman_provider *provider,
+ const char *host, const char *netmask,
+ const char *gateway);
+
const char *connman_provider_get_driver_name(struct connman_provider *provider);
struct connman_provider_driver {
diff --git a/src/provider.c b/src/provider.c
index efcf7481..53b3ddd3 100644
--- a/src/provider.c
+++ b/src/provider.c
@@ -35,6 +35,12 @@ static GHashTable *provider_hash = NULL;
static GSList *driver_list = NULL;
+struct connman_route {
+ char *host;
+ char *netmask;
+ char *gateway;
+};
+
struct connman_provider {
struct connman_element element;
struct connman_service *vpn_service;
@@ -44,6 +50,7 @@ struct connman_provider {
char *host;
char *dns;
char *domain;
+ GSList *route_list;
struct connman_provider_driver *driver;
void *driver_data;
};
@@ -261,6 +268,7 @@ static int set_connected(struct connman_provider *provider,
char *nameservers = NULL, *name = NULL;
const char *value;
char *second_ns;
+ GSList *list;
int err;
__connman_service_indicate_state(provider->vpn_service,
@@ -312,6 +320,15 @@ static int set_connected(struct connman_provider *provider,
g_free(nameservers);
g_free(name);
+ for (list = provider->route_list; list; list = list->next) {
+ struct connman_route *route = list->data;
+
+ connman_inet_add_network_route(provider->element.index,
+ route->host,
+ route->gateway,
+ route->netmask);
+ /* XXX Need to handle IPv6 too */
+ }
} else {
connman_element_unregister_children(&provider->element);
__connman_service_indicate_state(service,
@@ -365,6 +382,7 @@ static void unregister_provider(gpointer data)
static void provider_destruct(struct connman_element *element)
{
struct connman_provider *provider = element->private;
+ GSList *list;
DBG("provider %p", provider);
@@ -373,6 +391,15 @@ static void provider_destruct(struct connman_element *element)
g_free(provider->domain);
g_free(provider->identifier);
g_free(provider->dns);
+
+ for (list = provider->route_list; list; list = list->next) {
+ struct connman_route *route = list->data;
+
+ g_free(route->host);
+ g_free(route->netmask);
+ g_free(route->gateway);
+ }
+ g_slist_free(provider->route_list);
}
static void provider_initialize(struct connman_provider *provider)
@@ -395,6 +422,7 @@ static void provider_initialize(struct connman_provider *provider)
provider->dns = NULL;
provider->domain = NULL;
provider->identifier = NULL;
+ provider->route_list = NULL;
}
static struct connman_provider *connman_provider_new(void)
@@ -709,6 +737,25 @@ int connman_provider_get_index(struct connman_provider *provider)
return provider->element.index;
}
+int connman_provider_append_route(struct connman_provider *provider,
+ const char *host, const char *netmask,
+ const char *gateway)
+{
+ struct connman_route *route;
+
+ route = g_try_new0(struct connman_route, 1);
+ if (route == NULL)
+ return -ENOMEM;
+
+ route->host = g_strdup(host);
+ route->netmask = g_strdup(netmask);
+ route->gateway = g_strdup(gateway);
+
+ provider->route_list = g_slist_append(provider->route_list, route);
+
+ return TRUE;
+}
+
const char *connman_provider_get_driver_name(struct connman_provider *provider)
{
return provider->driver->name;