Changeset 5304
- Timestamp:
- 08/24/09 06:54:38 (4 years ago)
- Location:
- luci/trunk/libs/iwinfo
- Files:
-
- 2 added
- 10 modified
-
Makefile (modified) (1 diff)
-
src/iwinfo.h (modified) (1 diff)
-
src/iwinfo_lualib.c (modified) (7 diffs)
-
src/iwinfo_lualib.h (modified) (1 diff)
-
src/iwinfo_madwifi.c (modified) (1 diff)
-
src/iwinfo_madwifi.h (modified) (1 diff)
-
src/iwinfo_wext.c (modified) (2 diffs)
-
src/iwinfo_wext.h (modified) (2 diffs)
-
src/iwinfo_wext_scan.c (added)
-
src/iwinfo_wext_scan.h (added)
-
src/iwinfo_wl.c (modified) (1 diff)
-
src/iwinfo_wl.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/iwinfo/Makefile
r5289 r5304 11 11 IWINFO_SO = iwinfo.so 12 12 IWINFO_LUA = iwinfo.lua 13 IWINFO_OBJ = src/iwinfo_wl.o src/iwinfo_madwifi.o src/iwinfo_wext.o src/iwinfo_lualib.o 13 IWINFO_OBJ = src/iwinfo_wl.o src/iwinfo_madwifi.o \ 14 src/iwinfo_wext.o src/iwinfo_wext_scan.o src/iwinfo_lualib.o 14 15 15 16 %.o: %.c -
luci/trunk/libs/iwinfo/src/iwinfo.h
r5292 r5304 35 35 }; 36 36 37 struct iwinfo_crypto_entry { 38 uint8_t enabled; 39 uint8_t wpa_version; 40 uint8_t group_ciphers[8]; 41 uint8_t pair_ciphers[8]; 42 uint8_t auth_suites[8]; 43 }; 44 45 struct iwinfo_scanlist_entry { 46 uint8_t mac[6]; 47 uint8_t ssid[IW_ESSID_MAX_SIZE+1]; 48 uint8_t mode[8]; 49 uint8_t channel; 50 struct iwinfo_crypto_entry crypto; 51 }; 52 37 53 #endif 38 54 -
luci/trunk/libs/iwinfo/src/iwinfo_lualib.c
r5294 r5304 108 108 } 109 109 110 /* Wrapper for scan list */ 111 static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int *)) 112 { 113 int i, j, x, y, len; 114 char rv[IWINFO_BUFSIZE]; 115 char macstr[18]; 116 const char *ifname = luaL_checkstring(L, 1); 117 struct iwinfo_scanlist_entry *e; 118 119 lua_newtable(L); 120 memset(rv, 0, sizeof(rv)); 121 122 if( !(*func)(ifname, rv, &len) ) 123 { 124 for( i = 0, x = 1; i < len; i += sizeof(struct iwinfo_scanlist_entry), x++ ) 125 { 126 e = (struct iwinfo_scanlist_entry *) &rv[i]; 127 128 lua_newtable(L); 129 130 /* BSSID */ 131 sprintf(macstr, "%02X:%02X:%02X:%02X:%02X:%02X", 132 e->mac[0], e->mac[1], e->mac[2], 133 e->mac[3], e->mac[4], e->mac[5]); 134 135 lua_pushstring(L, macstr); 136 lua_setfield(L, -2, "mac"); 137 138 /* ESSID */ 139 if( e->ssid[0] ) 140 { 141 lua_pushstring(L, (char *) e->ssid); 142 lua_setfield(L, -2, "ssid"); 143 } 144 145 /* Channel */ 146 lua_pushinteger(L, e->channel); 147 lua_setfield(L, -2, "channel"); 148 149 /* Mode */ 150 lua_pushstring(L, (char *) e->mode); 151 lua_setfield(L, -2, "mode"); 152 153 /* Crypto */ 154 lua_pushinteger(L, e->crypto.wpa_version); 155 lua_setfield(L, -2, "wpa_version"); 156 157 lua_newtable(L); 158 for( j = 0, y = 1; j < sizeof(e->crypto.group_ciphers); j++ ) 159 { 160 if( e->crypto.group_ciphers[j] ) 161 { 162 lua_pushstring(L, (j < IW_IE_CYPHER_NUM) 163 ? iw_ie_cypher_name[j] : "Proprietary"); 164 165 lua_rawseti(L, -2, y++); 166 } 167 } 168 lua_setfield(L, -2, "group_ciphers"); 169 170 lua_newtable(L); 171 for( j = 0, y = 1; j < sizeof(e->crypto.pair_ciphers); j++ ) 172 { 173 if( e->crypto.pair_ciphers[j] ) 174 { 175 lua_pushstring(L, (j < IW_IE_CYPHER_NUM) 176 ? iw_ie_cypher_name[j] : "Proprietary"); 177 178 lua_rawseti(L, -2, y++); 179 } 180 } 181 lua_setfield(L, -2, "pair_ciphers"); 182 183 lua_newtable(L); 184 for( j = 0, y = 1; j < sizeof(e->crypto.auth_suites); j++ ) 185 { 186 if( e->crypto.auth_suites[j] ) 187 { 188 lua_pushstring(L, (j < IW_IE_KEY_MGMT_NUM) 189 ? iw_ie_key_mgmt_name[j] : "Proprietary"); 190 191 lua_rawseti(L, -2, y++); 192 } 193 } 194 lua_setfield(L, -2, "auth_suites"); 195 196 lua_rawseti(L, -2, x); 197 } 198 } 199 200 return 1; 201 } 202 203 110 204 /* Broadcom */ 111 205 LUA_WRAP_INT(wl,channel) … … 123 217 LUA_WRAP_LIST(wl,assoclist) 124 218 LUA_WRAP_LIST(wl,txpwrlist) 219 LUA_WRAP_LIST(wl,scanlist) 125 220 126 221 /* Madwifi */ … … 139 234 LUA_WRAP_LIST(madwifi,assoclist) 140 235 LUA_WRAP_LIST(madwifi,txpwrlist) 236 LUA_WRAP_LIST(madwifi,scanlist) 141 237 142 238 /* Wext */ … … 155 251 LUA_WRAP_LIST(wext,assoclist) 156 252 LUA_WRAP_LIST(wext,txpwrlist) 253 LUA_WRAP_LIST(wext,scanlist) 157 254 158 255 /* Broadcom table */ … … 171 268 LUA_REG(wl,assoclist), 172 269 LUA_REG(wl,txpwrlist), 270 LUA_REG(wl,scanlist), 173 271 LUA_REG(wl,mbssid_support), 174 272 { NULL, NULL } … … 190 288 LUA_REG(madwifi,assoclist), 191 289 LUA_REG(madwifi,txpwrlist), 290 LUA_REG(madwifi,scanlist), 192 291 LUA_REG(madwifi,mbssid_support), 193 292 { NULL, NULL } … … 209 308 LUA_REG(wext,assoclist), 210 309 LUA_REG(wext,txpwrlist), 310 LUA_REG(wext,scanlist), 211 311 LUA_REG(wext,mbssid_support), 212 312 { NULL, NULL } -
luci/trunk/libs/iwinfo/src/iwinfo_lualib.h
r5294 r5304 25 25 26 26 #include "iwinfo.h" 27 #include "iwinfo_wext_scan.h" 27 28 28 29 -
luci/trunk/libs/iwinfo/src/iwinfo_madwifi.c
r5292 r5304 404 404 } 405 405 406 int madwifi_get_scanlist(const char *ifname, char *buf, int *len) 407 { 408 return wext_get_scanlist(ifname, buf, len); 409 } 410 406 411 int madwifi_get_mbssid_support(const char *ifname, int *buf) 407 412 { -
luci/trunk/libs/iwinfo/src/iwinfo_madwifi.h
r5292 r5304 37 37 int madwifi_get_assoclist(const char *ifname, char *buf, int *len); 38 38 int madwifi_get_txpwrlist(const char *ifname, char *buf, int *len); 39 int madwifi_get_scanlist(const char *ifname, char *buf, int *len); 39 40 int madwifi_get_mbssid_support(const char *ifname, int *buf); 40 41 -
luci/trunk/libs/iwinfo/src/iwinfo_wext.c
r5292 r5304 190 190 if(wext_ioctl(ifname, SIOCGIWRATE, &wrq) >= 0) 191 191 { 192 *buf = wrq.u.bitrate.value;192 *buf = (wrq.u.bitrate.value / 1000000); 193 193 return 0; 194 194 } … … 200 200 { 201 201 struct iwreq wrq; 202 struct iw_range range; 203 double freq; 204 int i; 202 205 203 206 if(wext_ioctl(ifname, SIOCGIWFREQ, &wrq) >= 0) 204 207 { 205 /* FIXME: iwlib has some strange workarounds here, maybe we need them as well... */ 206 *buf = (int) wext_freq2float(&wrq.u.freq); 207 return 0; 208 if( wrq.u.freq.m >= 1000 ) 209 { 210 freq = wext_freq2float(&wrq.u.freq); 211 wrq.u.data.pointer = (caddr_t) ⦥ 212 wrq.u.data.length = sizeof(struct iw_range); 213 wrq.u.data.flags = 0; 214 215 if(wext_ioctl(ifname, SIOCGIWRANGE, &wrq) >= 0) 216 { 217 for(i = 0; i < range.num_frequency; i++) 218 { 219 if( wext_freq2float(&range.freq[i]) == freq ) 220 { 221 *buf = range.freq[i].i; 222 return 0; 223 } 224 } 225 } 226 } 227 else 228 { 229 *buf = wrq.u.freq.m; 230 return 0; 231 } 208 232 } 209 233 -
luci/trunk/libs/iwinfo/src/iwinfo_wext.h
r5292 r5304 23 23 #include "include/wext.h" 24 24 25 25 26 int wext_probe(const char *ifname); 26 27 int wext_get_mode(const char *ifname, char *buf); … … 37 38 int wext_get_assoclist(const char *ifname, char *buf, int *len); 38 39 int wext_get_txpwrlist(const char *ifname, char *buf, int *len); 40 int wext_get_scanlist(const char *ifname, char *buf, int *len); 39 41 int wext_get_mbssid_support(const char *ifname, int *buf); 40 42 -
luci/trunk/libs/iwinfo/src/iwinfo_wl.c
r5292 r5304 385 385 } 386 386 387 int wl_get_scanlist(const char *ifname, char *buf, int *len) 388 { 389 return wext_get_scanlist(ifname, buf, len); 390 } 391 387 392 int wl_get_mbssid_support(const char *ifname, int *buf) 388 393 { -
luci/trunk/libs/iwinfo/src/iwinfo_wl.h
r5292 r5304 37 37 int wl_get_assoclist(const char *ifname, char *buf, int *len); 38 38 int wl_get_txpwrlist(const char *ifname, char *buf, int *len); 39 int wl_get_scanlist(const char *ifname, char *buf, int *len); 39 40 int wl_get_mbssid_support(const char *ifname, int *buf); 40 41
