Changeset 5308

Show
Ignore:
Timestamp:
08/24/09 17:11:15 (4 years ago)
Author:
jow
Message:

libs/iwinfo: fixes for brcm-2.4

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

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/iwinfo/src/iwinfo_lualib.c

    r5307 r5308  
    162162 
    163163            /* Crypto */ 
    164             lua_pushinteger(L, e->crypto.wpa_version); 
    165             lua_setfield(L, -2, "wpa"); 
    166  
    167164            lua_pushboolean(L, (!e->crypto.wpa_version && e->crypto.enabled)); 
    168165            lua_setfield(L, -2, "wep"); 
    169166 
    170             lua_newtable(L); 
    171             for( j = 0, y = 1; j < IW_IE_CYPHER_NUM; j++ ) 
     167            if( e->crypto.wpa_version ) 
    172168            { 
    173                 if( e->crypto.group_ciphers & (1<<j) ) 
     169                lua_pushinteger(L, e->crypto.wpa_version); 
     170                lua_setfield(L, -2, "wpa"); 
     171 
     172                lua_newtable(L); 
     173                for( j = 0, y = 1; j < IW_IE_CYPHER_NUM; j++ ) 
    174174                { 
    175                     lua_pushstring(L, iw_ie_cypher_name[j]); 
    176                     lua_rawseti(L, -2, y++); 
     175                    if( e->crypto.group_ciphers & (1<<j) ) 
     176                    { 
     177                        lua_pushstring(L, iw_ie_cypher_name[j]); 
     178                        lua_rawseti(L, -2, y++); 
     179                    } 
    177180                } 
     181                lua_setfield(L, -2, "group_ciphers"); 
     182 
     183                lua_newtable(L); 
     184                for( j = 0, y = 1; j < IW_IE_CYPHER_NUM; j++ ) 
     185                { 
     186                    if( e->crypto.pair_ciphers & (1<<j) ) 
     187                    { 
     188                        lua_pushstring(L, iw_ie_cypher_name[j]); 
     189                        lua_rawseti(L, -2, y++); 
     190                    } 
     191                } 
     192                lua_setfield(L, -2, "pair_ciphers"); 
     193 
     194                lua_newtable(L); 
     195                for( j = 0, y = 1; j < IW_IE_KEY_MGMT_NUM; j++ ) 
     196                { 
     197                    if( e->crypto.auth_suites & (1<<j) ) 
     198                    { 
     199                        lua_pushstring(L, iw_ie_key_mgmt_name[j]); 
     200                        lua_rawseti(L, -2, y++); 
     201                    } 
     202                } 
     203                lua_setfield(L, -2, "auth_suites"); 
    178204            } 
    179             lua_setfield(L, -2, "group_ciphers"); 
    180  
    181             lua_newtable(L); 
    182             for( j = 0, y = 1; j < IW_IE_CYPHER_NUM; j++ ) 
    183             { 
    184                 if( e->crypto.pair_ciphers & (1<<j) ) 
    185                 { 
    186                     lua_pushstring(L, iw_ie_cypher_name[j]); 
    187                     lua_rawseti(L, -2, y++); 
    188                 } 
    189             } 
    190             lua_setfield(L, -2, "pair_ciphers"); 
    191  
    192             lua_newtable(L); 
    193             for( j = 0, y = 1; j < IW_IE_KEY_MGMT_NUM; j++ ) 
    194             { 
    195                 if( e->crypto.auth_suites & (1<<j) ) 
    196                 { 
    197                     lua_pushstring(L, iw_ie_key_mgmt_name[j]); 
    198                     lua_rawseti(L, -2, y++); 
    199                 } 
    200             } 
    201             lua_setfield(L, -2, "auth_suites"); 
    202205 
    203206            lua_rawseti(L, -2, x); 
  • luci/trunk/libs/iwinfo/src/iwinfo_wext_scan.c

    r5307 r5308  
    4444} 
    4545 
    46 static int wext_extract_event(struct stream_descr *stream, struct iw_event *iwe) 
     46static int wext_extract_event(struct stream_descr *stream, struct iw_event *iwe, int wev) 
    4747{ 
    4848    const struct iw_ioctl_description *descr = NULL; 
     
    8484    event_len = event_type_size[event_type]; 
    8585 
     86    /* Fixup for earlier version of WE */ 
     87    if((wev <= 18) && (event_type == IW_HEADER_TYPE_POINT)) 
     88        event_len += IW_EV_POINT_OFF; 
     89 
    8690    /* Check if we know about this event */ 
    8791    if(event_len <= IW_EV_LCP_PK_LEN) 
     
    110114    /* Fixup for WE-19 and later : pointer no longer in the stream */ 
    111115    /* Beware of alignement. Dest has local alignement, not packed */ 
    112     if( event_type == IW_HEADER_TYPE_POINT ) 
     116    if( (wev > 18) && (event_type == IW_HEADER_TYPE_POINT) ) 
    113117        memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len); 
    114118    else 
     
    231235    struct iwinfo_crypto_entry *ce = &e->crypto; 
    232236 
    233     if( !ce->enabled ) 
    234         return; 
    235  
    236     //memset(&e->crypto, 0, sizeof(struct iwinfo_crypto_entry)); 
    237  
    238237    if(ielen > buflen) 
    239238        ielen = buflen; 
     
    392391                    break; 
    393392 
     393                case 2: 
    394394                case 3: 
    395395                    sprintf((char *) e->mode, "Master"); 
     
    609609                { 
    610610                    /* Extract an event and print it */ 
    611                     ret = wext_extract_event(&stream, &iwe); 
     611                    ret = wext_extract_event(&stream, &iwe, range.we_version_compiled); 
    612612 
    613613                    if(ret >= 0) 
     
    621621                            else if( (entrylen + sizeof(struct iwinfo_scanlist_entry)) <= IWINFO_BUFSIZE ) 
    622622                            { 
     623                                /* if encryption is off, clear the crypto strunct */ 
     624                                if( !e.crypto.enabled ) 
     625                                    memset(&e.crypto, 0, sizeof(struct iwinfo_crypto_entry)); 
     626 
    623627                                memcpy(&buf[entrylen], &e, sizeof(struct iwinfo_scanlist_entry)); 
    624628                                entrylen += sizeof(struct iwinfo_scanlist_entry);