projects
/
framework
/
connectivity
/
connman.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
76b4545
)
openconnect: Support IPv6 settings
author
Samuel Ortiz
<sameo@linux.intel.com>
Fri, 25 Feb 2011 18:36:33 +0000
(19:36 +0100)
committer
Samuel Ortiz
<sameo@linux.intel.com>
Fri, 25 Feb 2011 18:55:29 +0000
(19:55 +0100)
plugins/openconnect.c
patch
|
blob
|
history
diff --git
a/plugins/openconnect.c
b/plugins/openconnect.c
index
45c78fe
..
94bfcfc
100644
(file)
--- a/
plugins/openconnect.c
+++ b/
plugins/openconnect.c
@@
-23,6
+23,7
@@
#include <config.h>
#endif
#include <config.h>
#endif
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.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;
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);
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"))
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_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"))
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);
}
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) {
if (ipaddress == NULL) {
- g_free(address);
+ g_free(addressv4);
+ g_free(addressv6);
g_free(netmask);
g_free(gateway);
return VPN_STATE_FAILURE;
}
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);
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);
g_free(netmask);
g_free(gateway);
connman_ipaddress_free(ipaddress);