lib: add iwinfo_backend_by_name()
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 27 Oct 2014 15:57:19 +0000 (16:57 +0100)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 27 Oct 2014 15:57:19 +0000 (16:57 +0100)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
include/iwinfo.h
iwinfo_lib.c

index 68d459b..38120e6 100644 (file)
@@ -182,6 +182,7 @@ struct iwinfo_ops {
 
 const char * iwinfo_type(const char *ifname);
 const struct iwinfo_ops * iwinfo_backend(const char *ifname);
+const struct iwinfo_ops * iwinfo_backend_by_name(const char *name);
 void iwinfo_finish(void);
 
 extern const struct iwinfo_ops wext_ops;
index 4ae8f59..c30d834 100644 (file)
@@ -350,6 +350,17 @@ const struct iwinfo_ops * iwinfo_backend(const char *ifname)
        return NULL;
 }
 
+const struct iwinfo_ops * iwinfo_backend_by_name(const char *name)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(backends); i++)
+               if (!strcmp(backends[i]->name, name))
+                       return backends[i];
+
+       return NULL;
+}
+
 void iwinfo_finish(void)
 {
        int i;