69 {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108};
78 static unsigned char s_byGetRateIdx(
unsigned char byRate);
82 s_vGetDASA(
unsigned char *pbyRxBufferAddr,
unsigned int *pcbHeaderSize,
86 s_vProcessRxMACHeader(
PSDevice pDevice,
unsigned char *pbyRxBufferAddr,
87 unsigned int cbPacketSize,
bool bIsWEP,
bool bExtIV,
88 unsigned int *pcbHeadSize);
90 static bool s_bAPModeRxCtl(
92 unsigned char *pbyFrame,
98 static bool s_bAPModeRxData (
101 unsigned int FrameSize,
102 unsigned int cbHeaderOffset,
108 static bool s_bHandleRxEncryption(
110 unsigned char *pbyFrame,
111 unsigned int FrameSize,
112 unsigned char *pbyRsr,
113 unsigned char *pbyNewRsr,
116 unsigned short *pwRxTSC15_0,
117 unsigned long *pdwRxTSC47_16
120 static bool s_bHostWepRxEncryption(
123 unsigned char *pbyFrame,
124 unsigned int FrameSize,
125 unsigned char *pbyRsr,
128 unsigned char *pbyNewRsr,
130 unsigned short *pwRxTSC15_0,
131 unsigned long *pdwRxTSC47_16
155 s_vProcessRxMACHeader(
PSDevice pDevice,
unsigned char *pbyRxBufferAddr,
156 unsigned int cbPacketSize,
bool bIsWEP,
bool bExtIV,
157 unsigned int *pcbHeadSize)
159 unsigned char *pbyRxBuffer;
160 unsigned int cbHeaderSize = 0;
161 unsigned short *pwType;
168 s_vGetDASA((
unsigned char *)pMACHeader, &cbHeaderSize, &pDevice->
sRxEthHeader);
183 pbyRxBuffer = (
unsigned char *) (pbyRxBufferAddr + cbHeaderSize);
187 else if (!compare_ether_addr(pbyRxBuffer, &pDevice->
abySNAP_RFC1042[0])) {
189 pwType = (
unsigned short *) (pbyRxBufferAddr + cbHeaderSize);
194 pwType = (
unsigned short *) (pbyRxBufferAddr + cbHeaderSize);
209 pwType = (
unsigned short *) (pbyRxBufferAddr + cbHeaderSize);
223 pbyRxBuffer = (
unsigned char *) (pbyRxBufferAddr + cbHeaderSize);
226 for(ii=0;ii<ETH_ALEN;ii++)
229 *pcbHeadSize = cbHeaderSize;
235 static unsigned char s_byGetRateIdx (
unsigned char byRate)
237 unsigned char byRateIdx;
239 for (byRateIdx = 0; byRateIdx <
MAX_RATE ; byRateIdx++) {
248 s_vGetDASA(
unsigned char *pbyRxBufferAddr,
unsigned int *pcbHeaderSize,
251 unsigned int cbHeaderSize = 0;
257 if ((pMACHeader->wFrameCtl &
FC_TODS) == 0) {
260 psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii];
261 psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr3[ii];
267 psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii];
268 psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii];
276 psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii];
277 psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr4[ii];
283 psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii];
284 psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii];
288 *pcbHeaderSize = cbHeaderSize;
301 spin_lock_irq(&pDevice->
lock);
304 pRxMgmtPacket = DeQueue(pDevice);
307 spin_unlock_irq(&pDevice->
lock);
331 unsigned char *pbyRsr;
332 unsigned char *pbyNewRsr;
333 unsigned char *pbyRSSI;
335 unsigned short *pwFrameSize;
336 unsigned char *pbyFrame;
337 bool bDeFragRx =
false;
339 unsigned int cbHeaderOffset;
340 unsigned int FrameSize;
341 unsigned short wEtherType = 0;
342 int iSANodeIndex = -1;
343 int iDANodeIndex = -1;
345 unsigned int cbIVOffset;
347 unsigned char *pbyRxSts;
348 unsigned char *pbyRxRate;
349 unsigned char *pbySQ;
350 unsigned int cbHeaderSize;
352 unsigned short wRxTSC15_0 = 0;
353 unsigned long dwRxTSC47_16 = 0;
356 unsigned long dwDuration = 0;
358 long ldBmThreshold = 0;
360 bool bRxeapol_key =
false;
373 pwFrameSize = (
unsigned short *)(skb->
data + 2);
378 if ((FrameSize > 2364)||(FrameSize <= 32)) {
384 pbyRxSts = (
unsigned char *) (skb->
data);
385 pbyRxRate = (
unsigned char *) (skb->
data + 1);
386 pbyRsr = (
unsigned char *) (skb->
data + FrameSize - 1);
387 pbyRSSI = (
unsigned char *) (skb->
data + FrameSize - 2);
388 pbyNewRsr = (
unsigned char *) (skb->
data + FrameSize - 3);
389 pbySQ = (
unsigned char *) (skb->
data + FrameSize - 4);
390 pqwTSFTime = (
PQWORD) (skb->
data + FrameSize - 12);
391 pbyFrame = (
unsigned char *)(skb->
data + 4);
396 if ((FrameSize > 2346)|(FrameSize < 14)) {
419 dwDuration = (FrameSize << 4);
422 if (*pbyRxSts & 0x01) {
434 for (ii = 7; ii > 0;) {
435 if (ldBm > ldBmThreshold) {
441 pDevice->
dwRPIs[ii] += dwDuration;
445 if (!is_multicast_ether_addr(pbyFrame)) {
464 if (
BSSDBbIsSTAInNodeDB(pMgmt, (
unsigned char *)(p802_11Header->abyAddr2), &iSANodeIndex)) {
472 if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex) ==
true) {
479 bool bRxDecryOK =
false;
483 if ((pDevice->bEnableHostWEP) && (iSANodeIndex >= 0)) {
495 bRxDecryOK = s_bHostWepRxEncryption(pDevice,
506 bRxDecryOK = s_bHandleRxEncryption(pDevice,
576 unsigned char *pbyData1;
577 unsigned char *pbyData2;
581 pRxPacket->
uRSSI = *pbyRSSI;
582 pRxPacket->
bySQ = *pbySQ;
589 for (ii = 0; ii < (FrameSize - 4); ii++) {
590 *pbyData1 = *pbyData2;
595 pRxPacket->
byRxRate = s_byGetRateIdx(*pbyRxRate);
601 EnQueue(pDevice,pRxPacket);
609 EnQueue(pDevice,pRxPacket);
621 if (pDevice->bEnableHostapd) {
622 skb->
dev = pDevice->apdev;
626 skb_reset_mac_header(skb);
629 memset(skb->cb, 0,
sizeof(skb->cb));
666 unsigned char Protocol_Version;
667 unsigned char Packet_Type;
672 wEtherType = (skb->
data[cbIVOffset + 8 + 24 + 6] << 8) |
673 skb->
data[cbIVOffset + 8 + 24 + 6 + 1];
674 Protocol_Version = skb->
data[cbIVOffset + 8 + 24 + 6 + 1 +1];
675 Packet_Type = skb->
data[cbIVOffset + 8 + 24 + 6 + 1 +1+1];
677 if(((Protocol_Version==1) ||(Protocol_Version==2)) &&
718 if ((*pbyRSSI != 0) &&
726 if (pMgmt->
pCurrBSS->ldBmAverage[ii] != 0) {
735 unsigned char abyMacHdr[24];
742 wEtherType = (skb->
data[cbIVOffset + 4 + 24 + 6] << 8) |
743 skb->
data[cbIVOffset + 4 + 24 + 6 + 1];
747 skb->
dev = pDevice->apdev;
749 if (bIsWEP ==
true) {
752 memcpy((skb->
data + 4 + cbIVOffset), &abyMacHdr[0], 24);
754 skb->
data += (cbIVOffset + 4);
755 skb->
tail += (cbIVOffset + 4);
757 skb_reset_mac_header(skb);
761 memset(skb->cb, 0,
sizeof(skb->cb));
782 unsigned long *pdwMIC_L;
783 unsigned long *pdwMIC_R;
784 unsigned long dwMIC_Priority;
785 unsigned long dwMICKey0 = 0, dwMICKey1 = 0;
786 unsigned long dwLocalMIC_L = 0;
787 unsigned long dwLocalMIC_R = 0;
818 pdwMIC_L = (
unsigned long *)(skb->
data + 4 + FrameSize);
819 pdwMIC_R = (
unsigned long *)(skb->
data + 4 + FrameSize + 4);
838 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
844 int keyidx = pbyFrame[cbHeaderSize+3] >> 6;
845 memset(&ev, 0,
sizeof(ev));
857 memset(&wrqu, 0,
sizeof(wrqu));
858 wrqu.
data.length =
sizeof(ev);
880 skb_reset_mac_header(pDevice->
skb);
899 unsigned short wLocalTSC15_0 = 0;
900 unsigned long dwLocalTSC47_16 = 0;
901 unsigned long long RSC = 0;
903 RSC = *((
unsigned long long *) &(pKey->
KeyRSC));
904 wLocalTSC15_0 = (
unsigned short) RSC;
905 dwLocalTSC47_16 = (
unsigned long) (RSC>>16);
915 if ( (wRxTSC15_0 < wLocalTSC15_0) &&
916 (dwRxTSC47_16 <= dwLocalTSC47_16) &&
917 !((dwRxTSC47_16 == 0) && (dwLocalTSC47_16 == 0xFFFFFFFF))) {
940 if ((pKey !=
NULL) && (bIsWEP)) {
945 s_vProcessRxMACHeader(pDevice, (
unsigned char *)(skb->
data+4), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset);
946 FrameSize -= cbHeaderOffset;
954 if (s_bAPModeRxData(pDevice,
979 skb->
data += cbHeaderOffset;
980 skb->
tail += cbHeaderOffset;
1011 pDevice->
dev->name);
1020 static bool s_bAPModeRxCtl (
1022 unsigned char *pbyFrame,
1038 if (iSANodeIndex > 0) {
1045 (
unsigned char *)(p802_11Header->abyAddr2),
1057 (
unsigned char *)(p802_11Header->abyAddr2),
1104 (
unsigned char *)(p802_11Header->abyAddr2),
1110 p802_11Header->abyAddr3);
1112 p802_11Header->abyAddr2);
1114 p802_11Header->abyAddr1);
1126 static bool s_bHandleRxEncryption (
1128 unsigned char *pbyFrame,
1129 unsigned int FrameSize,
1130 unsigned char *pbyRsr,
1131 unsigned char *pbyNewRsr,
1134 unsigned short *pwRxTSC15_0,
1135 unsigned long *pdwRxTSC47_16
1138 unsigned int PayloadLen = FrameSize;
1139 unsigned char *pbyIV;
1140 unsigned char byKeyIdx;
1155 byKeyIdx = (*(pbyIV+3) & 0xc0);
1202 }
else if (pDevice->
bLinkPass ==
true) {
1210 }
else if (pDevice->
bLinkPass ==
true) {
1224 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4);
1238 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4);
1239 *pdwRxTSC47_16 =
cpu_to_le32(*(
unsigned long *)(pbyIV + 4));
1244 *pwRxTSC15_0 =
cpu_to_le16(*(
unsigned short *)pbyIV);
1266 if ((*(pbyIV+3) & 0x20) != 0)
1272 static bool s_bHostWepRxEncryption (
1274 unsigned char *pbyFrame,
1275 unsigned int FrameSize,
1276 unsigned char *pbyRsr,
1279 unsigned char *pbyNewRsr,
1281 unsigned short *pwRxTSC15_0,
1282 unsigned long *pdwRxTSC47_16
1285 unsigned int PayloadLen = FrameSize;
1286 unsigned char *pbyIV;
1287 unsigned char byKeyIdx;
1302 byKeyIdx = (*(pbyIV+3) & 0xc0);
1317 }
else if (pDevice->
bLinkPass ==
true) {
1328 (bOnFly ==
false)) {
1334 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4);
1348 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4);
1349 *pdwRxTSC47_16 =
cpu_to_le32(*(
unsigned long *)(pbyIV + 4));
1355 *pwRxTSC15_0 =
cpu_to_le16(*(
unsigned short *)pbyIV);
1381 if (bOnFly ==
false) {
1396 if ((*(pbyIV+3) & 0x20) != 0)
1403 static bool s_bAPModeRxData (
1406 unsigned int FrameSize,
1407 unsigned int cbHeaderOffset,
1413 bool bRelayAndForward =
false;
1414 bool bRelayOnly =
false;
1415 unsigned char byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
1416 unsigned short wAID;
1424 if(is_multicast_ether_addr((
unsigned char *)(skb->
data+cbHeaderOffset))) {
1427 skbcpy = dev_alloc_skb((
int)pDevice->
rx_buf_sz);
1430 if (skbcpy ==
NULL) {
1434 skbcpy->
dev = pDevice->
dev;
1435 skbcpy->
len = FrameSize;
1445 bRelayAndForward =
true;
1455 skb->
data += cbHeaderOffset;
1456 skb->
tail += cbHeaderOffset;
1461 pMgmt->
abyPSTxMap[wAID >> 3] |= byMask[wAID & 7];
1463 iDANodeIndex, (wAID >> 3), pMgmt->
abyPSTxMap[wAID >> 3]);
1473 if (bRelayOnly || bRelayAndForward) {
1475 if (bRelayAndForward)
1478 if ((pDevice->
uAssocCount > 1) && (iDANodeIndex >= 0)) {
1479 ROUTEbRelay(pDevice, (
unsigned char *)(skb->
data + cbHeaderOffset), FrameSize, (
unsigned int)iDANodeIndex);