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