From 2d95197b84332c6f7f7dd40e584f95b52507e490 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 12 May 2009 16:18:49 -0700 Subject: [PATCH] Fix service lookup for WiFi and WiMAX devices --- src/element.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/element.c b/src/element.c index 9dd566a..ecdf4bf 100644 --- a/src/element.c +++ b/src/element.c @@ -272,9 +272,22 @@ int __connman_element_count(struct connman_element *element, return data.count; } +static struct connman_network *__connman_element_get_network(struct connman_element *element) +{ + if (element->type == CONNMAN_ELEMENT_TYPE_NETWORK && + element->network != NULL) + return element->network; + + if (element->parent == NULL) + return NULL; + + return __connman_element_get_network(element->parent); +} + struct connman_service *__connman_element_get_service(struct connman_element *element) { struct connman_service *service; + struct connman_network *network; struct connman_device *device; enum connman_device_type type; @@ -287,8 +300,6 @@ struct connman_service *__connman_element_get_service(struct connman_element *el switch (type) { case CONNMAN_DEVICE_TYPE_UNKNOWN: case CONNMAN_DEVICE_TYPE_VENDOR: - case CONNMAN_DEVICE_TYPE_WIFI: - case CONNMAN_DEVICE_TYPE_WIMAX: case CONNMAN_DEVICE_TYPE_BLUETOOTH: case CONNMAN_DEVICE_TYPE_GPS: case CONNMAN_DEVICE_TYPE_HSO: @@ -299,6 +310,13 @@ struct connman_service *__connman_element_get_service(struct connman_element *el case CONNMAN_DEVICE_TYPE_ETHERNET: service = __connman_service_lookup_from_device(device); break; + case CONNMAN_DEVICE_TYPE_WIFI: + case CONNMAN_DEVICE_TYPE_WIMAX: + network = __connman_element_get_network(element); + if (network == NULL) + return NULL; + service = __connman_service_lookup_from_network(network); + break; } return service; -- 2.7.4