Changeset 2847
- Timestamp:
- 11/13/07 18:45:58 (1 year ago)
- Files:
-
- madwifi/trunk/net80211/ieee80211_input.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
madwifi/trunk/net80211/ieee80211_input.c
r2839 r2847 2060 2060 } 2061 2061 2062 /* Record information element for later use. */ 2062 2063 void 2063 2064 ieee80211_saveie(u_int8_t **iep, const u_int8_t *ie) 2064 2065 { 2065 2066 u_int ielen = ie[1] + 2; 2066 /* 2067 * Record information element for later use. 2068 */ 2069 if (*iep == NULL || (*iep)[1] != ie[1]) { 2067 if ((*iep == NULL) || (ie == NULL) || ((*iep)[1] != ie[1])) { 2070 2068 if (*iep != NULL) 2071 2069 FREE(*iep, M_DEVBUF); 2072 MALLOC(*iep, void*, ielen, M_DEVBUF, M_NOWAIT); 2073 } 2074 if (*iep != NULL) 2070 *iep = NULL; 2071 if (ie != NULL) 2072 MALLOC(*iep, void*, ielen, M_DEVBUF, M_NOWAIT); 2073 } 2074 if ((*iep != NULL) && (ie != NULL)) 2075 2075 memcpy(*iep, ie, ielen); 2076 2076 } … … 2249 2249 (const struct ieee80211_ie_athAdvCap *) ie; 2250 2250 2251 ni->ni_ath_flags = athIe->athAdvCap_capability;2252 if (ni->ni_ath_flags & IEEE80211_ATHC_COMP)2253 ni->ni_ath_defkeyindex = LE_READ_2(&athIe->athAdvCap_defKeyIndex);2254 2251 ieee80211_saveie(&ni->ni_ath_ie, ie); 2252 if (athIe != NULL) { 2253 ni->ni_ath_flags = athIe->athAdvCap_capability; 2254 if (ni->ni_ath_flags & IEEE80211_ATHC_COMP) 2255 ni->ni_ath_defkeyindex = LE_READ_2(&athIe->athAdvCap_defKeyIndex); 2256 } else { 2257 ni->ni_ath_flags = 0; 2258 ni->ni_ath_defkeyindex = IEEE80211_INVAL_DEFKEY; 2259 } 2255 2260 } 2256 2261 … … 3189 3194 break; 3190 3195 case IEEE80211_ELEMID_VENDOR: 3191 /* don't override RSN element 3192 * XXX: actually the driver should report both WPA versions, 3193 * so wpa_supplicant can choose and also detect downgrade attacks 3194 */ 3196 /* NB: Provide all IEs for wpa_supplicant, so 3197 * it can handle downgrade attacks, etc. */ 3195 3198 if (iswpaoui(frm) && !wpa) { 3196 3199 if (vap->iv_flags & IEEE80211_F_WPA1) … … 3211 3214 if (frm > efrm) 3212 3215 return; 3216 3213 3217 IEEE80211_VERIFY_ELEMENT(rates, IEEE80211_RATE_MAXSIZE); 3214 3218 IEEE80211_VERIFY_ELEMENT(ssid, IEEE80211_NWID_LEN); … … 3243 3247 3244 3248 if (rsn != NULL) { 3245 /* 3246 * Parse WPA information element. Note that 3247 * we initialize the param block from the node 3248 * state so that information in the IE overrides 3249 * our defaults. The resulting parameters are 3250 * installed below after the association is assured. 3251 */ 3249 /* Initialise values to node defaults, which are then 3250 * overwritten by values in the IE. These are 3251 * installed once association is complete. */ 3252 3252 rsn_parm = ni->ni_rsn; 3253 3253 if (rsn[0] != IEEE80211_ELEMID_RSN) … … 3277 3277 ni->ni_challenge = NULL; 3278 3278 } 3279 /* 802.11 spec says to ignore station's privacy bit */3279 /* 802.11 spec. says to ignore station's privacy bit */ 3280 3280 if ((capinfo & IEEE80211_CAPINFO_ESS) == 0) { 3281 3281 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_ANY, wh->i_addr2, … … 3333 3333 ni->ni_fhdwell = vap->iv_bss->ni_fhdwell; 3334 3334 ni->ni_fhindex = vap->iv_bss->ni_fhindex; 3335 if (wpa != NULL) { 3336 /* 3337 * Record WPA/RSN parameters for station, mark 3338 * node as using WPA and record information element 3339 * for applications that require it. 3340 */ 3341 ieee80211_saveie(&ni->ni_wpa_ie, wpa); 3342 } else if (ni->ni_wpa_ie != NULL) { 3343 /* 3344 * Flush any state from a previous association. 3345 */ 3346 FREE(ni->ni_wpa_ie, M_DEVBUF); 3347 ni->ni_wpa_ie = NULL; 3348 } 3349 if (rsn != NULL) { 3350 /* 3351 * Record WPA/RSN parameters for station, mark 3352 * node as using WPA and record information element 3353 * for applications that require it. 3354 */ 3355 ni->ni_rsn = rsn_parm; 3356 ieee80211_saveie(&ni->ni_rsn_ie, rsn); 3357 } else if (ni->ni_rsn_ie != NULL) { 3358 /* 3359 * Flush any state from a previous association. 3360 */ 3361 FREE(ni->ni_rsn_ie, M_DEVBUF); 3362 ni->ni_rsn_ie = NULL; 3363 } 3364 if (wme != NULL) { 3365 /* 3366 * Record WME parameters for station, mark node 3367 * as capable of QoS and record information 3368 * element for applications that require it. 3369 */ 3370 ieee80211_saveie(&ni->ni_wme_ie, wme); 3371 if (ieee80211_parse_wmeie(wme, wh, ni) > 0) 3335 3336 /* WPA */ 3337 ieee80211_saveie(&ni->ni_wpa_ie, wpa); 3338 /* RSN */ 3339 ni->ni_rsn = rsn_parm; 3340 ieee80211_saveie(&ni->ni_rsn_ie, rsn); 3341 /* WME - including QoS flag */ 3342 ieee80211_saveie(&ni->ni_wme_ie, wme); 3343 ni->ni_flags &= ~IEEE80211_NODE_QOS; 3344 if ((wme != NULL) && (ieee80211_parse_wmeie(wme, wh, ni) > 0)) 3372 3345 ni->ni_flags |= IEEE80211_NODE_QOS; 3373 } else if (ni->ni_wme_ie != NULL) { 3374 /* 3375 * Flush any state from a previous association. 3376 */ 3377 FREE(ni->ni_wme_ie, M_DEVBUF); 3378 ni->ni_wme_ie = NULL; 3379 ni->ni_flags &= ~IEEE80211_NODE_QOS; 3380 } 3381 if (ath != NULL) 3382 ieee80211_saveath(ni, ath); 3383 else if (ni->ni_ath_ie != NULL) { 3384 /* 3385 * Flush any state from a previous association. 3386 */ 3387 FREE(ni->ni_ath_ie, M_DEVBUF); 3388 ni->ni_ath_ie = NULL; 3389 ni->ni_ath_flags = 0; 3390 } 3346 3347 ieee80211_saveath(ni, ath); 3391 3348 3392 3349 /* Send TGf L2UF frame on behalf of newly associated station */
