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