x86/xen: resume timer irqs early
[linux/fpc-iii.git] / drivers / staging / vt6655 / 80211mgr.c
blob76c8490b0734d212297e8fb00583c73bbaa5716b
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: 80211mgr.c
21 * Purpose: Handles the 802.11 management support functions
23 * Author: Lyndon Chen
25 * Date: May 8, 2002
27 * Functions:
28 * vMgrEncodeBeacon - Encode the Beacon frame
29 * vMgrDecodeBeacon - Decode the Beacon frame
30 * vMgrEncodeIBSSATIM - Encode the IBSS ATIM frame
31 * vMgrDecodeIBSSATIM - Decode the IBSS ATIM frame
32 * vMgrEncodeDisassociation - Encode the Disassociation frame
33 * vMgrDecodeDisassociation - Decode the Disassociation frame
34 * vMgrEncodeAssocRequest - Encode the Association request frame
35 * vMgrDecodeAssocRequest - Decode the Association request frame
36 * vMgrEncodeAssocResponse - Encode the Association response frame
37 * vMgrDecodeAssocResponse - Decode the Association response frame
38 * vMgrEncodeReAssocRequest - Encode the ReAssociation request frame
39 * vMgrDecodeReAssocRequest - Decode the ReAssociation request frame
40 * vMgrEncodeProbeRequest - Encode the Probe request frame
41 * vMgrDecodeProbeRequest - Decode the Probe request frame
42 * vMgrEncodeProbeResponse - Encode the Probe response frame
43 * vMgrDecodeProbeResponse - Decode the Probe response frame
44 * vMgrEncodeAuthen - Encode the Authentication frame
45 * vMgrDecodeAuthen - Decode the Authentication frame
46 * vMgrEncodeDeauthen - Encode the DeAuthentication frame
47 * vMgrDecodeDeauthen - Decode the DeAuthentication frame
48 * vMgrEncodeReassocResponse - Encode the Reassociation response frame
49 * vMgrDecodeReassocResponse - Decode the Reassociation response frame
51 * Revision History:
55 #include "tmacro.h"
56 #include "tether.h"
57 #include "80211mgr.h"
58 #include "80211hdr.h"
59 #include "device.h"
60 #include "wpa.h"
62 /*--------------------- Static Definitions -------------------------*/
64 /*--------------------- Static Classes ----------------------------*/
66 /*--------------------- Static Variables --------------------------*/
68 static int msglevel = MSG_LEVEL_INFO;
69 /* static int msglevel =MSG_LEVEL_DEBUG; */
70 /*--------------------- Static Functions --------------------------*/
72 /*--------------------- Export Variables --------------------------*/
74 /*--------------------- Export Functions --------------------------*/
76 /*+
78 * Routine Description:
79 * Encode Beacon frame body offset
81 * Return Value:
82 * None.
84 -*/
86 void
87 vMgrEncodeBeacon(
88 PWLAN_FR_BEACON pFrame
91 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
93 /* Fixed Fields */
94 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
95 + WLAN_BEACON_OFF_TS);
96 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
97 + WLAN_BEACON_OFF_BCN_INT);
98 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
99 + WLAN_BEACON_OFF_CAPINFO);
101 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
103 return;
108 * Routine Description:
109 * Decode Beacon frame body offset
112 * Return Value:
113 * None.
117 void
118 vMgrDecodeBeacon(
119 PWLAN_FR_BEACON pFrame
122 PWLAN_IE pItem;
124 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
126 /* Fixed Fields */
127 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
128 + WLAN_BEACON_OFF_TS);
129 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
130 + WLAN_BEACON_OFF_BCN_INT);
131 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
132 + WLAN_BEACON_OFF_CAPINFO);
134 /* Information elements */
135 pItem = (PWLAN_IE)((unsigned char *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
136 + WLAN_BEACON_OFF_SSID);
137 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
138 switch (pItem->byElementID) {
139 case WLAN_EID_SSID:
140 if (pFrame->pSSID == NULL)
141 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
142 break;
143 case WLAN_EID_SUPP_RATES:
144 if (pFrame->pSuppRates == NULL)
145 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
146 break;
147 case WLAN_EID_FH_PARMS:
148 /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */
149 break;
150 case WLAN_EID_DS_PARMS:
151 if (pFrame->pDSParms == NULL)
152 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
153 break;
154 case WLAN_EID_CF_PARMS:
155 if (pFrame->pCFParms == NULL)
156 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
157 break;
158 case WLAN_EID_IBSS_PARMS:
159 if (pFrame->pIBSSParms == NULL)
160 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
161 break;
162 case WLAN_EID_TIM:
163 if (pFrame->pTIM == NULL)
164 pFrame->pTIM = (PWLAN_IE_TIM)pItem;
165 break;
167 case WLAN_EID_RSN:
168 if (pFrame->pRSN == NULL) {
169 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
171 break;
172 case WLAN_EID_RSN_WPA:
173 if (pFrame->pRSNWPA == NULL) {
174 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
175 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
177 break;
179 case WLAN_EID_ERP:
180 if (pFrame->pERP == NULL)
181 pFrame->pERP = (PWLAN_IE_ERP)pItem;
182 break;
183 case WLAN_EID_EXTSUPP_RATES:
184 if (pFrame->pExtSuppRates == NULL)
185 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
186 break;
188 case WLAN_EID_COUNTRY: /* 7 */
189 if (pFrame->pIE_Country == NULL)
190 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
191 break;
193 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
194 if (pFrame->pIE_PowerConstraint == NULL)
195 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
196 break;
198 case WLAN_EID_CH_SWITCH: /* 37 */
199 if (pFrame->pIE_CHSW == NULL)
200 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
201 break;
203 case WLAN_EID_QUIET: /* 40 */
204 if (pFrame->pIE_Quiet == NULL)
205 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
206 break;
208 case WLAN_EID_IBSS_DFS:
209 if (pFrame->pIE_IBSSDFS == NULL)
210 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
211 break;
213 default:
214 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
215 break;
218 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
221 return;
226 * Routine Description:
227 * Encode IBSS ATIM
230 * Return Value:
231 * None.
235 void
236 vMgrEncodeIBSSATIM(
237 PWLAN_FR_IBSSATIM pFrame
240 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
241 pFrame->len = WLAN_HDR_ADDR3_LEN;
243 return;
248 * Routine Description:
249 * Decode IBSS ATIM
252 * Return Value:
253 * None.
257 void
258 vMgrDecodeIBSSATIM(
259 PWLAN_FR_IBSSATIM pFrame
262 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
264 return;
269 * Routine Description:
270 * Encode Disassociation
273 * Return Value:
274 * None.
278 void
279 vMgrEncodeDisassociation(
280 PWLAN_FR_DISASSOC pFrame
283 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
285 /* Fixed Fields */
286 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
287 + WLAN_DISASSOC_OFF_REASON);
288 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
290 return;
295 * Routine Description:
296 * Decode Disassociation
299 * Return Value:
300 * None.
304 void
305 vMgrDecodeDisassociation(
306 PWLAN_FR_DISASSOC pFrame
309 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
311 /* Fixed Fields */
312 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
313 + WLAN_DISASSOC_OFF_REASON);
315 return;
320 * Routine Description:
321 * Encode Association Request
324 * Return Value:
325 * None.
329 void
330 vMgrEncodeAssocRequest(
331 PWLAN_FR_ASSOCREQ pFrame
334 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
335 /* Fixed Fields */
336 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
337 + WLAN_ASSOCREQ_OFF_CAP_INFO);
338 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
339 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
340 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
341 return;
346 * Routine Description: (AP)
347 * Decode Association Request
350 * Return Value:
351 * None.
355 void
356 vMgrDecodeAssocRequest(
357 PWLAN_FR_ASSOCREQ pFrame
360 PWLAN_IE pItem;
362 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
363 /* Fixed Fields */
364 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
365 + WLAN_ASSOCREQ_OFF_CAP_INFO);
366 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
367 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
369 /* Information elements */
370 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
371 + WLAN_ASSOCREQ_OFF_SSID);
373 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
374 switch (pItem->byElementID) {
375 case WLAN_EID_SSID:
376 if (pFrame->pSSID == NULL)
377 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
378 break;
379 case WLAN_EID_SUPP_RATES:
380 if (pFrame->pSuppRates == NULL)
381 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
382 break;
384 case WLAN_EID_RSN:
385 if (pFrame->pRSN == NULL) {
386 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
388 break;
389 case WLAN_EID_RSN_WPA:
390 if (pFrame->pRSNWPA == NULL) {
391 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
392 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
394 break;
395 case WLAN_EID_EXTSUPP_RATES:
396 if (pFrame->pExtSuppRates == NULL)
397 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
398 break;
400 default:
401 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
402 pItem->byElementID);
403 break;
405 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
407 return;
412 * Routine Description: (AP)
413 * Encode Association Response
416 * Return Value:
417 * None.
421 void
422 vMgrEncodeAssocResponse(
423 PWLAN_FR_ASSOCRESP pFrame
426 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
428 /* Fixed Fields */
429 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
430 + WLAN_ASSOCRESP_OFF_CAP_INFO);
431 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
432 + WLAN_ASSOCRESP_OFF_STATUS);
433 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
434 + WLAN_ASSOCRESP_OFF_AID);
435 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
436 + sizeof(*(pFrame->pwAid));
438 return;
443 * Routine Description:
444 * Decode Association Response
447 * Return Value:
448 * None.
452 void
453 vMgrDecodeAssocResponse(
454 PWLAN_FR_ASSOCRESP pFrame
457 PWLAN_IE pItem;
459 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
461 /* Fixed Fields */
462 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
463 + WLAN_ASSOCRESP_OFF_CAP_INFO);
464 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
465 + WLAN_ASSOCRESP_OFF_STATUS);
466 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
467 + WLAN_ASSOCRESP_OFF_AID);
469 /* Information elements */
470 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
471 + WLAN_ASSOCRESP_OFF_SUPP_RATES);
473 pItem = (PWLAN_IE)(pFrame->pSuppRates);
474 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
476 if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) &&
477 (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
478 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
479 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
480 } else {
481 pFrame->pExtSuppRates = NULL;
483 return;
488 * Routine Description:
489 * Encode Reassociation Request
492 * Return Value:
493 * None.
497 void
498 vMgrEncodeReassocRequest(
499 PWLAN_FR_REASSOCREQ pFrame
502 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
504 /* Fixed Fields */
505 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
506 + WLAN_REASSOCREQ_OFF_CAP_INFO);
507 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
508 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
509 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
510 + WLAN_REASSOCREQ_OFF_CURR_AP);
511 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
513 return;
518 * Routine Description: (AP)
519 * Decode Reassociation Request
522 * Return Value:
523 * None.
527 void
528 vMgrDecodeReassocRequest(
529 PWLAN_FR_REASSOCREQ pFrame
532 PWLAN_IE pItem;
533 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
535 /* Fixed Fields */
536 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
537 + WLAN_REASSOCREQ_OFF_CAP_INFO);
538 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
539 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
540 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
541 + WLAN_REASSOCREQ_OFF_CURR_AP);
543 /* Information elements */
544 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
545 + WLAN_REASSOCREQ_OFF_SSID);
547 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
548 switch (pItem->byElementID) {
549 case WLAN_EID_SSID:
550 if (pFrame->pSSID == NULL)
551 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
552 break;
553 case WLAN_EID_SUPP_RATES:
554 if (pFrame->pSuppRates == NULL)
555 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
556 break;
558 case WLAN_EID_RSN:
559 if (pFrame->pRSN == NULL) {
560 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
562 break;
563 case WLAN_EID_RSN_WPA:
564 if (pFrame->pRSNWPA == NULL) {
565 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
566 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
568 break;
570 case WLAN_EID_EXTSUPP_RATES:
571 if (pFrame->pExtSuppRates == NULL)
572 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
573 break;
574 default:
575 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n",
576 pItem->byElementID);
577 break;
579 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
581 return;
586 * Routine Description:
587 * Encode Probe Request
590 * Return Value:
591 * None.
595 void
596 vMgrEncodeProbeRequest(
597 PWLAN_FR_PROBEREQ pFrame
600 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
601 pFrame->len = WLAN_HDR_ADDR3_LEN;
602 return;
607 * Routine Description:
608 * Decode Probe Request
611 * Return Value:
612 * None.
616 void
617 vMgrDecodeProbeRequest(
618 PWLAN_FR_PROBEREQ pFrame
621 PWLAN_IE pItem;
623 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
625 /* Information elements */
626 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
628 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
629 switch (pItem->byElementID) {
630 case WLAN_EID_SSID:
631 if (pFrame->pSSID == NULL)
632 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
633 break;
635 case WLAN_EID_SUPP_RATES:
636 if (pFrame->pSuppRates == NULL)
637 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
638 break;
640 case WLAN_EID_EXTSUPP_RATES:
641 if (pFrame->pExtSuppRates == NULL)
642 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
643 break;
645 default:
646 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
647 break;
650 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
652 return;
657 * Routine Description:
658 * Encode Probe Response
661 * Return Value:
662 * None.
666 void
667 vMgrEncodeProbeResponse(
668 PWLAN_FR_PROBERESP pFrame
671 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
673 /* Fixed Fields */
674 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
675 + WLAN_PROBERESP_OFF_TS);
676 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
677 + WLAN_PROBERESP_OFF_BCN_INT);
678 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
679 + WLAN_PROBERESP_OFF_CAP_INFO);
681 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
682 sizeof(*(pFrame->pwCapInfo));
684 return;
689 * Routine Description:
690 * Decode Probe Response
693 * Return Value:
694 * None.
698 void
699 vMgrDecodeProbeResponse(
700 PWLAN_FR_PROBERESP pFrame
703 PWLAN_IE pItem;
705 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
707 /* Fixed Fields */
708 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
709 + WLAN_PROBERESP_OFF_TS);
710 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
711 + WLAN_PROBERESP_OFF_BCN_INT);
712 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
713 + WLAN_PROBERESP_OFF_CAP_INFO);
715 /* Information elements */
716 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
717 + WLAN_PROBERESP_OFF_SSID);
719 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
720 switch (pItem->byElementID) {
721 case WLAN_EID_SSID:
722 if (pFrame->pSSID == NULL)
723 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
724 break;
725 case WLAN_EID_SUPP_RATES:
726 if (pFrame->pSuppRates == NULL)
727 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
728 break;
729 case WLAN_EID_FH_PARMS:
730 break;
731 case WLAN_EID_DS_PARMS:
732 if (pFrame->pDSParms == NULL)
733 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
734 break;
735 case WLAN_EID_CF_PARMS:
736 if (pFrame->pCFParms == NULL)
737 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
738 break;
739 case WLAN_EID_IBSS_PARMS:
740 if (pFrame->pIBSSParms == NULL)
741 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
742 break;
744 case WLAN_EID_RSN:
745 if (pFrame->pRSN == NULL) {
746 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
748 break;
749 case WLAN_EID_RSN_WPA:
750 if (pFrame->pRSNWPA == NULL) {
751 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
752 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
754 break;
755 case WLAN_EID_ERP:
756 if (pFrame->pERP == NULL)
757 pFrame->pERP = (PWLAN_IE_ERP)pItem;
758 break;
759 case WLAN_EID_EXTSUPP_RATES:
760 if (pFrame->pExtSuppRates == NULL)
761 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
762 break;
764 case WLAN_EID_COUNTRY: /* 7 */
765 if (pFrame->pIE_Country == NULL)
766 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
767 break;
769 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
770 if (pFrame->pIE_PowerConstraint == NULL)
771 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
772 break;
774 case WLAN_EID_CH_SWITCH: /* 37 */
775 if (pFrame->pIE_CHSW == NULL)
776 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
777 break;
779 case WLAN_EID_QUIET: /* 40 */
780 if (pFrame->pIE_Quiet == NULL)
781 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
782 break;
784 case WLAN_EID_IBSS_DFS:
785 if (pFrame->pIE_IBSSDFS == NULL)
786 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
787 break;
789 default:
790 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
791 break;
794 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
796 return;
801 * Routine Description:
802 * Encode Authentication frame
805 * Return Value:
806 * None.
810 void
811 vMgrEncodeAuthen(
812 PWLAN_FR_AUTHEN pFrame
815 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
817 /* Fixed Fields */
818 pFrame->pwAuthAlgorithm = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
819 + WLAN_AUTHEN_OFF_AUTH_ALG);
820 pFrame->pwAuthSequence = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
821 + WLAN_AUTHEN_OFF_AUTH_SEQ);
822 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
823 + WLAN_AUTHEN_OFF_STATUS);
824 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
826 return;
831 * Routine Description:
832 * Decode Authentication
835 * Return Value:
836 * None.
840 void
841 vMgrDecodeAuthen(
842 PWLAN_FR_AUTHEN pFrame
845 PWLAN_IE pItem;
847 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
849 /* Fixed Fields */
850 pFrame->pwAuthAlgorithm = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
851 + WLAN_AUTHEN_OFF_AUTH_ALG);
852 pFrame->pwAuthSequence = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
853 + WLAN_AUTHEN_OFF_AUTH_SEQ);
854 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
855 + WLAN_AUTHEN_OFF_STATUS);
857 /* Information elements */
858 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
859 + WLAN_AUTHEN_OFF_CHALLENGE);
861 if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) {
862 pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
865 return;
870 * Routine Description:
871 * Encode Authentication
874 * Return Value:
875 * None.
879 void
880 vMgrEncodeDeauthen(
881 PWLAN_FR_DEAUTHEN pFrame
884 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
886 /* Fixed Fields */
887 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
888 + WLAN_DEAUTHEN_OFF_REASON);
889 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
891 return;
896 * Routine Description:
897 * Decode Deauthentication
900 * Return Value:
901 * None.
905 void
906 vMgrDecodeDeauthen(
907 PWLAN_FR_DEAUTHEN pFrame
910 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
912 /* Fixed Fields */
913 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
914 + WLAN_DEAUTHEN_OFF_REASON);
916 return;
921 * Routine Description: (AP)
922 * Encode Reassociation Response
925 * Return Value:
926 * None.
930 void
931 vMgrEncodeReassocResponse(
932 PWLAN_FR_REASSOCRESP pFrame
935 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
937 /* Fixed Fields */
938 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
939 + WLAN_REASSOCRESP_OFF_CAP_INFO);
940 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
941 + WLAN_REASSOCRESP_OFF_STATUS);
942 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
943 + WLAN_REASSOCRESP_OFF_AID);
945 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
947 return;
952 * Routine Description:
953 * Decode Reassociation Response
956 * Return Value:
957 * None.
961 void
962 vMgrDecodeReassocResponse(
963 PWLAN_FR_REASSOCRESP pFrame
966 PWLAN_IE pItem;
968 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
970 /* Fixed Fields */
971 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
972 + WLAN_REASSOCRESP_OFF_CAP_INFO);
973 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
974 + WLAN_REASSOCRESP_OFF_STATUS);
975 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
976 + WLAN_REASSOCRESP_OFF_AID);
978 /* Information elements */
979 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
980 + WLAN_REASSOCRESP_OFF_SUPP_RATES);
982 pItem = (PWLAN_IE)(pFrame->pSuppRates);
983 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
985 if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) &&
986 (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
987 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
989 return;