if (index != ipconfig->index)
continue;
- if (ipconfig->ops) {
- if (up == TRUE && ipconfig->ops->up)
- ipconfig->ops->up(ipconfig);
- if (lower_up == TRUE && ipconfig->ops->lower_up)
- ipconfig->ops->lower_up(ipconfig);
-
- if (lower_down == TRUE && ipconfig->ops->lower_down)
- ipconfig->ops->lower_down(ipconfig);
- if (down == TRUE && ipconfig->ops->down)
- ipconfig->ops->down(ipconfig);
- }
+ if (up == TRUE && ipconfig->ops->up)
+ ipconfig->ops->up(ipconfig);
+ if (lower_up == TRUE && ipconfig->ops->lower_up)
+ ipconfig->ops->lower_up(ipconfig);
+
+ if (lower_down == TRUE && ipconfig->ops->lower_down)
+ ipconfig->ops->lower_down(ipconfig);
+ if (down == TRUE && ipconfig->ops->down)
+ ipconfig->ops->down(ipconfig);
}
if (lower_up)
ipconfig->index = -1;
- if (ipconfig->ops && ipconfig->ops->lower_down)
+ if (ipconfig->ops->lower_down)
ipconfig->ops->lower_down(ipconfig);
- if (ipconfig->ops && ipconfig->ops->down)
+ if (ipconfig->ops->down)
ipconfig->ops->down(ipconfig);
}
if (index != ipconfig->index)
continue;
- if (ipconfig->ops && ipconfig->ops->ip_bound)
+ if (ipconfig->ops->ip_bound)
ipconfig->ops->ip_bound(ipconfig);
}
}
if (index != ipconfig->index)
continue;
- if (ipconfig->ops && ipconfig->ops->ip_release)
+ if (ipconfig->ops->ip_release)
ipconfig->ops->ip_release(ipconfig);
}
}
DBG("ipconfig %p", ipconfig);
- ipconfig_list = g_list_append(ipconfig_list, ipconfig);
-
return ipconfig;
}
void connman_ipconfig_unref(struct connman_ipconfig *ipconfig)
{
if (g_atomic_int_dec_and_test(&ipconfig->refcount) == TRUE) {
- ipconfig_list = g_list_remove(ipconfig_list, ipconfig);
+ connman_ipconfig_set_ops(ipconfig, NULL);
connman_ipaddress_free(ipconfig->address);
g_free(ipconfig);
void connman_ipconfig_set_ops(struct connman_ipconfig *ipconfig,
const struct connman_ipconfig_ops *ops)
{
+ if (ipconfig->ops != NULL)
+ ipconfig_list = g_list_remove(ipconfig_list, ipconfig);
+
ipconfig->ops = ops;
+
+ if (ops != NULL)
+ ipconfig_list = g_list_append(ipconfig_list, ipconfig);
}
/**