Add method to retrieve interface name from service
authorMarcel Holtmann <marcel@holtmann.org>
Sat, 28 Nov 2009 16:38:43 +0000 (17:38 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Sat, 28 Nov 2009 16:38:43 +0000 (17:38 +0100)
include/service.h
src/service.c

index 3ab32db..3ec7125 100644 (file)
@@ -86,6 +86,7 @@ struct connman_service *connman_service_ref(struct connman_service *service);
 void connman_service_unref(struct connman_service *service);
 
 enum connman_service_type connman_service_get_type(struct connman_service *service);
+char *connman_service_get_interface(struct connman_service *service);
 
 int connman_service_set_favorite(struct connman_service *service,
                                                connman_bool_t favorite);
index 88ce4bb..09b5b5f 100644 (file)
@@ -1410,6 +1410,29 @@ enum connman_service_type connman_service_get_type(struct connman_service *servi
 }
 
 /**
+ * connman_service_get_interface:
+ * @service: service structure
+ *
+ * Get network interface of service
+ */
+char *connman_service_get_interface(struct connman_service *service)
+{
+       int index;
+
+       if (service == NULL)
+               return NULL;
+
+       if (service->network != NULL) {
+               index = connman_network_get_index(service->network);
+       } else if (service->device != NULL) {
+               index = connman_device_get_index(service->device);
+       } else
+               return NULL;
+
+       return connman_inet_ifname(index);
+}
+
+/**
  * connman_service_set_favorite:
  * @service: service structure
  * @favorite: favorite value