Changeset 5305

Show
Ignore:
Timestamp:
08/24/09 14:31:20 (4 years ago)
Author:
jow
Message:

libs/iwinfo: fixes for wpa/wep detection in wifi scan

Location:
luci/trunk/libs/iwinfo/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/iwinfo/src/iwinfo.h

    r5304 r5305  
    3838    uint8_t enabled; 
    3939    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; 
    4343}; 
    4444 
  • luci/trunk/libs/iwinfo/src/iwinfo_lualib.c

    r5304 r5305  
    134134 
    135135            lua_pushstring(L, macstr); 
    136             lua_setfield(L, -2, "mac"); 
     136            lua_setfield(L, -2, "bssid"); 
    137137 
    138138            /* ESSID */ 
     
    153153            /* Crypto */ 
    154154            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++ ) 
    159162            { 
    160                 if( e->crypto.group_ciphers[j] ) 
     163                if( e->crypto.group_ciphers & (1<<j) ) 
    161164                { 
    162165                    lua_pushstring(L, (j < IW_IE_CYPHER_NUM) 
     
    169172 
    170173            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++ ) 
    172175            { 
    173                 if( e->crypto.pair_ciphers[j] ) 
     176                if( e->crypto.pair_ciphers & (1<<j) ) 
    174177                { 
    175178                    lua_pushstring(L, (j < IW_IE_CYPHER_NUM) 
     
    182185 
    183186            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++ ) 
    185188            { 
    186                 if( e->crypto.auth_suites[j] ) 
     189                if( e->crypto.auth_suites & (1<<j) ) 
    187190                { 
    188191                    lua_pushstring(L, (j < IW_IE_KEY_MGMT_NUM) 
  • luci/trunk/libs/iwinfo/src/iwinfo_wext_scan.c

    r5304 r5305  
    285285    if(ielen < (offset + 4)) 
    286286    { 
    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 */ 
    288290        return; 
    289291    } 
    290292 
    291293    if(memcmp(&iebuf[offset], wpa_oui, 3) != 0) 
    292         ce->group_ciphers[7] = 1; /* Proprietary */ 
     294        ce->group_ciphers |= (1<<7); /* Proprietary */ 
    293295    else 
    294         ce->group_ciphers[iebuf[offset+3]] = 1; 
     296        ce->group_ciphers |= (1<<iebuf[offset+3]); 
    295297 
    296298    offset += 4; 
     
    298300    if(ielen < (offset + 2)) 
    299301    { 
    300         ce->pair_ciphers[2] = 1; /* TKIP */ 
     302        ce->pair_ciphers |= (1<<2); /* TKIP */ 
     303        ce->auth_suites  |= (1<<2); /* PSK */ 
    301304        return; 
    302305    } 
     
    313316    { 
    314317        if(memcmp(&iebuf[offset], wpa_oui, 3) != 0) 
    315             ce->pair_ciphers[7] = 1; /* Proprietary */ 
     318            ce->pair_ciphers |= (1<<7); /* Proprietary */ 
    316319        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]); 
    318321        //else 
    319322        //  ce->pair_ciphers[ce->pair_cipher_num++] = 255; /* Unknown */ 
     
    337340    { 
    338341        if(memcmp(&iebuf[offset], wpa_oui, 3) != 0) 
    339             ce->auth_suites[7] = 1; /* Proprietary */ 
     342            ce->auth_suites |= (1<<7); /* Proprietary */ 
    340343        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]); 
    342345        //else 
    343346        //  ce->auth_suites[ce->auth_suite_num++] = 255; /* Unknown */ 
     
    468471    int timeout = 15000000;     /* 15s */ 
    469472 
    470     int _len = 0; 
     473    int entrylen = 0; 
    471474    struct iwinfo_scanlist_entry e; 
    472475 
     
    611614                                first = 0; 
    612615                            } 
    613                             else if( (_len + sizeof(struct iwinfo_scanlist_entry)) <= IWINFO_BUFSIZE ) 
     616                            else if( (entrylen + sizeof(struct iwinfo_scanlist_entry)) <= IWINFO_BUFSIZE ) 
    614617                            { 
    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); 
    617620                            } 
    618621                            else 
     
    631634 
    632635                free(buffer); 
    633                 *len = _len; 
     636                *len = entrylen; 
    634637                return 0; 
    635638            }