/* ========================================================================== Description: peer sends reassoc rsp Parametrs: Elem - MLME message cntaining the received frame ========================================================================== */ VOID PeerReassocRspAction( IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM *Elem) { USHORT CapabilityInfo; USHORT Status; USHORT Aid; UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen; UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen; UCHAR Addr2[MAC_ADDR_LEN]; EDCA_PARM EdcaParm; BOOLEAN TimerCancelled; #ifdef RALINK_WPA_SUPPLICANT_SUPPORT union iwreq_data wrqu; #endif if(PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &EdcaParm)) { if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) // The frame is for me ? { DBGPRINT(RT_DEBUG_TRACE, "ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status); RTMPCancelTimer(&pAd->MlmeAux.ReassocTimer,&TimerCancelled); if(Status == MLME_SUCCESS) { // go to procedure listed on page 376 AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen, &EdcaParm); #ifdef RALINK_WPA_SUPPLICANT_SUPPORT if (pAd->PortCfg.WPA_Supplicant == TRUE) { //collect associate info link_status_handler(pAd); //send associnfo event to wpa_supplicant memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.flags = RT_ASSOC_EVENT_FLAG; wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); } DBGPRINT(RT_DEBUG_OFF, "ASSOC - receive REASSOC_RSP to me (status=%d)\n", Status); #endif #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT if (pAd->PortCfg.bNativeWpa == TRUE) // add by johnli wext_notify_event_assoc(pAd, SIOCGIWAP, TRUE); #endif // NATIVE_WPA_SUPPLICANT_SUPPORT } pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_REASSOC_CONF, 2, &Status); } } else { DBGPRINT(RT_DEBUG_TRACE, "ASSOC - PeerReassocRspAction() sanity check fail\n"); } }
/* ========================================================================== Description: left part of IEEE 802.11/1999 p.374 Parameters: Elem - MLME message containing the received frame ========================================================================== */ VOID PeerDisassocAction( IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM *Elem) { UCHAR Addr2[MAC_ADDR_LEN]; USHORT Reason; #ifdef RALINK_WPA_SUPPLICANT_SUPPORT union iwreq_data wrqu; #endif if(PeerDisassocSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &Reason)) { if (INFRA_ON(pAd) && MAC_ADDR_EQUAL(pAd->PortCfg.Bssid, Addr2)) { LinkDown(pAd, TRUE); pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; #ifdef RALINK_WPA_SUPPLICANT_SUPPORT if (pAd->PortCfg.WPA_Supplicant == TRUE) { // send disassoc event to wpa_supplicant memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.flags = RT_DISASSOC_EVENT_FLAG; wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); } #endif #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT if (pAd->PortCfg.bNativeWpa == TRUE) // add by johnli wext_notify_event_assoc(pAd, SIOCGIWAP, FALSE); #endif // NATIVE_WPA_SUPPLICANT_SUPPORT #if 0 // 2004-09-11 john: can't remember why AP will DISASSOCIATE us. // But since it says for 2430 only, we temporaily remove the patch. // 2002/11/21 - // patch RT2430/RT2420 hangup issue. We suspect this AP DIS-ASSOCIATE frame // is caused by PHY hangup, so we reset PHY, then auto recover the connection. // if this attempt fails, then remains in LinkDown and leaves the problem // to MlmePeriodicExec() // NICPatchRT2430Bug(pAd); pAd->RalinkCounters.BeenDisassociatedCount ++; // Remove auto recover effort when disassociate by AP, re-enable for patch 2430 only DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Disassociated by AP, Auto Recovery attempt #%d\n", pAd->RalinkCounters.BeenDisassociatedCount); MlmeAutoReconnectLastSSID(pAd); #endif } } else { DBGPRINT(RT_DEBUG_TRACE, "ASSOC - PeerDisassocAction() sanity check fail\n"); } }
/* ========================================================================== Description: peer sends assoc rsp back Parameters: Elme - MLME message containing the received frame ========================================================================== */ VOID PeerAssocRspAction( IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM *Elem) { USHORT CapabilityInfo, Status, Aid; UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], SupRateLen; UCHAR ExtRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRateLen; UCHAR Addr2[MAC_ADDR_LEN]; EDCA_PARM EdcaParm; BOOLEAN TimerCancelled; #ifdef RALINK_WPA_SUPPLICANT_SUPPORT union iwreq_data wrqu; #endif if (PeerAssocRspSanity(pAd, Elem->Msg, Elem->MsgLen, Addr2, &CapabilityInfo, &Status, &Aid, SupRate, &SupRateLen, ExtRate, &ExtRateLen, &EdcaParm)) { // The frame is for me ? if(MAC_ADDR_EQUAL(Addr2, pAd->MlmeAux.Bssid)) { DBGPRINT(RT_DEBUG_TRACE, "ASSOC - receive ASSOC_RSP to me (status=%d)\n", Status); RTMPCancelTimer(&pAd->MlmeAux.AssocTimer,&TimerCancelled); if(Status == MLME_SUCCESS) { // // There may some packets will be drop, if we haven't set the BSS type! // For example: EAPOL packet and the case of WHQL lost Packets. // Since this may some delays to set those variables at LinkUp(..) on this (Mlme) thread. // // This is a trick, set the BSS type here. // if (pAd->PortCfg.BssType == BSS_INFRA) { OPSTATUS_SET_FLAG(pAd, fOP_STATUS_MEDIA_STATE_CONNECTED); } // go to procedure listed on page 376 AssocPostProc(pAd, Addr2, CapabilityInfo, Aid, SupRate, SupRateLen, ExtRate, ExtRateLen, &EdcaParm); #ifdef RALINK_WPA_SUPPLICANT_SUPPORT if (pAd->PortCfg.WPA_Supplicant == TRUE) { // collect associate info link_status_handler(pAd); //send associnfo event to wpa_supplicant memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.flags = RT_ASSOC_EVENT_FLAG; wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); } #endif #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT // collect associate info and notify the wpa_supplicant. if (pAd->PortCfg.bNativeWpa == TRUE) // add by johnli wext_notify_event_assoc(pAd, SIOCGIWAP, TRUE); #endif // NATIVE_WPA_SUPPLICANT_SUPPORT } pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_ASSOC_CONF, 2, &Status); } } else { DBGPRINT(RT_DEBUG_TRACE, "ASSOC - PeerAssocRspAction() sanity check fail\n"); } }
/* ========================================================================== Description: Upper layer issues disassoc request Parameters: Elem - ========================================================================== */ VOID MlmeDisassocReqAction( IN PRTMP_ADAPTER pAd, IN MLME_QUEUE_ELEM *Elem) { PMLME_DISASSOC_REQ_STRUCT pDisassocReq; HEADER_802_11 DisassocHdr; PCHAR pOutBuffer = NULL; ULONG FrameLen = 0; ULONG Timeout = 0; USHORT Status; USHORT NStatus; BOOLEAN TimerCancelled; #ifdef RALINK_WPA_SUPPLICANT_SUPPORT union iwreq_data wrqu; #endif // skip sanity check pDisassocReq = (PMLME_DISASSOC_REQ_STRUCT)(Elem->Msg); // allocate and send out DeassocReq frame NStatus = MlmeAllocateMemory(pAd, (PVOID *)&pOutBuffer); //Get an unused nonpaged memory if (NStatus != NDIS_STATUS_SUCCESS) { DBGPRINT(RT_DEBUG_TRACE, "ASSOC - MlmeDisassocReqAction() allocate memory failed\n"); pAd->Mlme.AssocMachine.CurrState = ASSOC_IDLE; Status = MLME_FAIL_NO_RESOURCE; MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_DISASSOC_CONF, 2, &Status); return; } RTMPCancelTimer(&pAd->MlmeAux.DisassocTimer,&TimerCancelled); DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Send DISASSOC request\n"); MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pDisassocReq->Addr, pDisassocReq->Addr); MakeOutgoingFrame(pOutBuffer, &FrameLen, sizeof(HEADER_802_11),&DisassocHdr, 2, &pDisassocReq->Reason, END_OF_ARGS); MiniportMMRequest(pAd, QID_AC_BE, pOutBuffer, FrameLen); // Set the control aux SSID to prevent it reconnect to old SSID // Since calling this indicate user don't want to connect to that SSID anymore. // 2004-11-10 can't reset this info, cause it may be the new SSID that user requests for // pAd->MlmeAux.SsidLen = MAX_LEN_OF_SSID; // NdisZeroMemory(pAd->MlmeAux.Ssid, MAX_LEN_OF_SSID); // NdisZeroMemory(pAd->MlmeAux.Bssid, MAC_ADDR_LEN); #ifdef RALINK_WPA_SUPPLICANT_SUPPORT if (pAd->PortCfg.WPA_Supplicant == TRUE) { //send disassociate event to wpa_supplicant memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.flags = RT_DISASSOC_EVENT_FLAG; wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, NULL); } #endif #ifdef NATIVE_WPA_SUPPLICANT_SUPPORT if (pAd->PortCfg.bNativeWpa == TRUE) // add by johnli wext_notify_event_assoc(pAd, SIOCGIWAP, FALSE); #endif // NATIVE_WPA_SUPPLICANT_SUPPORT pAd->PortCfg.DisassocReason = REASON_DISASSOC_STA_LEAVING; COPY_MAC_ADDR(pAd->PortCfg.DisassocSta, pDisassocReq->Addr); RTMPSetTimer(&pAd->MlmeAux.DisassocTimer, Timeout); pAd->Mlme.AssocMachine.CurrState = DISASSOC_WAIT_RSP; }