uint8_t mw;
};
+struct iwinfo_freqlist_entry {
+ uint8_t channel;
+ uint32_t mhz;
+};
+
struct iwinfo_crypto_entry {
uint8_t enabled;
uint8_t wpa_version;
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)
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)
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)
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[] = {
LUA_REG(wl,assoclist),
LUA_REG(wl,txpwrlist),
LUA_REG(wl,scanlist),
+ LUA_REG(wl,freqlist),
LUA_REG(wl,mbssid_support),
{ NULL, NULL }
};
LUA_REG(madwifi,assoclist),
LUA_REG(madwifi,txpwrlist),
LUA_REG(madwifi,scanlist),
+ LUA_REG(madwifi,freqlist),
LUA_REG(madwifi,mbssid_support),
{ NULL, NULL }
};
LUA_REG(wext,assoclist),
LUA_REG(wext,txpwrlist),
LUA_REG(wext,scanlist),
+ LUA_REG(wext,freqlist),
LUA_REG(wext,mbssid_support),
{ NULL, NULL }
};
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 */
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
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 */
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
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;
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