Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux/fpc-iii.git] / drivers / staging / vt6655 / 80211mgr.c
blob7949d58ad7d153e8508556db9f4ef10f349e1c38
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;
170 break;
171 case WLAN_EID_RSN_WPA:
172 if (pFrame->pRSNWPA == NULL) {
173 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
174 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
176 break;
178 case WLAN_EID_ERP:
179 if (pFrame->pERP == NULL)
180 pFrame->pERP = (PWLAN_IE_ERP)pItem;
181 break;
182 case WLAN_EID_EXTSUPP_RATES:
183 if (pFrame->pExtSuppRates == NULL)
184 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
185 break;
187 case WLAN_EID_COUNTRY: /* 7 */
188 if (pFrame->pIE_Country == NULL)
189 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
190 break;
192 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
193 if (pFrame->pIE_PowerConstraint == NULL)
194 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
195 break;
197 case WLAN_EID_CH_SWITCH: /* 37 */
198 if (pFrame->pIE_CHSW == NULL)
199 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
200 break;
202 case WLAN_EID_QUIET: /* 40 */
203 if (pFrame->pIE_Quiet == NULL)
204 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
205 break;
207 case WLAN_EID_IBSS_DFS:
208 if (pFrame->pIE_IBSSDFS == NULL)
209 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
210 break;
212 default:
213 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
214 break;
217 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
220 return;
225 * Routine Description:
226 * Encode IBSS ATIM
229 * Return Value:
230 * None.
234 void
235 vMgrEncodeIBSSATIM(
236 PWLAN_FR_IBSSATIM pFrame
239 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
240 pFrame->len = WLAN_HDR_ADDR3_LEN;
242 return;
247 * Routine Description:
248 * Decode IBSS ATIM
251 * Return Value:
252 * None.
256 void
257 vMgrDecodeIBSSATIM(
258 PWLAN_FR_IBSSATIM pFrame
261 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
263 return;
268 * Routine Description:
269 * Encode Disassociation
272 * Return Value:
273 * None.
277 void
278 vMgrEncodeDisassociation(
279 PWLAN_FR_DISASSOC pFrame
282 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
284 /* Fixed Fields */
285 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
286 + WLAN_DISASSOC_OFF_REASON);
287 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
289 return;
294 * Routine Description:
295 * Decode Disassociation
298 * Return Value:
299 * None.
303 void
304 vMgrDecodeDisassociation(
305 PWLAN_FR_DISASSOC pFrame
308 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
310 /* Fixed Fields */
311 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
312 + WLAN_DISASSOC_OFF_REASON);
314 return;
319 * Routine Description:
320 * Encode Association Request
323 * Return Value:
324 * None.
328 void
329 vMgrEncodeAssocRequest(
330 PWLAN_FR_ASSOCREQ pFrame
333 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
334 /* Fixed Fields */
335 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
336 + WLAN_ASSOCREQ_OFF_CAP_INFO);
337 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
338 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
339 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
340 return;
345 * Routine Description: (AP)
346 * Decode Association Request
349 * Return Value:
350 * None.
354 void
355 vMgrDecodeAssocRequest(
356 PWLAN_FR_ASSOCREQ pFrame
359 PWLAN_IE pItem;
361 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
362 /* Fixed Fields */
363 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
364 + WLAN_ASSOCREQ_OFF_CAP_INFO);
365 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
366 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
368 /* Information elements */
369 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
370 + WLAN_ASSOCREQ_OFF_SSID);
372 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
373 switch (pItem->byElementID) {
374 case WLAN_EID_SSID:
375 if (pFrame->pSSID == NULL)
376 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
377 break;
378 case WLAN_EID_SUPP_RATES:
379 if (pFrame->pSuppRates == NULL)
380 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
381 break;
383 case WLAN_EID_RSN:
384 if (pFrame->pRSN == NULL)
385 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
386 break;
387 case WLAN_EID_RSN_WPA:
388 if (pFrame->pRSNWPA == NULL) {
389 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
390 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
392 break;
393 case WLAN_EID_EXTSUPP_RATES:
394 if (pFrame->pExtSuppRates == NULL)
395 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
396 break;
398 default:
399 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
400 pItem->byElementID);
401 break;
403 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
405 return;
410 * Routine Description: (AP)
411 * Encode Association Response
414 * Return Value:
415 * None.
419 void
420 vMgrEncodeAssocResponse(
421 PWLAN_FR_ASSOCRESP pFrame
424 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
426 /* Fixed Fields */
427 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
428 + WLAN_ASSOCRESP_OFF_CAP_INFO);
429 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
430 + WLAN_ASSOCRESP_OFF_STATUS);
431 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
432 + WLAN_ASSOCRESP_OFF_AID);
433 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
434 + sizeof(*(pFrame->pwAid));
436 return;
441 * Routine Description:
442 * Decode Association Response
445 * Return Value:
446 * None.
450 void
451 vMgrDecodeAssocResponse(
452 PWLAN_FR_ASSOCRESP pFrame
455 PWLAN_IE pItem;
457 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
459 /* Fixed Fields */
460 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
461 + WLAN_ASSOCRESP_OFF_CAP_INFO);
462 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
463 + WLAN_ASSOCRESP_OFF_STATUS);
464 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
465 + WLAN_ASSOCRESP_OFF_AID);
467 /* Information elements */
468 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
469 + WLAN_ASSOCRESP_OFF_SUPP_RATES);
471 pItem = (PWLAN_IE)(pFrame->pSuppRates);
472 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
474 if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) &&
475 (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
476 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
477 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
478 } else {
479 pFrame->pExtSuppRates = NULL;
481 return;
486 * Routine Description:
487 * Encode Reassociation Request
490 * Return Value:
491 * None.
495 void
496 vMgrEncodeReassocRequest(
497 PWLAN_FR_REASSOCREQ pFrame
500 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
502 /* Fixed Fields */
503 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
504 + WLAN_REASSOCREQ_OFF_CAP_INFO);
505 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
506 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
507 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
508 + WLAN_REASSOCREQ_OFF_CURR_AP);
509 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
511 return;
516 * Routine Description: (AP)
517 * Decode Reassociation Request
520 * Return Value:
521 * None.
525 void
526 vMgrDecodeReassocRequest(
527 PWLAN_FR_REASSOCREQ pFrame
530 PWLAN_IE pItem;
531 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
533 /* Fixed Fields */
534 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
535 + WLAN_REASSOCREQ_OFF_CAP_INFO);
536 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
537 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
538 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
539 + WLAN_REASSOCREQ_OFF_CURR_AP);
541 /* Information elements */
542 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
543 + WLAN_REASSOCREQ_OFF_SSID);
545 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
546 switch (pItem->byElementID) {
547 case WLAN_EID_SSID:
548 if (pFrame->pSSID == NULL)
549 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
550 break;
551 case WLAN_EID_SUPP_RATES:
552 if (pFrame->pSuppRates == NULL)
553 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
554 break;
556 case WLAN_EID_RSN:
557 if (pFrame->pRSN == NULL)
558 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
559 break;
560 case WLAN_EID_RSN_WPA:
561 if (pFrame->pRSNWPA == NULL) {
562 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
563 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
565 break;
567 case WLAN_EID_EXTSUPP_RATES:
568 if (pFrame->pExtSuppRates == NULL)
569 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
570 break;
571 default:
572 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n",
573 pItem->byElementID);
574 break;
576 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
578 return;
583 * Routine Description:
584 * Encode Probe Request
587 * Return Value:
588 * None.
592 void
593 vMgrEncodeProbeRequest(
594 PWLAN_FR_PROBEREQ pFrame
597 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
598 pFrame->len = WLAN_HDR_ADDR3_LEN;
599 return;
604 * Routine Description:
605 * Decode Probe Request
608 * Return Value:
609 * None.
613 void
614 vMgrDecodeProbeRequest(
615 PWLAN_FR_PROBEREQ pFrame
618 PWLAN_IE pItem;
620 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
622 /* Information elements */
623 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
625 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
626 switch (pItem->byElementID) {
627 case WLAN_EID_SSID:
628 if (pFrame->pSSID == NULL)
629 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
630 break;
632 case WLAN_EID_SUPP_RATES:
633 if (pFrame->pSuppRates == NULL)
634 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
635 break;
637 case WLAN_EID_EXTSUPP_RATES:
638 if (pFrame->pExtSuppRates == NULL)
639 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
640 break;
642 default:
643 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
644 break;
647 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
649 return;
654 * Routine Description:
655 * Encode Probe Response
658 * Return Value:
659 * None.
663 void
664 vMgrEncodeProbeResponse(
665 PWLAN_FR_PROBERESP pFrame
668 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
670 /* Fixed Fields */
671 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
672 + WLAN_PROBERESP_OFF_TS);
673 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
674 + WLAN_PROBERESP_OFF_BCN_INT);
675 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
676 + WLAN_PROBERESP_OFF_CAP_INFO);
678 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
679 sizeof(*(pFrame->pwCapInfo));
681 return;
686 * Routine Description:
687 * Decode Probe Response
690 * Return Value:
691 * None.
695 void
696 vMgrDecodeProbeResponse(
697 PWLAN_FR_PROBERESP pFrame
700 PWLAN_IE pItem;
702 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
704 /* Fixed Fields */
705 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
706 + WLAN_PROBERESP_OFF_TS);
707 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
708 + WLAN_PROBERESP_OFF_BCN_INT);
709 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
710 + WLAN_PROBERESP_OFF_CAP_INFO);
712 /* Information elements */
713 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
714 + WLAN_PROBERESP_OFF_SSID);
716 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
717 switch (pItem->byElementID) {
718 case WLAN_EID_SSID:
719 if (pFrame->pSSID == NULL)
720 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
721 break;
722 case WLAN_EID_SUPP_RATES:
723 if (pFrame->pSuppRates == NULL)
724 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
725 break;
726 case WLAN_EID_FH_PARMS:
727 break;
728 case WLAN_EID_DS_PARMS:
729 if (pFrame->pDSParms == NULL)
730 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
731 break;
732 case WLAN_EID_CF_PARMS:
733 if (pFrame->pCFParms == NULL)
734 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
735 break;
736 case WLAN_EID_IBSS_PARMS:
737 if (pFrame->pIBSSParms == NULL)
738 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
739 break;
741 case WLAN_EID_RSN:
742 if (pFrame->pRSN == NULL)
743 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
744 break;
745 case WLAN_EID_RSN_WPA:
746 if (pFrame->pRSNWPA == NULL) {
747 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
748 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
750 break;
751 case WLAN_EID_ERP:
752 if (pFrame->pERP == NULL)
753 pFrame->pERP = (PWLAN_IE_ERP)pItem;
754 break;
755 case WLAN_EID_EXTSUPP_RATES:
756 if (pFrame->pExtSuppRates == NULL)
757 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
758 break;
760 case WLAN_EID_COUNTRY: /* 7 */
761 if (pFrame->pIE_Country == NULL)
762 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
763 break;
765 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
766 if (pFrame->pIE_PowerConstraint == NULL)
767 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
768 break;
770 case WLAN_EID_CH_SWITCH: /* 37 */
771 if (pFrame->pIE_CHSW == NULL)
772 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
773 break;
775 case WLAN_EID_QUIET: /* 40 */
776 if (pFrame->pIE_Quiet == NULL)
777 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
778 break;
780 case WLAN_EID_IBSS_DFS:
781 if (pFrame->pIE_IBSSDFS == NULL)
782 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
783 break;
785 default:
786 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
787 break;
790 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
792 return;
797 * Routine Description:
798 * Encode Authentication frame
801 * Return Value:
802 * None.
806 void
807 vMgrEncodeAuthen(
808 PWLAN_FR_AUTHEN pFrame
811 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
813 /* Fixed Fields */
814 pFrame->pwAuthAlgorithm = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
815 + WLAN_AUTHEN_OFF_AUTH_ALG);
816 pFrame->pwAuthSequence = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
817 + WLAN_AUTHEN_OFF_AUTH_SEQ);
818 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
819 + WLAN_AUTHEN_OFF_STATUS);
820 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
822 return;
827 * Routine Description:
828 * Decode Authentication
831 * Return Value:
832 * None.
836 void
837 vMgrDecodeAuthen(
838 PWLAN_FR_AUTHEN pFrame
841 PWLAN_IE pItem;
843 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
845 /* Fixed Fields */
846 pFrame->pwAuthAlgorithm = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
847 + WLAN_AUTHEN_OFF_AUTH_ALG);
848 pFrame->pwAuthSequence = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
849 + WLAN_AUTHEN_OFF_AUTH_SEQ);
850 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
851 + WLAN_AUTHEN_OFF_STATUS);
853 /* Information elements */
854 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
855 + WLAN_AUTHEN_OFF_CHALLENGE);
857 if (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len) &&
858 pItem->byElementID == WLAN_EID_CHALLENGE)
859 pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
861 return;
866 * Routine Description:
867 * Encode Authentication
870 * Return Value:
871 * None.
875 void
876 vMgrEncodeDeauthen(
877 PWLAN_FR_DEAUTHEN pFrame
880 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
882 /* Fixed Fields */
883 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
884 + WLAN_DEAUTHEN_OFF_REASON);
885 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
887 return;
892 * Routine Description:
893 * Decode Deauthentication
896 * Return Value:
897 * None.
901 void
902 vMgrDecodeDeauthen(
903 PWLAN_FR_DEAUTHEN pFrame
906 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
908 /* Fixed Fields */
909 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
910 + WLAN_DEAUTHEN_OFF_REASON);
912 return;
917 * Routine Description: (AP)
918 * Encode Reassociation Response
921 * Return Value:
922 * None.
926 void
927 vMgrEncodeReassocResponse(
928 PWLAN_FR_REASSOCRESP pFrame
931 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
933 /* Fixed Fields */
934 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
935 + WLAN_REASSOCRESP_OFF_CAP_INFO);
936 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
937 + WLAN_REASSOCRESP_OFF_STATUS);
938 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
939 + WLAN_REASSOCRESP_OFF_AID);
941 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
943 return;
948 * Routine Description:
949 * Decode Reassociation Response
952 * Return Value:
953 * None.
957 void
958 vMgrDecodeReassocResponse(
959 PWLAN_FR_REASSOCRESP pFrame
962 PWLAN_IE pItem;
964 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
966 /* Fixed Fields */
967 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
968 + WLAN_REASSOCRESP_OFF_CAP_INFO);
969 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
970 + WLAN_REASSOCRESP_OFF_STATUS);
971 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
972 + WLAN_REASSOCRESP_OFF_AID);
974 /* Information elements */
975 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
976 + WLAN_REASSOCRESP_OFF_SUPP_RATES);
978 pItem = (PWLAN_IE)(pFrame->pSuppRates);
979 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
981 if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) &&
982 (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
983 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
985 return;