iwinfo: expose txpower and frequency offset information
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 4 Dec 2011 20:37:01 +0000 (20:37 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 4 Dec 2011 20:37:01 +0000 (20:37 +0000)
SVN-Revision: 29425

13 files changed:
package/iwinfo/Makefile
package/iwinfo/src/include/iwinfo.h
package/iwinfo/src/include/iwinfo/madwifi.h
package/iwinfo/src/include/iwinfo/nl80211.h
package/iwinfo/src/include/iwinfo/wext.h
package/iwinfo/src/include/iwinfo/wl.h
package/iwinfo/src/iwinfo_cli.c
package/iwinfo/src/iwinfo_lib.c
package/iwinfo/src/iwinfo_lua.c
package/iwinfo/src/iwinfo_madwifi.c
package/iwinfo/src/iwinfo_nl80211.c
package/iwinfo/src/iwinfo_wext.c
package/iwinfo/src/iwinfo_wl.c

index db11844cfb0bae3bc49e8b5f7c1157c3d606c75e..471904432ee61ef0ee14a78c224b608ac920c7b5 100644 (file)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libiwinfo
-PKG_RELEASE:=19
+PKG_RELEASE:=20
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
index 86bf8b1b6d067af47a4b2f4bcba9b0e494cc46a2..198d57c9d2a4644cca2b8b75845365bfafa0a44f 100644 (file)
@@ -120,7 +120,9 @@ extern const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[];
 struct iwinfo_ops {
        int (*channel)(const char *, int *);
        int (*frequency)(const char *, int *);
+       int (*frequency_offset)(const char *, int *);
        int (*txpower)(const char *, int *);
+       int (*txpower_offset)(const char *, int *);
        int (*bitrate)(const char *, int *);
        int (*signal)(const char *, int *);
        int (*noise)(const char *, int *);
index ecbe749c8abd50d4e6116abbda40132d312a9b39..9acbc36460ed224b883a0b7d85395fb668031373 100644 (file)
@@ -32,7 +32,9 @@ int madwifi_get_bssid(const char *ifname, char *buf);
 int madwifi_get_country(const char *ifname, char *buf);
 int madwifi_get_channel(const char *ifname, int *buf);
 int madwifi_get_frequency(const char *ifname, int *buf);
+int madwifi_get_frequency_offset(const char *ifname, int *buf);
 int madwifi_get_txpower(const char *ifname, int *buf);
+int madwifi_get_txpower_offset(const char *ifname, int *buf);
 int madwifi_get_bitrate(const char *ifname, int *buf);
 int madwifi_get_signal(const char *ifname, int *buf);
 int madwifi_get_noise(const char *ifname, int *buf);
@@ -51,29 +53,31 @@ int madwifi_get_hardware_name(const char *ifname, char *buf);
 void madwifi_close(void);
 
 static const struct iwinfo_ops madwifi_ops = {
-       .channel        = madwifi_get_channel,
-       .frequency      = madwifi_get_frequency,
-       .txpower        = madwifi_get_txpower,
-       .bitrate        = madwifi_get_bitrate,
-       .signal         = madwifi_get_signal,
-       .noise          = madwifi_get_noise,
-       .quality        = madwifi_get_quality,
-       .quality_max    = madwifi_get_quality_max,
-       .mbssid_support = madwifi_get_mbssid_support,
-       .hwmodelist     = madwifi_get_hwmodelist,
-       .mode           = madwifi_get_mode,
-       .ssid           = madwifi_get_ssid,
-       .bssid          = madwifi_get_bssid,
-       .country        = madwifi_get_country,
-       .hardware_id    = madwifi_get_hardware_id,
-       .hardware_name  = madwifi_get_hardware_name,
-       .encryption     = madwifi_get_encryption,
-       .assoclist      = madwifi_get_assoclist,
-       .txpwrlist      = madwifi_get_txpwrlist,
-       .scanlist       = madwifi_get_scanlist,
-       .freqlist       = madwifi_get_freqlist,
-       .countrylist    = madwifi_get_countrylist,
-       .close          = madwifi_close
+       .channel          = madwifi_get_channel,
+       .frequency        = madwifi_get_frequency,
+       .frequency_offset = madwifi_get_frequency_offset,
+       .txpower          = madwifi_get_txpower,
+       .txpower_offset   = madwifi_get_txpower_offset,
+       .bitrate          = madwifi_get_bitrate,
+       .signal           = madwifi_get_signal,
+       .noise            = madwifi_get_noise,
+       .quality          = madwifi_get_quality,
+       .quality_max      = madwifi_get_quality_max,
+       .mbssid_support   = madwifi_get_mbssid_support,
+       .hwmodelist       = madwifi_get_hwmodelist,
+       .mode             = madwifi_get_mode,
+       .ssid             = madwifi_get_ssid,
+       .bssid            = madwifi_get_bssid,
+       .country          = madwifi_get_country,
+       .hardware_id      = madwifi_get_hardware_id,
+       .hardware_name    = madwifi_get_hardware_name,
+       .encryption       = madwifi_get_encryption,
+       .assoclist        = madwifi_get_assoclist,
+       .txpwrlist        = madwifi_get_txpwrlist,
+       .scanlist         = madwifi_get_scanlist,
+       .freqlist         = madwifi_get_freqlist,
+       .countrylist      = madwifi_get_countrylist,
+       .close            = madwifi_close
 };
 
 #endif
index 3df25d34b44a68c3705a16de0cf31a6372992ff3..fd0ddb43ab0208f3a278c774adb96d5ce7c43904 100644 (file)
@@ -63,7 +63,9 @@ int nl80211_get_bssid(const char *ifname, char *buf);
 int nl80211_get_country(const char *ifname, char *buf);
 int nl80211_get_channel(const char *ifname, int *buf);
 int nl80211_get_frequency(const char *ifname, int *buf);
+int nl80211_get_frequency_offset(const char *ifname, int *buf);
 int nl80211_get_txpower(const char *ifname, int *buf);
+int nl80211_get_txpower_offset(const char *ifname, int *buf);
 int nl80211_get_bitrate(const char *ifname, int *buf);
 int nl80211_get_signal(const char *ifname, int *buf);
 int nl80211_get_noise(const char *ifname, int *buf);
@@ -82,29 +84,31 @@ int nl80211_get_hardware_name(const char *ifname, char *buf);
 void nl80211_close(void);
 
 static const struct iwinfo_ops nl80211_ops = {
-       .channel        = nl80211_get_channel,
-       .frequency      = nl80211_get_frequency,
-       .txpower        = nl80211_get_txpower,
-       .bitrate        = nl80211_get_bitrate,
-       .signal         = nl80211_get_signal,
-       .noise          = nl80211_get_noise,
-       .quality        = nl80211_get_quality,
-       .quality_max    = nl80211_get_quality_max,
-       .mbssid_support = nl80211_get_mbssid_support,
-       .hwmodelist     = nl80211_get_hwmodelist,
-       .mode           = nl80211_get_mode,
-       .ssid           = nl80211_get_ssid,
-       .bssid          = nl80211_get_bssid,
-       .country        = nl80211_get_country,
-       .hardware_id    = nl80211_get_hardware_id,
-       .hardware_name  = nl80211_get_hardware_name,
-       .encryption     = nl80211_get_encryption,
-       .assoclist      = nl80211_get_assoclist,
-       .txpwrlist      = nl80211_get_txpwrlist,
-       .scanlist       = nl80211_get_scanlist,
-       .freqlist       = nl80211_get_freqlist,
-       .countrylist    = nl80211_get_countrylist,
-       .close          = nl80211_close
+       .channel          = nl80211_get_channel,
+       .frequency        = nl80211_get_frequency,
+       .frequency_offset = nl80211_get_frequency_offset,
+       .txpower          = nl80211_get_txpower,
+       .txpower_offset   = nl80211_get_txpower_offset,
+       .bitrate          = nl80211_get_bitrate,
+       .signal           = nl80211_get_signal,
+       .noise            = nl80211_get_noise,
+       .quality          = nl80211_get_quality,
+       .quality_max      = nl80211_get_quality_max,
+       .mbssid_support   = nl80211_get_mbssid_support,
+       .hwmodelist       = nl80211_get_hwmodelist,
+       .mode             = nl80211_get_mode,
+       .ssid             = nl80211_get_ssid,
+       .bssid            = nl80211_get_bssid,
+       .country          = nl80211_get_country,
+       .hardware_id      = nl80211_get_hardware_id,
+       .hardware_name    = nl80211_get_hardware_name,
+       .encryption       = nl80211_get_encryption,
+       .assoclist        = nl80211_get_assoclist,
+       .txpwrlist        = nl80211_get_txpwrlist,
+       .scanlist         = nl80211_get_scanlist,
+       .freqlist         = nl80211_get_freqlist,
+       .countrylist      = nl80211_get_countrylist,
+       .close            = nl80211_close
 };
 
 #endif
index 4d2f4aa0a246894a252eb03f3d6e6e1949d63b30..8412ef39b3474921335bf49ca2dcca298c6b95bf 100644 (file)
@@ -33,7 +33,9 @@ int wext_get_bssid(const char *ifname, char *buf);
 int wext_get_country(const char *ifname, char *buf);
 int wext_get_channel(const char *ifname, int *buf);
 int wext_get_frequency(const char *ifname, int *buf);
+int wext_get_frequency_offset(const char *ifname, int *buf);
 int wext_get_txpower(const char *ifname, int *buf);
+int wext_get_txpower_offset(const char *ifname, int *buf);
 int wext_get_bitrate(const char *ifname, int *buf);
 int wext_get_signal(const char *ifname, int *buf);
 int wext_get_noise(const char *ifname, int *buf);
@@ -52,29 +54,31 @@ int wext_get_hardware_name(const char *ifname, char *buf);
 void wext_close(void);
 
 static const struct iwinfo_ops wext_ops = {
-       .channel        = wext_get_channel,
-       .frequency      = wext_get_frequency,
-       .txpower        = wext_get_txpower,
-       .bitrate        = wext_get_bitrate,
-       .signal         = wext_get_signal,
-       .noise          = wext_get_noise,
-       .quality        = wext_get_quality,
-       .quality_max    = wext_get_quality_max,
-       .mbssid_support = wext_get_mbssid_support,
-       .hwmodelist     = wext_get_hwmodelist,
-       .mode           = wext_get_mode,
-       .ssid           = wext_get_ssid,
-       .bssid          = wext_get_bssid,
-       .country        = wext_get_country,
-       .hardware_id    = wext_get_hardware_id,
-       .hardware_name  = wext_get_hardware_name,
-       .encryption     = wext_get_encryption,
-       .assoclist      = wext_get_assoclist,
-       .txpwrlist      = wext_get_txpwrlist,
-       .scanlist       = wext_get_scanlist,
-       .freqlist       = wext_get_freqlist,
-       .countrylist    = wext_get_countrylist,
-       .close          = wext_close
+       .channel          = wext_get_channel,
+       .frequency        = wext_get_frequency,
+       .frequency_offset = wext_get_frequency_offset,
+       .txpower          = wext_get_txpower,
+       .txpower_offset   = wext_get_txpower_offset,
+       .bitrate          = wext_get_bitrate,
+       .signal           = wext_get_signal,
+       .noise            = wext_get_noise,
+       .quality          = wext_get_quality,
+       .quality_max      = wext_get_quality_max,
+       .mbssid_support   = wext_get_mbssid_support,
+       .hwmodelist       = wext_get_hwmodelist,
+       .mode             = wext_get_mode,
+       .ssid             = wext_get_ssid,
+       .bssid            = wext_get_bssid,
+       .country          = wext_get_country,
+       .hardware_id      = wext_get_hardware_id,
+       .hardware_name    = wext_get_hardware_name,
+       .encryption       = wext_get_encryption,
+       .assoclist        = wext_get_assoclist,
+       .txpwrlist        = wext_get_txpwrlist,
+       .scanlist         = wext_get_scanlist,
+       .freqlist         = wext_get_freqlist,
+       .countrylist      = wext_get_countrylist,
+       .close            = wext_close
 };
 
 #endif
index 10be96aeb9a540a4bb30fdbeea902f0578d7f64a..47dda47102ca0cb1fd8e101948ff794fa549f696 100644 (file)
@@ -32,7 +32,9 @@ int wl_get_bssid(const char *ifname, char *buf);
 int wl_get_country(const char *ifname, char *buf);
 int wl_get_channel(const char *ifname, int *buf);
 int wl_get_frequency(const char *ifname, int *buf);
+int wl_get_frequency_offset(const char *ifname, int *buf);
 int wl_get_txpower(const char *ifname, int *buf);
+int wl_get_txpower_offset(const char *ifname, int *buf);
 int wl_get_bitrate(const char *ifname, int *buf);
 int wl_get_signal(const char *ifname, int *buf);
 int wl_get_noise(const char *ifname, int *buf);
@@ -52,29 +54,31 @@ int wl_get_hardware_name(const char *ifname, char *buf);
 void wl_close(void);
 
 static const struct iwinfo_ops wl_ops = {
-       .channel        = wl_get_channel,
-       .frequency      = wl_get_frequency,
-       .txpower        = wl_get_txpower,
-       .bitrate        = wl_get_bitrate,
-       .signal         = wl_get_signal,
-       .noise          = wl_get_noise,
-       .quality        = wl_get_quality,
-       .quality_max    = wl_get_quality_max,
-       .mbssid_support = wl_get_mbssid_support,
-       .hwmodelist     = wl_get_hwmodelist,
-       .mode           = wl_get_mode,
-       .ssid           = wl_get_ssid,
-       .bssid          = wl_get_bssid,
-       .country        = wl_get_country,
-       .hardware_id    = wl_get_hardware_id,
-       .hardware_name  = wl_get_hardware_name,
-       .encryption     = wl_get_encryption,
-       .assoclist      = wl_get_assoclist,
-       .txpwrlist      = wl_get_txpwrlist,
-       .scanlist       = wl_get_scanlist,
-       .freqlist       = wl_get_freqlist,
-       .countrylist    = wl_get_countrylist,
-       .close          = wl_close
+       .channel          = wl_get_channel,
+       .frequency        = wl_get_frequency,
+       .frequency_offset = wl_get_frequency_offset,
+       .txpower          = wl_get_txpower,
+       .txpower_offset   = wl_get_txpower_offset,
+       .bitrate          = wl_get_bitrate,
+       .signal           = wl_get_signal,
+       .noise            = wl_get_noise,
+       .quality          = wl_get_quality,
+       .quality_max      = wl_get_quality_max,
+       .mbssid_support   = wl_get_mbssid_support,
+       .hwmodelist       = wl_get_hwmodelist,
+       .mode             = wl_get_mode,
+       .ssid             = wl_get_ssid,
+       .bssid            = wl_get_bssid,
+       .country          = wl_get_country,
+       .hardware_id      = wl_get_hardware_id,
+       .hardware_name    = wl_get_hardware_name,
+       .encryption       = wl_get_encryption,
+       .assoclist        = wl_get_assoclist,
+       .txpwrlist        = wl_get_txpwrlist,
+       .scanlist         = wl_get_scanlist,
+       .freqlist         = wl_get_freqlist,
+       .countrylist      = wl_get_countrylist,
+       .close            = wl_close
 };
 
 #endif
index bfa1d88ef90b48752cf7c858f14bcfe0bd8da73f..d5be084bdb422ca5f23c33ab5176b033a8d56c04 100644 (file)
@@ -311,6 +311,36 @@ static char * print_hardware_name(const struct iwinfo_ops *iw, const char *ifnam
        return buf;
 }
 
+static char * print_txpower_offset(const struct iwinfo_ops *iw, const char *ifname)
+{
+       int off;
+       static char buf[12];
+
+       if (iw->txpower_offset(ifname, &off))
+               snprintf(buf, sizeof(buf), "unknown");
+       else if (off != 0)
+               snprintf(buf, sizeof(buf), "%d dB", off);
+       else
+               snprintf(buf, sizeof(buf), "none");
+
+       return buf;
+}
+
+static char * print_frequency_offset(const struct iwinfo_ops *iw, const char *ifname)
+{
+       int off;
+       static char buf[12];
+
+       if (iw->frequency_offset(ifname, &off))
+               snprintf(buf, sizeof(buf), "unknown");
+       else if (off != 0)
+               snprintf(buf, sizeof(buf), "%.3f GHz", ((float)off / 1000.0));
+       else
+               snprintf(buf, sizeof(buf), "none");
+
+       return buf;
+}
+
 static char * print_ssid(const struct iwinfo_ops *iw, const char *ifname)
 {
        char buf[IWINFO_ESSID_MAX_SIZE+1] = { 0 };
@@ -473,6 +503,10 @@ static void print_info(const struct iwinfo_ops *iw, const char *ifname)
        printf("          Hardware: %s [%s]\n",
                print_hardware_id(iw, ifname),
                print_hardware_name(iw, ifname));
+       printf("          TX power offset: %s\n",
+               print_txpower_offset(iw, ifname));
+       printf("          Frequency offset: %s\n",
+               print_frequency_offset(iw, ifname));
        printf("          Supports VAPs: %s\n",
                print_mbssid_supp(iw, ifname));
 }
index e088d03f05761b9344edd91176452e9742140fd9..e33c7950781810ea83ceaedb864dc18c33ac64de 100644 (file)
@@ -347,7 +347,7 @@ const struct iwinfo_hardware_entry IWINFO_HARDWARE_ENTRIES[] = {
        { VENDOR_UBNT, "SR71A",                 0x168c, 0x0027, 0x168c, 0x2082, 10,     0 },
        { VENDOR_UBNT, "SR71",                  0x168c, 0x0027, 0x0777, 0x4082, 10,     0 },
 #endif
-#ifdef NL80211
+#ifdef USE_NL80211
        { VENDOR_UBNT, "NanoStation M2",        0x168c, 0x002a, 0x0777, 0xe012, 10,     0 }, /* ToDo: confirm offset */
        { VENDOR_UBNT, "NanoStation M5",        0x168c, 0x002a, 0x0777, 0xe005,  5,     0 }, /* ToDo: confirm offset */
        { VENDOR_UBNT, "Bullet M2",             0x168c, 0x002a, 0x0777, 0xe202, 12,     0 },
index 08eec18bd92abf2d0406ccdfcea50a1d8d3a751a..533236b4d2078268bb10ef68c8eb0195e339194d 100644 (file)
@@ -558,7 +558,9 @@ static int iwinfo_L_countrylist(lua_State *L, int (*func)(const char *, char *,
 /* Broadcom */
 LUA_WRAP_INT(wl,channel)
 LUA_WRAP_INT(wl,frequency)
+LUA_WRAP_INT(wl,frequency_offset)
 LUA_WRAP_INT(wl,txpower)
+LUA_WRAP_INT(wl,txpower_offset)
 LUA_WRAP_INT(wl,bitrate)
 LUA_WRAP_INT(wl,signal)
 LUA_WRAP_INT(wl,noise)
@@ -584,7 +586,9 @@ LUA_WRAP_STRUCT(wl,hardware_id)
 /* Madwifi */
 LUA_WRAP_INT(madwifi,channel)
 LUA_WRAP_INT(madwifi,frequency)
+LUA_WRAP_INT(madwifi,frequency_offset)
 LUA_WRAP_INT(madwifi,txpower)
+LUA_WRAP_INT(madwifi,txpower_offset)
 LUA_WRAP_INT(madwifi,bitrate)
 LUA_WRAP_INT(madwifi,signal)
 LUA_WRAP_INT(madwifi,noise)
@@ -610,7 +614,9 @@ LUA_WRAP_STRUCT(madwifi,hardware_id)
 /* NL80211 */
 LUA_WRAP_INT(nl80211,channel)
 LUA_WRAP_INT(nl80211,frequency)
+LUA_WRAP_INT(nl80211,frequency_offset)
 LUA_WRAP_INT(nl80211,txpower)
+LUA_WRAP_INT(nl80211,txpower_offset)
 LUA_WRAP_INT(nl80211,bitrate)
 LUA_WRAP_INT(nl80211,signal)
 LUA_WRAP_INT(nl80211,noise)
@@ -635,7 +641,9 @@ LUA_WRAP_STRUCT(nl80211,hardware_id)
 /* Wext */
 LUA_WRAP_INT(wext,channel)
 LUA_WRAP_INT(wext,frequency)
+LUA_WRAP_INT(wext,frequency_offset)
 LUA_WRAP_INT(wext,txpower)
+LUA_WRAP_INT(wext,txpower_offset)
 LUA_WRAP_INT(wext,bitrate)
 LUA_WRAP_INT(wext,signal)
 LUA_WRAP_INT(wext,noise)
@@ -661,7 +669,9 @@ LUA_WRAP_STRUCT(wext,hardware_id)
 static const luaL_reg R_wl[] = {
        LUA_REG(wl,channel),
        LUA_REG(wl,frequency),
+       LUA_REG(wl,frequency_offset),
        LUA_REG(wl,txpower),
+       LUA_REG(wl,txpower_offset),
        LUA_REG(wl,bitrate),
        LUA_REG(wl,signal),
        LUA_REG(wl,noise),
@@ -690,7 +700,9 @@ static const luaL_reg R_wl[] = {
 static const luaL_reg R_madwifi[] = {
        LUA_REG(madwifi,channel),
        LUA_REG(madwifi,frequency),
+       LUA_REG(madwifi,frequency_offset),
        LUA_REG(madwifi,txpower),
+       LUA_REG(madwifi,txpower_offset),
        LUA_REG(madwifi,bitrate),
        LUA_REG(madwifi,signal),
        LUA_REG(madwifi,noise),
@@ -719,7 +731,9 @@ static const luaL_reg R_madwifi[] = {
 static const luaL_reg R_nl80211[] = {
        LUA_REG(nl80211,channel),
        LUA_REG(nl80211,frequency),
+       LUA_REG(nl80211,frequency_offset),
        LUA_REG(nl80211,txpower),
+       LUA_REG(nl80211,txpower_offset),
        LUA_REG(nl80211,bitrate),
        LUA_REG(nl80211,signal),
        LUA_REG(nl80211,noise),
@@ -747,7 +761,9 @@ static const luaL_reg R_nl80211[] = {
 static const luaL_reg R_wext[] = {
        LUA_REG(wext,channel),
        LUA_REG(wext,frequency),
+       LUA_REG(wext,frequency_offset),
        LUA_REG(wext,txpower),
+       LUA_REG(wext,txpower_offset),
        LUA_REG(wext,bitrate),
        LUA_REG(wext,signal),
        LUA_REG(wext,noise),
index 50793c4937edfd3c9b5ab36c882e0a4efc3daee3..732cfe56fe8f02121ab855e11729f9c8d5ae5f31 100644 (file)
@@ -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;
 }
index d3726821fceb0797c3b769a5009d5232c3ac1df8..4b8b37daa89b7b96c053a50e1cd102802c1c2b7a 100644 (file)
@@ -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;
 }
index 3923c9e7604c9c3298b361a1045f0841258d58ee..c74785f874875593d2d48b9b87d1378043843b3f 100644 (file)
@@ -515,3 +515,17 @@ int wext_get_hardware_name(const char *ifname, char *buf)
        sprintf(buf, "Generic WEXT");
        return 0;
 }
+
+int wext_get_txpower_offset(const char *ifname, int *buf)
+{
+       /* Stub */
+       *buf = 0;
+       return -1;
+}
+
+int wext_get_frequency_offset(const char *ifname, int *buf)
+{
+       /* Stub */
+       *buf = 0;
+       return -1;
+}
index 76984de3369f8ab022d000bfba15437123f9b46d..7b39a9b863f1130df9cf228d85d0e3bacfc1ebad 100644 (file)
@@ -585,3 +585,28 @@ int wl_get_hardware_name(const char *ifname, char *buf)
 
        return 0;
 }
+
+int wl_get_txpower_offset(const char *ifname, int *buf)
+{
+       FILE *p;
+       char off[8];
+
+       *buf = 0;
+
+       if ((p = popen("/usr/sbin/nvram get opo", "r")) != NULL)
+       {
+               if (fread(off, 1, sizeof(off), p))
+                       *buf = strtoul(off, NULL, 16);
+
+               pclose(p);
+       }
+
+       return 0;
+}
+
+int wl_get_frequency_offset(const char *ifname, int *buf)
+{
+       /* Stub */
+       *buf = 0;
+       return -1;
+}