From de1bb6ef97ddd71db237578bd5f7ed8c5a61fb82 Mon Sep 17 00:00:00 2001 From: jow Date: Sun, 4 Dec 2011 20:37:01 +0000 Subject: [package] iwinfo: expose txpower and frequency offset information git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29425 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/iwinfo/src/iwinfo_nl80211.c | 41 ++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'package/iwinfo/src/iwinfo_nl80211.c') diff --git a/package/iwinfo/src/iwinfo_nl80211.c b/package/iwinfo/src/iwinfo_nl80211.c index d3726821f..4b8b37daa 100644 --- a/package/iwinfo/src/iwinfo_nl80211.c +++ b/package/iwinfo/src/iwinfo_nl80211.c @@ -1634,20 +1634,47 @@ int nl80211_get_hardware_id(const char *ifname, char *buf) return wext_get_hardware_id(ifname, buf); } -int nl80211_get_hardware_name(const char *ifname, char *buf) +static const struct iwinfo_hardware_entry * +nl80211_get_hardware_entry(const char *ifname) { struct iwinfo_hardware_id id; - struct iwinfo_hardware_entry *hw; if (nl80211_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); - else +int nl80211_get_hardware_name(const char *ifname, char *buf) +{ + const struct iwinfo_hardware_entry *hw; + + if (!(hw = nl80211_get_hardware_entry(ifname))) sprintf(buf, "Generic MAC80211"); + else + sprintf(buf, "%s %s", hw->vendor_name, hw->device_name); + + return 0; +} + +int nl80211_get_txpower_offset(const char *ifname, int *buf) +{ + const struct iwinfo_hardware_entry *hw; + + if (!(hw = nl80211_get_hardware_entry(ifname))) + return -1; + + *buf = hw->txpower_offset; + return 0; +} + +int nl80211_get_frequency_offset(const char *ifname, int *buf) +{ + const struct iwinfo_hardware_entry *hw; + + if (!(hw = nl80211_get_hardware_entry(ifname))) + return -1; + *buf = hw->frequency_offset; return 0; } -- cgit v1.2.3