service: Add interface name matching in __connman_service_lookup().
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 30 Sep 2011 09:06:30 +0000 (12:06 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 5 Oct 2011 10:05:50 +0000 (12:05 +0200)
Fixes BMC#23419

src/service.c

index ae15470..22f8320 100644 (file)
@@ -4588,6 +4588,8 @@ int __connman_service_lookup(const char *pattern, const char **path)
 {
        GHashTableIter iter;
        gpointer key, value;
+       struct connman_device *device;
+       const char *ifname;
 
        g_hash_table_iter_init(&iter, service_hash);
 
@@ -4600,6 +4602,20 @@ int __connman_service_lookup(const char *pattern, const char **path)
                        *path = (const char *) service->path;
                        return 0;
                }
+
+               if (service->network == NULL)
+                       continue;
+
+               device = connman_network_get_device(service->network);
+               if (device == NULL)
+                       continue;
+
+               ifname = connman_device_get_string(device, "Interface");
+               if (ifname != NULL && g_strcmp0(ifname, pattern) == 0) {
+                       *path = (const char *) service->path;
+                       return 0;
+               }
+
        }
 
        return -ENXIO;