include: replace linux/module.h with "struct module" wherever possible
[linux-2.6/next.git] / drivers / staging / vt6656 / 80211mgr.c
blobfceec4999c361b6e3aa897bfa8e8bee72885a100
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 -------------------------*/
66 /*--------------------- Static Classes ----------------------------*/
68 /*--------------------- Static Variables --------------------------*/
70 static int msglevel = MSG_LEVEL_INFO;
71 /*static int msglevel =MSG_LEVEL_DEBUG;*/
72 /*--------------------- Static Functions --------------------------*/
76 /*--------------------- Export Variables --------------------------*/
79 /*--------------------- Export Functions --------------------------*/
82 /*+
84 * Routine Description:
85 * Encode Beacon frame body offset
87 * Return Value:
88 * None.
90 -*/
92 void
93 vMgrEncodeBeacon(
94 PWLAN_FR_BEACON pFrame
97 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
99 /* Fixed Fields */
100 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
101 + WLAN_BEACON_OFF_TS);
102 pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
103 + WLAN_BEACON_OFF_BCN_INT);
104 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
105 + WLAN_BEACON_OFF_CAPINFO);
107 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
109 return;
114 * Routine Description:
115 * Decode Beacon frame body offset
118 * Return Value:
119 * None.
124 void
125 vMgrDecodeBeacon(
126 PWLAN_FR_BEACON pFrame
129 PWLAN_IE pItem;
131 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
133 /* Fixed Fields */
134 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
135 + WLAN_BEACON_OFF_TS);
136 pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
137 + WLAN_BEACON_OFF_BCN_INT);
138 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
139 + WLAN_BEACON_OFF_CAPINFO);
141 /* Information elements */
142 pItem = (PWLAN_IE)((PBYTE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
143 + WLAN_BEACON_OFF_SSID);
144 while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
146 switch (pItem->byElementID) {
147 case WLAN_EID_SSID:
148 if (pFrame->pSSID == NULL)
149 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
150 break;
151 case WLAN_EID_SUPP_RATES:
152 if (pFrame->pSuppRates == NULL)
153 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
154 break;
155 case WLAN_EID_FH_PARMS:
156 /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */
157 break;
158 case WLAN_EID_DS_PARMS:
159 if (pFrame->pDSParms == NULL)
160 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
161 break;
162 case WLAN_EID_CF_PARMS:
163 if (pFrame->pCFParms == NULL)
164 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
165 break;
166 case WLAN_EID_IBSS_PARMS:
167 if (pFrame->pIBSSParms == NULL)
168 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
169 break;
170 case WLAN_EID_TIM:
171 if (pFrame->pTIM == NULL)
172 pFrame->pTIM = (PWLAN_IE_TIM)pItem;
173 break;
175 case WLAN_EID_RSN:
176 if (pFrame->pRSN == NULL)
177 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
178 break;
179 case WLAN_EID_RSN_WPA:
180 if (pFrame->pRSNWPA == NULL) {
181 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
182 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
184 break;
186 case WLAN_EID_ERP:
187 if (pFrame->pERP == NULL)
188 pFrame->pERP = (PWLAN_IE_ERP)pItem;
189 break;
190 case WLAN_EID_EXTSUPP_RATES:
191 if (pFrame->pExtSuppRates == NULL)
192 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
193 break;
195 case WLAN_EID_COUNTRY: /* 7 */
196 if (pFrame->pIE_Country == NULL)
197 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
198 break;
200 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
201 if (pFrame->pIE_PowerConstraint == NULL)
202 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
203 break;
205 case WLAN_EID_CH_SWITCH: /* 37 */
206 if (pFrame->pIE_CHSW == NULL)
207 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
208 break;
210 case WLAN_EID_QUIET: /* 40 */
211 if (pFrame->pIE_Quiet == NULL)
212 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
213 break;
215 case WLAN_EID_IBSS_DFS:
216 if (pFrame->pIE_IBSSDFS == NULL)
217 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
218 break;
220 default:
221 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
222 break;
225 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
228 return;
234 * Routine Description:
235 * Encode IBSS ATIM
238 * Return Value:
239 * None.
244 void
245 vMgrEncodeIBSSATIM(
246 PWLAN_FR_IBSSATIM pFrame
249 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
250 pFrame->len = WLAN_HDR_ADDR3_LEN;
252 return;
258 * Routine Description:
259 * Decode IBSS ATIM
262 * Return Value:
263 * None.
267 void
268 vMgrDecodeIBSSATIM(
269 PWLAN_FR_IBSSATIM pFrame
272 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
274 return;
280 * Routine Description:
281 * Encode Disassociation
284 * Return Value:
285 * None.
289 void
290 vMgrEncodeDisassociation(
291 PWLAN_FR_DISASSOC pFrame
294 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
297 /* Fixed Fields */
298 pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
299 + WLAN_DISASSOC_OFF_REASON);
300 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
302 return;
308 * Routine Description:
309 * Decode Disassociation
312 * Return Value:
313 * None.
317 void
318 vMgrDecodeDisassociation(
319 PWLAN_FR_DISASSOC pFrame
322 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
324 /* Fixed Fields */
325 pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
326 + WLAN_DISASSOC_OFF_REASON);
328 return;
333 * Routine Description:
334 * Encode Association Request
337 * Return Value:
338 * None.
343 void
344 vMgrEncodeAssocRequest(
345 PWLAN_FR_ASSOCREQ pFrame
348 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
349 /* Fixed Fields */
350 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
351 + WLAN_ASSOCREQ_OFF_CAP_INFO);
352 pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
353 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
354 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
355 return;
361 * Routine Description: (AP)
362 * Decode Association Request
365 * Return Value:
366 * None.
370 void
371 vMgrDecodeAssocRequest(
372 PWLAN_FR_ASSOCREQ pFrame
375 PWLAN_IE pItem;
377 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
378 /* Fixed Fields */
379 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
380 + WLAN_ASSOCREQ_OFF_CAP_INFO);
381 pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
382 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
384 /* Information elements */
385 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
386 + WLAN_ASSOCREQ_OFF_SSID);
388 while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
389 switch (pItem->byElementID) {
390 case WLAN_EID_SSID:
391 if (pFrame->pSSID == NULL)
392 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
393 break;
394 case WLAN_EID_SUPP_RATES:
395 if (pFrame->pSuppRates == NULL)
396 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
397 break;
399 case WLAN_EID_RSN:
400 if (pFrame->pRSN == NULL)
401 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
402 break;
403 case WLAN_EID_RSN_WPA:
404 if (pFrame->pRSNWPA == NULL) {
405 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
406 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
408 break;
409 case WLAN_EID_EXTSUPP_RATES:
410 if (pFrame->pExtSuppRates == NULL)
411 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
412 break;
414 default:
415 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
416 pItem->byElementID);
417 break;
419 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
421 return;
426 * Routine Description: (AP)
427 * Encode Association Response
430 * Return Value:
431 * None.
435 void
436 vMgrEncodeAssocResponse(
437 PWLAN_FR_ASSOCRESP pFrame
440 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
442 /* Fixed Fields */
443 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
444 + WLAN_ASSOCRESP_OFF_CAP_INFO);
445 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
446 + WLAN_ASSOCRESP_OFF_STATUS);
447 pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
448 + WLAN_ASSOCRESP_OFF_AID);
449 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
450 + sizeof(*(pFrame->pwAid));
452 return;
458 * Routine Description:
459 * Decode Association Response
462 * Return Value:
463 * None.
467 void
468 vMgrDecodeAssocResponse(
469 PWLAN_FR_ASSOCRESP pFrame
472 PWLAN_IE pItem;
474 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
476 /* Fixed Fields */
477 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
478 + WLAN_ASSOCRESP_OFF_CAP_INFO);
479 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
480 + WLAN_ASSOCRESP_OFF_STATUS);
481 pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
482 + WLAN_ASSOCRESP_OFF_AID);
484 /* Information elements */
485 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
486 + WLAN_ASSOCRESP_OFF_SUPP_RATES);
488 pItem = (PWLAN_IE)(pFrame->pSuppRates);
489 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
491 if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
492 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
493 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
494 } else {
495 pFrame->pExtSuppRates = NULL;
497 return;
503 * Routine Description:
504 * Encode Reassociation Request
507 * Return Value:
508 * None.
512 void
513 vMgrEncodeReassocRequest(
514 PWLAN_FR_REASSOCREQ pFrame
517 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
519 /* Fixed Fields */
520 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
521 + WLAN_REASSOCREQ_OFF_CAP_INFO);
522 pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
523 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
524 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
525 + WLAN_REASSOCREQ_OFF_CURR_AP);
526 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
528 return;
534 * Routine Description: (AP)
535 * Decode Reassociation Request
538 * Return Value:
539 * None.
544 void
545 vMgrDecodeReassocRequest(
546 PWLAN_FR_REASSOCREQ pFrame
549 PWLAN_IE pItem;
550 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
552 /* Fixed Fields */
553 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
554 + WLAN_REASSOCREQ_OFF_CAP_INFO);
555 pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
556 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
557 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
558 + WLAN_REASSOCREQ_OFF_CURR_AP);
560 /* Information elements */
561 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
562 + WLAN_REASSOCREQ_OFF_SSID);
564 while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
566 switch (pItem->byElementID) {
567 case WLAN_EID_SSID:
568 if (pFrame->pSSID == NULL)
569 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
570 break;
571 case WLAN_EID_SUPP_RATES:
572 if (pFrame->pSuppRates == NULL)
573 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
574 break;
576 case WLAN_EID_RSN:
577 if (pFrame->pRSN == NULL)
578 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
579 break;
580 case WLAN_EID_RSN_WPA:
581 if (pFrame->pRSNWPA == NULL) {
582 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
583 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
585 break;
587 case WLAN_EID_EXTSUPP_RATES:
588 if (pFrame->pExtSuppRates == NULL)
589 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
590 break;
591 default:
592 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n",
593 pItem->byElementID);
594 break;
596 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
598 return;
605 * Routine Description:
606 * Encode Probe Request
609 * Return Value:
610 * None.
615 void
616 vMgrEncodeProbeRequest(
617 PWLAN_FR_PROBEREQ pFrame
620 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
621 pFrame->len = WLAN_HDR_ADDR3_LEN;
622 return;
627 * Routine Description:
628 * Decode Probe Request
631 * Return Value:
632 * None.
636 void
637 vMgrDecodeProbeRequest(
638 PWLAN_FR_PROBEREQ pFrame
641 PWLAN_IE pItem;
643 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
645 /* Information elements */
646 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
648 while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
650 switch (pItem->byElementID) {
651 case WLAN_EID_SSID:
652 if (pFrame->pSSID == NULL)
653 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
654 break;
656 case WLAN_EID_SUPP_RATES:
657 if (pFrame->pSuppRates == NULL)
658 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
659 break;
661 case WLAN_EID_EXTSUPP_RATES:
662 if (pFrame->pExtSuppRates == NULL)
663 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
664 break;
666 default:
667 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
668 break;
671 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
673 return;
679 * Routine Description:
680 * Encode Probe Response
683 * Return Value:
684 * None.
689 void
690 vMgrEncodeProbeResponse(
691 PWLAN_FR_PROBERESP pFrame
694 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
696 /* Fixed Fields */
697 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
698 + WLAN_PROBERESP_OFF_TS);
699 pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
700 + WLAN_PROBERESP_OFF_BCN_INT);
701 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
702 + WLAN_PROBERESP_OFF_CAP_INFO);
704 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
705 sizeof(*(pFrame->pwCapInfo));
707 return;
714 * Routine Description:
715 * Decode Probe Response
718 * Return Value:
719 * None.
723 void
724 vMgrDecodeProbeResponse(
725 PWLAN_FR_PROBERESP pFrame
728 PWLAN_IE pItem;
731 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
733 /* Fixed Fields */
734 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
735 + WLAN_PROBERESP_OFF_TS);
736 pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
737 + WLAN_PROBERESP_OFF_BCN_INT);
738 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
739 + WLAN_PROBERESP_OFF_CAP_INFO);
741 /* Information elements */
742 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
743 + WLAN_PROBERESP_OFF_SSID);
745 while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
746 switch (pItem->byElementID) {
747 case WLAN_EID_SSID:
748 if (pFrame->pSSID == NULL)
749 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
750 break;
751 case WLAN_EID_SUPP_RATES:
752 if (pFrame->pSuppRates == NULL)
753 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
754 break;
755 case WLAN_EID_FH_PARMS:
756 break;
757 case WLAN_EID_DS_PARMS:
758 if (pFrame->pDSParms == NULL)
759 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
760 break;
761 case WLAN_EID_CF_PARMS:
762 if (pFrame->pCFParms == NULL)
763 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
764 break;
765 case WLAN_EID_IBSS_PARMS:
766 if (pFrame->pIBSSParms == NULL)
767 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
768 break;
770 case WLAN_EID_RSN:
771 if (pFrame->pRSN == NULL)
772 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
773 break;
774 case WLAN_EID_RSN_WPA:
775 if (pFrame->pRSNWPA == NULL) {
776 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
777 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
779 break;
780 case WLAN_EID_ERP:
781 if (pFrame->pERP == NULL)
782 pFrame->pERP = (PWLAN_IE_ERP)pItem;
783 break;
784 case WLAN_EID_EXTSUPP_RATES:
785 if (pFrame->pExtSuppRates == NULL)
786 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
787 break;
789 case WLAN_EID_COUNTRY: /* 7 */
790 if (pFrame->pIE_Country == NULL)
791 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
792 break;
794 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
795 if (pFrame->pIE_PowerConstraint == NULL)
796 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
797 break;
799 case WLAN_EID_CH_SWITCH: /* 37 */
800 if (pFrame->pIE_CHSW == NULL)
801 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
802 break;
804 case WLAN_EID_QUIET: /* 40 */
805 if (pFrame->pIE_Quiet == NULL)
806 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
807 break;
809 case WLAN_EID_IBSS_DFS:
810 if (pFrame->pIE_IBSSDFS == NULL)
811 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
812 break;
814 default:
815 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
816 break;
819 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
821 return;
827 * Routine Description:
828 * Encode Authentication frame
831 * Return Value:
832 * None.
836 void
837 vMgrEncodeAuthen(
838 PWLAN_FR_AUTHEN pFrame
841 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
843 /* Fixed Fields */
844 pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
845 + WLAN_AUTHEN_OFF_AUTH_ALG);
846 pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
847 + WLAN_AUTHEN_OFF_AUTH_SEQ);
848 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
849 + WLAN_AUTHEN_OFF_STATUS);
850 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
851 return;
857 * Routine Description:
858 * Decode Authentication
861 * Return Value:
862 * None.
866 void
867 vMgrDecodeAuthen(
868 PWLAN_FR_AUTHEN pFrame
871 PWLAN_IE pItem;
873 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
875 /* Fixed Fields */
876 pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
877 + WLAN_AUTHEN_OFF_AUTH_ALG);
878 pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
879 + WLAN_AUTHEN_OFF_AUTH_SEQ);
880 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
881 + WLAN_AUTHEN_OFF_STATUS);
883 /* Information elements */
884 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
885 + WLAN_AUTHEN_OFF_CHALLENGE);
887 if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE))
888 pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
889 return;
895 * Routine Description:
896 * Encode Authentication
899 * Return Value:
900 * None.
904 void
905 vMgrEncodeDeauthen(
906 PWLAN_FR_DEAUTHEN pFrame
909 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
911 /* Fixed Fields */
912 pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
913 + WLAN_DEAUTHEN_OFF_REASON);
914 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
915 return;
921 * Routine Description:
922 * Decode Deauthentication
925 * Return Value:
926 * None.
930 void
931 vMgrDecodeDeauthen(
932 PWLAN_FR_DEAUTHEN pFrame
935 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
937 /* Fixed Fields */
938 pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
939 + WLAN_DEAUTHEN_OFF_REASON);
940 return;
946 * Routine Description: (AP)
947 * Encode Reassociation Response
950 * Return Value:
951 * None.
955 void
956 vMgrEncodeReassocResponse(
957 PWLAN_FR_REASSOCRESP pFrame
960 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
962 /* Fixed Fields */
963 pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
964 + WLAN_REASSOCRESP_OFF_CAP_INFO);
965 pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
966 + WLAN_REASSOCRESP_OFF_STATUS);
967 pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
968 + WLAN_REASSOCRESP_OFF_AID);
970 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
971 return;
977 * Routine Description:
978 * Decode Reassociation Response
981 * Return Value:
982 * None.
987 void
988 vMgrDecodeReassocResponse(
989 PWLAN_FR_REASSOCRESP pFrame
992 PWLAN_IE pItem;
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 /* Information elements */
1005 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
1006 + WLAN_REASSOCRESP_OFF_SUPP_RATES);
1008 pItem = (PWLAN_IE)(pFrame->pSuppRates);
1009 pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
1011 if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES))
1012 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
1013 return;