From: Jo-Philipp Wich Date: Mon, 24 Aug 2009 16:11:15 +0000 (+0000) Subject: libs/iwinfo: fixes for brcm-2.4 X-Git-Tag: 0.10.0~1156 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=3b42dc16889bc10889e9f8cd56e0ab93b105086b;ds=sidebyside libs/iwinfo: fixes for brcm-2.4 --- diff --git a/libs/iwinfo/src/iwinfo_lualib.c b/libs/iwinfo/src/iwinfo_lualib.c index a798d7729..2efc7871a 100644 --- a/libs/iwinfo/src/iwinfo_lualib.c +++ b/libs/iwinfo/src/iwinfo_lualib.c @@ -161,44 +161,47 @@ static int iwinfo_L_scanlist(lua_State *L, int (*func)(const char *, char *, int lua_setfield(L, -2, "signal"); /* Crypto */ - lua_pushinteger(L, e->crypto.wpa_version); - lua_setfield(L, -2, "wpa"); - lua_pushboolean(L, (!e->crypto.wpa_version && e->crypto.enabled)); lua_setfield(L, -2, "wep"); - lua_newtable(L); - for( j = 0, y = 1; j < IW_IE_CYPHER_NUM; j++ ) + if( e->crypto.wpa_version ) { - if( e->crypto.group_ciphers & (1<crypto.wpa_version); + lua_setfield(L, -2, "wpa"); + + lua_newtable(L); + for( j = 0, y = 1; j < IW_IE_CYPHER_NUM; j++ ) { - lua_pushstring(L, iw_ie_cypher_name[j]); - lua_rawseti(L, -2, y++); + if( e->crypto.group_ciphers & (1<crypto.pair_ciphers & (1<crypto.pair_ciphers & (1<crypto.auth_suites & (1<crypto.auth_suites & (1< event_type=0 => IW_EV_LCP_PK_LEN */ event_len = event_type_size[event_type]; + /* Fixup for earlier version of WE */ + if((wev <= 18) && (event_type == IW_HEADER_TYPE_POINT)) + event_len += IW_EV_POINT_OFF; + /* Check if we know about this event */ if(event_len <= IW_EV_LCP_PK_LEN) { @@ -109,7 +113,7 @@ static int wext_extract_event(struct stream_descr *stream, struct iw_event *iwe) /* Fixup for WE-19 and later : pointer no longer in the stream */ /* Beware of alignement. Dest has local alignement, not packed */ - if( event_type == IW_HEADER_TYPE_POINT ) + if( (wev > 18) && (event_type == IW_HEADER_TYPE_POINT) ) memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF, pointer, event_len); else memcpy((char *) iwe + IW_EV_LCP_LEN, pointer, event_len); @@ -230,11 +234,6 @@ static inline void wext_fill_wpa(unsigned char *iebuf, int buflen, struct iwinfo struct iwinfo_crypto_entry *ce = &e->crypto; - if( !ce->enabled ) - return; - - //memset(&e->crypto, 0, sizeof(struct iwinfo_crypto_entry)); - if(ielen > buflen) ielen = buflen; @@ -391,6 +390,7 @@ static inline int wext_fill_entry(struct stream_descr *stream, struct iw_event * sprintf((char *) e->mode, "Ad-Hoc"); break; + case 2: case 3: sprintf((char *) e->mode, "Master"); break; @@ -608,7 +608,7 @@ int wext_get_scanlist(const char *ifname, char *buf, int *len) do { /* Extract an event and print it */ - ret = wext_extract_event(&stream, &iwe); + ret = wext_extract_event(&stream, &iwe, range.we_version_compiled); if(ret >= 0) { @@ -620,6 +620,10 @@ int wext_get_scanlist(const char *ifname, char *buf, int *len) } else if( (entrylen + sizeof(struct iwinfo_scanlist_entry)) <= IWINFO_BUFSIZE ) { + /* if encryption is off, clear the crypto strunct */ + if( !e.crypto.enabled ) + memset(&e.crypto, 0, sizeof(struct iwinfo_crypto_entry)); + memcpy(&buf[entrylen], &e, sizeof(struct iwinfo_scanlist_entry)); entrylen += sizeof(struct iwinfo_scanlist_entry); }