summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2011-02-25 19:36:33 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2011-02-25 19:55:29 +0100
commitb26c668fd1ffbd32961a6c23e852ee346de4fa1a (patch)
tree117df8f8981870bc8b23629084bed5975ef6ac5b /plugins
parent76b454562798599cfc81ada45e3d634117c89aed (diff)
downloadconnman-b26c668fd1ffbd32961a6c23e852ee346de4fa1a.tar.gz
connman-b26c668fd1ffbd32961a6c23e852ee346de4fa1a.tar.bz2
connman-b26c668fd1ffbd32961a6c23e852ee346de4fa1a.zip
openconnect: Support IPv6 settings
Diffstat (limited to 'plugins')
-rw-r--r--plugins/openconnect.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/plugins/openconnect.c b/plugins/openconnect.c
index 45c78fe5..94bfcfcc 100644
--- a/plugins/openconnect.c
+++ b/plugins/openconnect.c
@@ -23,6 +23,7 @@
#include <config.h>
#endif
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
@@ -44,7 +45,9 @@ static int oc_notify(DBusMessage *msg, struct connman_provider *provider)
DBusMessageIter iter, dict;
const char *reason, *key, *value;
const char *domain = NULL;
- char *address = NULL, *netmask = NULL, *gateway = NULL;
+ char *addressv4 = NULL, *addressv6 = NULL;
+ char *netmask = NULL, *gateway = NULL;
+ unsigned char prefix_len = 0;
struct connman_ipaddress *ipaddress;
dbus_message_iter_init(msg, &iter);
@@ -79,12 +82,32 @@ static int oc_notify(DBusMessage *msg, struct connman_provider *provider)
gateway = g_strdup(value);
if (!strcmp(key, "INTERNAL_IP4_ADDRESS"))
- address = g_strdup(value);
+ addressv4 = g_strdup(value);
+
+ if (!strcmp(key, "INTERNAL_IP6_ADDRESS")) {
+ addressv6 = g_strdup(value);
+ prefix_len = 128;
+ }
if (!strcmp(key, "INTERNAL_IP4_NETMASK"))
netmask = g_strdup(value);
- if (!strcmp(key, "INTERNAL_IP4_DNS"))
+ if (!strcmp(key, "INTERNAL_IP6_NETMASK")) {
+ char *sep;
+
+ /* The netmask contains the address and the prefix */
+ sep = strchr(value, '/');
+ if (sep != NULL) {
+ unsigned char ip_len = sep - value;
+
+ addressv6 = g_strndup(value, ip_len);
+ prefix_len = (unsigned char)
+ strtol(sep + 1, NULL, 10);
+ }
+ }
+
+ if (!strcmp(key, "INTERNAL_IP4_DNS") ||
+ !strcmp(key, "INTERNAL_IP6_DNS"))
connman_provider_set_nameservers(provider, value);
if (!strcmp(key, "CISCO_PROXY_PAC"))
@@ -100,20 +123,35 @@ static int oc_notify(DBusMessage *msg, struct connman_provider *provider)
dbus_message_iter_next(&dict);
}
- ipaddress = connman_ipaddress_alloc(AF_INET);
+ DBG("%p %p", addressv4, addressv6);
+
+ if (addressv4 != NULL)
+ ipaddress = connman_ipaddress_alloc(AF_INET);
+ else if (addressv6 != NULL)
+ ipaddress = connman_ipaddress_alloc(AF_INET6);
+ else
+ ipaddress = NULL;
+
if (ipaddress == NULL) {
- g_free(address);
+ g_free(addressv4);
+ g_free(addressv6);
g_free(netmask);
g_free(gateway);
return VPN_STATE_FAILURE;
}
- connman_ipaddress_set_ipv4(ipaddress, address, netmask, gateway);
+ if (addressv4 != NULL)
+ connman_ipaddress_set_ipv4(ipaddress, addressv4,
+ netmask, gateway);
+ else
+ connman_ipaddress_set_ipv6(ipaddress, addressv6,
+ gateway, prefix_len);
connman_provider_set_ipaddress(provider, ipaddress);
connman_provider_set_domain(provider, domain);
- g_free(address);
+ g_free(addressv4);
+ g_free(addressv6);
g_free(netmask);
g_free(gateway);
connman_ipaddress_free(ipaddress);