jbd: Fix a race between checkpointing code and journal_get_write_access()
[linux/fpc-iii.git] / drivers / staging / vt6655 / dpc.c
blobacc6d82a9544045ba2f1bae7d8e26f9864f18fbf
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 * File: dpc.c
21 * Purpose: handle dpc rx functions
23 * Author: Lyndon Chen
25 * Date: May 20, 2003
27 * Functions:
28 * device_receive_frame - Rcv 802.11 frame function
29 * s_bAPModeRxCtl- AP Rcv frame filer Ctl.
30 * s_bAPModeRxData- AP Rcv data frame handle
31 * s_bHandleRxEncryption- Rcv decrypted data via on-fly
32 * s_bHostWepRxEncryption- Rcv encrypted data via host
33 * s_byGetRateIdx- get rate index
34 * s_vGetDASA- get data offset
35 * s_vProcessRxMACHeader- Rcv 802.11 and translate to 802.3
37 * Revision History:
42 #if !defined(__DEVICE_H__)
43 #include "device.h"
44 #endif
45 #if !defined(__RXTX_H__)
46 #include "rxtx.h"
47 #endif
48 #if !defined(__TETHER_H__)
49 #include "tether.h"
50 #endif
51 #if !defined(__CARD_H__)
52 #include "card.h"
53 #endif
54 #if !defined(__BSSDB_H__)
55 #include "bssdb.h"
56 #endif
57 #if !defined(__MAC_H__)
58 #include "mac.h"
59 #endif
60 #if !defined(__BASEBAND_H__)
61 #include "baseband.h"
62 #endif
63 #if !defined(__UMEM_H__)
64 #include "umem.h"
65 #endif
66 #if !defined(__MICHAEL_H__)
67 #include "michael.h"
68 #endif
69 #if !defined(__TKIP_H__)
70 #include "tkip.h"
71 #endif
72 #if !defined(__TCRC_H__)
73 #include "tcrc.h"
74 #endif
75 #if !defined(__WCTL_H__)
76 #include "wctl.h"
77 #endif
78 #if !defined(__WROUTE_H__)
79 #include "wroute.h"
80 #endif
81 #if !defined(__TBIT_H__)
82 #include "tbit.h"
83 #endif
84 #if !defined(__HOSTAP_H__)
85 #include "hostap.h"
86 #endif
87 #if !defined(__RF_H__)
88 #include "rf.h"
89 #endif
90 #if !defined(__IOWPA_H__)
91 #include "iowpa.h"
92 #endif
93 #if !defined(__AES_H__)
94 #include "aes_ccmp.h"
95 #endif
97 //#define PLICE_DEBUG
100 /*--------------------- Static Definitions -------------------------*/
102 /*--------------------- Static Classes ----------------------------*/
104 /*--------------------- Static Variables --------------------------*/
105 //static int msglevel =MSG_LEVEL_DEBUG;
106 static int msglevel =MSG_LEVEL_INFO;
108 const BYTE acbyRxRate[MAX_RATE] =
109 {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108};
112 /*--------------------- Static Functions --------------------------*/
114 /*--------------------- Static Definitions -------------------------*/
116 /*--------------------- Static Functions --------------------------*/
118 static BYTE s_byGetRateIdx(IN BYTE byRate);
121 static
122 VOID
123 s_vGetDASA(
124 IN PBYTE pbyRxBufferAddr,
125 OUT PUINT pcbHeaderSize,
126 OUT PSEthernetHeader psEthHeader
129 static
130 VOID
131 s_vProcessRxMACHeader (
132 IN PSDevice pDevice,
133 IN PBYTE pbyRxBufferAddr,
134 IN UINT cbPacketSize,
135 IN BOOL bIsWEP,
136 IN BOOL bExtIV,
137 OUT PUINT pcbHeadSize
140 static BOOL s_bAPModeRxCtl(
141 IN PSDevice pDevice,
142 IN PBYTE pbyFrame,
143 IN INT iSANodeIndex
146 #ifdef PRIVATE_OBJ
148 static BOOL s_bAPModeRxData (
149 IN PSDevice pDevice,
150 IN ref_sk_buff* skb,
151 IN UINT FrameSize,
152 IN UINT cbHeaderOffset,
153 IN INT iSANodeIndex,
154 IN INT iDANodeIndex
156 #else
158 static BOOL s_bAPModeRxData (
159 IN PSDevice pDevice,
160 IN struct sk_buff* skb,
161 IN UINT FrameSize,
162 IN UINT cbHeaderOffset,
163 IN INT iSANodeIndex,
164 IN INT iDANodeIndex
166 #endif
169 static BOOL s_bHandleRxEncryption(
170 IN PSDevice pDevice,
171 IN PBYTE pbyFrame,
172 IN UINT FrameSize,
173 IN PBYTE pbyRsr,
174 OUT PBYTE pbyNewRsr,
175 OUT PSKeyItem *pKeyOut,
176 OUT PBOOL pbExtIV,
177 OUT PWORD pwRxTSC15_0,
178 OUT PDWORD pdwRxTSC47_16
181 static BOOL s_bHostWepRxEncryption(
183 IN PSDevice pDevice,
184 IN PBYTE pbyFrame,
185 IN UINT FrameSize,
186 IN PBYTE pbyRsr,
187 IN BOOL bOnFly,
188 IN PSKeyItem pKey,
189 OUT PBYTE pbyNewRsr,
190 OUT PBOOL pbExtIV,
191 OUT PWORD pwRxTSC15_0,
192 OUT PDWORD pdwRxTSC47_16
196 /*--------------------- Export Variables --------------------------*/
200 * Description:
201 * Translate Rcv 802.11 header to 802.3 header with Rx buffer
203 * Parameters:
204 * In:
205 * pDevice
206 * dwRxBufferAddr - Address of Rcv Buffer
207 * cbPacketSize - Rcv Packet size
208 * bIsWEP - If Rcv with WEP
209 * Out:
210 * pcbHeaderSize - 802.11 header size
212 * Return Value: None
215 static
216 VOID
217 s_vProcessRxMACHeader (
218 IN PSDevice pDevice,
219 IN PBYTE pbyRxBufferAddr,
220 IN UINT cbPacketSize,
221 IN BOOL bIsWEP,
222 IN BOOL bExtIV,
223 OUT PUINT pcbHeadSize
226 PBYTE pbyRxBuffer;
227 UINT cbHeaderSize = 0;
228 PWORD pwType;
229 PS802_11Header pMACHeader;
230 int ii;
233 pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize);
235 s_vGetDASA((PBYTE)pMACHeader, &cbHeaderSize, &pDevice->sRxEthHeader);
237 if (bIsWEP) {
238 if (bExtIV) {
239 // strip IV&ExtIV , add 8 byte
240 cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 8);
241 } else {
242 // strip IV , add 4 byte
243 cbHeaderSize += (WLAN_HDR_ADDR3_LEN + 4);
246 else {
247 cbHeaderSize += WLAN_HDR_ADDR3_LEN;
250 pbyRxBuffer = (PBYTE) (pbyRxBufferAddr + cbHeaderSize);
251 if (IS_ETH_ADDRESS_EQUAL(pbyRxBuffer, &pDevice->abySNAP_Bridgetunnel[0])) {
252 cbHeaderSize += 6;
254 else if (IS_ETH_ADDRESS_EQUAL(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) {
255 cbHeaderSize += 6;
256 pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
257 if ((*pwType!= TYPE_PKT_IPX) && (*pwType != cpu_to_le16(0xF380))) {
259 else {
260 cbHeaderSize -= 8;
261 pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
262 if (bIsWEP) {
263 if (bExtIV) {
264 *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV
265 } else {
266 *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); // 4 is IV
269 else {
270 *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN);
274 else {
275 cbHeaderSize -= 2;
276 pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize);
277 if (bIsWEP) {
278 if (bExtIV) {
279 *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV
280 } else {
281 *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 4); // 4 is IV
284 else {
285 *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN);
289 cbHeaderSize -= (U_ETHER_ADDR_LEN * 2);
290 pbyRxBuffer = (PBYTE) (pbyRxBufferAddr + cbHeaderSize);
291 for(ii=0;ii<U_ETHER_ADDR_LEN;ii++)
292 *pbyRxBuffer++ = pDevice->sRxEthHeader.abyDstAddr[ii];
293 for(ii=0;ii<U_ETHER_ADDR_LEN;ii++)
294 *pbyRxBuffer++ = pDevice->sRxEthHeader.abySrcAddr[ii];
296 *pcbHeadSize = cbHeaderSize;
302 static BYTE s_byGetRateIdx (IN BYTE byRate)
304 BYTE byRateIdx;
306 for (byRateIdx = 0; byRateIdx <MAX_RATE ; byRateIdx++) {
307 if (acbyRxRate[byRateIdx%MAX_RATE] == byRate)
308 return byRateIdx;
310 return 0;
314 static
315 VOID
316 s_vGetDASA (
317 IN PBYTE pbyRxBufferAddr,
318 OUT PUINT pcbHeaderSize,
319 OUT PSEthernetHeader psEthHeader
322 UINT cbHeaderSize = 0;
323 PS802_11Header pMACHeader;
324 int ii;
326 pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize);
328 if ((pMACHeader->wFrameCtl & FC_TODS) == 0) {
329 if (pMACHeader->wFrameCtl & FC_FROMDS) {
330 for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) {
331 psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii];
332 psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr3[ii];
335 else {
336 // IBSS mode
337 for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) {
338 psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii];
339 psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii];
343 else {
344 // Is AP mode..
345 if (pMACHeader->wFrameCtl & FC_FROMDS) {
346 for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) {
347 psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii];
348 psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr4[ii];
349 cbHeaderSize += 6;
352 else {
353 for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) {
354 psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii];
355 psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii];
359 *pcbHeaderSize = cbHeaderSize;
365 //PLICE_DEBUG ->
367 VOID MngWorkItem(PVOID Context)
369 PSRxMgmtPacket pRxMgmtPacket;
370 PSDevice pDevice = (PSDevice) Context;
371 //printk("Enter MngWorkItem,Queue packet num is %d\n",pDevice->rxManeQueue.packet_num);
372 spin_lock_irq(&pDevice->lock);
373 while(pDevice->rxManeQueue.packet_num != 0)
375 pRxMgmtPacket = DeQueue(pDevice);
376 vMgrRxManagePacket(pDevice, pDevice->pMgmt, pRxMgmtPacket);
378 spin_unlock_irq(&pDevice->lock);
382 //PLICE_DEBUG<-
386 BOOL
387 device_receive_frame (
388 IN PSDevice pDevice,
389 IN PSRxDesc pCurrRD
393 PDEVICE_RD_INFO pRDInfo = pCurrRD->pRDInfo;
394 #ifdef PLICE_DEBUG
395 //printk("device_receive_frame:pCurrRD is %x,pRDInfo is %x\n",pCurrRD,pCurrRD->pRDInfo);
396 #endif
397 struct net_device_stats* pStats=&pDevice->stats;
398 #ifdef PRIVATE_OBJ
399 ref_sk_buff* skb;
400 #else
401 struct sk_buff* skb;
402 #endif
403 PSMgmtObject pMgmt = pDevice->pMgmt;
404 PSRxMgmtPacket pRxPacket = &(pDevice->pMgmt->sRxPacket);
405 PS802_11Header p802_11Header;
406 PBYTE pbyRsr;
407 PBYTE pbyNewRsr;
408 PBYTE pbyRSSI;
409 PQWORD pqwTSFTime;
410 PWORD pwFrameSize;
411 PBYTE pbyFrame;
412 BOOL bDeFragRx = FALSE;
413 BOOL bIsWEP = FALSE;
414 UINT cbHeaderOffset;
415 UINT FrameSize;
416 WORD wEtherType = 0;
417 INT iSANodeIndex = -1;
418 INT iDANodeIndex = -1;
419 UINT ii;
420 UINT cbIVOffset;
421 BOOL bExtIV = FALSE;
422 PBYTE pbyRxSts;
423 PBYTE pbyRxRate;
424 PBYTE pbySQ;
425 UINT cbHeaderSize;
426 PSKeyItem pKey = NULL;
427 WORD wRxTSC15_0 = 0;
428 DWORD dwRxTSC47_16 = 0;
429 SKeyItem STempKey;
430 // 802.11h RPI
431 DWORD dwDuration = 0;
432 LONG ldBm = 0;
433 LONG ldBmThreshold = 0;
434 PS802_11Header pMACHeader;
435 BOOL bRxeapol_key = FALSE;
437 // DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- device_receive_frame---\n");
438 #ifdef PRIVATE_OBJ
439 skb = &(pRDInfo->ref_skb);
440 #else
442 skb = pRDInfo->skb;
443 #endif
446 //PLICE_DEBUG->
447 #if 1
448 pci_unmap_single(pDevice->pcid, pRDInfo->skb_dma,
449 pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE);
450 #endif
451 //PLICE_DEBUG<-
452 pwFrameSize = (PWORD)(skb->data + 2);
453 FrameSize = cpu_to_le16(pCurrRD->m_rd1RD1.wReqCount) - cpu_to_le16(pCurrRD->m_rd0RD0.wResCount);
455 // Max: 2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR
456 // Min (ACK): 10HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR
457 if ((FrameSize > 2364)||(FrameSize <= 32)) {
458 // Frame Size error drop this packet.
459 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- WRONG Length 1 \n");
460 return FALSE;
463 pbyRxSts = (PBYTE) (skb->data);
464 pbyRxRate = (PBYTE) (skb->data + 1);
465 pbyRsr = (PBYTE) (skb->data + FrameSize - 1);
466 pbyRSSI = (PBYTE) (skb->data + FrameSize - 2);
467 pbyNewRsr = (PBYTE) (skb->data + FrameSize - 3);
468 pbySQ = (PBYTE) (skb->data + FrameSize - 4);
469 pqwTSFTime = (PQWORD) (skb->data + FrameSize - 12);
470 pbyFrame = (PBYTE)(skb->data + 4);
472 // get packet size
473 FrameSize = cpu_to_le16(*pwFrameSize);
475 if ((FrameSize > 2346)|(FrameSize < 14)) { // Max: 2312Payload + 30HD +4CRC
476 // Min: 14 bytes ACK
477 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---------- WRONG Length 2 \n");
478 return FALSE;
480 //PLICE_DEBUG->
481 #if 1
482 // update receive statistic counter
483 STAvUpdateRDStatCounter(&pDevice->scStatistic,
484 *pbyRsr,
485 *pbyNewRsr,
486 *pbyRxRate,
487 pbyFrame,
488 FrameSize);
490 #endif
492 pMACHeader=(PS802_11Header)((PBYTE) (skb->data)+8);
493 //PLICE_DEBUG<-
494 if (pDevice->bMeasureInProgress == TRUE) {
495 if ((*pbyRsr & RSR_CRCOK) != 0) {
496 pDevice->byBasicMap |= 0x01;
498 dwDuration = (FrameSize << 4);
499 dwDuration /= acbyRxRate[*pbyRxRate%MAX_RATE];
500 if (*pbyRxRate <= RATE_11M) {
501 if (BITbIsBitOn(*pbyRxSts, 0x01)) {
502 // long preamble
503 dwDuration += 192;
504 } else {
505 // short preamble
506 dwDuration += 96;
508 } else {
509 dwDuration += 16;
511 RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm);
512 ldBmThreshold = -57;
513 for (ii = 7; ii > 0;) {
514 if (ldBm > ldBmThreshold) {
515 break;
517 ldBmThreshold -= 5;
518 ii--;
520 pDevice->dwRPIs[ii] += dwDuration;
521 return FALSE;
524 if (!IS_MULTICAST_ADDRESS(pbyFrame) && !IS_BROADCAST_ADDRESS(pbyFrame)) {
525 if (WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header) (skb->data + 4))) {
526 pDevice->s802_11Counter.FrameDuplicateCount++;
527 return FALSE;
532 // Use for TKIP MIC
533 s_vGetDASA(skb->data+4, &cbHeaderSize, &pDevice->sRxEthHeader);
535 // filter packet send from myself
536 if (IS_ETH_ADDRESS_EQUAL((PBYTE)&(pDevice->sRxEthHeader.abySrcAddr[0]), pDevice->abyCurrentNetAddr))
537 return FALSE;
539 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) {
540 if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) {
541 p802_11Header = (PS802_11Header) (pbyFrame);
542 // get SA NodeIndex
543 if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(p802_11Header->abyAddr2), &iSANodeIndex)) {
544 #ifdef PRIVATE_OBJ
545 pMgmt->sNodeDBTable[iSANodeIndex].ulLastRxJiffer = get_jiffies();
546 #else
547 pMgmt->sNodeDBTable[iSANodeIndex].ulLastRxJiffer = jiffies;
548 #endif
549 pMgmt->sNodeDBTable[iSANodeIndex].uInActiveCount = 0;
554 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
555 if (s_bAPModeRxCtl(pDevice, pbyFrame, iSANodeIndex) == TRUE) {
556 return FALSE;
559 if (IS_FC_WEP(pbyFrame)) {
560 BOOL bRxDecryOK = FALSE;
562 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rx WEP pkt\n");
563 bIsWEP = TRUE;
564 if ((pDevice->bEnableHostWEP) && (iSANodeIndex >= 0)) {
565 pKey = &STempKey;
566 pKey->byCipherSuite = pMgmt->sNodeDBTable[iSANodeIndex].byCipherSuite;
567 pKey->dwKeyIndex = pMgmt->sNodeDBTable[iSANodeIndex].dwKeyIndex;
568 pKey->uKeyLength = pMgmt->sNodeDBTable[iSANodeIndex].uWepKeyLength;
569 pKey->dwTSC47_16 = pMgmt->sNodeDBTable[iSANodeIndex].dwTSC47_16;
570 pKey->wTSC15_0 = pMgmt->sNodeDBTable[iSANodeIndex].wTSC15_0;
571 memcpy(pKey->abyKey,
572 &pMgmt->sNodeDBTable[iSANodeIndex].abyWepKey[0],
573 pKey->uKeyLength
576 bRxDecryOK = s_bHostWepRxEncryption(pDevice,
577 pbyFrame,
578 FrameSize,
579 pbyRsr,
580 pMgmt->sNodeDBTable[iSANodeIndex].bOnFly,
581 pKey,
582 pbyNewRsr,
583 &bExtIV,
584 &wRxTSC15_0,
585 &dwRxTSC47_16);
586 } else {
587 bRxDecryOK = s_bHandleRxEncryption(pDevice,
588 pbyFrame,
589 FrameSize,
590 pbyRsr,
591 pbyNewRsr,
592 &pKey,
593 &bExtIV,
594 &wRxTSC15_0,
595 &dwRxTSC47_16);
598 if (bRxDecryOK) {
599 if ((*pbyNewRsr & NEWRSR_DECRYPTOK) == 0) {
600 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV Fail\n");
601 if ( (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
602 (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
603 (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) ||
604 (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
605 (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
607 if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) {
608 pDevice->s802_11Counter.TKIPICVErrors++;
609 } else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP)) {
610 pDevice->s802_11Counter.CCMPDecryptErrors++;
611 } else if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_WEP)) {
612 // pDevice->s802_11Counter.WEPICVErrorCount.QuadPart++;
615 return FALSE;
617 } else {
618 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WEP Func Fail\n");
619 return FALSE;
621 if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_CCMP))
622 FrameSize -= 8; // Message Integrity Code
623 else
624 FrameSize -= 4; // 4 is ICV
629 // RX OK
631 //remove the CRC length
632 FrameSize -= U_CRC_LEN;
634 if ((BITbIsAllBitsOff(*pbyRsr, (RSR_ADDRBROAD | RSR_ADDRMULTI))) && // unicast address
635 (IS_FRAGMENT_PKT((skb->data+4)))
637 // defragment
638 bDeFragRx = WCTLbHandleFragment(pDevice, (PS802_11Header) (skb->data+4), FrameSize, bIsWEP, bExtIV);
639 pDevice->s802_11Counter.ReceivedFragmentCount++;
640 if (bDeFragRx) {
641 // defrag complete
642 #ifdef PRIVATE_OBJ
643 skb = &(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].ref_skb);
644 #else
645 skb = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb;
646 #endif
647 FrameSize = pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength;
650 else {
651 return FALSE;
656 // Management & Control frame Handle
657 if ((IS_TYPE_DATA((skb->data+4))) == FALSE) {
658 // Handle Control & Manage Frame
660 if (IS_TYPE_MGMT((skb->data+4))) {
661 PBYTE pbyData1;
662 PBYTE pbyData2;
664 pRxPacket->p80211Header = (PUWLAN_80211HDR)(skb->data+4);
665 pRxPacket->cbMPDULen = FrameSize;
666 pRxPacket->uRSSI = *pbyRSSI;
667 pRxPacket->bySQ = *pbySQ;
668 HIDWORD(pRxPacket->qwLocalTSF) = cpu_to_le32(HIDWORD(*pqwTSFTime));
669 LODWORD(pRxPacket->qwLocalTSF) = cpu_to_le32(LODWORD(*pqwTSFTime));
670 if (bIsWEP) {
671 // strip IV
672 pbyData1 = WLAN_HDR_A3_DATA_PTR(skb->data+4);
673 pbyData2 = WLAN_HDR_A3_DATA_PTR(skb->data+4) + 4;
674 for (ii = 0; ii < (FrameSize - 4); ii++) {
675 *pbyData1 = *pbyData2;
676 pbyData1++;
677 pbyData2++;
680 pRxPacket->byRxRate = s_byGetRateIdx(*pbyRxRate);
681 pRxPacket->byRxChannel = (*pbyRxSts) >> 2;
682 //PLICE_DEBUG->
683 //EnQueue(pDevice,pRxPacket);
685 #ifdef THREAD
686 EnQueue(pDevice,pRxPacket);
688 //printk("enque time is %x\n",jiffies);
689 //up(&pDevice->mlme_semaphore);
690 //Enque (pDevice->FirstRecvMngList,pDevice->LastRecvMngList,pMgmt);
691 #else
693 #ifdef TASK_LET
694 EnQueue(pDevice,pRxPacket);
695 tasklet_schedule(&pDevice->RxMngWorkItem);
696 #else
697 //printk("RxMan\n");
698 vMgrRxManagePacket((HANDLE)pDevice, pDevice->pMgmt, pRxPacket);
699 //tasklet_schedule(&pDevice->RxMngWorkItem);
700 #endif
702 #endif
703 //PLICE_DEBUG<-
704 //vMgrRxManagePacket((HANDLE)pDevice, pDevice->pMgmt, pRxPacket);
705 // hostap Deamon handle 802.11 management
706 if (pDevice->bEnableHostapd) {
707 skb->dev = pDevice->apdev;
708 #ifdef PRIVATE_OBJ
709 ref_skb_add_offset(skb->skb, 4);
710 ref_skb_set_dev(pDevice->apdev, skb->skb);
711 skb_put(skb->skb, FrameSize);
712 skb->mac_header = skb->data;
713 *(skb->pkt_type) = PACKET_OTHERHOST;
714 *(skb->protocol) = htons(ETH_P_802_2);
715 memset(skb->cb, 0, sizeof(skb->cb));
716 netif_rx(skb->skb);
717 #else
718 skb->data += 4;
719 skb->tail += 4;
720 skb_put(skb, FrameSize);
721 skb->mac_header = skb->data;
722 skb->pkt_type = PACKET_OTHERHOST;
723 skb->protocol = htons(ETH_P_802_2);
724 memset(skb->cb, 0, sizeof(skb->cb));
725 netif_rx(skb);
726 #endif
727 return TRUE;
730 else {
731 // Control Frame
733 return FALSE;
735 else {
736 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
737 //In AP mode, hw only check addr1(BSSID or RA) if equal to local MAC.
738 if (BITbIsBitOff(*pbyRsr, RSR_BSSIDOK)) {
739 if (bDeFragRx) {
740 if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
741 DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
742 pDevice->dev->name);
745 return FALSE;
748 else {
749 // discard DATA packet while not associate || BSSID error
750 if ((pDevice->bLinkPass == FALSE) ||
751 BITbIsBitOff(*pbyRsr, RSR_BSSIDOK)) {
752 if (bDeFragRx) {
753 if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
754 DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
755 pDevice->dev->name);
758 return FALSE;
761 //mike add:station mode check eapol-key challenge--->
763 BYTE Protocol_Version; //802.1x Authentication
764 BYTE Packet_Type; //802.1x Authentication
765 if (bIsWEP)
766 cbIVOffset = 8;
767 else
768 cbIVOffset = 0;
769 wEtherType = (skb->data[cbIVOffset + 8 + 24 + 6] << 8) |
770 skb->data[cbIVOffset + 8 + 24 + 6 + 1];
771 Protocol_Version = skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1];
772 Packet_Type = skb->data[cbIVOffset + 8 + 24 + 6 + 1 +1+1];
773 if (wEtherType == ETH_P_PAE) { //Protocol Type in LLC-Header
774 if(((Protocol_Version==1) ||(Protocol_Version==2)) &&
775 (Packet_Type==3)) { //802.1x OR eapol-key challenge frame receive
776 bRxeapol_key = TRUE;
780 //mike add:station mode check eapol-key challenge<---
784 // Data frame Handle
786 if (pDevice->bEnablePSMode) {
787 if (IS_FC_MOREDATA((skb->data+4))) {
788 if (BITbIsBitOn(*pbyRsr, RSR_ADDROK)) {
789 //PSbSendPSPOLL((PSDevice)pDevice);
792 else {
793 if (pDevice->pMgmt->bInTIMWake == TRUE) {
794 pDevice->pMgmt->bInTIMWake = FALSE;
799 // Now it only supports 802.11g Infrastructure Mode, and support rate must up to 54 Mbps
800 if (pDevice->bDiversityEnable && (FrameSize>50) &&
801 (pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) &&
802 (pDevice->bLinkPass == TRUE)) {
803 //printk("device_receive_frame: RxRate is %d\n",*pbyRxRate);
804 BBvAntennaDiversity(pDevice, s_byGetRateIdx(*pbyRxRate), 0);
808 if (pDevice->byLocalID != REV_ID_VT3253_B1) {
809 pDevice->uCurrRSSI = *pbyRSSI;
811 pDevice->byCurrSQ = *pbySQ;
813 if ((*pbyRSSI != 0) &&
814 (pMgmt->pCurrBSS!=NULL)) {
815 RFvRSSITodBm(pDevice, *pbyRSSI, &ldBm);
816 // Moniter if RSSI is too strong.
817 pMgmt->pCurrBSS->byRSSIStatCnt++;
818 pMgmt->pCurrBSS->byRSSIStatCnt %= RSSI_STAT_COUNT;
819 pMgmt->pCurrBSS->ldBmAverage[pMgmt->pCurrBSS->byRSSIStatCnt] = ldBm;
820 for(ii=0;ii<RSSI_STAT_COUNT;ii++) {
821 if (pMgmt->pCurrBSS->ldBmAverage[ii] != 0) {
822 pMgmt->pCurrBSS->ldBmMAX = max(pMgmt->pCurrBSS->ldBmAverage[ii], ldBm);
827 // -----------------------------------------------
829 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pDevice->bEnable8021x == TRUE)){
830 BYTE abyMacHdr[24];
832 // Only 802.1x packet incoming allowed
833 if (bIsWEP)
834 cbIVOffset = 8;
835 else
836 cbIVOffset = 0;
837 wEtherType = (skb->data[cbIVOffset + 4 + 24 + 6] << 8) |
838 skb->data[cbIVOffset + 4 + 24 + 6 + 1];
840 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wEtherType = %04x \n", wEtherType);
841 if (wEtherType == ETH_P_PAE) {
842 skb->dev = pDevice->apdev;
844 if (bIsWEP == TRUE) {
845 // strip IV header(8)
846 memcpy(&abyMacHdr[0], (skb->data + 4), 24);
847 memcpy((skb->data + 4 + cbIVOffset), &abyMacHdr[0], 24);
849 #ifdef PRIVATE_OBJ
850 ref_skb_add_offset(skb->skb, (cbIVOffset + 4));
851 ref_skb_set_dev(pDevice->apdev, skb->skb);
852 skb_put(skb->skb, FrameSize);
853 skb->mac_header = skb->data;
854 *(skb->pkt_type) = PACKET_OTHERHOST;
855 *(skb->protocol) = htons(ETH_P_802_2);
856 memset(skb->cb, 0, sizeof(skb->cb));
857 netif_rx(skb->skb);
858 #else
859 skb->data += (cbIVOffset + 4);
860 skb->tail += (cbIVOffset + 4);
861 skb_put(skb, FrameSize);
862 skb->mac_header = skb->data;
864 skb->pkt_type = PACKET_OTHERHOST;
865 skb->protocol = htons(ETH_P_802_2);
866 memset(skb->cb, 0, sizeof(skb->cb));
867 netif_rx(skb);
868 #endif
869 return TRUE;
872 // check if 802.1x authorized
873 if (!(pMgmt->sNodeDBTable[iSANodeIndex].dwFlags & WLAN_STA_AUTHORIZED))
874 return FALSE;
878 if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) {
879 if (bIsWEP) {
880 FrameSize -= 8; //MIC
884 //--------------------------------------------------------------------------------
885 // Soft MIC
886 if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) {
887 if (bIsWEP) {
888 PDWORD pdwMIC_L;
889 PDWORD pdwMIC_R;
890 DWORD dwMIC_Priority;
891 DWORD dwMICKey0 = 0, dwMICKey1 = 0;
892 DWORD dwLocalMIC_L = 0;
893 DWORD dwLocalMIC_R = 0;
894 viawget_wpa_header *wpahdr;
897 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
898 dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[24]));
899 dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[28]));
901 else {
902 if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) {
903 dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[16]));
904 dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[20]));
905 } else if ((pKey->dwKeyIndex & BIT28) == 0) {
906 dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[16]));
907 dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[20]));
908 } else {
909 dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[24]));
910 dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[28]));
914 MIC_vInit(dwMICKey0, dwMICKey1);
915 MIC_vAppend((PBYTE)&(pDevice->sRxEthHeader.abyDstAddr[0]), 12);
916 dwMIC_Priority = 0;
917 MIC_vAppend((PBYTE)&dwMIC_Priority, 4);
918 // 4 is Rcv buffer header, 24 is MAC Header, and 8 is IV and Ext IV.
919 MIC_vAppend((PBYTE)(skb->data + 4 + WLAN_HDR_ADDR3_LEN + 8),
920 FrameSize - WLAN_HDR_ADDR3_LEN - 8);
921 MIC_vGetMIC(&dwLocalMIC_L, &dwLocalMIC_R);
922 MIC_vUnInit();
924 pdwMIC_L = (PDWORD)(skb->data + 4 + FrameSize);
925 pdwMIC_R = (PDWORD)(skb->data + 4 + FrameSize + 4);
926 //DBG_PRN_GRP12(("RxL: %lx, RxR: %lx\n", *pdwMIC_L, *pdwMIC_R));
927 //DBG_PRN_GRP12(("LocalL: %lx, LocalR: %lx\n", dwLocalMIC_L, dwLocalMIC_R));
928 //DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwMICKey0= %lx,dwMICKey1= %lx \n", dwMICKey0, dwMICKey1);
931 if ((cpu_to_le32(*pdwMIC_L) != dwLocalMIC_L) || (cpu_to_le32(*pdwMIC_R) != dwLocalMIC_R) ||
932 (pDevice->bRxMICFail == TRUE)) {
933 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC comparison is fail!\n");
934 pDevice->bRxMICFail = FALSE;
935 //pDevice->s802_11Counter.TKIPLocalMICFailures.QuadPart++;
936 pDevice->s802_11Counter.TKIPLocalMICFailures++;
937 if (bDeFragRx) {
938 if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
939 DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
940 pDevice->dev->name);
944 //2008-0409-07, <Add> by Einsn Liu
945 #ifdef WPA_SUPPLICANT_DRIVER_WEXT_SUPPORT
946 //send event to wpa_supplicant
947 //if(pDevice->bWPADevEnable == TRUE)
949 union iwreq_data wrqu;
950 struct iw_michaelmicfailure ev;
951 int keyidx = pbyFrame[cbHeaderSize+3] >> 6; //top two-bits
952 memset(&ev, 0, sizeof(ev));
953 ev.flags = keyidx & IW_MICFAILURE_KEY_ID;
954 if ((pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
955 (pMgmt->eCurrState == WMAC_STATE_ASSOC) &&
956 (*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) {
957 ev.flags |= IW_MICFAILURE_PAIRWISE;
958 } else {
959 ev.flags |= IW_MICFAILURE_GROUP;
962 ev.src_addr.sa_family = ARPHRD_ETHER;
963 memcpy(ev.src_addr.sa_data, pMACHeader->abyAddr2, ETH_ALEN);
964 memset(&wrqu, 0, sizeof(wrqu));
965 wrqu.data.length = sizeof(ev);
966 wireless_send_event(pDevice->dev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev);
969 #endif
970 if ((pDevice->bWPADEVUp) && (pDevice->skb != NULL)) {
971 wpahdr = (viawget_wpa_header *)pDevice->skb->data;
972 if ((pDevice->pMgmt->eCurrMode == WMAC_MODE_ESS_STA) &&
973 (pDevice->pMgmt->eCurrState == WMAC_STATE_ASSOC) &&
974 (*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) {
975 //s802_11_Status.Flags = NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR;
976 wpahdr->type = VIAWGET_PTK_MIC_MSG;
977 } else {
978 //s802_11_Status.Flags = NDIS_802_11_AUTH_REQUEST_GROUP_ERROR;
979 wpahdr->type = VIAWGET_GTK_MIC_MSG;
981 wpahdr->resp_ie_len = 0;
982 wpahdr->req_ie_len = 0;
983 skb_put(pDevice->skb, sizeof(viawget_wpa_header));
984 pDevice->skb->dev = pDevice->wpadev;
985 pDevice->skb->mac_header = pDevice->skb->data;
986 pDevice->skb->pkt_type = PACKET_HOST;
987 pDevice->skb->protocol = htons(ETH_P_802_2);
988 memset(pDevice->skb->cb, 0, sizeof(pDevice->skb->cb));
989 netif_rx(pDevice->skb);
990 pDevice->skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
993 return FALSE;
997 } //---end of SOFT MIC-----------------------------------------------------------------------
999 // ++++++++++ Reply Counter Check +++++++++++++
1001 if ((pKey != NULL) && ((pKey->byCipherSuite == KEY_CTL_TKIP) ||
1002 (pKey->byCipherSuite == KEY_CTL_CCMP))) {
1003 if (bIsWEP) {
1004 WORD wLocalTSC15_0 = 0;
1005 DWORD dwLocalTSC47_16 = 0;
1006 ULONGLONG RSC = 0;
1007 // endian issues
1008 RSC = *((ULONGLONG *) &(pKey->KeyRSC));
1009 wLocalTSC15_0 = (WORD) RSC;
1010 dwLocalTSC47_16 = (DWORD) (RSC>>16);
1012 RSC = dwRxTSC47_16;
1013 RSC <<= 16;
1014 RSC += wRxTSC15_0;
1015 MEMvCopy(&(pKey->KeyRSC), &RSC, sizeof(QWORD));
1017 if ( (pDevice->sMgmtObj.eCurrMode == WMAC_MODE_ESS_STA) &&
1018 (pDevice->sMgmtObj.eCurrState == WMAC_STATE_ASSOC)) {
1019 // check RSC
1020 if ( (wRxTSC15_0 < wLocalTSC15_0) &&
1021 (dwRxTSC47_16 <= dwLocalTSC47_16) &&
1022 !((dwRxTSC47_16 == 0) && (dwLocalTSC47_16 == 0xFFFFFFFF))) {
1023 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC is illegal~~!\n ");
1024 if (pKey->byCipherSuite == KEY_CTL_TKIP)
1025 //pDevice->s802_11Counter.TKIPReplays.QuadPart++;
1026 pDevice->s802_11Counter.TKIPReplays++;
1027 else
1028 //pDevice->s802_11Counter.CCMPReplays.QuadPart++;
1029 pDevice->s802_11Counter.CCMPReplays++;
1031 if (bDeFragRx) {
1032 if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
1033 DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
1034 pDevice->dev->name);
1037 return FALSE;
1041 } // ----- End of Reply Counter Check --------------------------
1045 if ((pKey != NULL) && (bIsWEP)) {
1046 // pDevice->s802_11Counter.DecryptSuccessCount.QuadPart++;
1050 s_vProcessRxMACHeader(pDevice, (PBYTE)(skb->data+4), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset);
1051 FrameSize -= cbHeaderOffset;
1052 cbHeaderOffset += 4; // 4 is Rcv buffer header
1054 // Null data, framesize = 14
1055 if (FrameSize < 15)
1056 return FALSE;
1058 if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) {
1059 if (s_bAPModeRxData(pDevice,
1060 skb,
1061 FrameSize,
1062 cbHeaderOffset,
1063 iSANodeIndex,
1064 iDANodeIndex
1065 ) == FALSE) {
1067 if (bDeFragRx) {
1068 if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
1069 DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
1070 pDevice->dev->name);
1073 return FALSE;
1076 // if(pDevice->bRxMICFail == FALSE) {
1077 // for (ii =0; ii < 100; ii++)
1078 // printk(" %02x", *(skb->data + ii));
1079 // printk("\n");
1080 // }
1084 #ifdef PRIVATE_OBJ
1085 ref_skb_add_offset(skb->skb, cbHeaderOffset);
1086 skb_put(skb->skb, FrameSize);
1087 *(skb->protocol)=eth_type_trans(skb->skb, skb->dev);
1089 #else
1090 skb->data += cbHeaderOffset;
1091 skb->tail += cbHeaderOffset;
1092 skb_put(skb, FrameSize);
1093 skb->protocol=eth_type_trans(skb, skb->dev);
1094 #endif
1097 //drop frame not met IEEE 802.3
1099 if (pDevice->flags & DEVICE_FLAGS_VAL_PKT_LEN) {
1100 #ifdef PRIVATE_OBJ
1101 if ((*(skb->protocol)==htons(ETH_P_802_3)) &&
1102 (*(skb->len)!=htons(skb->mac.ethernet->h_proto))) {
1103 #else
1104 if ((skb->protocol==htons(ETH_P_802_3)) &&
1105 (skb->len!=htons(skb->mac.ethernet->h_proto))) {
1106 #endif
1107 pStats->rx_length_errors++;
1108 pStats->rx_dropped++;
1109 if (bDeFragRx) {
1110 if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
1111 DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
1112 pDevice->dev->name);
1115 return FALSE;
1120 #ifdef PRIVATE_OBJ
1121 *(skb->ip_summed)=CHECKSUM_NONE;
1122 pStats->rx_bytes +=*(skb->len);
1123 pStats->rx_packets++;
1124 netif_rx(skb->skb);
1125 #else
1126 skb->ip_summed=CHECKSUM_NONE;
1127 pStats->rx_bytes +=skb->len;
1128 pStats->rx_packets++;
1129 netif_rx(skb);
1130 #endif
1132 if (bDeFragRx) {
1133 if (!device_alloc_frag_buf(pDevice, &pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx])) {
1134 DEVICE_PRT(MSG_LEVEL_ERR,KERN_ERR "%s: can not alloc more frag bufs\n",
1135 pDevice->dev->name);
1137 return FALSE;
1139 return TRUE;
1143 static BOOL s_bAPModeRxCtl (
1144 IN PSDevice pDevice,
1145 IN PBYTE pbyFrame,
1146 IN INT iSANodeIndex
1149 PS802_11Header p802_11Header;
1150 CMD_STATUS Status;
1151 PSMgmtObject pMgmt = pDevice->pMgmt;
1154 if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) {
1156 p802_11Header = (PS802_11Header) (pbyFrame);
1157 if (!IS_TYPE_MGMT(pbyFrame)) {
1159 // Data & PS-Poll packet
1160 // check frame class
1161 if (iSANodeIndex > 0) {
1162 // frame class 3 fliter & checking
1163 if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_AUTH) {
1164 // send deauth notification
1165 // reason = (6) class 2 received from nonauth sta
1166 vMgrDeAuthenBeginSta(pDevice,
1167 pMgmt,
1168 (PBYTE)(p802_11Header->abyAddr2),
1169 (WLAN_MGMT_REASON_CLASS2_NONAUTH),
1170 &Status
1172 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 1\n");
1173 return TRUE;
1175 if (pMgmt->sNodeDBTable[iSANodeIndex].eNodeState < NODE_ASSOC) {
1176 // send deassoc notification
1177 // reason = (7) class 3 received from nonassoc sta
1178 vMgrDisassocBeginSta(pDevice,
1179 pMgmt,
1180 (PBYTE)(p802_11Header->abyAddr2),
1181 (WLAN_MGMT_REASON_CLASS3_NONASSOC),
1182 &Status
1184 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDisassocBeginSta 2\n");
1185 return TRUE;
1188 if (pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable) {
1189 // delcare received ps-poll event
1190 if (IS_CTL_PSPOLL(pbyFrame)) {
1191 pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = TRUE;
1192 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
1193 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 1\n");
1195 else {
1196 // check Data PS state
1197 // if PW bit off, send out all PS bufferring packets.
1198 if (!IS_FC_POWERMGT(pbyFrame)) {
1199 pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = FALSE;
1200 pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = TRUE;
1201 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
1202 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 2\n");
1206 else {
1207 if (IS_FC_POWERMGT(pbyFrame)) {
1208 pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = TRUE;
1209 // Once if STA in PS state, enable multicast bufferring
1210 pMgmt->sNodeDBTable[0].bPSEnable = TRUE;
1212 else {
1213 // clear all pending PS frame.
1214 if (pMgmt->sNodeDBTable[iSANodeIndex].wEnQueueCnt > 0) {
1215 pMgmt->sNodeDBTable[iSANodeIndex].bPSEnable = FALSE;
1216 pMgmt->sNodeDBTable[iSANodeIndex].bRxPSPoll = TRUE;
1217 bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL);
1218 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: WLAN_CMD_RX_PSPOLL 3\n");
1224 else {
1225 vMgrDeAuthenBeginSta(pDevice,
1226 pMgmt,
1227 (PBYTE)(p802_11Header->abyAddr2),
1228 (WLAN_MGMT_REASON_CLASS2_NONAUTH),
1229 &Status
1231 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: send vMgrDeAuthenBeginSta 3\n");
1232 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "BSSID:%02x-%02x-%02x=%02x-%02x-%02x \n",
1233 p802_11Header->abyAddr3[0],
1234 p802_11Header->abyAddr3[1],
1235 p802_11Header->abyAddr3[2],
1236 p802_11Header->abyAddr3[3],
1237 p802_11Header->abyAddr3[4],
1238 p802_11Header->abyAddr3[5]
1240 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR2:%02x-%02x-%02x=%02x-%02x-%02x \n",
1241 p802_11Header->abyAddr2[0],
1242 p802_11Header->abyAddr2[1],
1243 p802_11Header->abyAddr2[2],
1244 p802_11Header->abyAddr2[3],
1245 p802_11Header->abyAddr2[4],
1246 p802_11Header->abyAddr2[5]
1248 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "ADDR1:%02x-%02x-%02x=%02x-%02x-%02x \n",
1249 p802_11Header->abyAddr1[0],
1250 p802_11Header->abyAddr1[1],
1251 p802_11Header->abyAddr1[2],
1252 p802_11Header->abyAddr1[3],
1253 p802_11Header->abyAddr1[4],
1254 p802_11Header->abyAddr1[5]
1256 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc: wFrameCtl= %x\n", p802_11Header->wFrameCtl );
1257 VNSvInPortB(pDevice->PortOffset + MAC_REG_RCR, &(pDevice->byRxMode));
1258 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "dpc:pDevice->byRxMode = %x\n", pDevice->byRxMode );
1259 return TRUE;
1263 return FALSE;
1267 static BOOL s_bHandleRxEncryption (
1268 IN PSDevice pDevice,
1269 IN PBYTE pbyFrame,
1270 IN UINT FrameSize,
1271 IN PBYTE pbyRsr,
1272 OUT PBYTE pbyNewRsr,
1273 OUT PSKeyItem *pKeyOut,
1274 OUT PBOOL pbExtIV,
1275 OUT PWORD pwRxTSC15_0,
1276 OUT PDWORD pdwRxTSC47_16
1279 UINT PayloadLen = FrameSize;
1280 PBYTE pbyIV;
1281 BYTE byKeyIdx;
1282 PSKeyItem pKey = NULL;
1283 BYTE byDecMode = KEY_CTL_WEP;
1284 PSMgmtObject pMgmt = pDevice->pMgmt;
1287 *pwRxTSC15_0 = 0;
1288 *pdwRxTSC47_16 = 0;
1290 pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
1291 if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) &&
1292 WLAN_GET_FC_FROMDS(*(PWORD)pbyFrame) ) {
1293 pbyIV += 6; // 6 is 802.11 address4
1294 PayloadLen -= 6;
1296 byKeyIdx = (*(pbyIV+3) & 0xc0);
1297 byKeyIdx >>= 6;
1298 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\nKeyIdx: %d\n", byKeyIdx);
1300 if ((pMgmt->eAuthenMode == WMAC_AUTH_WPA) ||
1301 (pMgmt->eAuthenMode == WMAC_AUTH_WPAPSK) ||
1302 (pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) ||
1303 (pMgmt->eAuthenMode == WMAC_AUTH_WPA2) ||
1304 (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) {
1305 if (((*pbyRsr & (RSR_ADDRBROAD | RSR_ADDRMULTI)) == 0) &&
1306 (pDevice->pMgmt->byCSSPK != KEY_CTL_NONE)) {
1307 // unicast pkt use pairwise key
1308 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"unicast pkt\n");
1309 if (KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, 0xFFFFFFFF, &pKey) == TRUE) {
1310 if (pDevice->pMgmt->byCSSPK == KEY_CTL_TKIP)
1311 byDecMode = KEY_CTL_TKIP;
1312 else if (pDevice->pMgmt->byCSSPK == KEY_CTL_CCMP)
1313 byDecMode = KEY_CTL_CCMP;
1315 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"unicast pkt: %d, %p\n", byDecMode, pKey);
1316 } else {
1317 // use group key
1318 KeybGetKey(&(pDevice->sKey), pDevice->abyBSSID, byKeyIdx, &pKey);
1319 if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP)
1320 byDecMode = KEY_CTL_TKIP;
1321 else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP)
1322 byDecMode = KEY_CTL_CCMP;
1323 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"group pkt: %d, %d, %p\n", byKeyIdx, byDecMode, pKey);
1326 // our WEP only support Default Key
1327 if (pKey == NULL) {
1328 // use default group key
1329 KeybGetKey(&(pDevice->sKey), pDevice->abyBroadcastAddr, byKeyIdx, &pKey);
1330 if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP)
1331 byDecMode = KEY_CTL_TKIP;
1332 else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP)
1333 byDecMode = KEY_CTL_CCMP;
1335 *pKeyOut = pKey;
1337 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"AES:%d %d %d\n", pDevice->pMgmt->byCSSPK, pDevice->pMgmt->byCSSGK, byDecMode);
1339 if (pKey == NULL) {
1340 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pKey == NULL\n");
1341 if (byDecMode == KEY_CTL_WEP) {
1342 // pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++;
1343 } else if (pDevice->bLinkPass == TRUE) {
1344 // pDevice->s802_11Counter.DecryptFailureCount.QuadPart++;
1346 return FALSE;
1348 if (byDecMode != pKey->byCipherSuite) {
1349 if (byDecMode == KEY_CTL_WEP) {
1350 // pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++;
1351 } else if (pDevice->bLinkPass == TRUE) {
1352 // pDevice->s802_11Counter.DecryptFailureCount.QuadPart++;
1354 *pKeyOut = NULL;
1355 return FALSE;
1357 if (byDecMode == KEY_CTL_WEP) {
1358 // handle WEP
1359 if ((pDevice->byLocalID <= REV_ID_VT3253_A1) ||
1360 (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == TRUE)) {
1361 // Software WEP
1362 // 1. 3253A
1363 // 2. WEP 256
1365 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc
1366 MEMvCopy(pDevice->abyPRNG, pbyIV, 3);
1367 MEMvCopy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength);
1368 rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3);
1369 rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen);
1371 if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) {
1372 *pbyNewRsr |= NEWRSR_DECRYPTOK;
1375 } else if ((byDecMode == KEY_CTL_TKIP) ||
1376 (byDecMode == KEY_CTL_CCMP)) {
1377 // TKIP/AES
1379 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc
1380 *pdwRxTSC47_16 = cpu_to_le32(*(PDWORD)(pbyIV + 4));
1381 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %lx\n",*pdwRxTSC47_16);
1382 if (byDecMode == KEY_CTL_TKIP) {
1383 *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV));
1384 } else {
1385 *pwRxTSC15_0 = cpu_to_le16(*(PWORD)pbyIV);
1387 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC0_15: %x\n", *pwRxTSC15_0);
1389 if ((byDecMode == KEY_CTL_TKIP) &&
1390 (pDevice->byLocalID <= REV_ID_VT3253_A1)) {
1391 // Software TKIP
1392 // 1. 3253 A
1393 PS802_11Header pMACHeader = (PS802_11Header) (pbyFrame);
1394 TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG);
1395 rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN);
1396 rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen);
1397 if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) {
1398 *pbyNewRsr |= NEWRSR_DECRYPTOK;
1399 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV OK!\n");
1400 } else {
1401 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV FAIL!!!\n");
1402 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PayloadLen = %d\n", PayloadLen);
1405 }// end of TKIP/AES
1407 if ((*(pbyIV+3) & 0x20) != 0)
1408 *pbExtIV = TRUE;
1409 return TRUE;
1413 static BOOL s_bHostWepRxEncryption (
1414 IN PSDevice pDevice,
1415 IN PBYTE pbyFrame,
1416 IN UINT FrameSize,
1417 IN PBYTE pbyRsr,
1418 IN BOOL bOnFly,
1419 IN PSKeyItem pKey,
1420 OUT PBYTE pbyNewRsr,
1421 OUT PBOOL pbExtIV,
1422 OUT PWORD pwRxTSC15_0,
1423 OUT PDWORD pdwRxTSC47_16
1426 UINT PayloadLen = FrameSize;
1427 PBYTE pbyIV;
1428 BYTE byKeyIdx;
1429 BYTE byDecMode = KEY_CTL_WEP;
1430 PS802_11Header pMACHeader;
1434 *pwRxTSC15_0 = 0;
1435 *pdwRxTSC47_16 = 0;
1437 pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN;
1438 if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) &&
1439 WLAN_GET_FC_FROMDS(*(PWORD)pbyFrame) ) {
1440 pbyIV += 6; // 6 is 802.11 address4
1441 PayloadLen -= 6;
1443 byKeyIdx = (*(pbyIV+3) & 0xc0);
1444 byKeyIdx >>= 6;
1445 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\nKeyIdx: %d\n", byKeyIdx);
1448 if (pDevice->pMgmt->byCSSGK == KEY_CTL_TKIP)
1449 byDecMode = KEY_CTL_TKIP;
1450 else if (pDevice->pMgmt->byCSSGK == KEY_CTL_CCMP)
1451 byDecMode = KEY_CTL_CCMP;
1453 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"AES:%d %d %d\n", pDevice->pMgmt->byCSSPK, pDevice->pMgmt->byCSSGK, byDecMode);
1455 if (byDecMode != pKey->byCipherSuite) {
1456 if (byDecMode == KEY_CTL_WEP) {
1457 // pDevice->s802_11Counter.WEPUndecryptableCount.QuadPart++;
1458 } else if (pDevice->bLinkPass == TRUE) {
1459 // pDevice->s802_11Counter.DecryptFailureCount.QuadPart++;
1461 return FALSE;
1464 if (byDecMode == KEY_CTL_WEP) {
1465 // handle WEP
1466 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"byDecMode == KEY_CTL_WEP \n");
1467 if ((pDevice->byLocalID <= REV_ID_VT3253_A1) ||
1468 (((PSKeyTable)(pKey->pvKeyTable))->bSoftWEP == TRUE) ||
1469 (bOnFly == FALSE)) {
1470 // Software WEP
1471 // 1. 3253A
1472 // 2. WEP 256
1473 // 3. NotOnFly
1475 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 4 + 4); // 24 is 802.11 header,4 is IV, 4 is crc
1476 MEMvCopy(pDevice->abyPRNG, pbyIV, 3);
1477 MEMvCopy(pDevice->abyPRNG + 3, pKey->abyKey, pKey->uKeyLength);
1478 rc4_init(&pDevice->SBox, pDevice->abyPRNG, pKey->uKeyLength + 3);
1479 rc4_encrypt(&pDevice->SBox, pbyIV+4, pbyIV+4, PayloadLen);
1481 if (ETHbIsBufferCrc32Ok(pbyIV+4, PayloadLen)) {
1482 *pbyNewRsr |= NEWRSR_DECRYPTOK;
1485 } else if ((byDecMode == KEY_CTL_TKIP) ||
1486 (byDecMode == KEY_CTL_CCMP)) {
1487 // TKIP/AES
1489 PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc
1490 *pdwRxTSC47_16 = cpu_to_le32(*(PDWORD)(pbyIV + 4));
1491 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %lx\n",*pdwRxTSC47_16);
1493 if (byDecMode == KEY_CTL_TKIP) {
1494 *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV));
1495 } else {
1496 *pwRxTSC15_0 = cpu_to_le16(*(PWORD)pbyIV);
1498 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC0_15: %x\n", *pwRxTSC15_0);
1500 if (byDecMode == KEY_CTL_TKIP) {
1501 if ((pDevice->byLocalID <= REV_ID_VT3253_A1) || (bOnFly == FALSE)) {
1502 // Software TKIP
1503 // 1. 3253 A
1504 // 2. NotOnFly
1505 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_TKIP \n");
1506 pMACHeader = (PS802_11Header) (pbyFrame);
1507 TKIPvMixKey(pKey->abyKey, pMACHeader->abyAddr2, *pwRxTSC15_0, *pdwRxTSC47_16, pDevice->abyPRNG);
1508 rc4_init(&pDevice->SBox, pDevice->abyPRNG, TKIP_KEY_LEN);
1509 rc4_encrypt(&pDevice->SBox, pbyIV+8, pbyIV+8, PayloadLen);
1510 if (ETHbIsBufferCrc32Ok(pbyIV+8, PayloadLen)) {
1511 *pbyNewRsr |= NEWRSR_DECRYPTOK;
1512 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV OK!\n");
1513 } else {
1514 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ICV FAIL!!!\n");
1515 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"PayloadLen = %d\n", PayloadLen);
1520 if (byDecMode == KEY_CTL_CCMP) {
1521 if (bOnFly == FALSE) {
1522 // Software CCMP
1523 // NotOnFly
1524 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"soft KEY_CTL_CCMP\n");
1525 if (AESbGenCCMP(pKey->abyKey, pbyFrame, FrameSize)) {
1526 *pbyNewRsr |= NEWRSR_DECRYPTOK;
1527 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC compare OK!\n");
1528 } else {
1529 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO"CCMP MIC fail!\n");
1534 }// end of TKIP/AES
1536 if ((*(pbyIV+3) & 0x20) != 0)
1537 *pbExtIV = TRUE;
1538 return TRUE;
1544 #ifdef PRIVATE_OBJ
1546 static BOOL s_bAPModeRxData (
1547 IN PSDevice pDevice,
1548 IN ref_sk_buff* skb,
1549 IN UINT FrameSize,
1550 IN UINT cbHeaderOffset,
1551 IN INT iSANodeIndex,
1552 IN INT iDANodeIndex
1555 #else
1557 static BOOL s_bAPModeRxData (
1558 IN PSDevice pDevice,
1559 IN struct sk_buff* skb,
1560 IN UINT FrameSize,
1561 IN UINT cbHeaderOffset,
1562 IN INT iSANodeIndex,
1563 IN INT iDANodeIndex
1565 #endif
1567 PSMgmtObject pMgmt = pDevice->pMgmt;
1568 BOOL bRelayAndForward = FALSE;
1569 BOOL bRelayOnly = FALSE;
1570 BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
1571 WORD wAID;
1572 #ifdef PRIVATE_OBJ
1573 struct sk_buff* tmp_skb;
1574 ref_sk_buff s_ref_skb;
1575 ref_sk_buff* skbcpy = &s_ref_skb;
1576 #else
1577 struct sk_buff* skbcpy = NULL;
1578 #endif
1582 if (FrameSize > CB_MAX_BUF_SIZE)
1583 return FALSE;
1584 // check DA
1585 if(IS_MULTICAST_ADDRESS((PBYTE)(skb->data+cbHeaderOffset))) {
1586 if (pMgmt->sNodeDBTable[0].bPSEnable) {
1588 #ifdef PRIVATE_OBJ
1589 tmp_skb = dev_alloc_skb((int)pDevice->rx_buf_sz);
1590 skbcpy = &s_ref_skb;
1591 ref_skb_remap(pDevice->dev, skbcpy, tmp_skb);
1592 #else
1593 skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz);
1594 #endif
1595 // if any node in PS mode, buffer packet until DTIM.
1596 if (skbcpy == NULL) {
1597 DEVICE_PRT(MSG_LEVEL_NOTICE, KERN_INFO "relay multicast no skb available \n");
1599 else {
1600 skbcpy->dev = pDevice->dev;
1601 #ifdef PRIVATE_OBJ
1602 *(skbcpy->len) = FrameSize;
1603 memcpy(skbcpy->data, skb->data+cbHeaderOffset, FrameSize);
1604 skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy->skb);
1605 #else
1606 skbcpy->len = FrameSize;
1607 memcpy(skbcpy->data, skb->data+cbHeaderOffset, FrameSize);
1608 skb_queue_tail(&(pMgmt->sNodeDBTable[0].sTxPSQueue), skbcpy);
1609 #endif
1610 pMgmt->sNodeDBTable[0].wEnQueueCnt++;
1611 // set tx map
1612 pMgmt->abyPSTxMap[0] |= byMask[0];
1615 else {
1616 bRelayAndForward = TRUE;
1619 else {
1620 // check if relay
1621 if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(skb->data+cbHeaderOffset), &iDANodeIndex)) {
1622 if (pMgmt->sNodeDBTable[iDANodeIndex].eNodeState >= NODE_ASSOC) {
1623 if (pMgmt->sNodeDBTable[iDANodeIndex].bPSEnable) {
1624 // queue this skb until next PS tx, and then release.
1626 #ifdef PRIVATE_OBJ
1627 ref_skb_add_offset(skb->skb, cbHeaderOffset);
1628 skb_put(skb->skb, FrameSize);
1629 skb_queue_tail(&pMgmt->sNodeDBTable[iDANodeIndex].sTxPSQueue, skb->skb);
1630 #else
1631 skb->data += cbHeaderOffset;
1632 skb->tail += cbHeaderOffset;
1633 skb_put(skb, FrameSize);
1634 skb_queue_tail(&pMgmt->sNodeDBTable[iDANodeIndex].sTxPSQueue, skb);
1635 #endif
1636 pMgmt->sNodeDBTable[iDANodeIndex].wEnQueueCnt++;
1637 wAID = pMgmt->sNodeDBTable[iDANodeIndex].wAID;
1638 pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7];
1639 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "relay: index= %d, pMgmt->abyPSTxMap[%d]= %d\n",
1640 iDANodeIndex, (wAID >> 3), pMgmt->abyPSTxMap[wAID >> 3]);
1641 return TRUE;
1643 else {
1644 bRelayOnly = TRUE;
1650 if (bRelayOnly || bRelayAndForward) {
1651 // relay this packet right now
1652 if (bRelayAndForward)
1653 iDANodeIndex = 0;
1655 if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0)) {
1656 ROUTEbRelay(pDevice, (PBYTE)(skb->data + cbHeaderOffset), FrameSize, (UINT)iDANodeIndex);
1659 if (bRelayOnly)
1660 return FALSE;
1662 // none associate, don't forward
1663 if (pDevice->uAssocCount == 0)
1664 return FALSE;
1666 return TRUE;