enum connman_ipconfig_method method;
struct connman_ipaddress *address;
+ struct connman_ipaddress *system;
char *eth;
uint16_t mtu;
g_free(ipaddress);
}
+void connman_ipaddress_clear(struct connman_ipaddress *ipaddress)
+{
+ if (ipaddress == NULL)
+ return;
+
+ ipaddress->prefixlen = 0;
+
+ g_free(ipaddress->local);
+ ipaddress->local = NULL;
+
+ g_free(ipaddress->peer);
+ ipaddress->peer = NULL;
+
+ g_free(ipaddress->broadcast);
+ ipaddress->broadcast = NULL;
+}
+
void connman_ipaddress_copy(struct connman_ipaddress *ipaddress,
struct connman_ipaddress *source)
{
connman_info("%s {add} address %s/%u label %s", ipdevice->ifname,
address, prefixlen, label);
+ if (ipdevice->config != NULL)
+ connman_ipaddress_copy(ipdevice->config->system, ipaddress);
+
if ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) != (IFF_RUNNING | IFF_LOWER_UP))
return;
return NULL;
}
+ ipconfig->system = connman_ipaddress_alloc();
+
DBG("ipconfig %p", ipconfig);
return ipconfig;
ipconfig->origin = NULL;
}
+ connman_ipaddress_free(ipconfig->system);
connman_ipaddress_free(ipconfig->address);
g_free(ipconfig->eth);
g_free(ipconfig);
if (ipdevice == NULL)
return -ENXIO;
- if (ipdevice->config != NULL)
+ if (ipdevice->config != NULL) {
+ connman_ipaddress_clear(ipdevice->config->system);
+
connman_ipconfig_unref(ipdevice->config);
+ }
ipdevice->config = connman_ipconfig_ref(ipconfig);
if (ipdevice->config == NULL || ipdevice->config != ipconfig)
return -EINVAL;
+ connman_ipaddress_clear(ipdevice->config->system);
+
connman_ipconfig_unref(ipdevice->config);
ipdevice->config = NULL;
connman_dbus_dict_append_basic(iter, "Method", DBUS_TYPE_STRING, &str);
- if (ipconfig->address == NULL)
+ if (ipconfig->system == NULL)
return;
- if (ipconfig->address->local != NULL) {
+ if (ipconfig->system->local != NULL) {
struct in_addr netmask;
char *mask;
connman_dbus_dict_append_basic(iter, "Address",
- DBUS_TYPE_STRING, &ipconfig->address->local);
+ DBUS_TYPE_STRING, &ipconfig->system->local);
- netmask.s_addr = ~0 << (32 - ipconfig->address->prefixlen);
+ netmask.s_addr = ~0 << (32 - ipconfig->system->prefixlen);
mask = inet_ntoa(netmask);
connman_dbus_dict_append_basic(iter, "Netmask",
DBUS_TYPE_STRING, &mask);