libiwinfo: add restricted flag for freqlist
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 19 Oct 2010 03:52:55 +0000 (03:52 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 19 Oct 2010 03:52:55 +0000 (03:52 +0000)
contrib/package/iwinfo/Makefile
contrib/package/iwinfo/src/iwinfo.h
contrib/package/iwinfo/src/iwinfo.lua
contrib/package/iwinfo/src/iwinfo_lualib.c
contrib/package/iwinfo/src/iwinfo_madwifi.c
contrib/package/iwinfo/src/iwinfo_nl80211.c
contrib/package/iwinfo/src/iwinfo_wext.c

index 82c5482737d54081cbe6fb47a5e87dba039b816e..e7e16f626ab5688e1a38ea48c642b14658f5c188 100644 (file)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libiwinfo
-PKG_RELEASE:=5
+PKG_RELEASE:=6
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
index 44865505728a12db8b83b9937ea0abfcdc1e3b6f..6d05289e9b2abc27f2e0abf994964f06721c302f 100644 (file)
@@ -66,6 +66,7 @@ struct iwinfo_txpwrlist_entry {
 struct iwinfo_freqlist_entry {
        uint8_t channel;
        uint32_t mhz;
+       uint8_t restricted;
 };
 
 struct iwinfo_crypto_entry {
index f7dbf42fdb6a80c5fc2ce7357e7602c6e6f10f62..76b9e4ad1f7df1eb3e192d9fbb77eb3028a1f454 100755 (executable)
@@ -105,9 +105,10 @@ function print_freqlist(api, dev)
 
        if fl and #fl > 0 then
                for _, fe in ipairs(fl) do
-                       printf("%s %.3f GHz (Channel %d)",
+                       printf("%s %.3f GHz (Channel %d)%s",
                                (cc == fe.channel) and "*" or " ",
-                               n(fe.mhz) / 1000, n(fe.channel))
+                               n(fe.mhz) / 1000, n(fe.channel),
+                               fe.restricted and " [restricted]" or "")
                end
        else
                print("No frequency information available")
index 312a3dae7b05bd82c3404f5840dd6d227e41ac93..95600c86584aa95414b9171e269493dfe202b382 100644 (file)
@@ -671,6 +671,10 @@ static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int
                        lua_pushinteger(L, e->channel);
                        lua_setfield(L, -2, "channel");
 
+                       /* Restricted (DFS/TPC/Radar) */
+                       lua_pushboolean(L, e->restricted);
+                       lua_setfield(L, -2, "restricted");
+
                        lua_rawseti(L, -2, x);
                }
        }
index 9c3bb2688ac213b6eb35c3cfb34a3beff153e1e2..5289f42e0f7504a796e04ed822bf06cba7061a49 100644 (file)
@@ -805,8 +805,9 @@ int madwifi_get_freqlist(const char *ifname, char *buf, int *len)
 
                for( i = 0; i < chans.ic_nchans; i++ )
                {
-                       entry.mhz     = chans.ic_chans[i].ic_freq;
-                       entry.channel = chans.ic_chans[i].ic_ieee;
+                       entry.mhz        = chans.ic_chans[i].ic_freq;
+                       entry.channel    = chans.ic_chans[i].ic_ieee;
+                       entry.restricted = 0;
 
                        memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry));
                        bl += sizeof(struct iwinfo_freqlist_entry);
index ff30e0e94f491d73488fd6ed74723c61a20b55d4..6b980235ec187717ba84196c666c3bebbfe67294 100644 (file)
@@ -1319,9 +1319,6 @@ int nl80211_get_freqlist(const char *ifname, char *buf, int *len)
                [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32  },
        };
 
-       if( !wext_get_freqlist(ifname, buf, len) )
-               return 0;
-
        req = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, 0);
        if( req )
        {
@@ -1340,9 +1337,18 @@ int nl80211_get_freqlist(const char *ifname, char *buf, int *len)
                                        nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
                                                nla_data(freq), nla_len(freq), freq_policy);
 
+                                       if( freqs[NL80211_FREQUENCY_ATTR_DISABLED] )
+                                               continue;
+
                                        e->mhz = nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]);
                                        e->channel = nl80211_freq2channel(e->mhz);
 
+                                       e->restricted = (
+                                               freqs[NL80211_FREQUENCY_ATTR_PASSIVE_SCAN] ||
+                                               freqs[NL80211_FREQUENCY_ATTR_NO_IBSS]      ||
+                                               freqs[NL80211_FREQUENCY_ATTR_RADAR]
+                                       ) ? 1 : 0;
+
                                        e++;
                                        count++;
                                }
index e9e79e3757e91231b93b966c59f332f5540f2184..298fd931786399150aa24176bc6c52403c572f20 100644 (file)
@@ -444,8 +444,9 @@ int wext_get_freqlist(const char *ifname, char *buf, int *len)
 
                for(i = 0; i < range.num_frequency; i++)
                {
-                       entry.mhz     = wext_freq2mhz(&range.freq[i]);
-                       entry.channel = range.freq[i].i;
+                       entry.mhz        = wext_freq2mhz(&range.freq[i]);
+                       entry.channel    = range.freq[i].i;
+                       entry.restricted = 0;
 
                        memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry));
                        bl += sizeof(struct iwinfo_freqlist_entry);