zram: promote zram from staging
[firefly-linux-kernel-4.4.55.git] / drivers / staging / vt6655 / 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 "tmacro.h"
56 #include "tether.h"
57 #include "80211mgr.h"
58 #include "80211hdr.h"
59 #include "device.h"
60 #include "wpa.h"
61
62 /*---------------------  Static Definitions -------------------------*/
63
64 /*---------------------  Static Classes  ----------------------------*/
65
66 /*---------------------  Static Variables  --------------------------*/
67
68 static int msglevel = MSG_LEVEL_INFO;
69 /* static int          msglevel                =MSG_LEVEL_DEBUG; */
70 /*---------------------  Static Functions  --------------------------*/
71
72 /*---------------------  Export Variables  --------------------------*/
73
74 /*---------------------  Export Functions  --------------------------*/
75
76 /*+
77  *
78  * Routine Description:
79  * Encode Beacon frame body offset
80  *
81  * Return Value:
82  *    None.
83  *
84  -*/
85
86 void
87 vMgrEncodeBeacon(
88         PWLAN_FR_BEACON  pFrame
89 )
90 {
91         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
92
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);
100
101         pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
102
103         return;
104 }
105
106 /*+
107  *
108  * Routine Description:
109  * Decode Beacon frame body offset
110  *
111  *
112  * Return Value:
113  *    None.
114  *
115  -*/
116
117 void
118 vMgrDecodeBeacon(
119         PWLAN_FR_BEACON  pFrame
120 )
121 {
122         PWLAN_IE        pItem;
123
124         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
125
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);
133
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;
166
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;
175                         }
176                         break;
177
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;
186
187                 case WLAN_EID_COUNTRY:      /* 7 */
188                         if (pFrame->pIE_Country == NULL)
189                                 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
190                         break;
191
192                 case WLAN_EID_PWR_CONSTRAINT:   /* 32 */
193                         if (pFrame->pIE_PowerConstraint == NULL)
194                                 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
195                         break;
196
197                 case WLAN_EID_CH_SWITCH:    /* 37 */
198                         if (pFrame->pIE_CHSW == NULL)
199                                 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
200                         break;
201
202                 case WLAN_EID_QUIET:        /* 40 */
203                         if (pFrame->pIE_Quiet == NULL)
204                                 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
205                         break;
206
207                 case WLAN_EID_IBSS_DFS:
208                         if (pFrame->pIE_IBSSDFS == NULL)
209                                 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
210                         break;
211
212                 default:
213                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
214                         break;
215
216                 }
217                 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
218         }
219
220         return;
221 }
222
223 /*+
224  *
225  * Routine Description:
226  *  Encode IBSS ATIM
227  *
228  *
229  * Return Value:
230  *    None.
231  *
232  -*/
233
234 void
235 vMgrEncodeIBSSATIM(
236         PWLAN_FR_IBSSATIM   pFrame
237 )
238 {
239         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
240         pFrame->len = WLAN_HDR_ADDR3_LEN;
241
242         return;
243 }
244
245 /*+
246  *
247  * Routine Description:
248  *  Decode IBSS ATIM
249  *
250  *
251  * Return Value:
252  *    None.
253  *
254  -*/
255
256 void
257 vMgrDecodeIBSSATIM(
258         PWLAN_FR_IBSSATIM   pFrame
259 )
260 {
261         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
262
263         return;
264 }
265
266 /*+
267  *
268  * Routine Description:
269  *  Encode Disassociation
270  *
271  *
272  * Return Value:
273  *    None.
274  *
275  -*/
276
277 void
278 vMgrEncodeDisassociation(
279         PWLAN_FR_DISASSOC  pFrame
280 )
281 {
282         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
283
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));
288
289         return;
290 }
291
292 /*+
293  *
294  * Routine Description:
295  *  Decode Disassociation
296  *
297  *
298  * Return Value:
299  *    None.
300  *
301  -*/
302
303 void
304 vMgrDecodeDisassociation(
305         PWLAN_FR_DISASSOC  pFrame
306 )
307 {
308         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
309
310         /* Fixed Fields */
311         pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
312                                               + WLAN_DISASSOC_OFF_REASON);
313
314         return;
315 }
316
317 /*+
318  *
319  * Routine Description:
320  *  Encode Association Request
321  *
322  *
323  * Return Value:
324  *    None.
325  *
326  -*/
327
328 void
329 vMgrEncodeAssocRequest(
330         PWLAN_FR_ASSOCREQ  pFrame
331 )
332 {
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;
341 }
342
343 /*+
344  *
345  * Routine Description: (AP)
346  *  Decode Association Request
347  *
348  *
349  * Return Value:
350  *    None.
351  *
352  -*/
353
354 void
355 vMgrDecodeAssocRequest(
356         PWLAN_FR_ASSOCREQ  pFrame
357 )
358 {
359         PWLAN_IE   pItem;
360
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);
367
368         /* Information elements */
369         pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
370                            + WLAN_ASSOCREQ_OFF_SSID);
371
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;
382
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;
391                         }
392                         break;
393                 case WLAN_EID_EXTSUPP_RATES:
394                         if (pFrame->pExtSuppRates == NULL)
395                                 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
396                         break;
397
398                 default:
399                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
400                                 pItem->byElementID);
401                         break;
402                 }
403                 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
404         }
405         return;
406 }
407
408 /*+
409  *
410  * Routine Description: (AP)
411  *  Encode Association Response
412  *
413  *
414  * Return Value:
415  *    None.
416  *
417  -*/
418
419 void
420 vMgrEncodeAssocResponse(
421         PWLAN_FR_ASSOCRESP  pFrame
422 )
423 {
424         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
425
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));
435
436         return;
437 }
438
439 /*+
440  *
441  * Routine Description:
442  *  Decode Association Response
443  *
444  *
445  * Return Value:
446  *    None.
447  *
448  -*/
449
450 void
451 vMgrDecodeAssocResponse(
452         PWLAN_FR_ASSOCRESP  pFrame
453 )
454 {
455         PWLAN_IE   pItem;
456
457         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
458
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);
466
467         /* Information elements */
468         pFrame->pSuppRates  = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
469                                                     + WLAN_ASSOCRESP_OFF_SUPP_RATES);
470
471         pItem = (PWLAN_IE)(pFrame->pSuppRates);
472         pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
473
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;
480         }
481         return;
482 }
483
484 /*+
485  *
486  * Routine Description:
487  *  Encode Reassociation Request
488  *
489  *
490  * Return Value:
491  *    None.
492  *
493  -*/
494
495 void
496 vMgrEncodeReassocRequest(
497         PWLAN_FR_REASSOCREQ  pFrame
498 )
499 {
500         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
501
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));
510
511         return;
512 }
513
514 /*+
515  *
516  * Routine Description: (AP)
517  *  Decode Reassociation Request
518  *
519  *
520  * Return Value:
521  *    None.
522  *
523  -*/
524
525 void
526 vMgrDecodeReassocRequest(
527         PWLAN_FR_REASSOCREQ  pFrame
528 )
529 {
530         PWLAN_IE   pItem;
531         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
532
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);
540
541         /* Information elements */
542         pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
543                            + WLAN_REASSOCREQ_OFF_SSID);
544
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;
555
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;
564                         }
565                         break;
566
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;
575                 }
576                 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
577         }
578         return;
579 }
580
581 /*+
582  *
583  * Routine Description:
584  *  Encode Probe Request
585  *
586  *
587  * Return Value:
588  *    None.
589  *
590  -*/
591
592 void
593 vMgrEncodeProbeRequest(
594         PWLAN_FR_PROBEREQ  pFrame
595 )
596 {
597         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
598         pFrame->len = WLAN_HDR_ADDR3_LEN;
599         return;
600 }
601
602 /*+
603  *
604  * Routine Description:
605  *  Decode Probe Request
606  *
607  *
608  * Return Value:
609  *    None.
610  *
611  -*/
612
613 void
614 vMgrDecodeProbeRequest(
615         PWLAN_FR_PROBEREQ  pFrame
616 )
617 {
618         PWLAN_IE   pItem;
619
620         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
621
622         /* Information elements */
623         pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
624
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;
631
632                 case WLAN_EID_SUPP_RATES:
633                         if (pFrame->pSuppRates == NULL)
634                                 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
635                         break;
636
637                 case WLAN_EID_EXTSUPP_RATES:
638                         if (pFrame->pExtSuppRates == NULL)
639                                 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
640                         break;
641
642                 default:
643                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
644                         break;
645                 }
646
647                 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 +  pItem->len);
648         }
649         return;
650 }
651
652 /*+
653  *
654  * Routine Description:
655  *  Encode Probe Response
656  *
657  *
658  * Return Value:
659  *    None.
660  *
661  -*/
662
663 void
664 vMgrEncodeProbeResponse(
665         PWLAN_FR_PROBERESP  pFrame
666 )
667 {
668         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
669
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);
677
678         pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
679                 sizeof(*(pFrame->pwCapInfo));
680
681         return;
682 }
683
684 /*+
685  *
686  * Routine Description:
687  *  Decode Probe Response
688  *
689  *
690  * Return Value:
691  *    None.
692  *
693  -*/
694
695 void
696 vMgrDecodeProbeResponse(
697         PWLAN_FR_PROBERESP  pFrame
698 )
699 {
700         PWLAN_IE    pItem;
701
702         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
703
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);
711
712         /* Information elements */
713         pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
714                            + WLAN_PROBERESP_OFF_SSID);
715
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;
740
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;
749                         }
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;
759
760                 case WLAN_EID_COUNTRY:      /* 7 */
761                         if (pFrame->pIE_Country == NULL)
762                                 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
763                         break;
764
765                 case WLAN_EID_PWR_CONSTRAINT:   /* 32 */
766                         if (pFrame->pIE_PowerConstraint == NULL)
767                                 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
768                         break;
769
770                 case WLAN_EID_CH_SWITCH:    /* 37 */
771                         if (pFrame->pIE_CHSW == NULL)
772                                 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
773                         break;
774
775                 case WLAN_EID_QUIET:        /* 40 */
776                         if (pFrame->pIE_Quiet == NULL)
777                                 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
778                         break;
779
780                 case WLAN_EID_IBSS_DFS:
781                         if (pFrame->pIE_IBSSDFS == NULL)
782                                 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
783                         break;
784
785                 default:
786                         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
787                         break;
788                 }
789
790                 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 +  pItem->len);
791         }
792         return;
793 }
794
795 /*+
796  *
797  * Routine Description:
798  *     Encode Authentication frame
799  *
800  *
801  * Return Value:
802  *    None.
803  *
804  -*/
805
806 void
807 vMgrEncodeAuthen(
808         PWLAN_FR_AUTHEN  pFrame
809 )
810 {
811         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
812
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));
821
822         return;
823 }
824
825 /*+
826  *
827  * Routine Description:
828  *   Decode Authentication
829  *
830  *
831  * Return Value:
832  *    None.
833  *
834  -*/
835
836 void
837 vMgrDecodeAuthen(
838         PWLAN_FR_AUTHEN  pFrame
839 )
840 {
841         PWLAN_IE    pItem;
842
843         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
844
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);
852
853         /* Information elements */
854         pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
855                            + WLAN_AUTHEN_OFF_CHALLENGE);
856
857         if (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len) &&
858             pItem->byElementID == WLAN_EID_CHALLENGE)
859                 pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
860
861         return;
862 }
863
864 /*+
865  *
866  * Routine Description:
867  *   Encode Authentication
868  *
869  *
870  * Return Value:
871  *    None.
872  *
873  -*/
874
875 void
876 vMgrEncodeDeauthen(
877         PWLAN_FR_DEAUTHEN  pFrame
878 )
879 {
880         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
881
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));
886
887         return;
888 }
889
890 /*+
891  *
892  * Routine Description:
893  *   Decode Deauthentication
894  *
895  *
896  * Return Value:
897  *    None.
898  *
899  -*/
900
901 void
902 vMgrDecodeDeauthen(
903         PWLAN_FR_DEAUTHEN  pFrame
904 )
905 {
906         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
907
908         /* Fixed Fields */
909         pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
910                                               + WLAN_DEAUTHEN_OFF_REASON);
911
912         return;
913 }
914
915 /*+
916  *
917  * Routine Description: (AP)
918  *   Encode Reassociation Response
919  *
920  *
921  * Return Value:
922  *    None.
923  *
924  -*/
925
926 void
927 vMgrEncodeReassocResponse(
928         PWLAN_FR_REASSOCRESP  pFrame
929 )
930 {
931         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
932
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);
940
941         pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
942
943         return;
944 }
945
946 /*+
947  *
948  * Routine Description:
949  *   Decode Reassociation Response
950  *
951  *
952  * Return Value:
953  *    None.
954  *
955  -*/
956
957 void
958 vMgrDecodeReassocResponse(
959         PWLAN_FR_REASSOCRESP  pFrame
960 )
961 {
962         PWLAN_IE   pItem;
963
964         pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
965
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);
973
974         /* Information elements */
975         pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
976                                                    + WLAN_REASSOCRESP_OFF_SUPP_RATES);
977
978         pItem = (PWLAN_IE)(pFrame->pSuppRates);
979         pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
980
981         if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) &&
982             (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
983                 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
984         }
985         return;
986 }