aboutsummaryrefslogtreecommitdiffstats
path: root/package/iwinfo/src/iwinfo_madwifi.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-12-04 20:37:01 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-12-04 20:37:01 +0000
commit3a9d303059a1689ad9ff856e430fef04bd3fb7f5 (patch)
treeb17658b91c9b0e70814987b4deb882da2a416ff7 /package/iwinfo/src/iwinfo_madwifi.c
parent33750dc3e93e6d2279b9f39ce7c46e8a1e1f1c48 (diff)
downloadupstream-3a9d303059a1689ad9ff856e430fef04bd3fb7f5.tar.gz
upstream-3a9d303059a1689ad9ff856e430fef04bd3fb7f5.tar.bz2
upstream-3a9d303059a1689ad9ff856e430fef04bd3fb7f5.zip
iwinfo: expose txpower and frequency offset information
SVN-Revision: 29425
Diffstat (limited to 'package/iwinfo/src/iwinfo_madwifi.c')
-rw-r--r--package/iwinfo/src/iwinfo_madwifi.c53
1 files changed, 46 insertions, 7 deletions
diff --git a/package/iwinfo/src/iwinfo_madwifi.c b/package/iwinfo/src/iwinfo_madwifi.c
index 50793c4937..732cfe56fe 100644
--- a/package/iwinfo/src/iwinfo_madwifi.c
+++ b/package/iwinfo/src/iwinfo_madwifi.c
@@ -1060,20 +1060,59 @@ int madwifi_get_hardware_id(const char *ifname, char *buf)
return 0;
}
-int madwifi_get_hardware_name(const char *ifname, char *buf)
+static const struct iwinfo_hardware_entry *
+madwifi_get_hardware_entry(const char *ifname)
{
struct iwinfo_hardware_id id;
- struct iwinfo_hardware_entry *hw;
if (madwifi_get_hardware_id(ifname, (char *)&id))
- return -1;
+ return NULL;
- hw = iwinfo_hardware(&id);
+ return iwinfo_hardware(&id);
+}
- if (hw)
- sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+int madwifi_get_hardware_name(const char *ifname, char *buf)
+{
+ char vendor[64];
+ char device[64];
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = madwifi_get_hardware_entry(ifname)))
+ {
+ madwifi_proc_file(ifname, "dev_vendor", vendor, sizeof(vendor));
+ madwifi_proc_file(ifname, "dev_name", device, sizeof(device));
+
+ if (vendor[0] && device[0])
+ sprintf(buf, "%s %s", vendor, device);
+ else
+ sprintf(buf, "Generic Atheros");
+ }
else
- sprintf(buf, "Generic Atheros");
+ {
+ sprintf(buf, "%s %s", hw->vendor_name, hw->device_name);
+ }
+
+ return 0;
+}
+
+int madwifi_get_txpower_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = madwifi_get_hardware_entry(ifname)))
+ return -1;
+
+ *buf = hw->txpower_offset;
+ return 0;
+}
+
+int madwifi_get_frequency_offset(const char *ifname, int *buf)
+{
+ const struct iwinfo_hardware_entry *hw;
+
+ if (!(hw = madwifi_get_hardware_entry(ifname)))
+ return -1;
+ *buf = hw->frequency_offset;
return 0;
}