Changeset 6606
- Timestamp:
- 12/05/10 00:25:14 (2 years ago)
- Location:
- luci/trunk/contrib/package/iwinfo
- Files:
-
- 3 modified
-
Makefile (modified) (1 diff)
-
src/iwinfo_madwifi.c (modified) (7 diffs)
-
src/iwinfo_nl80211.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/contrib/package/iwinfo/Makefile
r6590 r6606 8 8 9 9 PKG_NAME:=libiwinfo 10 PKG_RELEASE:=1 210 PKG_RELEASE:=13 11 11 12 12 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) -
luci/trunk/contrib/package/iwinfo/src/iwinfo_madwifi.c
r6565 r6606 550 550 { 551 551 int ciphers = 0, key_len = 0; 552 char keybuf[IW_ENCODING_TOKEN_MAX]; 552 553 struct iwinfo_crypto_entry *c = (struct iwinfo_crypto_entry *)buf; 553 554 struct iwreq wrq; … … 555 556 556 557 memset(&wrq, 0, sizeof(wrq)); 557 memset(&wk, 0, sizeof(wk)); 558 memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN); 558 559 /* Obtain key info */ 560 if( madwifi_wrq(&wrq, ifname, SIOCGIWENCODE, keybuf, sizeof(keybuf)) < 0 ) 561 return -1; 562 563 /* Have any encryption? */ 564 if( (wrq.u.data.flags & IW_ENCODE_DISABLED) || (wrq.u.data.length == 0) ) 565 return 0; 566 567 /* Save key len */ 568 key_len = wrq.u.data.length; 559 569 560 570 /* Get wpa protocol version */ … … 590 600 } 591 601 602 memset(&wk, 0, sizeof(wk)); 603 memset(wk.ik_macaddr, 0xff, IEEE80211_ADDR_LEN); 604 592 605 /* Get key information */ 593 606 if( get80211priv(ifname, IEEE80211_IOCTL_GETKEY, &wk, sizeof(wk)) >= 0 ) … … 598 611 } 599 612 600 /* Get group key length */601 wrq.u.mode = IEEE80211_PARAM_MCASTKEYLEN;602 if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 )603 key_len = wrq.u.mode;604 605 613 /* Get used pairwise ciphers */ 606 614 wrq.u.mode = IEEE80211_PARAM_UCASTCIPHERS; … … 609 617 ciphers = wrq.u.mode; 610 618 611 if( c iphers & (1 << IEEE80211_CIPHER_TKIP) )619 if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_TKIP) ) 612 620 c->pair_ciphers |= IWINFO_CIPHER_TKIP; 613 621 614 if( c iphers & (1 << IEEE80211_CIPHER_AES_CCM) )622 if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_AES_CCM) ) 615 623 c->pair_ciphers |= IWINFO_CIPHER_CCMP; 616 624 617 if( c iphers & (1 << IEEE80211_CIPHER_AES_OCB) )625 if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_AES_OCB) ) 618 626 c->pair_ciphers |= IWINFO_CIPHER_AESOCB; 619 627 620 if( c iphers & (1 << IEEE80211_CIPHER_CKIP) )628 if( c->wpa_version && ciphers & (1 << IEEE80211_CIPHER_CKIP) ) 621 629 c->pair_ciphers |= IWINFO_CIPHER_CKIP; 622 630 … … 633 641 634 642 default: 643 c->pair_ciphers = IWINFO_CIPHER_WEP40 | 644 IWINFO_CIPHER_WEP104; 635 645 break; 636 646 } … … 645 655 if( madwifi_wrq(&wrq, ifname, IEEE80211_IOCTL_GETPARAM, NULL, 0) >= 0 ) 646 656 { 647 ciphers = wrq.u.mode;648 649 switch( wrq.u.mode) {657 ciphers = c->wpa_version ? wrq.u.mode : IEEE80211_CIPHER_WEP; 658 659 switch(ciphers) { 650 660 case IEEE80211_CIPHER_TKIP: 651 661 c->group_ciphers |= IWINFO_CIPHER_TKIP; -
luci/trunk/contrib/package/iwinfo/src/iwinfo_nl80211.c
r6590 r6606 334 334 } 335 335 336 static char * nl80211_wpasupp_info(const char *ifname, const char *cmd) 337 { 338 int sock = -1, len; 336 static inline int nl80211_wpactl_recv(int sock, char *buf, int blen) 337 { 338 fd_set rfds; 339 struct timeval tv = { 2, 0 }; 340 341 FD_ZERO(&rfds); 342 FD_SET(sock, &rfds); 343 344 memset(buf, 0, blen); 345 346 347 if( select(sock + 1, &rfds, NULL, NULL, &tv) < 0 ) 348 return -1; 349 350 if( !FD_ISSET(sock, &rfds) ) 351 return -1; 352 353 return recv(sock, buf, blen, 0); 354 } 355 356 static char * nl80211_wpactl_info(const char *ifname, const char *cmd, 357 const char *event) 358 { 359 int sock = -1; 339 360 char *rv = NULL; 340 361 size_t remote_length, local_length; 341 static char buffer[1024] = { 0 }; 342 343 struct timeval tv = { 2, 0 }; 362 static char buffer[10240] = { 0 }; 363 344 364 struct sockaddr_un local = { 0 }; 345 365 struct sockaddr_un remote = { 0 }; 346 366 347 fd_set rfds;348 367 349 368 sock = socket(PF_UNIX, SOCK_DGRAM, 0); … … 368 387 goto out; 369 388 389 390 send(sock, "ATTACH", 6, 0); 391 392 if( nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0 ) 393 goto out; 394 395 370 396 send(sock, cmd, strlen(cmd), 0); 371 397 372 398 while( 1 ) 373 399 { 374 FD_ZERO(&rfds); 375 FD_SET(sock, &rfds); 376 377 if( select(sock + 1, &rfds, NULL, NULL, &tv) < 0 ) 378 goto out; 379 380 if( !FD_ISSET(sock, &rfds) ) 400 if( nl80211_wpactl_recv(sock, buffer, sizeof(buffer)) <= 0 ) 401 { 402 if( event ) 403 continue; 404 381 405 break; 382 383 if( (len = recv(sock, buffer, sizeof(buffer), 0)) <= 0 ) 384 goto out; 385 386 buffer[len] = 0; 387 388 if( buffer[0] != '<' ) 406 } 407 408 if( (!event && buffer[0] != '<') || strstr(buffer, event) ) 389 409 break; 390 410 } … … 934 954 935 955 /* WPA supplicant */ 936 else if( (res = nl80211_wpa supp_info(ifname, "STATUS")) &&956 else if( (res = nl80211_wpactl_info(ifname, "STATUS", NULL)) && 937 957 (val = nl80211_getval(NULL, res, "pairwise_cipher")) ) 938 958 { … … 1250 1270 1251 1271 /* WPA supplicant */ 1252 if( (res = nl80211_wpasupp_info(ifname, "SCAN")) && !strcmp(res, "OK\n") ) 1253 { 1254 sleep(2); 1255 1256 if( (res = nl80211_wpasupp_info(ifname, "SCAN_RESULTS")) ) 1272 if( (res = nl80211_wpactl_info(ifname, "SCAN", "CTRL-EVENT-SCAN-RESULTS")) ) 1273 { 1274 if( (res = nl80211_wpactl_info(ifname, "SCAN_RESULTS", NULL)) ) 1257 1275 { 1258 1276 nl80211_get_quality_max(ifname, &qmax); … … 1263 1281 count = 0; 1264 1282 1265 while( sscanf(res, "%17s %d %d %255s %127[^\n]\n",1283 while( sscanf(res, "%17s %d %d %255s%*[ \t]%127[^\n]\n", 1266 1284 bssid, &freq, &rssi, cipher, ssid) > 0 ) 1267 1285 { … … 1316 1334 count++; 1317 1335 e++; 1336 1337 memset(ssid, 0, sizeof(ssid)); 1338 memset(bssid, 0, sizeof(bssid)); 1339 memset(cipher, 0, sizeof(cipher)); 1318 1340 } 1319 1341
