diff options
Diffstat (limited to 'libs/iwinfo/src')
-rw-r--r-- | libs/iwinfo/src/iwinfo.h | 5 | ||||
-rw-r--r-- | libs/iwinfo/src/iwinfo_lualib.c | 39 | ||||
-rw-r--r-- | libs/iwinfo/src/iwinfo_madwifi.c | 26 | ||||
-rw-r--r-- | libs/iwinfo/src/iwinfo_madwifi.h | 1 | ||||
-rw-r--r-- | libs/iwinfo/src/iwinfo_wext.c | 31 | ||||
-rw-r--r-- | libs/iwinfo/src/iwinfo_wext.h | 1 | ||||
-rw-r--r-- | libs/iwinfo/src/iwinfo_wl.c | 5 | ||||
-rw-r--r-- | libs/iwinfo/src/iwinfo_wl.h | 1 |
8 files changed, 109 insertions, 0 deletions
diff --git a/libs/iwinfo/src/iwinfo.h b/libs/iwinfo/src/iwinfo.h index eebe6b4199..f15e38327f 100644 --- a/libs/iwinfo/src/iwinfo.h +++ b/libs/iwinfo/src/iwinfo.h @@ -36,6 +36,11 @@ struct iwinfo_txpwrlist_entry { uint8_t mw; }; +struct iwinfo_freqlist_entry { + uint8_t channel; + uint32_t mhz; +}; + struct iwinfo_crypto_entry { uint8_t enabled; uint8_t wpa_version; diff --git a/libs/iwinfo/src/iwinfo_lualib.c b/libs/iwinfo/src/iwinfo_lualib.c index 8eb4ad5dc1..61ad5d325f 100644 --- a/libs/iwinfo/src/iwinfo_lualib.c +++ b/libs/iwinfo/src/iwinfo_lualib.c @@ -210,6 +210,39 @@ static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int return 1; } +/* Wrapper for frequency list */ +static int iwinfo_L_freqlist(lua_State *L, int (*func)(const char *, char *, int *)) +{ + int i, x, len; + char rv[IWINFO_BUFSIZE]; + const char *ifname = luaL_checkstring(L, 1); + struct iwinfo_freqlist_entry *e; + + lua_newtable(L); + memset(rv, 0, sizeof(rv)); + + if( !(*func)(ifname, rv, &len) ) + { + for( i = 0, x = 1; i < len; i += sizeof(struct iwinfo_freqlist_entry), x++ ) + { + e = (struct iwinfo_freqlist_entry *) &rv[i]; + + lua_newtable(L); + + /* MHz */ + lua_pushinteger(L, e->mhz); + lua_setfield(L, -2, "mhz"); + + /* Channel */ + lua_pushinteger(L, e->channel); + lua_setfield(L, -2, "channel"); + + lua_rawseti(L, -2, x); + } + } + + return 1; +} /* Broadcom */ LUA_WRAP_INT(wl,channel) @@ -227,6 +260,7 @@ LUA_WRAP_STRING(wl,enctype) LUA_WRAP_LIST(wl,assoclist) LUA_WRAP_LIST(wl,txpwrlist) LUA_WRAP_LIST(wl,scanlist) +LUA_WRAP_LIST(wl,freqlist) /* Madwifi */ LUA_WRAP_INT(madwifi,channel) @@ -244,6 +278,7 @@ LUA_WRAP_STRING(madwifi,enctype) LUA_WRAP_LIST(madwifi,assoclist) LUA_WRAP_LIST(madwifi,txpwrlist) LUA_WRAP_LIST(madwifi,scanlist) +LUA_WRAP_LIST(madwifi,freqlist) /* Wext */ LUA_WRAP_INT(wext,channel) @@ -261,6 +296,7 @@ LUA_WRAP_STRING(wext,enctype) LUA_WRAP_LIST(wext,assoclist) LUA_WRAP_LIST(wext,txpwrlist) LUA_WRAP_LIST(wext,scanlist) +LUA_WRAP_LIST(wext,freqlist) /* Broadcom table */ static const luaL_reg R_wl[] = { @@ -278,6 +314,7 @@ static const luaL_reg R_wl[] = { LUA_REG(wl,assoclist), LUA_REG(wl,txpwrlist), LUA_REG(wl,scanlist), + LUA_REG(wl,freqlist), LUA_REG(wl,mbssid_support), { NULL, NULL } }; @@ -298,6 +335,7 @@ static const luaL_reg R_madwifi[] = { LUA_REG(madwifi,assoclist), LUA_REG(madwifi,txpwrlist), LUA_REG(madwifi,scanlist), + LUA_REG(madwifi,freqlist), LUA_REG(madwifi,mbssid_support), { NULL, NULL } }; @@ -318,6 +356,7 @@ static const luaL_reg R_wext[] = { LUA_REG(wext,assoclist), LUA_REG(wext,txpwrlist), LUA_REG(wext,scanlist), + LUA_REG(wext,freqlist), LUA_REG(wext,mbssid_support), { NULL, NULL } }; diff --git a/libs/iwinfo/src/iwinfo_madwifi.c b/libs/iwinfo/src/iwinfo_madwifi.c index 1fe777f1d5..99c02dcd05 100644 --- a/libs/iwinfo/src/iwinfo_madwifi.c +++ b/libs/iwinfo/src/iwinfo_madwifi.c @@ -494,6 +494,32 @@ int madwifi_get_scanlist(const char *ifname, char *buf, int *len) return ret; } +int madwifi_get_freqlist(const char *ifname, char *buf, int *len) +{ + int i, bl; + struct ieee80211req_chaninfo chans; + struct iwinfo_freqlist_entry entry; + + if( get80211priv(ifname, IEEE80211_IOCTL_GETCHANINFO, &chans, sizeof(chans)) >= 0 ) + { + bl = 0; + + for( i = 0; i < chans.ic_nchans; i++ ) + { + entry.mhz = (int)(chans.ic_chans[i].ic_freq / 1000); + entry.channel = chans.ic_chans[i].ic_ieee; + + memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry)); + bl += sizeof(struct iwinfo_freqlist_entry); + } + + *len = bl; + return 0; + } + + return -1; +} + int madwifi_get_mbssid_support(const char *ifname, int *buf) { /* We assume that multi bssid is always possible */ diff --git a/libs/iwinfo/src/iwinfo_madwifi.h b/libs/iwinfo/src/iwinfo_madwifi.h index 9c5b7fa589..18511c80c2 100644 --- a/libs/iwinfo/src/iwinfo_madwifi.h +++ b/libs/iwinfo/src/iwinfo_madwifi.h @@ -37,6 +37,7 @@ int madwifi_get_enctype(const char *ifname, char *buf); int madwifi_get_assoclist(const char *ifname, char *buf, int *len); int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len); int madwifi_get_scanlist(const char *ifname, char *buf, int *len); +int madwifi_get_freqlist(const char *ifname, char *buf, int *len); int madwifi_get_mbssid_support(const char *ifname, int *buf); #endif diff --git a/libs/iwinfo/src/iwinfo_wext.c b/libs/iwinfo/src/iwinfo_wext.c index 387cb13b44..eebaea6af8 100644 --- a/libs/iwinfo/src/iwinfo_wext.c +++ b/libs/iwinfo/src/iwinfo_wext.c @@ -394,6 +394,37 @@ int wext_get_txpwrlist(const char *ifname, char *buf, int *len) return -1; } +int wext_get_freqlist(const char *ifname, char *buf, int *len) +{ + struct iwreq wrq; + struct iw_range range; + struct iwinfo_freqlist_entry entry; + int i, bl; + + wrq.u.data.pointer = (caddr_t) ⦥ + wrq.u.data.length = sizeof(struct iw_range); + wrq.u.data.flags = 0; + + if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0) + { + bl = 0; + + for(i = 0; i < range.num_frequency; i++) + { + entry.mhz = wext_freq2mhz(&range.freq[i]); + entry.channel = range.freq[i].i; + + memcpy(&buf[bl], &entry, sizeof(struct iwinfo_freqlist_entry)); + bl += sizeof(struct iwinfo_freqlist_entry); + } + + *len = bl; + return 0; + } + + return -1; +} + int wext_get_mbssid_support(const char *ifname, int *buf) { /* No multi bssid support atm */ diff --git a/libs/iwinfo/src/iwinfo_wext.h b/libs/iwinfo/src/iwinfo_wext.h index dd1922fc8c..7861fdc9f1 100644 --- a/libs/iwinfo/src/iwinfo_wext.h +++ b/libs/iwinfo/src/iwinfo_wext.h @@ -38,6 +38,7 @@ int wext_get_enctype(const char *ifname, char *buf); int wext_get_assoclist(const char *ifname, char *buf, int *len); int wext_get_txpwrlist(const char *ifname, char *buf, int *len); int wext_get_scanlist(const char *ifname, char *buf, int *len); +int wext_get_freqlist(const char *ifname, char *buf, int *len); int wext_get_mbssid_support(const char *ifname, int *buf); #endif diff --git a/libs/iwinfo/src/iwinfo_wl.c b/libs/iwinfo/src/iwinfo_wl.c index 8519dbc561..f8ee4f3e32 100644 --- a/libs/iwinfo/src/iwinfo_wl.c +++ b/libs/iwinfo/src/iwinfo_wl.c @@ -389,6 +389,11 @@ int wl_get_scanlist(const char *ifname, char *buf, int *len) return wext_get_scanlist(ifname, buf, len); } +int wl_get_freqlist(const char *ifname, char *buf, int *len) +{ + return wext_get_freqlist(ifname, buf, len); +} + int wl_get_mbssid_support(const char *ifname, int *buf) { wlc_rev_info_t revinfo; diff --git a/libs/iwinfo/src/iwinfo_wl.h b/libs/iwinfo/src/iwinfo_wl.h index 31832d985e..2892715cd5 100644 --- a/libs/iwinfo/src/iwinfo_wl.h +++ b/libs/iwinfo/src/iwinfo_wl.h @@ -37,6 +37,7 @@ int wl_get_enctype(const char *ifname, char *buf); int wl_get_assoclist(const char *ifname, char *buf, int *len); int wl_get_txpwrlist(const char *ifname, char *buf, int *len); int wl_get_scanlist(const char *ifname, char *buf, int *len); +int wl_get_freqlist(const char *ifname, char *buf, int *len); int wl_get_mbssid_support(const char *ifname, int *buf); #endif |