Changeset 2847

Show
Ignore:
Timestamp:
11/13/07 18:45:58 (1 year ago)
Author:
mentor
Message:

Modify ieee80211_saveie and ieee80211_saveath(ewww) to take a NULL source parameter, and to cleanup in this case.
On reception of an Associatiion request, always save IEs correctly (i.e., cleanup up any no longer valid IEs in the case that no new, valid IE is received).

Ticket: http://madwifi.org/ticket/1188
Original Patch: Signed-Off-By: Bas

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • madwifi/trunk/net80211/ieee80211_input.c

    r2839 r2847  
    20602060} 
    20612061 
     2062/* Record information element for later use. */ 
    20622063void 
    20632064ieee80211_saveie(u_int8_t **iep, const u_int8_t *ie) 
    20642065{ 
    20652066        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])) { 
    20702068                if (*iep != NULL) 
    20712069                        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)) 
    20752075                memcpy(*iep, ie, ielen); 
    20762076} 
     
    22492249                (const struct ieee80211_ie_athAdvCap *) ie; 
    22502250 
    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); 
    22542251        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        } 
    22552260} 
    22562261 
     
    31893194                                break; 
    31903195                        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. */ 
    31953198                                if (iswpaoui(frm) && !wpa) { 
    31963199                                        if (vap->iv_flags & IEEE80211_F_WPA1) 
     
    32113214                if (frm > efrm) 
    32123215                        return; 
     3216 
    32133217                IEEE80211_VERIFY_ELEMENT(rates, IEEE80211_RATE_MAXSIZE); 
    32143218                IEEE80211_VERIFY_ELEMENT(ssid, IEEE80211_NWID_LEN); 
     
    32433247 
    32443248                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. */ 
    32523252                        rsn_parm = ni->ni_rsn; 
    32533253                        if (rsn[0] != IEEE80211_ELEMID_RSN) 
     
    32773277                        ni->ni_challenge = NULL; 
    32783278                } 
    3279                 /* 802.11 spec says to ignore station's privacy bit */ 
     3279                /* 802.11 spec. says to ignore station's privacy bit */ 
    32803280                if ((capinfo & IEEE80211_CAPINFO_ESS) == 0) { 
    32813281                        IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_ANY, wh->i_addr2, 
     
    33333333                ni->ni_fhdwell = vap->iv_bss->ni_fhdwell; 
    33343334                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)) 
    33723345                                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); 
    33913348 
    33923349                /* Send TGf L2UF frame on behalf of newly associated station */