jbd: Fix a race between checkpointing code and journal_get_write_access()
[linux/fpc-iii.git] / drivers / staging / vt6655 / 80211mgr.c
blob84745fb6b03515d94ebdb76e99bb9878f7c0376b
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.
20 * File: 80211mgr.c
22 * Purpose: Handles the 802.11 managment support functions
24 * Author: Lyndon Chen
26 * Date: May 8, 2002
28 * Functions:
29 * vMgrEncodeBeacon - Encode the Beacon frame
30 * vMgrDecodeBeacon - Decode the Beacon frame
31 * vMgrEncodeIBSSATIM - Encode the IBSS ATIM frame
32 * vMgrDecodeIBSSATIM - Decode the IBSS ATIM frame
33 * vMgrEncodeDisassociation - Encode the Disassociation frame
34 * vMgrDecodeDisassociation - Decode the Disassociation frame
35 * vMgrEncodeAssocRequest - Encode the Association request frame
36 * vMgrDecodeAssocRequest - Decode the Association request frame
37 * vMgrEncodeAssocResponse - Encode the Association response frame
38 * vMgrDecodeAssocResponse - Decode the Association response frame
39 * vMgrEncodeReAssocRequest - Encode the ReAssociation request frame
40 * vMgrDecodeReAssocRequest - Decode the ReAssociation request frame
41 * vMgrEncodeProbeRequest - Encode the Probe request frame
42 * vMgrDecodeProbeRequest - Decode the Probe request frame
43 * vMgrEncodeProbeResponse - Encode the Probe response frame
44 * vMgrDecodeProbeResponse - Decode the Probe response frame
45 * vMgrEncodeAuthen - Encode the Authentication frame
46 * vMgrDecodeAuthen - Decode the Authentication frame
47 * vMgrEncodeDeauthen - Encode the DeAuthentication frame
48 * vMgrDecodeDeauthen - Decode the DeAuthentication frame
49 * vMgrEncodeReassocResponse - Encode the Reassociation response frame
50 * vMgrDecodeReassocResponse - Decode the Reassociation response frame
52 * Revision History:
58 #if !defined(__TMACRO_H__)
59 #include "tmacro.h"
60 #endif
61 #if !defined(__TETHER_H__)
62 #include "tether.h"
63 #endif
64 #if !defined(__80211MGR_H__)
65 #include "80211mgr.h"
66 #endif
67 #if !defined(__80211HDR_H__)
68 #include "80211hdr.h"
69 #endif
70 #if !defined(__DEVICE_H__)
71 #include "device.h"
72 #endif
73 #if !defined(__WPA_H__)
74 #include "wpa.h"
75 #endif
79 /*--------------------- Static Definitions -------------------------*/
83 /*--------------------- Static Classes ----------------------------*/
85 /*--------------------- Static Variables --------------------------*/
87 static int msglevel =MSG_LEVEL_INFO;
88 //static int msglevel =MSG_LEVEL_DEBUG;
89 /*--------------------- Static Functions --------------------------*/
93 /*--------------------- Export Variables --------------------------*/
96 /*--------------------- Export Functions --------------------------*/
99 /*+
101 * Routine Description:
102 * Encode Beacon frame body offset
104 * Return Value:
105 * None.
109 VOID
110 vMgrEncodeBeacon(
111 IN PWLAN_FR_BEACON pFrame
114 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
116 // Fixed Fields
117 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
118 + WLAN_BEACON_OFF_TS);
119 pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
120 + WLAN_BEACON_OFF_BCN_INT);
121 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
122 + WLAN_BEACON_OFF_CAPINFO);
124 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
126 return;
131 * Routine Description:
132 * Decode Beacon frame body offset
135 * Return Value:
136 * None.
141 VOID
142 vMgrDecodeBeacon(
143 IN PWLAN_FR_BEACON pFrame
146 PWLAN_IE pItem;
148 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
150 // Fixed Fields
151 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
152 + WLAN_BEACON_OFF_TS);
153 pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
154 + WLAN_BEACON_OFF_BCN_INT);
155 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
156 + WLAN_BEACON_OFF_CAPINFO);
158 // Information elements
159 pItem = (PWLAN_IE)((PBYTE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
160 + WLAN_BEACON_OFF_SSID);
161 while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ){
163 switch (pItem->byElementID) {
164 case WLAN_EID_SSID:
165 if (pFrame->pSSID == NULL)
166 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
167 break;
168 case WLAN_EID_SUPP_RATES:
169 if (pFrame->pSuppRates == NULL)
170 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
171 break;
172 case WLAN_EID_FH_PARMS:
173 //pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem;
174 break;
175 case WLAN_EID_DS_PARMS:
176 if (pFrame->pDSParms == NULL)
177 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
178 break;
179 case WLAN_EID_CF_PARMS:
180 if (pFrame->pCFParms == NULL)
181 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
182 break;
183 case WLAN_EID_IBSS_PARMS:
184 if (pFrame->pIBSSParms == NULL)
185 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
186 break;
187 case WLAN_EID_TIM:
188 if (pFrame->pTIM == NULL)
189 pFrame->pTIM = (PWLAN_IE_TIM)pItem;
190 break;
192 case WLAN_EID_RSN:
193 if (pFrame->pRSN == NULL) {
194 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
196 break;
197 case WLAN_EID_RSN_WPA:
198 if (pFrame->pRSNWPA == NULL) {
199 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
200 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
202 break;
204 case WLAN_EID_ERP:
205 if (pFrame->pERP == NULL)
206 pFrame->pERP = (PWLAN_IE_ERP)pItem;
207 break;
208 case WLAN_EID_EXTSUPP_RATES:
209 if (pFrame->pExtSuppRates == NULL)
210 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
211 break;
213 case WLAN_EID_COUNTRY: //7
214 if (pFrame->pIE_Country == NULL)
215 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
216 break;
218 case WLAN_EID_PWR_CONSTRAINT: //32
219 if (pFrame->pIE_PowerConstraint == NULL)
220 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
221 break;
223 case WLAN_EID_CH_SWITCH: //37
224 if (pFrame->pIE_CHSW == NULL)
225 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
226 break;
228 case WLAN_EID_QUIET: //40
229 if (pFrame->pIE_Quiet == NULL)
230 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
231 break;
233 case WLAN_EID_IBSS_DFS:
234 if (pFrame->pIE_IBSSDFS == NULL)
235 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
236 break;
238 default:
239 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
240 break;
243 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
246 return;
252 * Routine Description:
253 * Encode IBSS ATIM
256 * Return Value:
257 * None.
262 VOID
263 vMgrEncodeIBSSATIM(
264 IN PWLAN_FR_IBSSATIM pFrame
267 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
268 pFrame->len = WLAN_HDR_ADDR3_LEN;
270 return;
276 * Routine Description:
277 * Decode IBSS ATIM
280 * Return Value:
281 * None.
285 VOID
286 vMgrDecodeIBSSATIM(
287 IN PWLAN_FR_IBSSATIM pFrame
290 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
292 return;
298 * Routine Description:
299 * Encode Disassociation
302 * Return Value:
303 * None.
307 VOID
308 vMgrEncodeDisassociation(
309 IN PWLAN_FR_DISASSOC pFrame
312 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
315 // Fixed Fields
316 pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
317 + WLAN_DISASSOC_OFF_REASON);
318 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
320 return;
326 * Routine Description:
327 * Decode Disassociation
330 * Return Value:
331 * None.
335 VOID
336 vMgrDecodeDisassociation(
337 IN PWLAN_FR_DISASSOC pFrame
340 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
342 // Fixed Fields
343 pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
344 + WLAN_DISASSOC_OFF_REASON);
346 return;
351 * Routine Description:
352 * Encode Association Request
355 * Return Value:
356 * None.
361 VOID
362 vMgrEncodeAssocRequest(
363 IN PWLAN_FR_ASSOCREQ pFrame
366 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
367 // Fixed Fields
368 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
369 + WLAN_ASSOCREQ_OFF_CAP_INFO);
370 pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
371 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
372 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
373 return;
379 * Routine Description: (AP)
380 * Decode Association Request
383 * Return Value:
384 * None.
388 VOID
389 vMgrDecodeAssocRequest(
390 IN PWLAN_FR_ASSOCREQ pFrame
393 PWLAN_IE pItem;
395 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
396 // Fixed Fields
397 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
398 + WLAN_ASSOCREQ_OFF_CAP_INFO);
399 pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
400 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
402 // Information elements
403 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
404 + WLAN_ASSOCREQ_OFF_SSID);
406 while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
407 switch (pItem->byElementID){
408 case WLAN_EID_SSID:
409 if (pFrame->pSSID == NULL)
410 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
411 break;
412 case WLAN_EID_SUPP_RATES:
413 if (pFrame->pSuppRates == NULL)
414 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
415 break;
417 case WLAN_EID_RSN:
418 if (pFrame->pRSN == NULL) {
419 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
421 break;
422 case WLAN_EID_RSN_WPA:
423 if (pFrame->pRSNWPA == NULL) {
424 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
425 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
427 break;
428 case WLAN_EID_EXTSUPP_RATES:
429 if (pFrame->pExtSuppRates == NULL)
430 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
431 break;
433 default:
434 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
435 pItem->byElementID);
436 break;
438 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
440 return;
445 * Routine Description: (AP)
446 * Encode Association Response
449 * Return Value:
450 * None.
454 VOID
455 vMgrEncodeAssocResponse(
456 IN PWLAN_FR_ASSOCRESP pFrame
459 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
461 // Fixed Fields
462 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
463 + WLAN_ASSOCRESP_OFF_CAP_INFO);
464 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
465 + WLAN_ASSOCRESP_OFF_STATUS);
466 pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
467 + WLAN_ASSOCRESP_OFF_AID);
468 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
469 + sizeof(*(pFrame->pwAid));
471 return;
477 * Routine Description:
478 * Decode Association Response
481 * Return Value:
482 * None.
486 VOID
487 vMgrDecodeAssocResponse(
488 IN PWLAN_FR_ASSOCRESP pFrame
491 PWLAN_IE pItem;
493 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
495 // Fixed Fields
496 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
497 + WLAN_ASSOCRESP_OFF_CAP_INFO);
498 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
499 + WLAN_ASSOCRESP_OFF_STATUS);
500 pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
501 + WLAN_ASSOCRESP_OFF_AID);
503 // Information elements
504 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
505 + WLAN_ASSOCRESP_OFF_SUPP_RATES);
507 pItem = (PWLAN_IE)(pFrame->pSuppRates);
508 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
510 if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
511 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
512 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
514 else {
515 pFrame->pExtSuppRates = NULL;
517 return;
523 * Routine Description:
524 * Encode Reassociation Request
527 * Return Value:
528 * None.
532 VOID
533 vMgrEncodeReassocRequest(
534 IN PWLAN_FR_REASSOCREQ pFrame
537 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
539 // Fixed Fields
540 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
541 + WLAN_REASSOCREQ_OFF_CAP_INFO);
542 pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
543 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
544 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
545 + WLAN_REASSOCREQ_OFF_CURR_AP);
546 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
548 return;
554 * Routine Description: (AP)
555 * Decode Reassociation Request
558 * Return Value:
559 * None.
564 VOID
565 vMgrDecodeReassocRequest(
566 IN PWLAN_FR_REASSOCREQ pFrame
569 PWLAN_IE pItem;
570 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
572 // Fixed Fields
573 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
574 + WLAN_REASSOCREQ_OFF_CAP_INFO);
575 pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
576 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
577 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
578 + WLAN_REASSOCREQ_OFF_CURR_AP);
580 // Information elements
581 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
582 + WLAN_REASSOCREQ_OFF_SSID);
584 while(((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
586 switch (pItem->byElementID){
587 case WLAN_EID_SSID:
588 if (pFrame->pSSID == NULL)
589 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
590 break;
591 case WLAN_EID_SUPP_RATES:
592 if (pFrame->pSuppRates == NULL)
593 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
594 break;
596 case WLAN_EID_RSN:
597 if (pFrame->pRSN == NULL) {
598 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
600 break;
601 case WLAN_EID_RSN_WPA:
602 if (pFrame->pRSNWPA == NULL) {
603 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
604 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
606 break;
608 case WLAN_EID_EXTSUPP_RATES:
609 if (pFrame->pExtSuppRates == NULL)
610 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
611 break;
612 default:
613 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n",
614 pItem->byElementID);
615 break;
617 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
619 return;
626 * Routine Description:
627 * Encode Probe Request
630 * Return Value:
631 * None.
636 VOID
637 vMgrEncodeProbeRequest(
638 IN PWLAN_FR_PROBEREQ pFrame
641 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
642 pFrame->len = WLAN_HDR_ADDR3_LEN;
643 return;
648 * Routine Description:
649 * Decode Probe Request
652 * Return Value:
653 * None.
657 VOID
658 vMgrDecodeProbeRequest(
659 IN PWLAN_FR_PROBEREQ pFrame
662 PWLAN_IE pItem;
664 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
666 // Information elements
667 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
669 while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ) {
671 switch (pItem->byElementID) {
672 case WLAN_EID_SSID:
673 if (pFrame->pSSID == NULL)
674 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
675 break;
677 case WLAN_EID_SUPP_RATES:
678 if (pFrame->pSuppRates == NULL)
679 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
680 break;
682 case WLAN_EID_EXTSUPP_RATES:
683 if (pFrame->pExtSuppRates == NULL)
684 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
685 break;
687 default:
688 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
689 break;
692 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
694 return;
700 * Routine Description:
701 * Encode Probe Response
704 * Return Value:
705 * None.
710 VOID
711 vMgrEncodeProbeResponse(
712 IN PWLAN_FR_PROBERESP pFrame
715 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
717 // Fixed Fields
718 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
719 + WLAN_PROBERESP_OFF_TS);
720 pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
721 + WLAN_PROBERESP_OFF_BCN_INT);
722 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
723 + WLAN_PROBERESP_OFF_CAP_INFO);
725 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
726 sizeof(*(pFrame->pwCapInfo));
728 return;
735 * Routine Description:
736 * Decode Probe Response
739 * Return Value:
740 * None.
744 VOID
745 vMgrDecodeProbeResponse(
746 IN PWLAN_FR_PROBERESP pFrame
749 PWLAN_IE pItem;
750 // BYTE byCheckEID = 0;
753 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
755 // Fixed Fields
756 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
757 + WLAN_PROBERESP_OFF_TS);
758 pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
759 + WLAN_PROBERESP_OFF_BCN_INT);
760 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
761 + WLAN_PROBERESP_OFF_CAP_INFO);
763 // Information elements
764 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
765 + WLAN_PROBERESP_OFF_SSID);
767 while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ) {
769 if (pItem->byElementID < byCheckEID)
770 break;
771 else
772 byCheckEID = pItem->byElementID;
774 switch (pItem->byElementID) {
775 case WLAN_EID_SSID:
776 if (pFrame->pSSID == NULL)
777 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
778 break;
779 case WLAN_EID_SUPP_RATES:
780 if (pFrame->pSuppRates == NULL)
781 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
782 break;
783 case WLAN_EID_FH_PARMS:
784 break;
785 case WLAN_EID_DS_PARMS:
786 if (pFrame->pDSParms == NULL)
787 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
788 break;
789 case WLAN_EID_CF_PARMS:
790 if (pFrame->pCFParms == NULL)
791 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
792 break;
793 case WLAN_EID_IBSS_PARMS:
794 if (pFrame->pIBSSParms == NULL)
795 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
796 break;
798 case WLAN_EID_RSN:
799 if (pFrame->pRSN == NULL) {
800 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
802 break;
803 case WLAN_EID_RSN_WPA:
804 if (pFrame->pRSNWPA == NULL) {
805 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
806 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
808 break;
809 case WLAN_EID_ERP:
810 if (pFrame->pERP == NULL)
811 pFrame->pERP = (PWLAN_IE_ERP)pItem;
812 break;
813 case WLAN_EID_EXTSUPP_RATES:
814 if (pFrame->pExtSuppRates == NULL)
815 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
816 break;
818 case WLAN_EID_COUNTRY: //7
819 if (pFrame->pIE_Country == NULL)
820 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
821 break;
823 case WLAN_EID_PWR_CONSTRAINT: //32
824 if (pFrame->pIE_PowerConstraint == NULL)
825 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
826 break;
828 case WLAN_EID_CH_SWITCH: //37
829 if (pFrame->pIE_CHSW == NULL)
830 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
831 break;
833 case WLAN_EID_QUIET: //40
834 if (pFrame->pIE_Quiet == NULL)
835 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
836 break;
838 case WLAN_EID_IBSS_DFS:
839 if (pFrame->pIE_IBSSDFS == NULL)
840 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
841 break;
843 default:
844 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
845 break;
848 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
850 return;
856 * Routine Description:
857 * Encode Authentication frame
860 * Return Value:
861 * None.
865 VOID
866 vMgrEncodeAuthen(
867 IN PWLAN_FR_AUTHEN pFrame
870 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
872 // Fixed Fields
873 pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
874 + WLAN_AUTHEN_OFF_AUTH_ALG);
875 pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
876 + WLAN_AUTHEN_OFF_AUTH_SEQ);
877 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
878 + WLAN_AUTHEN_OFF_STATUS);
879 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
881 return;
887 * Routine Description:
888 * Decode Authentication
891 * Return Value:
892 * None.
896 VOID
897 vMgrDecodeAuthen(
898 IN PWLAN_FR_AUTHEN pFrame
901 PWLAN_IE pItem;
903 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
905 // Fixed Fields
906 pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
907 + WLAN_AUTHEN_OFF_AUTH_ALG);
908 pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
909 + WLAN_AUTHEN_OFF_AUTH_SEQ);
910 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
911 + WLAN_AUTHEN_OFF_STATUS);
913 // Information elements
914 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
915 + WLAN_AUTHEN_OFF_CHALLENGE);
917 if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) {
918 pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
921 return;
927 * Routine Description:
928 * Encode Authentication
931 * Return Value:
932 * None.
936 VOID
937 vMgrEncodeDeauthen(
938 IN PWLAN_FR_DEAUTHEN pFrame
941 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
943 // Fixed Fields
944 pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
945 + WLAN_DEAUTHEN_OFF_REASON);
946 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
948 return;
954 * Routine Description:
955 * Decode Deauthentication
958 * Return Value:
959 * None.
963 VOID
964 vMgrDecodeDeauthen(
965 IN PWLAN_FR_DEAUTHEN pFrame
968 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
970 // Fixed Fields
971 pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
972 + WLAN_DEAUTHEN_OFF_REASON);
974 return;
980 * Routine Description: (AP)
981 * Encode Reassociation Response
984 * Return Value:
985 * None.
989 VOID
990 vMgrEncodeReassocResponse(
991 IN PWLAN_FR_REASSOCRESP pFrame
994 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
996 // Fixed Fields
997 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
998 + WLAN_REASSOCRESP_OFF_CAP_INFO);
999 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
1000 + WLAN_REASSOCRESP_OFF_STATUS);
1001 pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
1002 + WLAN_REASSOCRESP_OFF_AID);
1004 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
1006 return;
1012 * Routine Description:
1013 * Decode Reassociation Response
1016 * Return Value:
1017 * None.
1022 VOID
1023 vMgrDecodeReassocResponse(
1024 IN PWLAN_FR_REASSOCRESP pFrame
1027 PWLAN_IE pItem;
1029 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
1031 // Fixed Fields
1032 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
1033 + WLAN_REASSOCRESP_OFF_CAP_INFO);
1034 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
1035 + WLAN_REASSOCRESP_OFF_STATUS);
1036 pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
1037 + WLAN_REASSOCRESP_OFF_AID);
1039 //Information elements
1040 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
1041 + WLAN_REASSOCRESP_OFF_SUPP_RATES);
1043 pItem = (PWLAN_IE)(pFrame->pSuppRates);
1044 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
1046 if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
1047 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
1049 return;