diff options
author | Samuel Ortiz <sameo@linux.intel.com> | 2011-01-26 17:03:12 +0100 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-01-26 17:03:12 +0100 |
commit | 91b1c84ffa2c1053737402e8ea94ca5bcc2db2f9 (patch) | |
tree | 4f115bd68908504db63a1351217738252b96da35 | |
parent | a089c11d2e4cd8149a179f605c19c4fde5a55756 (diff) | |
download | connman-91b1c84ffa2c1053737402e8ea94ca5bcc2db2f9.tar.gz connman-91b1c84ffa2c1053737402e8ea94ca5bcc2db2f9.tar.bz2 connman-91b1c84ffa2c1053737402e8ea94ca5bcc2db2f9.zip |
provider: Implement IPv6 route setting
-rw-r--r-- | include/provider.h | 3 | ||||
-rw-r--r-- | plugins/openvpn.c | 7 | ||||
-rw-r--r-- | src/provider.c | 22 |
3 files changed, 26 insertions, 6 deletions
diff --git a/include/provider.h b/include/provider.h index 569d47ff..085bda30 100644 --- a/include/provider.h +++ b/include/provider.h @@ -84,7 +84,8 @@ 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, + int family, const char *host, + const char *netmask, const char *gateway); const char *connman_provider_get_driver_name(struct connman_provider *provider); diff --git a/plugins/openvpn.c b/plugins/openvpn.c index 24aa0bc7..410cfbd7 100644 --- a/plugins/openvpn.c +++ b/plugins/openvpn.c @@ -43,6 +43,7 @@ static DBusConnection *connection; struct ov_route { + int family; char *host; char *netmask; char *gateway; @@ -64,8 +65,8 @@ static void ov_provider_append_routes(gpointer key, gpointer value, struct ov_route *route = value; struct connman_provider *provider = user_data; - connman_provider_append_route(provider, route->host, route->netmask, - route->gateway); + connman_provider_append_route(provider, route->family, route->host, + route->netmask, route->gateway); } static struct ov_route *ov_route_lookup(const char *key, const char *prefix_key, @@ -95,6 +96,8 @@ static struct ov_route *ov_route_lookup(const char *key, const char *prefix_key, return NULL; } + route->family = AF_INET; + g_hash_table_replace(routes, GINT_TO_POINTER(idx), route); } diff --git a/src/provider.c b/src/provider.c index b47b6b9d..f7a512c7 100644 --- a/src/provider.c +++ b/src/provider.c @@ -25,6 +25,7 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> #include <gdbus.h> #include "connman.h" @@ -36,6 +37,7 @@ static GHashTable *provider_hash = NULL; static GSList *driver_list = NULL; struct connman_route { + int family; char *host; char *netmask; char *gateway; @@ -331,12 +333,21 @@ static int set_connected(struct connman_provider *provider, for (list = provider->route_list; list; list = list->next) { struct connman_route *route = list->data; + int index = provider->element.index; - connman_inet_add_network_route(provider->element.index, + if (route->family == AF_INET6) { + unsigned char prefix_len = atoi(route->netmask); + + connman_inet_add_ipv6_network_route(index, + route->host, + route->gateway, + prefix_len); + } else { + connman_inet_add_network_route(index, route->host, route->gateway, route->netmask); - /* XXX Need to handle IPv6 too */ + } } } else { connman_element_unregister_children(&provider->element); @@ -747,15 +758,20 @@ int connman_provider_get_index(struct connman_provider *provider) } int connman_provider_append_route(struct connman_provider *provider, - const char *host, const char *netmask, + int family, const char *host, + const char *netmask, const char *gateway) { struct connman_route *route; + if (family != AF_INET && family != AF_INET6) + return -EINVAL; + route = g_try_new0(struct connman_route, 1); if (route == NULL) return -ENOMEM; + route->family = family; route->host = g_strdup(host); route->netmask = g_strdup(netmask); route->gateway = g_strdup(gateway); |