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