assoc.c
来自「Ralink RT61 SoftAP Driver source code. 」· C语言 代码 · 共 796 行 · 第 1/3 页
C
796 行
#endif
}
DBGPRINT(RT_DEBUG_TRACE, "ASSOC - receive DIS-ASSOC request from %02x:%02x:%02x:%02x:%02x:%02x\n",
Addr2[0],Addr2[1],Addr2[2],Addr2[3],Addr2[4],Addr2[5]);
}
/*
==========================================================================
Description:
Upper layer orders to disassoc s STA
Parameters:
Elem -
==========================================================================
*/
VOID MlmeDisassocReqAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
{
MLME_DISASSOC_REQ_STRUCT *DisassocReq;
HEADER_802_11 DisassocHdr;
CHAR *OutBuffer = NULL;
ULONG FrameLen = 0;
MAC_TABLE_ENTRY *pEntry;
DisassocReq = (MLME_DISASSOC_REQ_STRUCT *)(Elem->Msg);
pEntry = MacTableLookup(pAd, DisassocReq->Addr);
if (pEntry)
{
#ifdef RTL865X_FAST_PATH
rtl865x_extDev_removeHost(pEntry->Addr, CONFIG_8139CP_VID);
#endif
ApLogEvent(pAd, DisassocReq->Addr, EVENT_DISASSOCIATED, pEntry->ApIdx);
MacTableDeleteEntry(pAd, DisassocReq->Addr);
//send out a DISASSOC request frame
OutBuffer = kmalloc(MAX_LEN_OF_MLME_BUFFER, MEM_ALLOC_FLAG);
if(OutBuffer == NULL)
return;
DBGPRINT(RT_DEBUG_TRACE, "ASSOC - MLME disassociates %02x:%02x:%02x:%02x:%02x:%02x; Send DISASSOC request\n",
DisassocReq->Addr[0],DisassocReq->Addr[1],DisassocReq->Addr[2],
DisassocReq->Addr[3],DisassocReq->Addr[4],DisassocReq->Addr[5]);
MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, DisassocReq->Addr, pAd->PortCfg.MBSSID[pEntry->ApIdx].Bssid);
MakeOutgoingFrame(OutBuffer, &FrameLen,
sizeof(HEADER_802_11), &DisassocHdr,
2, &DisassocReq->Reason,
END_OF_ARGS);
MiniportMMRequest(pAd, OutBuffer, FrameLen);
kfree(OutBuffer);
}
}
/*
==========================================================================
Description:
right part of IEEE 802.11/1999 page 374
Note:
This event should never cause ASSOC state machine perform state
transition, and has no relationship with CNTL machine. So we separate
this routine as a service outside of ASSOC state transition table.
==========================================================================
*/
VOID Cls3errAction(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr1,
IN PUCHAR pAddr2)
{
HEADER_802_11 DisassocHdr;
CHAR *OutBuffer = NULL;
ULONG FrameLen = 0;
USHORT Reason = REASON_CLS3ERR;
MAC_TABLE_ENTRY *pEntry;
pEntry = MacTableLookup(pAd, pAddr2);
if (pEntry)
{
//ApLogEvent(pAd, &pAddr, EVENT_DISASSOCIATED, pEntry->ApIdx);
MacTableDeleteEntry(pAd, pAddr2);
}
// send out a DISASSOC request frame
OutBuffer = kmalloc(MAX_LEN_OF_MLME_BUFFER, MEM_ALLOC_FLAG);
if(OutBuffer == NULL)
return;
DBGPRINT(RT_DEBUG_TRACE, "ASSOC - Class 3 Error, Send DISASSOC frame to %02x:%02x:%02x:%02x:%02x:%02x\n",
pAddr2[0],pAddr2[1],pAddr2[2],pAddr2[3],pAddr2[4],pAddr2[5]);
MgtMacHeaderInit(pAd, &DisassocHdr, SUBTYPE_DISASSOC, 0, pAddr2, pAddr1);
MakeOutgoingFrame(OutBuffer, &FrameLen,
sizeof(HEADER_802_11), &DisassocHdr,
2, &Reason,
END_OF_ARGS);
MiniportMMRequest(pAd, OutBuffer, FrameLen);
kfree(OutBuffer);
}
/*
==========================================================================
Description:
search for entire MAC table to find next available AID to be used
if none is available, return 0
==========================================================================
*/
USHORT AssignAid(
IN PRTMP_ADAPTER pAd,
IN PMAC_TABLE_ENTRY pEntry)
{
USHORT Aid = 0;
if (pEntry)
Aid = ((ULONG)pEntry - (ULONG)&pAd->MacTab.Content[0])/sizeof(MAC_TABLE_ENTRY);
DBGPRINT(RT_DEBUG_TRACE, "AssignAid (AID=%d)\n", Aid);
return Aid;
}
/*
==========================================================================
Description:
assign a new AID to the newly associated/re-associated STA and
decide its MaxSupportedRate and CurrTxRate. Both rates should not
exceed AP's capapbility
Return:
MLME_SUCCESS - association successfully built
others - association failed due to resource issue
==========================================================================
*/
USHORT BuildAssociation(
IN PRTMP_ADAPTER pAd,
IN PUCHAR pAddr,
IN USHORT CapabilityInfo,
IN UCHAR MaxSupportedRateIn500Kbps,
IN UCHAR *RSN,
IN UCHAR *pRSNLen,
IN BOOLEAN bWmmCapable,
IN ULONG ClientRalinkIe,
OUT USHORT *pAid)
{
USHORT StatusCode = MLME_SUCCESS;
PMAC_TABLE_ENTRY pEntry;
UCHAR MaxSupportedRate = RATE_11;
switch (MaxSupportedRateIn500Kbps)
{
case 108: MaxSupportedRate = RATE_54; break;
case 96: MaxSupportedRate = RATE_48; break;
case 72: MaxSupportedRate = RATE_36; break;
case 48: MaxSupportedRate = RATE_24; break;
case 36: MaxSupportedRate = RATE_18; break;
case 24: MaxSupportedRate = RATE_12; break;
case 18: MaxSupportedRate = RATE_9; break;
case 12: MaxSupportedRate = RATE_6; break;
case 22: MaxSupportedRate = RATE_11; break;
case 11: MaxSupportedRate = RATE_5_5; break;
case 4: MaxSupportedRate = RATE_2; break;
case 2: MaxSupportedRate = RATE_1; break;
default: MaxSupportedRate = RATE_11; break;
}
pEntry = MacTableLookup(pAd, pAddr);
if (pEntry && ((pEntry->Sst == SST_AUTH) || (pEntry->Sst == SST_ASSOC)))
{
// TODO:
// should qualify other parameters, for example - capablity, supported rates, listen interval, ... etc
// to decide the Status Code
*pAid = AssignAid(pAd, pEntry);
pEntry->Aid = *pAid;
NdisMoveMemory(pEntry->RSN_IE, RSN, *pRSNLen);
pEntry->RSNIE_Len = *pRSNLen;
if (*pAid == 0)
StatusCode = MLME_ASSOC_REJ_UNABLE_HANDLE_STA;
else
{
pEntry->Sst = SST_ASSOC;
pEntry->GTKState = REKEY_NEGOTIATING;
// patch for Nintendo DS support rate bug - it only support tx rate 1 and 2
if ((((pAddr[0]==0x00) && (pAddr[1]==0x09) && (pAddr[2]==0xBF)) ||
((pAddr[0]==0x00) && (pAddr[1]==0x16) && (pAddr[2]==0x56)))
&& MaxSupportedRate == RATE_11)
{
DBGPRINT(RT_DEBUG_TRACE, "==>Assoc-Req from Nintendo DS client.\n");
MaxSupportedRate = RATE_2;
}
pEntry->MaxSupportedRate = min(pAd->PortCfg.MBSSID[pEntry->ApIdx].MaxTxRate, MaxSupportedRate);
pEntry->CapabilityInfo = CapabilityInfo;
if ((pEntry->AuthMode == Ndis802_11AuthModeWPAPSK) || (pEntry->AuthMode == Ndis802_11AuthModeWPA2PSK))
{
pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
pEntry->WpaState = AS_INITPSK;
}
else if ((pEntry->AuthMode == Ndis802_11AuthModeWPA) || (pEntry->AuthMode == Ndis802_11AuthModeWPA2)
|| (pAd->PortCfg.MBSSID[pEntry->ApIdx].IEEE8021X == TRUE))
{
pEntry->PrivacyFilter = Ndis802_11PrivFilter8021xWEP;
pEntry->WpaState = AS_AUTHENTICATION;
}
if (bWmmCapable)
{
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
}
else
{
CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_WMM_CAPABLE);
}
if (pAd->PortCfg.bAggregationCapable)
{
if ((ClientRalinkIe & 0x00000001) == 1)
{
CLIENT_STATUS_SET_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
}
else
{
CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
}
}
else
{
CLIENT_STATUS_CLEAR_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE);
}
// if (pAd->PortCfg.MBSSID[pEntry->ApIdx].IEEE8021X)
pEntry->PortSecured = WPA_802_1X_PORT_NOT_SECURED;
// else
// pEntry->PortSecured = WPA_802_1X_PORT_SECURED;
DBGPRINT(RT_DEBUG_TRACE, "BuildAssoc-IF(%d):AuthMode=%d,WepStatus=%d,GroupWepStatus=%d,WpaState=%d,AGGRE=%d,APSD=%d\n",
pEntry->ApIdx, pEntry->AuthMode, pEntry->WepStatus, pAd->PortCfg.MBSSID[pEntry->ApIdx].GroupKeyWepStatus, pEntry->WpaState,
CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_AGGREGATION_CAPABLE), CLIENT_STATUS_TEST_FLAG(pEntry, fCLIENT_STATUS_APSD_CAPABLE));
pEntry->LastTxRate = pEntry->CurrTxRate;// last time tx rate;
pEntry->CurrTxRate = pEntry->MaxSupportedRate;// RATE_24;
ApLogEvent(pAd, pEntry->Addr, EVENT_ASSOCIATED, pEntry->ApIdx);
ApUpdateCapabilityAndErpIe(pAd);
DBGPRINT(RT_DEBUG_TRACE, "Init entry init retry timer\n");
pEntry->RetryTimerRunning = FALSE;
pEntry->RetryTimer.expires = jiffies + WPA_RETRY_EXEC_INTV;
pEntry->RetryTimer.data = (unsigned long) pEntry;
pEntry->RetryTimer.function = &WPARetryExec; // This might change for different call routine
pEntry->ReTryCounter = PEER_MSG1_RETRY_TIMER_CTR;
DBGPRINT(RT_DEBUG_TRACE,"assign AID=%d to %02x:%02x:%02x:%02x:%02x:%02x,MaxSupportedRate=%dMbps,CurrTxRate=%dMbps\n",
*pAid, pAddr[0], pAddr[1], pAddr[2], pAddr[3], pAddr[4], pAddr[5], RateIdToMbps[pEntry->MaxSupportedRate], RateIdToMbps[pEntry->CurrTxRate]);
DBGPRINT(RT_DEBUG_TRACE, "RSNIE_Len=0x%x,pEntry->RSNIE_Len=%d,pEntry->PrivacyFilter=%x\n",*pRSNLen,pEntry->RSNIE_Len,pEntry->PrivacyFilter);
StatusCode = MLME_SUCCESS;
}
}
else // CLASS 3 error should have been handled beforehand; here should be MAC table full
StatusCode = MLME_ASSOC_REJ_UNABLE_HANDLE_STA;
return StatusCode;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?