aboutsummaryrefslogtreecommitdiffstats
path: root/package/iwinfo/src/iwinfo_wext.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-12-04 03:42:17 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-12-04 03:42:17 +0000
commit0d587a173c3ab39ea95719110d8e6791bd3dfbb1 (patch)
tree96b02527f41c9a14ec51ec7d631e3785930d9e8f /package/iwinfo/src/iwinfo_wext.c
parent83e6c14f82f6c2d9028f4ec9f4da943c0e524345 (diff)
downloadupstream-0d587a173c3ab39ea95719110d8e6791bd3dfbb1.tar.gz
upstream-0d587a173c3ab39ea95719110d8e6791bd3dfbb1.tar.bz2
upstream-0d587a173c3ab39ea95719110d8e6791bd3dfbb1.zip
iwinfo: add initial hardware detection capabilities
SVN-Revision: 29421
Diffstat (limited to 'package/iwinfo/src/iwinfo_wext.c')
-rw-r--r--package/iwinfo/src/iwinfo_wext.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/package/iwinfo/src/iwinfo_wext.c b/package/iwinfo/src/iwinfo_wext.c
index 283f77e9f8..3923c9e760 100644
--- a/package/iwinfo/src/iwinfo_wext.c
+++ b/package/iwinfo/src/iwinfo_wext.c
@@ -462,3 +462,56 @@ int wext_get_mbssid_support(const char *ifname, int *buf)
/* No multi bssid support atm */
return -1;
}
+
+static char * wext_sysfs_ifname_file(const char *ifname, const char *path)
+{
+ FILE *f;
+ static char buf[128];
+ char *rv = NULL;
+
+ snprintf(buf, sizeof(buf), "/sys/class/net/%s/%s", ifname, path);
+
+ if ((f = fopen(buf, "r")) != NULL)
+ {
+ memset(buf, 0, sizeof(buf));
+
+ if (fread(buf, 1, sizeof(buf), f))
+ rv = buf;
+
+ fclose(f);
+ }
+
+ return rv;
+}
+
+int wext_get_hardware_id(const char *ifname, char *buf)
+{
+ char *data;
+ struct iwinfo_hardware_id *id = (struct iwinfo_hardware_id *)buf;
+
+ memset(id, 0, sizeof(struct iwinfo_hardware_id));
+
+ data = wext_sysfs_ifname_file(ifname, "device/vendor");
+ if (data)
+ id->vendor_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/device");
+ if (data)
+ id->device_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/subsystem_device");
+ if (data)
+ id->subsystem_device_id = strtoul(data, NULL, 16);
+
+ data = wext_sysfs_ifname_file(ifname, "device/subsystem_vendor");
+ if (data)
+ id->subsystem_vendor_id = strtoul(data, NULL, 16);
+
+ return (id->vendor_id > 0 && id->device_id > 0) ? 0 : -1;
+}
+
+int wext_get_hardware_name(const char *ifname, char *buf)
+{
+ sprintf(buf, "Generic WEXT");
+ return 0;
+}