From 56553da25bd1a4d7f8976e2d4f818f27c40233dc Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 29 Jun 2009 21:04:30 +0200 Subject: [PATCH] Add IP configuration details to devices, networks and services --- src/device.c | 29 +++++++++++++++++++---------- src/network.c | 9 +++++++++ src/service.c | 13 ++++++++++--- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/device.c b/src/device.c index c6f89fc..2ff7d71 100644 --- a/src/device.c +++ b/src/device.c @@ -49,6 +49,7 @@ struct connman_device { char *ident; unsigned int connections; guint scan_timeout; + struct connman_ipconfig *ipconfig; struct connman_device_driver *driver; void *driver_data; @@ -861,12 +862,24 @@ static void device_destruct(struct connman_element *element) DBG("element %p name %s", element, element->name); + if (device->timeout > 0) { + g_source_remove(device->timeout); + device->timeout = 0; + } + + if (device->pending != NULL) { + dbus_message_unref(device->pending); + device->pending = NULL; + } + g_free(device->ident); g_free(device->node); g_free(device->name); g_free(device->address); g_free(device->interface); + connman_ipconfig_unref(device->ipconfig); + g_free(device->last_network); g_hash_table_destroy(device->networks); @@ -942,6 +955,12 @@ struct connman_device *connman_device_create(const char *node, break; } + device->ipconfig = connman_ipconfig_create(); + if (device->ipconfig == NULL) { + connman_device_unref(device); + return NULL; + } + device->networks = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, unregister_network); @@ -970,16 +989,6 @@ struct connman_device *connman_device_ref(struct connman_device *device) */ void connman_device_unref(struct connman_device *device) { - if (device->timeout > 0) { - g_source_remove(device->timeout); - device->timeout = 0; - } - - if (device->pending != NULL) { - dbus_message_unref(device->pending); - device->pending = NULL; - } - connman_element_unref(&device->element); } diff --git a/src/network.c b/src/network.c index cf0586b..f5c9033 100644 --- a/src/network.c +++ b/src/network.c @@ -45,6 +45,7 @@ struct connman_network { char *name; char *node; char *group; + struct connman_ipconfig *ipconfig; struct connman_network_driver *driver; void *driver_data; @@ -419,6 +420,8 @@ static void network_destruct(struct connman_element *element) g_free(network->name); g_free(network->address); g_free(network->identifier); + + connman_ipconfig_unref(network->ipconfig); } /** @@ -470,6 +473,12 @@ struct connman_network *connman_network_create(const char *identifier, network->secondary = FALSE; network->identifier = g_strdup(identifier); + network->ipconfig = connman_ipconfig_create(); + if (network->ipconfig == NULL) { + connman_network_unref(network); + return NULL; + } + return network; } diff --git a/src/service.c b/src/service.c index a2895a8..d0e8d28 100644 --- a/src/service.c +++ b/src/service.c @@ -48,6 +48,7 @@ struct connman_service { char *name; char *passphrase; char *profile; + struct connman_ipconfig *ipconfig; struct connman_device *device; struct connman_network *network; DBusMessage *pending; @@ -606,6 +607,8 @@ static void service_free(gpointer user_data) if (service->network != NULL) connman_network_unref(service->network); + connman_ipconfig_unref(service->ipconfig); + g_free(service->profile); g_free(service->name); g_free(service->passphrase); @@ -670,6 +673,12 @@ struct connman_service *connman_service_create(void) __connman_service_initialize(service); + service->ipconfig = connman_ipconfig_create(); + if (service->ipconfig == NULL) { + g_free(service); + return NULL; + } + return service; } @@ -909,14 +918,12 @@ static struct connman_service *__connman_service_get(const char *identifier) return service; } - service = g_try_new0(struct connman_service, 1); + service = connman_service_create(); if (service == NULL) return NULL; DBG("service %p", service); - __connman_service_initialize(service); - service->identifier = g_strdup(identifier); service->profile = g_strdup(__connman_profile_active_ident()); -- 2.7.4