perf callchain: Remove unnecessary validation
[linux-2.6/btrfs-unstable.git] / drivers / staging / vt6656 / 80211mgr.c
blob61edb51f383698d1259b69ea13deedacb28f7c26
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 * vMgrEncodeDisassociation - Encode the Disassociation frame
31 * vMgrDecodeDisassociation - Decode the Disassociation frame
32 * vMgrEncodeAssocRequest - Encode the Association request frame
33 * vMgrDecodeAssocRequest - Decode the Association request frame
34 * vMgrEncodeAssocResponse - Encode the Association response frame
35 * vMgrDecodeAssocResponse - Decode the Association response frame
36 * vMgrEncodeReAssocRequest - Encode the ReAssociation request frame
37 * vMgrDecodeReAssocRequest - Decode the ReAssociation request frame
38 * vMgrEncodeProbeRequest - Encode the Probe request frame
39 * vMgrDecodeProbeRequest - Decode the Probe request frame
40 * vMgrEncodeProbeResponse - Encode the Probe response frame
41 * vMgrDecodeProbeResponse - Decode the Probe response frame
42 * vMgrEncodeAuthen - Encode the Authentication frame
43 * vMgrDecodeAuthen - Decode the Authentication frame
44 * vMgrEncodeDeauthen - Encode the DeAuthentication frame
45 * vMgrDecodeDeauthen - Decode the DeAuthentication frame
46 * vMgrEncodeReassocResponse - Encode the Reassociation response frame
48 * Revision History:
52 #include "device.h"
53 #include "tmacro.h"
54 #include "tether.h"
55 #include "80211mgr.h"
56 #include "80211hdr.h"
57 #include "wpa.h"
59 static int msglevel = MSG_LEVEL_INFO;
60 /*static int msglevel =MSG_LEVEL_DEBUG;*/
62 /*+
64 * Routine Description:
65 * Encode Beacon frame body offset
67 * Return Value:
68 * None.
70 -*/
72 void
73 vMgrEncodeBeacon(
74 PWLAN_FR_BEACON pFrame
77 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
79 /* Fixed Fields */
80 pFrame->pqwTimestamp =
81 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
82 WLAN_BEACON_OFF_TS);
83 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
84 + WLAN_BEACON_OFF_BCN_INT);
85 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
86 + WLAN_BEACON_OFF_CAPINFO);
88 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
90 return;
93 /*+
95 * Routine Description:
96 * Decode Beacon frame body offset
99 * Return Value:
100 * None.
104 void
105 vMgrDecodeBeacon(
106 PWLAN_FR_BEACON pFrame
109 PWLAN_IE pItem;
111 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
113 /* Fixed Fields */
114 pFrame->pqwTimestamp =
115 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
116 WLAN_BEACON_OFF_TS);
117 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
118 + WLAN_BEACON_OFF_BCN_INT);
119 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
120 + WLAN_BEACON_OFF_CAPINFO);
122 /* Information elements */
123 pItem = (PWLAN_IE)((u8 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
124 + WLAN_BEACON_OFF_SSID);
125 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
127 switch (pItem->byElementID) {
128 case WLAN_EID_SSID:
129 if (pFrame->pSSID == NULL)
130 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
131 break;
132 case WLAN_EID_SUPP_RATES:
133 if (pFrame->pSuppRates == NULL)
134 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
135 break;
136 case WLAN_EID_FH_PARMS:
137 /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */
138 break;
139 case WLAN_EID_DS_PARMS:
140 if (pFrame->pDSParms == NULL)
141 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
142 break;
143 case WLAN_EID_CF_PARMS:
144 if (pFrame->pCFParms == NULL)
145 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
146 break;
147 case WLAN_EID_IBSS_PARMS:
148 if (pFrame->pIBSSParms == NULL)
149 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
150 break;
151 case WLAN_EID_TIM:
152 if (pFrame->pTIM == NULL)
153 pFrame->pTIM = (PWLAN_IE_TIM)pItem;
154 break;
156 case WLAN_EID_RSN:
157 if (pFrame->pRSN == NULL)
158 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
159 break;
160 case WLAN_EID_RSN_WPA:
161 if (pFrame->pRSNWPA == NULL) {
162 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
163 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
165 break;
167 case WLAN_EID_ERP:
168 if (pFrame->pERP == NULL)
169 pFrame->pERP = (PWLAN_IE_ERP)pItem;
170 break;
171 case WLAN_EID_EXTSUPP_RATES:
172 if (pFrame->pExtSuppRates == NULL)
173 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
174 break;
176 case WLAN_EID_COUNTRY: /* 7 */
177 if (pFrame->pIE_Country == NULL)
178 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
179 break;
181 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
182 if (pFrame->pIE_PowerConstraint == NULL)
183 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
184 break;
186 case WLAN_EID_CH_SWITCH: /* 37 */
187 if (pFrame->pIE_CHSW == NULL)
188 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
189 break;
191 case WLAN_EID_QUIET: /* 40 */
192 if (pFrame->pIE_Quiet == NULL)
193 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
194 break;
196 case WLAN_EID_IBSS_DFS:
197 if (pFrame->pIE_IBSSDFS == NULL)
198 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
199 break;
201 default:
202 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
203 break;
206 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
212 * Routine Description:
213 * Encode Disassociation
216 * Return Value:
217 * None.
221 void
222 vMgrEncodeDisassociation(
223 PWLAN_FR_DISASSOC pFrame
226 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
228 /* Fixed Fields */
229 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
230 + WLAN_DISASSOC_OFF_REASON);
231 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
236 * Routine Description:
237 * Decode Disassociation
240 * Return Value:
241 * None.
245 void
246 vMgrDecodeDisassociation(
247 PWLAN_FR_DISASSOC pFrame
250 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
252 /* Fixed Fields */
253 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
254 + WLAN_DISASSOC_OFF_REASON);
259 * Routine Description:
260 * Encode Association Request
263 * Return Value:
264 * None.
268 void
269 vMgrEncodeAssocRequest(
270 PWLAN_FR_ASSOCREQ pFrame
273 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
274 /* Fixed Fields */
275 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
276 + WLAN_ASSOCREQ_OFF_CAP_INFO);
277 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
278 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
279 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
284 * Routine Description: (AP)
285 * Decode Association Request
288 * Return Value:
289 * None.
293 void
294 vMgrDecodeAssocRequest(
295 PWLAN_FR_ASSOCREQ pFrame
298 PWLAN_IE pItem;
300 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
301 /* Fixed Fields */
302 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
303 + WLAN_ASSOCREQ_OFF_CAP_INFO);
304 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
305 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
307 /* Information elements */
308 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
309 + WLAN_ASSOCREQ_OFF_SSID);
311 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
312 switch (pItem->byElementID) {
313 case WLAN_EID_SSID:
314 if (pFrame->pSSID == NULL)
315 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
316 break;
317 case WLAN_EID_SUPP_RATES:
318 if (pFrame->pSuppRates == NULL)
319 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
320 break;
322 case WLAN_EID_RSN:
323 if (pFrame->pRSN == NULL)
324 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
325 break;
326 case WLAN_EID_RSN_WPA:
327 if (pFrame->pRSNWPA == NULL) {
328 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
329 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
331 break;
332 case WLAN_EID_EXTSUPP_RATES:
333 if (pFrame->pExtSuppRates == NULL)
334 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
335 break;
337 default:
338 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
339 pItem->byElementID);
340 break;
342 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
348 * Routine Description: (AP)
349 * Encode Association Response
352 * Return Value:
353 * None.
357 void
358 vMgrEncodeAssocResponse(
359 PWLAN_FR_ASSOCRESP pFrame
362 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
364 /* Fixed Fields */
365 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
366 + WLAN_ASSOCRESP_OFF_CAP_INFO);
367 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
368 + WLAN_ASSOCRESP_OFF_STATUS);
369 pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
370 + WLAN_ASSOCRESP_OFF_AID);
371 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
372 + sizeof(*(pFrame->pwAid));
377 * Routine Description:
378 * Decode Association Response
381 * Return Value:
382 * None.
386 void
387 vMgrDecodeAssocResponse(
388 PWLAN_FR_ASSOCRESP pFrame
391 PWLAN_IE pItem;
393 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
395 /* Fixed Fields */
396 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
397 + WLAN_ASSOCRESP_OFF_CAP_INFO);
398 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
399 + WLAN_ASSOCRESP_OFF_STATUS);
400 pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
401 + WLAN_ASSOCRESP_OFF_AID);
403 /* Information elements */
404 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
405 + WLAN_ASSOCRESP_OFF_SUPP_RATES);
407 pItem = (PWLAN_IE)(pFrame->pSuppRates);
408 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
410 if ((((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
411 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
412 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
413 } else
414 pFrame->pExtSuppRates = NULL;
419 * Routine Description:
420 * Encode Reassociation Request
423 * Return Value:
424 * None.
428 void
429 vMgrEncodeReassocRequest(
430 PWLAN_FR_REASSOCREQ pFrame
433 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
435 /* Fixed Fields */
436 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
437 + WLAN_REASSOCREQ_OFF_CAP_INFO);
438 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
439 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
440 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
441 + WLAN_REASSOCREQ_OFF_CURR_AP);
442 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
447 * Routine Description: (AP)
448 * Decode Reassociation Request
451 * Return Value:
452 * None.
456 void
457 vMgrDecodeReassocRequest(
458 PWLAN_FR_REASSOCREQ pFrame
461 PWLAN_IE pItem;
462 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
464 /* Fixed Fields */
465 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
466 + WLAN_REASSOCREQ_OFF_CAP_INFO);
467 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
468 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
469 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
470 + WLAN_REASSOCREQ_OFF_CURR_AP);
472 /* Information elements */
473 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
474 + WLAN_REASSOCREQ_OFF_SSID);
476 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
478 switch (pItem->byElementID) {
479 case WLAN_EID_SSID:
480 if (pFrame->pSSID == NULL)
481 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
482 break;
483 case WLAN_EID_SUPP_RATES:
484 if (pFrame->pSuppRates == NULL)
485 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
486 break;
488 case WLAN_EID_RSN:
489 if (pFrame->pRSN == NULL)
490 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
491 break;
492 case WLAN_EID_RSN_WPA:
493 if (pFrame->pRSNWPA == NULL)
494 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
495 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
496 break;
498 case WLAN_EID_EXTSUPP_RATES:
499 if (pFrame->pExtSuppRates == NULL)
500 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
501 break;
502 default:
503 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n",
504 pItem->byElementID);
505 break;
507 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
513 * Routine Description:
514 * Encode Probe Request
517 * Return Value:
518 * None.
522 void
523 vMgrEncodeProbeRequest(
524 PWLAN_FR_PROBEREQ pFrame
527 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
528 pFrame->len = WLAN_HDR_ADDR3_LEN;
533 * Routine Description:
534 * Decode Probe Request
537 * Return Value:
538 * None.
542 void
543 vMgrDecodeProbeRequest(
544 PWLAN_FR_PROBEREQ pFrame
547 PWLAN_IE pItem;
549 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
551 /* Information elements */
552 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
554 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
556 switch (pItem->byElementID) {
557 case WLAN_EID_SSID:
558 if (pFrame->pSSID == NULL)
559 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
560 break;
562 case WLAN_EID_SUPP_RATES:
563 if (pFrame->pSuppRates == NULL)
564 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
565 break;
567 case WLAN_EID_EXTSUPP_RATES:
568 if (pFrame->pExtSuppRates == NULL)
569 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
570 break;
572 default:
573 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
574 break;
577 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
583 * Routine Description:
584 * Encode Probe Response
587 * Return Value:
588 * None.
592 void
593 vMgrEncodeProbeResponse(
594 PWLAN_FR_PROBERESP pFrame
597 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
599 /* Fixed Fields */
600 pFrame->pqwTimestamp =
601 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
602 WLAN_PROBERESP_OFF_TS);
603 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
604 + WLAN_PROBERESP_OFF_BCN_INT);
605 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
606 + WLAN_PROBERESP_OFF_CAP_INFO);
608 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
609 sizeof(*(pFrame->pwCapInfo));
614 * Routine Description:
615 * Decode Probe Response
618 * Return Value:
619 * None.
623 void
624 vMgrDecodeProbeResponse(
625 PWLAN_FR_PROBERESP pFrame
628 PWLAN_IE pItem;
630 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
632 /* Fixed Fields */
633 pFrame->pqwTimestamp =
634 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
635 WLAN_PROBERESP_OFF_TS);
636 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
637 + WLAN_PROBERESP_OFF_BCN_INT);
638 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
639 + WLAN_PROBERESP_OFF_CAP_INFO);
641 /* Information elements */
642 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
643 + WLAN_PROBERESP_OFF_SSID);
645 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
646 switch (pItem->byElementID) {
647 case WLAN_EID_SSID:
648 if (pFrame->pSSID == NULL)
649 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
650 break;
651 case WLAN_EID_SUPP_RATES:
652 if (pFrame->pSuppRates == NULL)
653 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
654 break;
655 case WLAN_EID_FH_PARMS:
656 break;
657 case WLAN_EID_DS_PARMS:
658 if (pFrame->pDSParms == NULL)
659 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
660 break;
661 case WLAN_EID_CF_PARMS:
662 if (pFrame->pCFParms == NULL)
663 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
664 break;
665 case WLAN_EID_IBSS_PARMS:
666 if (pFrame->pIBSSParms == NULL)
667 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
668 break;
670 case WLAN_EID_RSN:
671 if (pFrame->pRSN == NULL)
672 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
673 break;
674 case WLAN_EID_RSN_WPA:
675 if (pFrame->pRSNWPA == NULL) {
676 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
677 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
679 break;
680 case WLAN_EID_ERP:
681 if (pFrame->pERP == NULL)
682 pFrame->pERP = (PWLAN_IE_ERP)pItem;
683 break;
684 case WLAN_EID_EXTSUPP_RATES:
685 if (pFrame->pExtSuppRates == NULL)
686 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
687 break;
689 case WLAN_EID_COUNTRY: /* 7 */
690 if (pFrame->pIE_Country == NULL)
691 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
692 break;
694 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
695 if (pFrame->pIE_PowerConstraint == NULL)
696 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
697 break;
699 case WLAN_EID_CH_SWITCH: /* 37 */
700 if (pFrame->pIE_CHSW == NULL)
701 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
702 break;
704 case WLAN_EID_QUIET: /* 40 */
705 if (pFrame->pIE_Quiet == NULL)
706 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
707 break;
709 case WLAN_EID_IBSS_DFS:
710 if (pFrame->pIE_IBSSDFS == NULL)
711 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
712 break;
714 default:
715 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
716 break;
719 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
725 * Routine Description:
726 * Encode Authentication frame
729 * Return Value:
730 * None.
734 void
735 vMgrEncodeAuthen(
736 PWLAN_FR_AUTHEN pFrame
739 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
741 /* Fixed Fields */
742 pFrame->pwAuthAlgorithm = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
743 + WLAN_AUTHEN_OFF_AUTH_ALG);
744 pFrame->pwAuthSequence = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
745 + WLAN_AUTHEN_OFF_AUTH_SEQ);
746 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
747 + WLAN_AUTHEN_OFF_STATUS);
748 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
753 * Routine Description:
754 * Decode Authentication
757 * Return Value:
758 * None.
762 void
763 vMgrDecodeAuthen(
764 PWLAN_FR_AUTHEN pFrame
767 PWLAN_IE pItem;
769 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
771 /* Fixed Fields */
772 pFrame->pwAuthAlgorithm = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
773 + WLAN_AUTHEN_OFF_AUTH_ALG);
774 pFrame->pwAuthSequence = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
775 + WLAN_AUTHEN_OFF_AUTH_SEQ);
776 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
777 + WLAN_AUTHEN_OFF_STATUS);
779 /* Information elements */
780 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
781 + WLAN_AUTHEN_OFF_CHALLENGE);
783 if ((((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE))
784 pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
789 * Routine Description:
790 * Encode Authentication
793 * Return Value:
794 * None.
798 void
799 vMgrEncodeDeauthen(
800 PWLAN_FR_DEAUTHEN pFrame
803 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
805 /* Fixed Fields */
806 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
807 + WLAN_DEAUTHEN_OFF_REASON);
808 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
813 * Routine Description:
814 * Decode Deauthentication
817 * Return Value:
818 * None.
822 void
823 vMgrDecodeDeauthen(
824 PWLAN_FR_DEAUTHEN pFrame
827 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
829 /* Fixed Fields */
830 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
831 + WLAN_DEAUTHEN_OFF_REASON);
836 * Routine Description: (AP)
837 * Encode Reassociation Response
840 * Return Value:
841 * None.
845 void
846 vMgrEncodeReassocResponse(
847 PWLAN_FR_REASSOCRESP pFrame
850 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
852 /* Fixed Fields */
853 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
854 + WLAN_REASSOCRESP_OFF_CAP_INFO);
855 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
856 + WLAN_REASSOCRESP_OFF_STATUS);
857 pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
858 + WLAN_REASSOCRESP_OFF_AID);
860 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));