*
* Connection Manager
*
- * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2012 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
#include <config.h>
#endif
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
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);
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"))
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,
+ prefix_len, gateway);
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);
return 0;
}
+static int oc_save (struct connman_provider *provider, GKeyFile *keyfile)
+{
+ const char *setting;
+
+ setting = connman_provider_get_string(provider,
+ "OpenConnect.ServerCert");
+ if (setting != NULL)
+ g_key_file_set_string(keyfile,
+ connman_provider_get_save_group(provider),
+ "OpenConnect.ServerCert", setting);
+
+ setting = connman_provider_get_string(provider,
+ "OpenConnect.CACert");
+ if (setting != NULL)
+ g_key_file_set_string(keyfile,
+ connman_provider_get_save_group(provider),
+ "OpenConnect.CACert", setting);
+
+ setting = connman_provider_get_string(provider,
+ "VPN.MTU");
+ if (setting != NULL)
+ g_key_file_set_string(keyfile,
+ connman_provider_get_save_group(provider),
+ "VPN.MTU", setting);
+
+ return 0;
+}
+
static int oc_error_code(int exit_code)
{
.notify = oc_notify,
.connect = oc_connect,
.error_code = oc_error_code,
+ .save = oc_save,
};
static int openconnect_init(void)