sync.c
来自「Ralink RT61 SoftAP Driver source code. 」· C语言 代码 · 共 1,606 行 · 第 1/5 页
C
1,606 行
TIMESTAMP_LEN, &FakeTimestamp,
2, &pAd->PortCfg.BeaconPeriod,
2, &pAd->PortCfg.MBSSID[apidx].CapabilityInfo,
1, &SsidIe,
1, &pAd->PortCfg.MBSSID[apidx].SsidLen,
pAd->PortCfg.MBSSID[apidx].SsidLen, pAd->PortCfg.MBSSID[apidx].Ssid,
1, &SuppIe,
1, &SupportedRatesLen,
SupportedRatesLen, pAd->PortCfg.SupportedRates,
1, &DsIe,
1, &DsLen,
1, &pAd->PortCfg.Channel,
1, &ErpIe,
1, &ErpLen,
1, &pAd->Mlme.ErpIeContent,
1, &ExtendedRatesIe,
1, &ExtendedRatesLen,
ExtendedRatesLen, &pAd->PortCfg.SupportedRates[SupportedRatesLen],
1, &RSNIe,
1, &pAd->PortCfg.MBSSID[apidx].RSNIE_Len[0],
pAd->PortCfg.MBSSID[apidx].RSNIE_Len[0], pAd->PortCfg.MBSSID[apidx].RSN_IE[0],
1, &RSNIe2,
1, &pAd->PortCfg.MBSSID[apidx].RSNIE_Len[1],
pAd->PortCfg.MBSSID[apidx].RSNIE_Len[1], pAd->PortCfg.MBSSID[apidx].RSN_IE[1],
END_OF_ARGS);
}
else if ((pAd->PortCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPA1WPA2) ||(pAd->PortCfg.MBSSID[apidx].AuthMode == Ndis802_11AuthModeWPAPSKWPA2PSK))
{
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &ProbeRspHdr,
TIMESTAMP_LEN, &FakeTimestamp,
2, &pAd->PortCfg.BeaconPeriod,
2, &pAd->PortCfg.MBSSID[apidx].CapabilityInfo,
1, &SsidIe,
1, &pAd->PortCfg.MBSSID[apidx].SsidLen,
pAd->PortCfg.MBSSID[apidx].SsidLen, pAd->PortCfg.MBSSID[apidx].Ssid,
1, &SuppIe,
1, &pAd->PortCfg.SupportedRatesLen,
pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates,
1, &DsIe,
1, &DsLen,
1, &pAd->PortCfg.Channel,
1, &RSNIe,
1, &pAd->PortCfg.MBSSID[apidx].RSNIE_Len[0],
pAd->PortCfg.MBSSID[apidx].RSNIE_Len[0], pAd->PortCfg.MBSSID[apidx].RSN_IE[0],
1, &RSNIe2,
1, &pAd->PortCfg.MBSSID[apidx].RSNIE_Len[1],
pAd->PortCfg.MBSSID[apidx].RSNIE_Len[1], pAd->PortCfg.MBSSID[apidx].RSN_IE[1],
END_OF_ARGS);
}
else if ((pAd->PortCfg.PhyMode == PHY_11BG_MIXED) || (pAd->PortCfg.PhyMode == PHY_11G))
{
UCHAR SupportedRatesLen = 4, ErpLen = 1;
UCHAR ExtendedRatesIe = IE_EXT_SUPP_RATES, ErpIe = IE_ERP;
UCHAR ExtendedRatesLen = pAd->PortCfg.SupportedRatesLen - SupportedRatesLen;
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &ProbeRspHdr,
TIMESTAMP_LEN, &FakeTimestamp,
2, &pAd->PortCfg.BeaconPeriod,
2, &pAd->PortCfg.MBSSID[apidx].CapabilityInfo,
1, &SsidIe,
1, &pAd->PortCfg.MBSSID[apidx].SsidLen,
pAd->PortCfg.MBSSID[apidx].SsidLen, pAd->PortCfg.MBSSID[apidx].Ssid,
1, &SuppIe,
1, &SupportedRatesLen,
SupportedRatesLen, pAd->PortCfg.SupportedRates,
1, &DsIe,
1, &DsLen,
1, &pAd->PortCfg.Channel,
1, &ErpIe,
1, &ErpLen,
1, &pAd->Mlme.ErpIeContent,
1, &ExtendedRatesIe,
1, &ExtendedRatesLen,
ExtendedRatesLen, &pAd->PortCfg.SupportedRates[SupportedRatesLen],
1, &RSNIe,
1, &pAd->PortCfg.MBSSID[apidx].RSNIE_Len[0],
pAd->PortCfg.MBSSID[apidx].RSNIE_Len[0], pAd->PortCfg.MBSSID[apidx].RSN_IE[0],
END_OF_ARGS);
}
else
{
MakeOutgoingFrame(pOutBuffer, &FrameLen,
sizeof(HEADER_802_11), &ProbeRspHdr,
TIMESTAMP_LEN, &FakeTimestamp,
2, &pAd->PortCfg.BeaconPeriod,
2, &pAd->PortCfg.MBSSID[apidx].CapabilityInfo,
1, &SsidIe,
1, &pAd->PortCfg.MBSSID[apidx].SsidLen,
pAd->PortCfg.MBSSID[apidx].SsidLen, pAd->PortCfg.MBSSID[apidx].Ssid,
1, &SuppIe,
1, &pAd->PortCfg.SupportedRatesLen,
pAd->PortCfg.SupportedRatesLen, pAd->PortCfg.SupportedRates,
1, &DsIe,
1, &DsLen,
1, &pAd->PortCfg.Channel,
1, &RSNIe,
1, &pAd->PortCfg.MBSSID[apidx].RSNIE_Len[0],
pAd->PortCfg.MBSSID[apidx].RSNIE_Len[0], pAd->PortCfg.MBSSID[apidx].RSN_IE[0],
END_OF_ARGS);
}
#ifdef WMM_SUPPORT
// add WMM IE here
if (pAd->PortCfg.MBSSID[apidx].bWmmCapable)
{
UCHAR i;
UCHAR WmeParmIe[26] = {IE_VENDOR_SPECIFIC, 24, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x01, 0, 0};
WmeParmIe[8] = pAd->PortCfg.BssEdcaParm.EdcaUpdateCount & 0x0f;
WmeParmIe[8] |= (pAd->PortCfg.bAPSDCapable) ? 0x80 : 0x00;
for (i=QID_AC_BE; i<=QID_AC_VO; i++)
{
WmeParmIe[10+ (i*4)] = (i << 5) + // b5-6 is ACI
((UCHAR)pAd->PortCfg.BssEdcaParm.bACM[i] << 4) + // b4 is ACM
(pAd->PortCfg.BssEdcaParm.Aifsn[i] & 0x0f); // b0-3 is AIFSN
WmeParmIe[11+ (i*4)] = (pAd->PortCfg.BssEdcaParm.Cwmax[i] << 4) + // b5-8 is CWMAX
(pAd->PortCfg.BssEdcaParm.Cwmin[i] & 0x0f); // b0-3 is CWMIN
WmeParmIe[12+ (i*4)] = (UCHAR)(pAd->PortCfg.BssEdcaParm.Txop[i] & 0xff); // low byte of TXOP
WmeParmIe[13+ (i*4)] = (UCHAR)(pAd->PortCfg.BssEdcaParm.Txop[i] >> 8); // high byte of TXOP
}
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
26, WmeParmIe,
END_OF_ARGS);
FrameLen += TmpLen;
}
#endif /* WMM_SUPPORT */
#ifdef AGGREGATION_SUPPORT
// add Ralink-specific IE here - Byte0.b0=1 for aggregation
if (pAd->PortCfg.bAggregationCapable)
{
{
ULONG TmpLen;
UCHAR RalinkSpecificIe[9] = {IE_VENDOR_SPECIFIC, 7, 0x00, 0x0c, 0x43, 0x01, 0x00, 0x00, 0x00};
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
9, RalinkSpecificIe,
END_OF_ARGS);
FrameLen += TmpLen;
}
}
#endif /* AGGREGATION_SUPPORT */
// add Channel switch announcement IE
if ((pAd->PortCfg.PhyMode == PHY_11A) && (pAd->PortCfg.RadarDetect.IEEE80211H == TRUE) && (pAd->PortCfg.RadarDetect.RDMode == RD_SWITCHING_MODE))
{
UCHAR CSAIe=IE_CHANNEL_SWITCH_ANNOUNCEMENT;
UCHAR CSALen=3;
UCHAR CSAMode=1;
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
1, &CSAIe,
1, &CSALen,
1, &CSAMode,
1, &pAd->PortCfg.Channel,
1, &pAd->PortCfg.RadarDetect.CSCount,
END_OF_ARGS);
FrameLen += TmpLen;
}
// add country IE, power constraint IE
if (pAd->PortCfg.bCountryFlag)
{
ULONG TmpLen2=0;
UCHAR TmpFrame[256];
UCHAR CountryIe = IE_COUNTRY;
UCHAR MaxTxPower=16;
// Only 802.11a APs that comply with 802.11h are required to include a Power Constrint Element(IE=32)
// in beacons and probe response frames
if (pAd->PortCfg.PhyMode == PHY_11A && pAd->PortCfg.RadarDetect.IEEE80211H == TRUE)
{
// prepare power constraint IE
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
3, PowerConstraintIE,
END_OF_ARGS);
FrameLen += TmpLen;
}
NdisZeroMemory(TmpFrame, sizeof(TmpFrame));
// prepare channel information
MakeOutgoingFrame(TmpFrame+TmpLen2, &TmpLen,
1, &pAd->ChannelList[0].Channel,
1, &pAd->ChannelListNum,
1, &MaxTxPower,
END_OF_ARGS);
TmpLen2 += TmpLen;
// need to do the padding bit check, and concatenate it
if ((TmpLen2%2) == 0)
{
UCHAR TmpLen3 = TmpLen2+4;
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
1, &CountryIe,
1, &TmpLen3,
3, pAd->PortCfg.CountryCode,
TmpLen2+1, TmpFrame,
END_OF_ARGS);
}
else
{
UCHAR TmpLen3 = TmpLen2+3;
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
1, &CountryIe,
1, &TmpLen3,
3, pAd->PortCfg.CountryCode,
TmpLen2, TmpFrame,
END_OF_ARGS);
}
FrameLen += TmpLen;
}
if (pAd->PortCfg.bGetAPConfig)
{
CHAR cfgBuf[MAX_CFG_BUFFER_LEN+1] = {0};
if ( getCfgDataForSTA(pAd, cfgBuf) )
{
UCHAR RalinkSpecificOUIForGetCfg[4] = {0x00, 0x0c, 0x43, 0x80};
SHORT dataLen = 0;
UCHAR Vendor_IE = IE_VENDOR_SPECIFIC, pktLen = 0, count = 0;
dataLen = strlen(cfgBuf);
for ( ; ; )
{
UCHAR tempBuf[251] = {0}, tempBufLen = 251;
if (dataLen <= 251)
{
pktLen = (UCHAR)dataLen + 4;
RalinkSpecificOUIForGetCfg[3] = 0x80;
NdisMoveMemory(tempBuf, cfgBuf+(count*tempBufLen), dataLen);
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
1, &Vendor_IE,
1, &pktLen,
4, RalinkSpecificOUIForGetCfg,
dataLen, tempBuf,
END_OF_ARGS);
FrameLen += TmpLen;
break;
}
else
{
pktLen = 4 + tempBufLen;
RalinkSpecificOUIForGetCfg[3] = 0x40;
NdisMoveMemory(tempBuf, cfgBuf+(count*tempBufLen), tempBufLen);
MakeOutgoingFrame(pOutBuffer+FrameLen, &TmpLen,
1, &Vendor_IE,
1, &pktLen,
4, RalinkSpecificOUIForGetCfg,
tempBufLen, tempBuf,
END_OF_ARGS);
FrameLen += TmpLen;
dataLen -= tempBufLen;
count++;
}
}
}
}
MiniportMMRequest(pAd, pOutBuffer, FrameLen);
kfree(pOutBuffer);
}
}
}
/*
==========================================================================
Description:
parse the received BEACON
NOTE:
The only thing AP cares about received BEACON frames is to decide
if there's any overlapped legacy BSS condition (OLBC).
If OLBC happened, this AP should set the ERP->Use_Protection bit in its
outgoing BEACON. The result is to tell all its clients to use RTC/CTS
or CTS-to-self protection to protect B/G mixed traffic
==========================================================================
*/
VOID PeerBeaconAction(
IN PRTMP_ADAPTER pAd,
IN MLME_QUEUE_ELEM *Elem)
{
UCHAR Bssid[MAC_ADDR_LEN], Addr2[MAC_ADDR_LEN];
CHAR Ssid[MAX_LEN_OF_SSID];
CF_PARM CfParm;
UCHAR SsidLen, MessageToMe=0, BssType, Channel;
UCHAR DtimCount=0, DtimPeriod=0, BcastFlag=0;
USHORT CapabilityInfo, AtimWin, BeaconPeriod;
LARGE_INTEGER TimeStamp;
UCHAR Erp;
UCHAR SupRate[MAX_LEN_OF_SUPPORTED_RATES], ExtRate[MAX_LEN_OF_SUPPORTED_RATES];
UCHAR SupRateLen, ExtRateLen;
UCHAR CkipFlag;
UCHAR AironetCellPowerLimit;
EDCA_PARM EdcaParm;
QBSS_LOAD_PARM QbssLoad;
QOS_CAPABILITY_PARM QosCapability;
ULONG RalinkIe;
// New for WPA security suites
UCHAR VarIE[MAX_VIE_LEN]; // Total VIE length = MAX_VIE_LEN - -5
NDIS_802_11_VARIABLE_IEs *pVIE = NULL;
UCHAR LenVIE;
BOOLEAN LegacyBssExist;
// Init Variable IE structure
pVIE = (PNDIS_802_11_VARIABLE_IEs) VarIE;
pVIE->Length = 0;
if (PeerBeaconAndProbeRspSanity(pAd,
Elem->Msg,
Elem->MsgLen,
Addr2,
Bssid,
Ssid,
&SsidLen,
&BssType,
&BeaconPeriod,
&Channel,
&TimeStamp,
&CfParm,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?