]> Pileus Git - ~andy/linux/blob - drivers/staging/vt6656/80211mgr.c
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[~andy/linux] / drivers / staging / vt6656 / 80211mgr.c
1 /*
2  * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3  * All rights reserved.
4  *
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.
9  *
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.
14  *
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.
18  *
19  * File: 80211mgr.c
20  *
21  * Purpose: Handles the 802.11 management support functions
22  *
23  * Author: Lyndon Chen
24  *
25  * Date: May 8, 2002
26  *
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
50  *
51  * Revision History:
52  *
53  */
54
55 #include "device.h"
56 #include "tmacro.h"
57 #include "tether.h"
58 #include "80211mgr.h"
59 #include "80211hdr.h"
60 #include "wpa.h"
61
62 /*---------------------  Static Definitions -------------------------*/
63
64
65
66 /*---------------------  Static Classes  ----------------------------*/
67
68 /*---------------------  Static Variables  --------------------------*/
69
70 static int          msglevel                = MSG_LEVEL_INFO;
71 /*static int          msglevel                =MSG_LEVEL_DEBUG;*/
72 /*---------------------  Static Functions  --------------------------*/
73
74
75
76 /*---------------------  Export Variables  --------------------------*/
77
78
79 /*---------------------  Export Functions  --------------------------*/
80
81
82 /*+
83  *
84  * Routine Description:
85  * Encode Beacon frame body offset
86  *
87  * Return Value:
88  *    None.
89  *
90 -*/
91
92 void
93 vMgrEncodeBeacon(
94       PWLAN_FR_BEACON  pFrame
95      )
96 {
97     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
98
99         /* Fixed Fields */
100         pFrame->pqwTimestamp =
101                 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
102                         WLAN_BEACON_OFF_TS);
103     pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
104                                        + WLAN_BEACON_OFF_BCN_INT);
105     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
106                                 + WLAN_BEACON_OFF_CAPINFO);
107
108     pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
109
110     return;
111 }
112
113 /*+
114  *
115  * Routine Description:
116  * Decode Beacon frame body offset
117  *
118  *
119  * Return Value:
120  *    None.
121  *
122 -*/
123
124
125 void
126 vMgrDecodeBeacon(
127       PWLAN_FR_BEACON  pFrame
128     )
129 {
130     PWLAN_IE        pItem;
131
132     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
133
134         /* Fixed Fields */
135         pFrame->pqwTimestamp =
136                 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
137                         WLAN_BEACON_OFF_TS);
138     pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
139                                        + WLAN_BEACON_OFF_BCN_INT);
140     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
141                                 + WLAN_BEACON_OFF_CAPINFO);
142
143     /* Information elements */
144     pItem = (PWLAN_IE)((PBYTE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
145                        + WLAN_BEACON_OFF_SSID);
146     while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
147
148         switch (pItem->byElementID) {
149         case WLAN_EID_SSID:
150             if (pFrame->pSSID == NULL)
151                 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
152             break;
153         case WLAN_EID_SUPP_RATES:
154             if (pFrame->pSuppRates == NULL)
155                 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
156             break;
157         case WLAN_EID_FH_PARMS:
158             /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */
159             break;
160         case WLAN_EID_DS_PARMS:
161             if (pFrame->pDSParms == NULL)
162                 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
163             break;
164         case WLAN_EID_CF_PARMS:
165             if (pFrame->pCFParms == NULL)
166                 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
167             break;
168         case WLAN_EID_IBSS_PARMS:
169             if (pFrame->pIBSSParms == NULL)
170                 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
171             break;
172         case WLAN_EID_TIM:
173             if (pFrame->pTIM == NULL)
174                 pFrame->pTIM = (PWLAN_IE_TIM)pItem;
175             break;
176
177         case WLAN_EID_RSN:
178             if (pFrame->pRSN == NULL) 
179                 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
180             break;
181         case WLAN_EID_RSN_WPA:
182             if (pFrame->pRSNWPA == NULL) {
183                 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
184                     pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
185             }
186             break;
187
188         case WLAN_EID_ERP:
189             if (pFrame->pERP == NULL)
190                 pFrame->pERP = (PWLAN_IE_ERP)pItem;
191             break;
192         case WLAN_EID_EXTSUPP_RATES:
193             if (pFrame->pExtSuppRates == NULL)
194                 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
195             break;
196
197         case WLAN_EID_COUNTRY:      /* 7 */
198             if (pFrame->pIE_Country == NULL)
199                 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
200             break;
201
202         case WLAN_EID_PWR_CONSTRAINT:   /* 32 */
203             if (pFrame->pIE_PowerConstraint == NULL)
204                 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
205             break;
206
207         case WLAN_EID_CH_SWITCH:    /* 37 */
208             if (pFrame->pIE_CHSW == NULL)
209                 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
210             break;
211
212         case WLAN_EID_QUIET:        /* 40 */
213             if (pFrame->pIE_Quiet == NULL)
214                 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
215             break;
216
217         case WLAN_EID_IBSS_DFS:
218             if (pFrame->pIE_IBSSDFS == NULL)
219                 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
220             break;
221
222         default:
223             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
224                 break;
225
226         }
227         pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
228     }
229 }
230
231
232 /*+
233  *
234  * Routine Description:
235  *  Encode IBSS ATIM
236  *
237  *
238  * Return Value:
239  *    None.
240  *
241 -*/
242
243
244 void
245 vMgrEncodeIBSSATIM(
246       PWLAN_FR_IBSSATIM   pFrame
247     )
248 {
249     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
250     pFrame->len = WLAN_HDR_ADDR3_LEN;
251 }
252
253
254 /*+
255  *
256  * Routine Description:
257  *  Decode IBSS ATIM
258  *
259  *
260  * Return Value:
261  *    None.
262  *
263 -*/
264
265 void
266 vMgrDecodeIBSSATIM(
267       PWLAN_FR_IBSSATIM   pFrame
268     )
269 {
270     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
271 }
272
273
274 /*+
275  *
276  * Routine Description:
277  *  Encode Disassociation
278  *
279  *
280  * Return Value:
281  *    None.
282  *
283 -*/
284
285 void
286 vMgrEncodeDisassociation(
287       PWLAN_FR_DISASSOC  pFrame
288     )
289 {
290     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
291
292
293     /* Fixed Fields */
294     pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
295                                + WLAN_DISASSOC_OFF_REASON);
296     pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
297 }
298
299
300 /*+
301  *
302  * Routine Description:
303  *  Decode Disassociation
304  *
305  *
306  * Return Value:
307  *    None.
308  *
309 -*/
310
311 void
312 vMgrDecodeDisassociation(
313       PWLAN_FR_DISASSOC  pFrame
314     )
315 {
316     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
317
318     /* Fixed Fields */
319     pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
320                                + WLAN_DISASSOC_OFF_REASON);
321 }
322
323 /*+
324  *
325  * Routine Description:
326  *  Encode Association Request
327  *
328  *
329  * Return Value:
330  *    None.
331  *
332 -*/
333
334
335 void
336 vMgrEncodeAssocRequest(
337       PWLAN_FR_ASSOCREQ  pFrame
338     )
339 {
340     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
341     /* Fixed Fields */
342     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
343                                 + WLAN_ASSOCREQ_OFF_CAP_INFO);
344     pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
345                                        + WLAN_ASSOCREQ_OFF_LISTEN_INT);
346     pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
347 }
348
349
350 /*+
351  *
352  * Routine Description: (AP)
353  *  Decode Association Request
354  *
355  *
356  * Return Value:
357  *    None.
358  *
359 -*/
360
361 void
362 vMgrDecodeAssocRequest(
363       PWLAN_FR_ASSOCREQ  pFrame
364     )
365 {
366     PWLAN_IE   pItem;
367
368     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
369     /* Fixed Fields */
370     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
371                                 + WLAN_ASSOCREQ_OFF_CAP_INFO);
372     pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
373                                 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
374
375     /* Information elements */
376     pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
377                             + WLAN_ASSOCREQ_OFF_SSID);
378
379     while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
380         switch (pItem->byElementID) {
381         case WLAN_EID_SSID:
382             if (pFrame->pSSID == NULL)
383                 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
384             break;
385         case WLAN_EID_SUPP_RATES:
386             if (pFrame->pSuppRates == NULL)
387                 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
388             break;
389
390         case WLAN_EID_RSN:
391             if (pFrame->pRSN == NULL)
392                 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
393             break;
394         case WLAN_EID_RSN_WPA:
395             if (pFrame->pRSNWPA == NULL) {
396                 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
397                     pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
398             }
399             break;
400         case WLAN_EID_EXTSUPP_RATES:
401             if (pFrame->pExtSuppRates == NULL)
402                 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
403             break;
404
405         default:
406             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
407                     pItem->byElementID);
408             break;
409         }
410         pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
411     }
412 }
413
414 /*+
415  *
416  * Routine Description: (AP)
417  *  Encode Association Response
418  *
419  *
420  * Return Value:
421  *    None.
422  *
423 -*/
424
425 void
426 vMgrEncodeAssocResponse(
427       PWLAN_FR_ASSOCRESP  pFrame
428      )
429 {
430     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
431
432     /* Fixed Fields */
433     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
434                                 + WLAN_ASSOCRESP_OFF_CAP_INFO);
435     pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
436                                + WLAN_ASSOCRESP_OFF_STATUS);
437     pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
438                             + WLAN_ASSOCRESP_OFF_AID);
439     pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
440                   + sizeof(*(pFrame->pwAid));
441 }
442
443
444 /*+
445  *
446  * Routine Description:
447  *  Decode Association Response
448  *
449  *
450  * Return Value:
451  *    None.
452  *
453 -*/
454
455 void
456 vMgrDecodeAssocResponse(
457      PWLAN_FR_ASSOCRESP  pFrame
458      )
459 {
460     PWLAN_IE   pItem;
461
462     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
463
464     /* Fixed Fields */
465     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
466                                 + WLAN_ASSOCRESP_OFF_CAP_INFO);
467     pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
468                                + WLAN_ASSOCRESP_OFF_STATUS);
469     pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
470                             + WLAN_ASSOCRESP_OFF_AID);
471
472     /* Information elements */
473     pFrame->pSuppRates  = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
474                            + WLAN_ASSOCRESP_OFF_SUPP_RATES);
475
476     pItem = (PWLAN_IE)(pFrame->pSuppRates);
477     pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
478
479     if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
480         pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
481         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
482         } else
483         pFrame->pExtSuppRates = NULL;
484 }
485
486
487 /*+
488  *
489  * Routine Description:
490  *  Encode Reassociation Request
491  *
492  *
493  * Return Value:
494  *    None.
495  *
496 -*/
497
498 void
499 vMgrEncodeReassocRequest(
500       PWLAN_FR_REASSOCREQ  pFrame
501      )
502 {
503     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
504
505     /* Fixed Fields */
506     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
507                                 + WLAN_REASSOCREQ_OFF_CAP_INFO);
508     pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
509                                       + WLAN_REASSOCREQ_OFF_LISTEN_INT);
510     pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
511                                        + WLAN_REASSOCREQ_OFF_CURR_AP);
512     pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
513 }
514
515
516 /*+
517  *
518  * Routine Description: (AP)
519  *  Decode Reassociation Request
520  *
521  *
522  * Return Value:
523  *    None.
524  *
525 -*/
526
527
528 void
529 vMgrDecodeReassocRequest(
530       PWLAN_FR_REASSOCREQ  pFrame
531      )
532 {
533     PWLAN_IE   pItem;
534     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
535
536     /* Fixed Fields */
537     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
538                                 + WLAN_REASSOCREQ_OFF_CAP_INFO);
539     pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
540                                       + WLAN_REASSOCREQ_OFF_LISTEN_INT);
541     pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
542                                        + WLAN_REASSOCREQ_OFF_CURR_AP);
543
544     /* Information elements */
545     pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
546                        + WLAN_REASSOCREQ_OFF_SSID);
547
548     while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
549
550         switch (pItem->byElementID) {
551         case WLAN_EID_SSID:
552             if (pFrame->pSSID == NULL)
553                 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
554             break;
555         case WLAN_EID_SUPP_RATES:
556             if (pFrame->pSuppRates == NULL)
557                 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
558             break;
559
560         case WLAN_EID_RSN:
561             if (pFrame->pRSN == NULL)
562                 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
563             break;
564         case WLAN_EID_RSN_WPA:
565                 if (pFrame->pRSNWPA == NULL)
566                 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
567                     pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
568             break;
569
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;
578         }
579         pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
580     }
581 }
582
583
584
585 /*+
586  *
587  * Routine Description:
588  *  Encode Probe Request
589  *
590  *
591  * Return Value:
592  *    None.
593  *
594 -*/
595
596
597 void
598 vMgrEncodeProbeRequest(
599      PWLAN_FR_PROBEREQ  pFrame
600      )
601 {
602     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
603     pFrame->len = WLAN_HDR_ADDR3_LEN;
604 }
605
606 /*+
607  *
608  * Routine Description:
609  *  Decode Probe Request
610  *
611  *
612  * Return Value:
613  *    None.
614  *
615 -*/
616
617 void
618 vMgrDecodeProbeRequest(
619      PWLAN_FR_PROBEREQ  pFrame
620      )
621 {
622     PWLAN_IE   pItem;
623
624     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
625
626     /* Information elements */
627     pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
628
629     while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
630
631         switch (pItem->byElementID) {
632         case WLAN_EID_SSID:
633             if (pFrame->pSSID == NULL)
634                 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
635             break;
636
637         case WLAN_EID_SUPP_RATES:
638             if (pFrame->pSuppRates == NULL)
639                 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
640             break;
641
642         case WLAN_EID_EXTSUPP_RATES:
643             if (pFrame->pExtSuppRates == NULL)
644                 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
645             break;
646
647         default:
648             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
649             break;
650         }
651
652         pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 +  pItem->len);
653     }
654 }
655
656
657 /*+
658  *
659  * Routine Description:
660  *  Encode Probe Response
661  *
662  *
663  * Return Value:
664  *    None.
665  *
666 -*/
667
668
669 void
670 vMgrEncodeProbeResponse(
671      PWLAN_FR_PROBERESP  pFrame
672     )
673 {
674     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
675
676         /* Fixed Fields */
677         pFrame->pqwTimestamp =
678                 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
679                         WLAN_PROBERESP_OFF_TS);
680     pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
681                                        + WLAN_PROBERESP_OFF_BCN_INT);
682     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
683                                 + WLAN_PROBERESP_OFF_CAP_INFO);
684
685     pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
686                   sizeof(*(pFrame->pwCapInfo));
687 }
688
689
690
691 /*+
692  *
693  * Routine Description:
694  *  Decode Probe Response
695  *
696  *
697  * Return Value:
698  *    None.
699  *
700 -*/
701
702 void
703 vMgrDecodeProbeResponse(
704      PWLAN_FR_PROBERESP  pFrame
705     )
706 {
707     PWLAN_IE    pItem;
708
709
710     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
711
712         /* Fixed Fields */
713         pFrame->pqwTimestamp =
714                 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
715                         WLAN_PROBERESP_OFF_TS);
716     pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
717                                        + WLAN_PROBERESP_OFF_BCN_INT);
718     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
719                                 + WLAN_PROBERESP_OFF_CAP_INFO);
720
721     /* Information elements */
722     pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
723                        + WLAN_PROBERESP_OFF_SSID);
724
725     while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
726         switch (pItem->byElementID) {
727         case WLAN_EID_SSID:
728             if (pFrame->pSSID == NULL)
729                 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
730             break;
731         case WLAN_EID_SUPP_RATES:
732             if (pFrame->pSuppRates == NULL)
733                 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
734             break;
735         case WLAN_EID_FH_PARMS:
736             break;
737         case WLAN_EID_DS_PARMS:
738             if (pFrame->pDSParms == NULL)
739                 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
740             break;
741         case WLAN_EID_CF_PARMS:
742             if (pFrame->pCFParms == NULL)
743                 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
744             break;
745         case WLAN_EID_IBSS_PARMS:
746             if (pFrame->pIBSSParms == NULL)
747                 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
748             break;
749
750         case WLAN_EID_RSN:
751             if (pFrame->pRSN == NULL)
752                 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
753             break;
754         case WLAN_EID_RSN_WPA:
755             if (pFrame->pRSNWPA == NULL) {
756                 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
757                     pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
758             }
759             break;
760         case WLAN_EID_ERP:
761             if (pFrame->pERP == NULL)
762                 pFrame->pERP = (PWLAN_IE_ERP)pItem;
763             break;
764         case WLAN_EID_EXTSUPP_RATES:
765             if (pFrame->pExtSuppRates == NULL)
766                 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
767             break;
768
769         case WLAN_EID_COUNTRY:      /* 7 */
770             if (pFrame->pIE_Country == NULL)
771                 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
772             break;
773
774         case WLAN_EID_PWR_CONSTRAINT:   /* 32 */
775             if (pFrame->pIE_PowerConstraint == NULL)
776                 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
777             break;
778
779         case WLAN_EID_CH_SWITCH:    /* 37 */
780             if (pFrame->pIE_CHSW == NULL)
781                 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
782             break;
783
784         case WLAN_EID_QUIET:        /* 40 */
785             if (pFrame->pIE_Quiet == NULL)
786                 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
787             break;
788
789         case WLAN_EID_IBSS_DFS:
790             if (pFrame->pIE_IBSSDFS == NULL)
791                 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
792             break;
793
794         default:
795             DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
796             break;
797         }
798
799         pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 +  pItem->len);
800     }
801 }
802
803
804 /*+
805  *
806  * Routine Description:
807  *     Encode Authentication frame
808  *
809  *
810  * Return Value:
811  *    None.
812  *
813 -*/
814
815 void
816 vMgrEncodeAuthen(
817       PWLAN_FR_AUTHEN  pFrame
818     )
819 {
820     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
821
822     /* Fixed Fields */
823     pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
824                                       + WLAN_AUTHEN_OFF_AUTH_ALG);
825     pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
826                                      + WLAN_AUTHEN_OFF_AUTH_SEQ);
827     pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
828                                + WLAN_AUTHEN_OFF_STATUS);
829     pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
830 }
831
832
833 /*+
834  *
835  * Routine Description:
836  *   Decode Authentication
837  *
838  *
839  * Return Value:
840  *    None.
841  *
842 -*/
843
844 void
845 vMgrDecodeAuthen(
846       PWLAN_FR_AUTHEN  pFrame
847     )
848 {
849     PWLAN_IE    pItem;
850
851     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
852
853     /* Fixed Fields */
854     pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
855                                       + WLAN_AUTHEN_OFF_AUTH_ALG);
856     pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
857                                      + WLAN_AUTHEN_OFF_AUTH_SEQ);
858     pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
859                                + WLAN_AUTHEN_OFF_STATUS);
860
861     /* Information elements */
862     pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
863                        + WLAN_AUTHEN_OFF_CHALLENGE);
864
865     if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE))
866         pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
867 }
868
869
870 /*+
871  *
872  * Routine Description:
873  *   Encode Authentication
874  *
875  *
876  * Return Value:
877  *    None.
878  *
879 -*/
880
881 void
882 vMgrEncodeDeauthen(
883       PWLAN_FR_DEAUTHEN  pFrame
884     )
885 {
886     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
887
888     /* Fixed Fields */
889     pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
890                                + WLAN_DEAUTHEN_OFF_REASON);
891     pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
892 }
893
894
895 /*+
896  *
897  * Routine Description:
898  *   Decode Deauthentication
899  *
900  *
901  * Return Value:
902  *    None.
903  *
904 -*/
905
906 void
907 vMgrDecodeDeauthen(
908       PWLAN_FR_DEAUTHEN  pFrame
909     )
910 {
911     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
912
913     /* Fixed Fields */
914     pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
915                                + WLAN_DEAUTHEN_OFF_REASON);
916 }
917
918
919 /*+
920  *
921  * Routine Description: (AP)
922  *   Encode Reassociation Response
923  *
924  *
925  * Return Value:
926  *    None.
927  *
928 -*/
929
930 void
931 vMgrEncodeReassocResponse(
932       PWLAN_FR_REASSOCRESP  pFrame
933      )
934 {
935     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
936
937     /* Fixed Fields */
938     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
939                                 + WLAN_REASSOCRESP_OFF_CAP_INFO);
940     pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
941                                + WLAN_REASSOCRESP_OFF_STATUS);
942     pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
943                             + WLAN_REASSOCRESP_OFF_AID);
944
945     pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
946 }
947
948
949 /*+
950  *
951  * Routine Description:
952  *   Decode Reassociation Response
953  *
954  *
955  * Return Value:
956  *    None.
957  *
958 -*/
959
960
961 void
962 vMgrDecodeReassocResponse(
963       PWLAN_FR_REASSOCRESP  pFrame
964      )
965 {
966     PWLAN_IE   pItem;
967
968     pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
969
970     /* Fixed Fields */
971     pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
972                                 + WLAN_REASSOCRESP_OFF_CAP_INFO);
973     pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
974                                + WLAN_REASSOCRESP_OFF_STATUS);
975     pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
976                             + WLAN_REASSOCRESP_OFF_AID);
977
978     /* Information elements */
979     pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
980                                                + WLAN_REASSOCRESP_OFF_SUPP_RATES);
981
982     pItem = (PWLAN_IE)(pFrame->pSuppRates);
983     pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
984
985     if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES))
986         pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
987 }