*
* 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
return ipdevice->flags;
}
-const char *__connman_ipconfig_get_gateway_from_index(int index)
+const char *__connman_ipconfig_get_gateway_from_index(int index,
+ enum connman_ipconfig_type type)
{
struct connman_ipdevice *ipdevice;
if (ipdevice == NULL)
return NULL;
- if (ipdevice->ipv4_gateway != NULL)
- return ipdevice->ipv4_gateway;
+ if (type != CONNMAN_IPCONFIG_TYPE_IPV6) {
+ if (ipdevice->ipv4_gateway != NULL)
+ return ipdevice->ipv4_gateway;
- if (ipdevice->config_ipv4 != NULL &&
- ipdevice->config_ipv4->address != NULL)
- return ipdevice->config_ipv4->address->gateway;
+ if (ipdevice->config_ipv4 != NULL &&
+ ipdevice->config_ipv4->address != NULL)
+ return ipdevice->config_ipv4->address->gateway;
+ }
- if (ipdevice->ipv6_gateway != NULL)
- return ipdevice->ipv6_gateway;
+ if (type != CONNMAN_IPCONFIG_TYPE_IPV4) {
+ if (ipdevice->ipv6_gateway != NULL)
+ return ipdevice->ipv6_gateway;
- if (ipdevice->config_ipv6 != NULL &&
- ipdevice->config_ipv6->address != NULL)
- return ipdevice->config_ipv6->address->gateway;
+ if (ipdevice->config_ipv6 != NULL &&
+ ipdevice->config_ipv6->address != NULL)
+ return ipdevice->config_ipv6->address->gateway;
+ }
return NULL;
}
static struct connman_ipconfig *create_ipv6config(int index)
{
struct connman_ipconfig *ipv6config;
+ struct connman_ipdevice *ipdevice;
DBG("index %d", index);
ipv6config->enabled = FALSE;
ipv6config->type = CONNMAN_IPCONFIG_TYPE_IPV6;
ipv6config->method = CONNMAN_IPCONFIG_METHOD_AUTO;
- ipv6config->ipv6_privacy_config = 0;
+
+ ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
+ if (ipdevice != NULL)
+ ipv6config->ipv6_privacy_config = ipdevice->ipv6_privacy;
ipv6config->address = connman_ipaddress_alloc(AF_INET6);
if (ipv6config->address == NULL) {
void __connman_ipconfig_append_ipv4(struct connman_ipconfig *ipconfig,
DBusMessageIter *iter)
{
+ struct connman_ipaddress *append_addr = NULL;
const char *str;
DBG("");
connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
- if (ipconfig->system == NULL)
+ append_addr = ipconfig->system;
+
+ switch (ipconfig->method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
return;
- if (ipconfig->system->local != NULL) {
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ if (append_addr == NULL)
+ append_addr = ipconfig->address;
+ break;
+
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ case CONNMAN_IPCONFIG_METHOD_AUTO:
+ break;
+ }
+
+ if (append_addr == NULL)
+ return;
+
+ if (append_addr->local != NULL) {
in_addr_t addr;
struct in_addr netmask;
char *mask;
connman_dbus_dict_append_basic(iter, "Address",
- DBUS_TYPE_STRING, &ipconfig->system->local);
+ DBUS_TYPE_STRING, &append_addr->local);
- addr = 0xffffffff << (32 - ipconfig->system->prefixlen);
+ addr = 0xffffffff << (32 - append_addr->prefixlen);
netmask.s_addr = htonl(addr);
mask = inet_ntoa(netmask);
connman_dbus_dict_append_basic(iter, "Netmask",
DBUS_TYPE_STRING, &mask);
}
- if (ipconfig->system->gateway != NULL)
+ if (append_addr->gateway != NULL)
connman_dbus_dict_append_basic(iter, "Gateway",
- DBUS_TYPE_STRING, &ipconfig->system->gateway);
+ DBUS_TYPE_STRING, &append_addr->gateway);
}
void __connman_ipconfig_append_ipv6(struct connman_ipconfig *ipconfig,
DBusMessageIter *iter,
struct connman_ipconfig *ipconfig_ipv4)
{
+ struct connman_ipaddress *append_addr = NULL;
const char *str, *privacy;
DBG("");
connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
- if (ipconfig->system == NULL)
+ append_addr = ipconfig->system;
+
+ switch (ipconfig->method) {
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ return;
+
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ if (append_addr == NULL)
+ append_addr = ipconfig->address;
+ break;
+
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ case CONNMAN_IPCONFIG_METHOD_AUTO:
+ break;
+ }
+
+ if (append_addr == NULL)
return;
- if (ipconfig->system->local != NULL) {
+ if (append_addr->local != NULL) {
connman_dbus_dict_append_basic(iter, "Address",
- DBUS_TYPE_STRING, &ipconfig->system->local);
+ DBUS_TYPE_STRING, &append_addr->local);
connman_dbus_dict_append_basic(iter, "PrefixLength",
DBUS_TYPE_BYTE,
- &ipconfig->system->prefixlen);
+ &append_addr->prefixlen);
}
- if (ipconfig->system->gateway != NULL)
+ if (append_addr->gateway != NULL)
connman_dbus_dict_append_basic(iter, "Gateway",
- DBUS_TYPE_STRING, &ipconfig->system->gateway);
+ DBUS_TYPE_STRING, &append_addr->gateway);
privacy = privacy2string(ipconfig->ipv6_privacy_config);
connman_dbus_dict_append_basic(iter, "Privacy",