Only manual/fixed setting supported for now.
until the new configuration has been successfully
installed.
+ dict IPv6 [readonly]
+
+ string Method [readonly]
+
+ Possible values are "dhcp", "manual"
+ and "off".
+
+ The value "fixed" indicates an IP address
+ that can not be modified. For example
+ cellular networks return fixed information.
+
+ "dhcp" is not supported currently.
+
+ string Address [readonly]
+
+ The current configured IPv6 address.
+
+ uint8 PrefixLength [readonly]
+
+ The prefix length of the IPv6 address.
+
+ string Gateway [readonly]
+
+ The current configured IPv6 gateway.
+
+ dict IPv6.Configuration [readwrite]
+
+ Same values as IPv6 property. The IPv6 represents
+ the actual system configuration while this allows
+ user configuration.
+
+ Changing these settings will cause a state change
+ of the service. The service will become unavailable
+ until the new configuration has been successfully
+ installed.
+
dict Proxy [readonly]
string Method [readonly]
gchar *timeserver;
gchar *pac;
} ipv4;
+
+ struct {
+ enum connman_ipconfig_method method;
+ gchar *address;
+ int prefix_len;
+ gchar *gateway;
+ gchar *network;
+ } ipv6;
};
struct connman_element *connman_element_create(const char *name);
int connman_inet_set_gateway_interface(int index);
int connman_inet_clear_gateway_interface(int index);
connman_bool_t connman_inet_compare_subnet(int index, const char *host);
+int connman_inet_set_ipv6_address(int index,
+ struct connman_ipaddress *ipaddress);
+int connman_inet_clear_ipv6_address(int index,
+ const char *address, int prefix_len);
+int connman_inet_add_ipv6_host_route(int index, const char *host,
+ const char *gateway);
+int connman_inet_del_ipv6_host_route(int index, const char *host);
+int connman_inet_set_ipv6_gateway_address(int index, const char *gateway);
+int connman_inet_clear_ipv6_gateway_address(int index, const char *gateway);
+
+void connman_ipaddress_set_ipv4(struct connman_ipaddress *ipaddress,
+ const char *address, const char *netmask, const char *gateway);
#ifdef __cplusplus
}
void connman_ipconfig_set_ops(struct connman_ipconfig *ipconfig,
const struct connman_ipconfig_ops *ops);
-
+int connman_ipaddress_set_ipv6(struct connman_ipaddress *ipaddress,
+ const char *address, const char *gateway,
+ unsigned char prefix_length);
+struct connman_ipconfig *connman_ipconfig_get_ipv6config(
+ struct connman_ipconfig *ipconfig);
int connman_ipconfig_set_method(struct connman_ipconfig *ipconfig,
enum connman_ipconfig_method method);
-
void connman_ipconfig_bind(struct connman_ipconfig *ipconfig,
struct connman_ipaddress *ipaddress);
CONNMAN_PROPERTY_ID_IPV4_NAMESERVER,
CONNMAN_PROPERTY_ID_IPV4_TIMESERVER,
CONNMAN_PROPERTY_ID_IPV4_PAC,
+
+ CONNMAN_PROPERTY_ID_IPV6_METHOD,
+ CONNMAN_PROPERTY_ID_IPV6_ADDRESS,
+ CONNMAN_PROPERTY_ID_IPV6_PREFIXLEN,
+ CONNMAN_PROPERTY_ID_IPV6_GATEWAY,
};
enum connman_property_type {
struct gateway_data {
int index;
char *ipv4_gateway;
+ char *ipv6_gateway;
struct connman_element *element;
unsigned int order;
gboolean active;
} else if (g_strcmp0(data->ipv4_gateway, "0.0.0.0") == 0) {
return connman_inet_clear_gateway_interface(data->index);
} else {
+ connman_inet_del_ipv6_host_route(data->index,
+ data->ipv6_gateway);
+ connman_inet_clear_ipv6_gateway_address(data->index,
+ data->ipv6_gateway);
connman_inet_del_host_route(data->index, data->ipv4_gateway);
return connman_inet_clear_gateway_address(data->index,
data->ipv4_gateway);
data->element = element;
}
-static struct gateway_data *add_gateway(int index, const char *gateway)
+static struct gateway_data *add_gateway(int index, const char *gateway,
+ const char *ipv6_gateway)
{
struct gateway_data *data;
struct connman_service *service;
+ DBG("index %d gateway %s ipv6_gateway %s", index, gateway,
+ ipv6_gateway);
+
if (strlen(gateway) == 0)
return NULL;
data->index = index;
data->ipv4_gateway = g_strdup(gateway);
+ data->ipv6_gateway = g_strdup(ipv6_gateway);
data->active = FALSE;
data->element = NULL;
data->vpn_ip = NULL;
goto done;
}
+ connman_inet_set_ipv6_gateway_address(element->index,
+ data->ipv6_gateway);
if (connman_inet_set_gateway_address(element->index,
data->ipv4_gateway) < 0)
return;
static int connection_probe(struct connman_element *element)
{
struct connman_service *service = NULL;
- const char *gateway = NULL;
+ const char *gateway = NULL, *ipv6_gateway = NULL;
const char *vpn_ip = NULL;
struct gateway_data *active_gateway = NULL;
struct gateway_data *new_gateway = NULL;
connman_element_get_value(element,
CONNMAN_PROPERTY_ID_IPV4_GATEWAY, &gateway);
+ connman_element_get_value(element,
+ CONNMAN_PROPERTY_ID_IPV6_GATEWAY, &ipv6_gateway);
connman_element_get_value(element,
CONNMAN_PROPERTY_ID_IPV4_ADDRESS, &vpn_ip);
- DBG("gateway %s", gateway);
+ DBG("gateway %s, ipv6_gateway %s", gateway, ipv6_gateway);
/*
* If gateway is NULL, it's a point to point link and the default
connman_element_set_enabled(element, TRUE);
active_gateway = find_active_gateway();
- new_gateway = add_gateway(element->index, gateway);
+ new_gateway = add_gateway(element->index, gateway, ipv6_gateway);
if (new_gateway == NULL)
return 0;
service = __connman_element_get_service(element);
+ connman_inet_add_ipv6_host_route(element->index,
+ new_gateway->ipv6_gateway, NULL);
connman_inet_add_host_route(element->index,
new_gateway->ipv4_gateway, NULL);
__connman_service_nameserver_add_routes(service,
DBusMessageIter *iter);
void __connman_ipconfig_append_ipv4config(struct connman_ipconfig *ipconfig,
DBusMessageIter *iter);
-int __connman_ipconfig_set_ipv4config(struct connman_ipconfig *ipconfig,
- DBusMessageIter *value);
+void __connman_ipconfig_append_ipv6(struct connman_ipconfig *ipconfig,
+ DBusMessageIter *iter);
+void __connman_ipconfig_append_ipv6config(struct connman_ipconfig *ipconfig,
+ DBusMessageIter *iter);
+int __connman_ipconfig_set_config(struct connman_ipconfig *ipconfig,
+ enum connman_ipconfig_type type, DBusMessageIter *array);
void __connman_ipconfig_append_proxy(struct connman_ipconfig *ipconfig,
DBusMessageIter *iter);
void __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
DBusMessageIter *iter);
enum connman_ipconfig_method __connman_ipconfig_get_method(
struct connman_ipconfig *ipconfig);
+
+void __connman_ipconfig_set_element_ipv6_gateway(
+ struct connman_ipconfig *ipconfig,
+ struct connman_element *element);
+
int __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig,
struct connman_element *parent);
int __connman_ipconfig_set_address(struct connman_ipconfig *ipconfig);
id, value);
*((char **) value) = element->ipv4.pac;
break;
+ case CONNMAN_PROPERTY_ID_IPV6_GATEWAY:
+ if (element->ipv6.gateway == NULL)
+ return connman_element_get_value(element->parent,
+ id, value);
+ *((char **) value) = element->ipv6.gateway;
+ break;
+
default:
return -EINVAL;
}
return device;
}
+struct in6_ifreq {
+ struct in6_addr ifr6_addr;
+ __u32 ifr6_prefixlen;
+ unsigned int ifr6_ifindex;
+};
+
+int connman_inet_set_ipv6_address(int index,
+ struct connman_ipaddress *ipaddress)
+{
+ int sk, err;
+ struct in6_ifreq ifr6;
+
+ DBG("index %d ipaddress->local %s", index, ipaddress->local);
+
+ if (ipaddress->local == NULL)
+ return 0;
+
+ sk = socket(PF_INET6, SOCK_DGRAM, 0);
+ if (sk < 0) {
+ err = -1;
+ goto out;
+ }
+
+ memset(&ifr6, 0, sizeof(ifr6));
+
+ err = inet_pton(AF_INET6, ipaddress->local, &ifr6.ifr6_addr);
+ if (err < 0)
+ goto out;
+
+ ifr6.ifr6_ifindex = index;
+ ifr6.ifr6_prefixlen = ipaddress->prefixlen;
+
+ err = ioctl(sk, SIOCSIFADDR, &ifr6);
+ close(sk);
+out:
+ if (err < 0)
+ connman_error("Set IPv6 address error");
+
+ return err;
+}
+
int connman_inet_set_address(int index, struct connman_ipaddress *ipaddress)
{
struct ifreq ifr;
return 0;
}
+int connman_inet_clear_ipv6_address(int index, const char *address,
+ int prefix_len)
+{
+ struct in6_ifreq ifr6;
+ int sk, err;
+
+ DBG("index %d address %s prefix_len %d", index, address, prefix_len);
+
+ memset(&ifr6, 0, sizeof(ifr6));
+
+ err = inet_pton(AF_INET6, address, &ifr6.ifr6_addr);
+ if (err < 0)
+ goto out;
+
+ ifr6.ifr6_ifindex = index;
+ ifr6.ifr6_prefixlen = prefix_len;
+
+ sk = socket(PF_INET6, SOCK_DGRAM, 0);
+ if (sk < 0) {
+ err = -1;
+ goto out;
+ }
+
+ err = ioctl(sk, SIOCDIFADDR, &ifr6);
+ close(sk);
+out:
+ if (err < 0)
+ connman_error("Clear IPv6 address error");
+
+ return err;
+}
+
int connman_inet_clear_address(int index)
{
+
+
struct ifreq ifr;
struct sockaddr_in addr;
int sk, err;
return err;
}
+int connman_inet_del_ipv6_host_route(int index, const char *host)
+{
+ struct in6_rtmsg rt;
+ int sk, err;
+
+ DBG("index %d host %s", index, host);
+
+ if (host == NULL)
+ return -EINVAL;
+
+ memset(&rt, 0, sizeof(rt));
+
+ rt.rtmsg_dst_len = 128;
+
+ err = inet_pton(AF_INET6, host, &rt.rtmsg_dst);
+ if (err < 0)
+ goto out;
+
+ rt.rtmsg_flags = RTF_UP | RTF_HOST;
+
+ rt.rtmsg_metric = 1;
+ rt.rtmsg_ifindex = index;
+
+ sk = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (sk < 0) {
+ err = -1;
+ goto out;
+ }
+
+ err = ioctl(sk, SIOCDELRT, &rt);
+ close(sk);
+out:
+ if (err < 0)
+ connman_error("Del IPv6 host route error");
+
+ return err;
+}
+
+int connman_inet_add_ipv6_host_route(int index, const char *host,
+ const char *gateway)
+{
+ struct in6_rtmsg rt;
+ int sk, err;
+
+ DBG("index %d host %s gateway %s", index, host, gateway);
+
+ if (host == NULL)
+ return -EINVAL;
+
+ memset(&rt, 0, sizeof(rt));
+
+ rt.rtmsg_dst_len = 128;
+
+ err = inet_pton(AF_INET6, host, &rt.rtmsg_dst);
+ if (err < 0)
+ goto out;
+
+ rt.rtmsg_flags = RTF_UP | RTF_HOST;
+
+ if (gateway != NULL) {
+ rt.rtmsg_flags |= RTF_GATEWAY;
+ inet_pton(AF_INET6, gateway, &rt.rtmsg_gateway);
+ }
+
+ rt.rtmsg_metric = 1;
+ rt.rtmsg_ifindex = index;
+
+ sk = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (sk < 0) {
+ err = -1;
+ goto out;
+ }
+
+ err = ioctl(sk, SIOCADDRT, &rt);
+ close(sk);
+out:
+ if (err < 0)
+ connman_error("Set IPv6 host route error");
+
+ return err;
+}
+
+int connman_inet_set_ipv6_gateway_address(int index, const char *gateway)
+{
+ struct in6_rtmsg rt;
+ int sk, err;
+
+ DBG("index %d, gateway %s", index, gateway);
+
+ if (gateway == NULL)
+ return -EINVAL;
+
+ memset(&rt, 0, sizeof(rt));
+
+ err = inet_pton(AF_INET6, gateway, &rt.rtmsg_gateway);
+ if (err < 0)
+ goto out;
+
+ rt.rtmsg_flags = RTF_UP | RTF_GATEWAY;
+ rt.rtmsg_metric = 1;
+ rt.rtmsg_dst_len = 0;
+ rt.rtmsg_ifindex = index;
+
+ sk = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (sk < 0) {
+ err = -1;
+ goto out;
+ }
+
+ err = ioctl(sk, SIOCADDRT, &rt);
+ close(sk);
+out:
+ if (err < 0)
+ connman_error("Set default IPv6 gateway error");
+
+ return err;
+}
+
+int connman_inet_clear_ipv6_gateway_address(int index, const char *gateway)
+{
+ struct in6_rtmsg rt;
+ int sk, err;
+
+ DBG("index %d, gateway %s", index, gateway);
+
+ if (gateway == NULL)
+ return -EINVAL;
+
+ memset(&rt, 0, sizeof(rt));
+
+ err = inet_pton(AF_INET6, gateway, &rt.rtmsg_gateway);
+ if (err < 0)
+ goto out;
+
+ rt.rtmsg_flags = RTF_UP | RTF_GATEWAY;
+ rt.rtmsg_metric = 1;
+ rt.rtmsg_dst_len = 0;
+ rt.rtmsg_ifindex = index;
+
+ sk = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (sk < 0) {
+ err = -1;
+ goto out;
+ }
+
+ err = ioctl(sk, SIOCDELRT, &rt);
+ close(sk);
+out:
+ if (err < 0)
+ connman_error("Clear default IPv6 gateway error");
+
+ return err;
+}
+
int connman_inet_set_gateway_address(int index, const char *gateway)
{
struct ifreq ifr;
#include <net/if.h>
#include <net/if_arp.h>
#include <linux/if_link.h>
+#include <string.h>
+#include <stdlib.h>
#ifndef IFF_LOWER_UP
#define IFF_LOWER_UP 0x10000
struct connman_ipconfig {
gint refcount;
int index;
+ enum connman_ipconfig_type type;
struct connman_ipconfig *origin;
enum connman_ipconfig_method method;
struct connman_ipaddress *address;
struct connman_ipaddress *system;
+
+ struct connman_ipconfig *ipv6;
};
struct connman_ipdevice {
if (ipaddress == NULL)
return NULL;
+ ipaddress->prefixlen = 0;
+ ipaddress->local = NULL;
+ ipaddress->peer = NULL;
+ ipaddress->broadcast = NULL;
+ ipaddress->gateway = NULL;
+
return ipaddress;
}
return bits;
}
-void connman_ipaddress_set(struct connman_ipaddress *ipaddress,
+static gboolean check_ipv6_address(const char *address)
+{
+ unsigned char buf[sizeof(struct in6_addr)];
+ int err;
+
+ err = inet_pton(AF_INET6, address, buf);
+ if (err > 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+int connman_ipaddress_set_ipv6(struct connman_ipaddress *ipaddress,
+ const char *address, const char *gateway,
+ unsigned char prefix_length)
+{
+ if (ipaddress == NULL)
+ return -EINVAL;
+
+ if (check_ipv6_address(address) == FALSE)
+ return -EINVAL;
+
+ if (check_ipv6_address(gateway) == FALSE)
+ return -EINVAL;
+
+ DBG("prefix_len %d address %s gateway %s",
+ prefix_length, address, gateway);
+
+ ipaddress->prefixlen = prefix_length;
+
+ g_free(ipaddress->local);
+ ipaddress->local = g_strdup(address);
+
+ g_free(ipaddress->gateway);
+ ipaddress->gateway = g_strdup(gateway);
+
+ return 0;
+}
+
+void connman_ipaddress_set_ipv4(struct connman_ipaddress *ipaddress,
const char *address, const char *netmask, const char *gateway)
{
if (ipaddress == NULL)
ipdevice->driver_config = NULL;
connman_inet_clear_address(ipdevice->index);
+ connman_inet_clear_ipv6_address(ipdevice->index,
+ ipdevice->driver_config->address->local,
+ ipdevice->driver_config->address->prefixlen);
}
static void update_stats(struct connman_ipdevice *ipdevice,
void __connman_ipconfig_set_index(struct connman_ipconfig *ipconfig, int index)
{
ipconfig->index = index;
+
+ if (ipconfig->ipv6 != NULL)
+ ipconfig->ipv6->index = index;
+}
+
+static struct connman_ipconfig *create_ipv6config(int index)
+{
+ struct connman_ipconfig *ipv6config;
+
+ DBG("index %d", index);
+
+ ipv6config = g_try_new0(struct connman_ipconfig, 1);
+ if (ipv6config == NULL)
+ return NULL;
+
+ ipv6config->index = index;
+ ipv6config->type = CONNMAN_IPCONFIG_TYPE_IPV6;
+
+ ipv6config->address = connman_ipaddress_alloc();
+ if (ipv6config->address == NULL) {
+ g_free(ipv6config);
+ return NULL;
+ }
+
+ ipv6config->system = connman_ipaddress_alloc();
+
+ ipv6config->ipv6 = NULL;
+
+ DBG("ipconfig %p", ipv6config);
+
+ return ipv6config;
}
/**
ipconfig->refcount = 1;
ipconfig->index = index;
+ ipconfig->type = CONNMAN_IPCONFIG_TYPE_IPV4;
ipconfig->address = connman_ipaddress_alloc();
if (ipconfig->address == NULL) {
ipconfig->system = connman_ipaddress_alloc();
+ ipconfig->ipv6 = create_ipv6config(index);
+
DBG("ipconfig %p", ipconfig);
return ipconfig;
return ipconfig;
}
+static void free_ipv6config(struct connman_ipconfig *ipconfig)
+{
+ if (ipconfig == NULL)
+ return;
+
+ connman_ipconfig_set_ops(ipconfig, NULL);
+ connman_ipaddress_free(ipconfig->system);
+ connman_ipaddress_free(ipconfig->address);
+ g_free(ipconfig->ipv6);
+}
+
/**
* connman_ipconfig_unref:
* @ipconfig: ipconfig structure
connman_ipaddress_free(ipconfig->system);
connman_ipaddress_free(ipconfig->address);
+ free_ipv6config(ipconfig->ipv6);
g_free(ipconfig);
}
}
ipconfig->ops = ops;
}
+struct connman_ipconfig *connman_ipconfig_get_ipv6config(
+ struct connman_ipconfig *ipconfig)
+{
+ if (ipconfig == NULL)
+ return NULL;
+
+ return ipconfig->ipv6;
+}
+
/**
* connman_ipconfig_set_method:
* @ipconfig: ipconfig structure
connman_inet_set_address(origin->index, origin->address);
}
-/* FIXME: The element soulution should be removed in the future */
+void __connman_ipconfig_set_element_ipv6_gateway(
+ struct connman_ipconfig *ipconfig,
+ struct connman_element *element)
+{
+ element->ipv6.gateway = ipconfig->ipv6->address->gateway;
+}
+
+/*
+ * FIXME: The element soulution should be removed in the future
+ * Set IPv4 and IPv6 gateway
+ */
int __connman_ipconfig_set_gateway(struct connman_ipconfig *ipconfig,
struct connman_element *parent)
{
connection = connman_element_create(NULL);
+ DBG("ipconfig %p", ipconfig);
+
connection->type = CONNMAN_ELEMENT_TYPE_CONNECTION;
connection->index = ipconfig->index;
connection->ipv4.gateway = ipconfig->address->gateway;
+ connection->ipv6.gateway = ipconfig->ipv6->address->gateway;
if (connman_element_register(connection, parent) < 0)
connman_element_unref(connection);
case CONNMAN_IPCONFIG_METHOD_DHCP:
break;
case CONNMAN_IPCONFIG_METHOD_MANUAL:
- return connman_inet_set_address(ipconfig->index,
- ipconfig->address);
+ if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4)
+ return connman_inet_set_address(ipconfig->index,
+ ipconfig->address);
+ else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6)
+ return connman_inet_set_ipv6_address(
+ ipconfig->index, ipconfig->address);
}
return 0;
case CONNMAN_IPCONFIG_METHOD_DHCP:
break;
case CONNMAN_IPCONFIG_METHOD_MANUAL:
- return connman_inet_clear_address(ipconfig->index);
+ if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV4)
+ return connman_inet_clear_address(ipconfig->index);
+ else if (ipconfig->type == CONNMAN_IPCONFIG_TYPE_IPV6)
+ return connman_inet_clear_ipv6_address(
+ ipconfig->index,
+ ipconfig->address->local,
+ ipconfig->address->prefixlen);
}
return 0;
-
}
int __connman_ipconfig_enable(struct connman_ipconfig *ipconfig)
ipconfig_list = g_list_remove(ipconfig_list, ipconfig);
connman_ipaddress_clear(ipdevice->config->system);
+ connman_ipaddress_clear(ipdevice->config->ipv6->system);
connman_ipconfig_unref(ipdevice->config);
ipdevice->config = NULL;
{
const char *str;
+ DBG("");
+
str = __connman_ipconfig_method2string(ipconfig->method);
if (str == NULL)
return;
DBUS_TYPE_STRING, &ipconfig->system->gateway);
}
+void __connman_ipconfig_append_ipv6(struct connman_ipconfig *ipconfig,
+ DBusMessageIter *iter)
+{
+ const char *str;
+
+ DBG("");
+
+ str = __connman_ipconfig_method2string(ipconfig->method);
+ if (str == NULL)
+ return;
+
+ connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
+
+ if (ipconfig->system == NULL)
+ return;
+
+ if (ipconfig->system->local != NULL) {
+ connman_dbus_dict_append_basic(iter, "Address",
+ DBUS_TYPE_STRING, &ipconfig->system->local);
+ connman_dbus_dict_append_basic(iter, "PrefixLength",
+ DBUS_TYPE_BYTE,
+ &ipconfig->system->prefixlen);
+ }
+
+ if (ipconfig->system->gateway != NULL)
+ connman_dbus_dict_append_basic(iter, "Gateway",
+ DBUS_TYPE_STRING, &ipconfig->system->gateway);
+}
+
+void __connman_ipconfig_append_ipv6config(struct connman_ipconfig *ipconfig,
+ DBusMessageIter *iter)
+{
+ const char *str;
+
+ DBG("");
+
+ str = __connman_ipconfig_method2string(ipconfig->method);
+ if (str == NULL)
+ return;
+
+ connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
+
+ switch (ipconfig->method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ return;
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ break;
+ }
+
+ if (ipconfig->address == NULL)
+ return;
+
+ if (ipconfig->address->local != NULL) {
+ connman_dbus_dict_append_basic(iter, "Address",
+ DBUS_TYPE_STRING, &ipconfig->address->local);
+ connman_dbus_dict_append_basic(iter, "PrefixLength",
+ DBUS_TYPE_BYTE,
+ &ipconfig->address->prefixlen);
+ }
+
+ if (ipconfig->address->gateway != NULL)
+ connman_dbus_dict_append_basic(iter, "Gateway",
+ DBUS_TYPE_STRING, &ipconfig->address->gateway);
+}
+
void __connman_ipconfig_append_ipv4config(struct connman_ipconfig *ipconfig,
DBusMessageIter *iter)
{
const char *str;
+ DBG("");
+
str = __connman_ipconfig_method2string(ipconfig->method);
if (str == NULL)
return;
DBUS_TYPE_STRING, &ipconfig->address->gateway);
}
-int __connman_ipconfig_set_ipv4config(struct connman_ipconfig *ipconfig,
- DBusMessageIter *array)
+int __connman_ipconfig_set_config(struct connman_ipconfig *ipconfig,
+ enum connman_ipconfig_type type, DBusMessageIter *array)
{
enum connman_ipconfig_method method = CONNMAN_IPCONFIG_METHOD_UNKNOWN;
- const char *address = NULL, *netmask = NULL, *gateway = NULL;
+ const char *address = NULL, *netmask = NULL, *gateway = NULL,
+ *prefix_length_string = NULL;
+ int prefix_length = 0;
DBusMessageIter dict;
- DBG("ipconfig %p", ipconfig);
+ DBG("ipconfig %p type %d", ipconfig, type);
+
+ if (type != CONNMAN_IPCONFIG_TYPE_IPV4 &&
+ type != CONNMAN_IPCONFIG_TYPE_IPV6)
+ return -EINVAL;
if (dbus_message_iter_get_arg_type(array) != DBUS_TYPE_ARRAY)
return -EINVAL;
return -EINVAL;
dbus_message_iter_get_basic(&entry, &address);
+ } else if (g_str_equal(key, "PrefixLength") == TRUE) {
+ if (type != DBUS_TYPE_STRING)
+ return -EINVAL;
+
+ dbus_message_iter_get_basic(&entry,
+ &prefix_length_string);
+
+ prefix_length = atoi(prefix_length_string);
+ if (prefix_length < 0 || prefix_length > 128)
+ return -EINVAL;
+
} else if (g_str_equal(key, "Netmask") == TRUE) {
if (type != DBUS_TYPE_STRING)
return -EINVAL;
dbus_message_iter_next(&dict);
}
- DBG("method %d address %s netmask %s gateway %s",
- method, address, netmask, gateway);
+ DBG("method %d address %s netmask %s gateway %s prefix_length %d",
+ method, address, netmask, gateway, prefix_length);
switch (method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
return -EINVAL;
ipconfig->method = method;
- connman_ipaddress_set(ipconfig->address,
- address, netmask, gateway);
+
+ if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+ connman_ipaddress_set_ipv4(ipconfig->address,
+ address, netmask, gateway);
+ else
+ return connman_ipaddress_set_ipv6(
+ ipconfig->address, address,
+ gateway, prefix_length);
break;
case CONNMAN_IPCONFIG_METHOD_DHCP:
static int ipv4_probe(struct connman_element *element)
{
+ struct connman_service *service;
+ struct connman_ipconfig *ipconfig;
struct connman_element *connection;
struct connman_ipv4 ipv4;
const char *address = NULL, *netmask = NULL, *broadcast = NULL;
set_ipv4(element, &ipv4);
- if (nameserver != NULL) {
- struct connman_service *service;
+ service = __connman_element_get_service(element);
- service = __connman_element_get_service(element);
+ if (nameserver != NULL)
__connman_service_append_nameserver(service, nameserver);
- }
connman_timeserver_append(timeserver);
connection->index = element->index;
connection->devname = index2name(element->index);
+ ipconfig = __connman_service_get_ipconfig(service);
+ if (ipconfig != NULL)
+ __connman_ipconfig_set_element_ipv6_gateway(
+ ipconfig, connection);
+
if (connman_element_register(connection, element) < 0)
connman_element_unref(connection);
return 0;
}
+static int manual_ipv6_set(struct connman_network *network,
+ struct connman_ipconfig *ipconfig_ipv6)
+{
+ struct connman_service *service;
+ int err;
+
+ service = __connman_service_lookup_from_network(network);
+ if (service == NULL)
+ return -EINVAL;
+
+ err = __connman_ipconfig_set_address(ipconfig_ipv6);
+ if (err < 0) {
+ connman_network_set_error(network,
+ CONNMAN_NETWORK_ERROR_CONFIGURE_FAIL);
+ return err;
+ }
+
+ /*
+ * READY state will be indicated by IPV4 setting
+ * gateway will be set by IPV4 setting
+ */
+
+ return 0;
+}
+
static gboolean set_connected(gpointer user_data)
{
struct connman_network *network = user_data;
DBG("method %d", method);
if (network->connected == TRUE) {
+ enum connman_ipconfig_method ipv6_method;
+ struct connman_ipconfig *ipv6config;
+ int ret;
+
+ ipv6config = connman_ipconfig_get_ipv6config(ipconfig);
+ ipv6_method = __connman_ipconfig_get_method(ipv6config);
+ switch (ipv6_method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ break;
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ ret = manual_ipv6_set(network, ipv6config);
+ if (ret != 0) {
+ connman_network_set_error(network,
+ CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
+ return FALSE;
+ }
+ break;
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ break;
+ }
+
switch (method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
*/
int __connman_network_connect(struct connman_network *network)
{
+ struct connman_service *service;
int err;
DBG("network %p", network);
network->connecting = TRUE;
+ service = __connman_service_lookup_from_network(network);
+
err = network->driver->connect(network);
if (err < 0) {
if (err == -EINPROGRESS)
return 0;
}
-int __connman_network_set_ipconfig(struct connman_network *network, struct connman_ipconfig *ipconfig)
+int __connman_network_set_ipconfig(struct connman_network *network,
+ struct connman_ipconfig *ipconfig)
{
+ struct connman_ipconfig *ipv6config;
enum connman_ipconfig_method method;
+ int ret;
+
+ ipv6config = connman_ipconfig_get_ipv6config(ipconfig);
+ method = __connman_ipconfig_get_method(ipv6config);
+ switch (method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ break;
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ ret = manual_ipv6_set(network, ipv6config);
+ if (ret != 0) {
+ connman_network_set_error(network,
+ CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
+ return FALSE;
+ }
+ break;
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ break;
+ }
method = __connman_ipconfig_get_method(ipconfig);
__connman_ipconfig_append_ipv4(service->ipconfig, iter);
}
+static void append_ipv6(DBusMessageIter *iter, void *user_data)
+{
+ struct connman_service *service = user_data;
+ struct connman_ipconfig *ipv6config;
+
+ if (is_connected(service) == FALSE)
+ return;
+
+ if (service->ipconfig == NULL)
+ return;
+
+ ipv6config = connman_ipconfig_get_ipv6config(service->ipconfig);
+ if (ipv6config == NULL)
+ return;
+
+ __connman_ipconfig_append_ipv6(ipv6config, iter);
+}
+
static void append_ipv4config(DBusMessageIter *iter, void *user_data)
{
struct connman_service *service = user_data;
__connman_ipconfig_append_ipv4config(service->ipconfig, iter);
}
+static void append_ipv6config(DBusMessageIter *iter, void *user_data)
+{
+ struct connman_service *service = user_data;
+ struct connman_ipconfig *ipv6config;
+
+ if (service->ipconfig == NULL)
+ return;
+
+ ipv6config = connman_ipconfig_get_ipv6config(service->ipconfig);
+ if (ipv6config == NULL)
+ return;
+
+ __connman_ipconfig_append_ipv6config(ipv6config, iter);
+}
+
static void append_dns(DBusMessageIter *iter, void *user_data)
{
struct connman_service *service = user_data;
connman_dbus_property_changed_dict(service->path,
CONNMAN_SERVICE_INTERFACE, "IPv4",
append_ipv4, service);
+
+ connman_dbus_property_changed_dict(service->path,
+ CONNMAN_SERVICE_INTERFACE, "IPv6",
+ append_ipv6, service);
}
static void ipv4_configuration_changed(struct connman_service *service)
service);
}
+static void ipv6_configuration_changed(struct connman_service *service)
+{
+ connman_dbus_property_changed_dict(service->path,
+ CONNMAN_SERVICE_INTERFACE,
+ "IPv6.Configuration",
+ append_ipv6config,
+ service);
+}
+
static void dns_changed(struct connman_service *service)
{
if (is_connected(service) == FALSE)
connman_dbus_dict_append_dict(dict, "IPv4.Configuration",
append_ipv4config, service);
+ connman_dbus_dict_append_dict(dict, "IPv6", append_ipv6, service);
+
+ connman_dbus_dict_append_dict(dict, "IPv6.Configuration",
+ append_ipv6config, service);
+
connman_dbus_dict_append_array(dict, "Nameservers",
DBUS_TYPE_STRING, append_dns, service);
domain_configuration_changed(service);
__connman_storage_save_service(service);
- } else if (g_str_equal(name, "IPv4.Configuration") == TRUE) {
- int err;
+ } else if (g_str_equal(name, "IPv4.Configuration") == TRUE ||
+ g_str_equal(name, "IPv6.Configuration")) {
+
+ enum connman_ipconfig_type type = CONNMAN_IPCONFIG_TYPE_UNKNOWN;
+ int err = 0;
+ struct connman_ipconfig *ipv6config;
+
+ DBG("%s", name);
+ ipv6config = connman_ipconfig_get_ipv6config(
+ service->ipconfig);
if (service->ipconfig == NULL)
return __connman_error_invalid_property(msg);
if (is_connecting(service) ||
- is_connected(service))
+ is_connected(service)) {
__connman_network_clear_ipconfig(service->network,
service->ipconfig);
+ __connman_network_clear_ipconfig(service->network,
+ ipv6config);
+ }
+
+ if (g_str_equal(name, "IPv4.Configuration") == TRUE) {
+ type = CONNMAN_IPCONFIG_TYPE_IPV4;
+ err = __connman_ipconfig_set_config(
+ service->ipconfig, type, &value);
+ } else if (g_str_equal(name, "IPv6.Configuration") == TRUE) {
+ type = CONNMAN_IPCONFIG_TYPE_IPV6;
+ err = __connman_ipconfig_set_config(
+ ipv6config, type, &value);
+ }
- err = __connman_ipconfig_set_ipv4config(service->ipconfig,
- &value);
if (err < 0) {
if (is_connected(service) ||
is_connecting(service))
- __connman_network_set_ipconfig(service->network,
+ __connman_network_set_ipconfig(
+ service->network,
service->ipconfig);
-
return __connman_error_failed(msg, -err);
}
- ipv4_configuration_changed(service);
+ if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
+ ipv4_configuration_changed(service);
+ else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
+ ipv6_configuration_changed(service);
if (is_connecting(service) ||
is_connected(service))
int __connman_service_disconnect(struct connman_service *service)
{
+ struct connman_ipconfig *ipv6config;
int err;
DBG("service %p", service);
__connman_ipconfig_clear_address(service->ipconfig);
+ ipv6config = connman_ipconfig_get_ipv6config(service->ipconfig);
+
+ __connman_ipconfig_clear_address(ipv6config);
+
__connman_ipconfig_disable(service->ipconfig);
if (err < 0) {
void __connman_service_create_ipconfig(struct connman_service *service,
int index)
{
+ struct connman_ipconfig *ipv6config;
const char *ident = service->profile;
GKeyFile *keyfile;
if (keyfile == NULL)
return;
+
+ ipv6config = connman_ipconfig_get_ipv6config(service->ipconfig);
+ if (ipv6config != NULL)
+ __connman_ipconfig_load(ipv6config, keyfile,
+ service->identifier, "IPv6.");
+
__connman_ipconfig_load(service->ipconfig, keyfile,
service->identifier, "IPv4.");
g_key_file_free(keyfile);
service->passphrase = str;
}
- if (service->ipconfig != NULL)
+ if (service->ipconfig != NULL) {
+ struct connman_ipconfig *ipv6config;
+
+ ipv6config = connman_ipconfig_get_ipv6config(
+ service->ipconfig);
+ if (ipv6config != NULL)
+ __connman_ipconfig_load(ipv6config, keyfile,
+ service->identifier, "IPv6.");
+
__connman_ipconfig_load(service->ipconfig, keyfile,
service->identifier, "IPv4.");
+ }
service->nameservers = g_key_file_get_string_list(keyfile,
service->identifier, "Nameservers", &length, NULL);
g_key_file_remove_key(keyfile, service->identifier,
"Passphrase", NULL);
- if (service->ipconfig != NULL)
+ if (service->ipconfig != NULL) {
+ struct connman_ipconfig *ipv6config;
+
+ ipv6config = connman_ipconfig_get_ipv6config(service->ipconfig);
+ if (ipv6config != NULL)
+ __connman_ipconfig_save(ipv6config, keyfile,
+ service->identifier, "IPv6.");
+
__connman_ipconfig_save(service->ipconfig, keyfile,
service->identifier, "IPv4.");
+ }
if (service->nameservers != NULL) {
guint len = g_strv_length(service->nameservers);