Changeset 5305
- Timestamp:
- 08/24/09 14:31:20 (4 years ago)
- Location:
- luci/trunk/libs/iwinfo/src
- Files:
-
- 3 modified
-
iwinfo.h (modified) (1 diff)
-
iwinfo_lualib.c (modified) (4 diffs)
-
iwinfo_wext_scan.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/libs/iwinfo/src/iwinfo.h
r5304 r5305 38 38 uint8_t enabled; 39 39 uint8_t wpa_version; 40 uint8_t group_ciphers [8];41 uint8_t pair_ciphers [8];42 uint8_t auth_suites [8];40 uint8_t group_ciphers; 41 uint8_t pair_ciphers; 42 uint8_t auth_suites; 43 43 }; 44 44 -
luci/trunk/libs/iwinfo/src/iwinfo_lualib.c
r5304 r5305 134 134 135 135 lua_pushstring(L, macstr); 136 lua_setfield(L, -2, " mac");136 lua_setfield(L, -2, "bssid"); 137 137 138 138 /* ESSID */ … … 153 153 /* Crypto */ 154 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++ ) 155 lua_setfield(L, -2, "wpa"); 156 157 lua_pushboolean(L, (!e->crypto.wpa_version && e->crypto.enabled)); 158 lua_setfield(L, -2, "wep"); 159 160 lua_newtable(L); 161 for( j = 0, y = 1; j < 8; j++ ) 159 162 { 160 if( e->crypto.group_ciphers [j])163 if( e->crypto.group_ciphers & (1<<j) ) 161 164 { 162 165 lua_pushstring(L, (j < IW_IE_CYPHER_NUM) … … 169 172 170 173 lua_newtable(L); 171 for( j = 0, y = 1; j < sizeof(e->crypto.pair_ciphers); j++ )174 for( j = 0, y = 1; j < 8; j++ ) 172 175 { 173 if( e->crypto.pair_ciphers [j])176 if( e->crypto.pair_ciphers & (1<<j) ) 174 177 { 175 178 lua_pushstring(L, (j < IW_IE_CYPHER_NUM) … … 182 185 183 186 lua_newtable(L); 184 for( j = 0, y = 1; j < sizeof(e->crypto.auth_suites); j++ )187 for( j = 0, y = 1; j < 8; j++ ) 185 188 { 186 if( e->crypto.auth_suites [j])189 if( e->crypto.auth_suites & (1<<j) ) 187 190 { 188 191 lua_pushstring(L, (j < IW_IE_KEY_MGMT_NUM) -
luci/trunk/libs/iwinfo/src/iwinfo_wext_scan.c
r5304 r5305 285 285 if(ielen < (offset + 4)) 286 286 { 287 ce->group_ciphers[2] = 1; /* TKIP */ 287 ce->group_ciphers |= (1<<2); /* TKIP */ 288 ce->pair_ciphers |= (1<<2); /* TKIP */ 289 ce->auth_suites |= (1<<2); /* PSK */ 288 290 return; 289 291 } 290 292 291 293 if(memcmp(&iebuf[offset], wpa_oui, 3) != 0) 292 ce->group_ciphers [7] = 1; /* Proprietary */294 ce->group_ciphers |= (1<<7); /* Proprietary */ 293 295 else 294 ce->group_ciphers [iebuf[offset+3]] = 1;296 ce->group_ciphers |= (1<<iebuf[offset+3]); 295 297 296 298 offset += 4; … … 298 300 if(ielen < (offset + 2)) 299 301 { 300 ce->pair_ciphers[2] = 1; /* TKIP */ 302 ce->pair_ciphers |= (1<<2); /* TKIP */ 303 ce->auth_suites |= (1<<2); /* PSK */ 301 304 return; 302 305 } … … 313 316 { 314 317 if(memcmp(&iebuf[offset], wpa_oui, 3) != 0) 315 ce->pair_ciphers [7] = 1; /* Proprietary */318 ce->pair_ciphers |= (1<<7); /* Proprietary */ 316 319 else if(iebuf[offset+3] <= IW_IE_CYPHER_NUM) 317 ce->pair_ciphers [iebuf[offset+3]] = 1;320 ce->pair_ciphers |= (1<<iebuf[offset+3]); 318 321 //else 319 322 // ce->pair_ciphers[ce->pair_cipher_num++] = 255; /* Unknown */ … … 337 340 { 338 341 if(memcmp(&iebuf[offset], wpa_oui, 3) != 0) 339 ce->auth_suites [7] = 1; /* Proprietary */342 ce->auth_suites |= (1<<7); /* Proprietary */ 340 343 else if(iebuf[offset+3] <= IW_IE_KEY_MGMT_NUM) 341 ce->auth_suites [iebuf[offset+3]] = 1;344 ce->auth_suites |= (1<<iebuf[offset+3]); 342 345 //else 343 346 // ce->auth_suites[ce->auth_suite_num++] = 255; /* Unknown */ … … 468 471 int timeout = 15000000; /* 15s */ 469 472 470 int _len = 0;473 int entrylen = 0; 471 474 struct iwinfo_scanlist_entry e; 472 475 … … 611 614 first = 0; 612 615 } 613 else if( ( _len + sizeof(struct iwinfo_scanlist_entry)) <= IWINFO_BUFSIZE )616 else if( (entrylen + sizeof(struct iwinfo_scanlist_entry)) <= IWINFO_BUFSIZE ) 614 617 { 615 memcpy(&buf[ _len], &e, sizeof(struct iwinfo_scanlist_entry));616 _len += sizeof(struct iwinfo_scanlist_entry);618 memcpy(&buf[entrylen], &e, sizeof(struct iwinfo_scanlist_entry)); 619 entrylen += sizeof(struct iwinfo_scanlist_entry); 617 620 } 618 621 else … … 631 634 632 635 free(buffer); 633 *len = _len;636 *len = entrylen; 634 637 return 0; 635 638 }
