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