Merge tag 'blackfin-for-linus' of http://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.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
92b96797
FB
30 * vMgrEncodeDisassociation - Encode the Disassociation frame
31 * vMgrDecodeDisassociation - Decode the Disassociation frame
32 * vMgrEncodeAssocRequest - Encode the Association request frame
33 * vMgrDecodeAssocRequest - Decode the Association request frame
34 * vMgrEncodeAssocResponse - Encode the Association response frame
35 * vMgrDecodeAssocResponse - Decode the Association response frame
36 * vMgrEncodeReAssocRequest - Encode the ReAssociation request frame
37 * vMgrDecodeReAssocRequest - Decode the ReAssociation request frame
38 * vMgrEncodeProbeRequest - Encode the Probe request frame
39 * vMgrDecodeProbeRequest - Decode the Probe request frame
40 * vMgrEncodeProbeResponse - Encode the Probe response frame
41 * vMgrDecodeProbeResponse - Decode the Probe response frame
42 * vMgrEncodeAuthen - Encode the Authentication frame
43 * vMgrDecodeAuthen - Decode the Authentication frame
44 * vMgrEncodeDeauthen - Encode the DeAuthentication frame
45 * vMgrDecodeDeauthen - Decode the DeAuthentication frame
46 * vMgrEncodeReassocResponse - Encode the Reassociation response frame
92b96797
FB
47 *
48 * Revision History:
49 *
50 */
51
11d404cb 52#include "device.h"
92b96797 53#include "tmacro.h"
92b96797 54#include "tether.h"
92b96797 55#include "80211mgr.h"
92b96797 56#include "80211hdr.h"
92b96797 57#include "wpa.h"
92b96797 58
2555cd9f
TT
59static int msglevel = MSG_LEVEL_INFO;
60/*static int msglevel =MSG_LEVEL_DEBUG;*/
92b96797 61
92b96797
FB
62/*+
63 *
64 * Routine Description:
65 * Encode Beacon frame body offset
66 *
67 * Return Value:
68 * None.
69 *
70-*/
71
8611a29a 72void
92b96797 73vMgrEncodeBeacon(
592ccfeb 74 PWLAN_FR_BEACON pFrame
92b96797
FB
75 )
76{
77 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
78
7c65fa2a
MP
79 /* Fixed Fields */
80 pFrame->pqwTimestamp =
81 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
82 WLAN_BEACON_OFF_TS);
3eaca0d2 83 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 84 + WLAN_BEACON_OFF_BCN_INT);
3eaca0d2 85 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
86 + WLAN_BEACON_OFF_CAPINFO);
87
88 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
89
90 return;
91}
92
93/*+
94 *
95 * Routine Description:
96 * Decode Beacon frame body offset
97 *
98 *
99 * Return Value:
100 * None.
101 *
102-*/
103
8611a29a 104void
92b96797 105vMgrDecodeBeacon(
592ccfeb 106 PWLAN_FR_BEACON pFrame
92b96797
FB
107 )
108{
109 PWLAN_IE pItem;
110
111 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
112
7c65fa2a
MP
113 /* Fixed Fields */
114 pFrame->pqwTimestamp =
115 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
116 WLAN_BEACON_OFF_TS);
3eaca0d2 117 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 118 + WLAN_BEACON_OFF_BCN_INT);
3eaca0d2 119 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
120 + WLAN_BEACON_OFF_CAPINFO);
121
2555cd9f 122 /* Information elements */
b902fbfe 123 pItem = (PWLAN_IE)((u8 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
92b96797 124 + WLAN_BEACON_OFF_SSID);
b902fbfe 125 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
92b96797
FB
126
127 switch (pItem->byElementID) {
2555cd9f
TT
128 case WLAN_EID_SSID:
129 if (pFrame->pSSID == NULL)
130 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
131 break;
132 case WLAN_EID_SUPP_RATES:
133 if (pFrame->pSuppRates == NULL)
134 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
135 break;
136 case WLAN_EID_FH_PARMS:
137 /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */
138 break;
139 case WLAN_EID_DS_PARMS:
140 if (pFrame->pDSParms == NULL)
141 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
142 break;
143 case WLAN_EID_CF_PARMS:
144 if (pFrame->pCFParms == NULL)
145 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
146 break;
147 case WLAN_EID_IBSS_PARMS:
148 if (pFrame->pIBSSParms == NULL)
149 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
150 break;
151 case WLAN_EID_TIM:
152 if (pFrame->pTIM == NULL)
153 pFrame->pTIM = (PWLAN_IE_TIM)pItem;
154 break;
155
156 case WLAN_EID_RSN:
157 if (pFrame->pRSN == NULL)
158 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
159 break;
160 case WLAN_EID_RSN_WPA:
161 if (pFrame->pRSNWPA == NULL) {
4e9b5e2b 162 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
2555cd9f
TT
163 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
164 }
165 break;
166
167 case WLAN_EID_ERP:
168 if (pFrame->pERP == NULL)
169 pFrame->pERP = (PWLAN_IE_ERP)pItem;
170 break;
171 case WLAN_EID_EXTSUPP_RATES:
172 if (pFrame->pExtSuppRates == NULL)
173 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
174 break;
175
176 case WLAN_EID_COUNTRY: /* 7 */
177 if (pFrame->pIE_Country == NULL)
178 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
179 break;
180
181 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
182 if (pFrame->pIE_PowerConstraint == NULL)
183 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
184 break;
185
186 case WLAN_EID_CH_SWITCH: /* 37 */
187 if (pFrame->pIE_CHSW == NULL)
188 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
189 break;
190
191 case WLAN_EID_QUIET: /* 40 */
192 if (pFrame->pIE_Quiet == NULL)
193 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
194 break;
195
196 case WLAN_EID_IBSS_DFS:
197 if (pFrame->pIE_IBSSDFS == NULL)
198 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
199 break;
200
201 default:
202 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
92b96797
FB
203 break;
204
205 }
b902fbfe 206 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
92b96797 207 }
92b96797
FB
208}
209
92b96797
FB
210/*+
211 *
212 * Routine Description:
213 * Encode Disassociation
214 *
215 *
216 * Return Value:
217 * None.
218 *
219-*/
220
8611a29a 221void
92b96797 222vMgrEncodeDisassociation(
592ccfeb 223 PWLAN_FR_DISASSOC pFrame
92b96797
FB
224 )
225{
226 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
227
2555cd9f 228 /* Fixed Fields */
3eaca0d2 229 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
230 + WLAN_DISASSOC_OFF_REASON);
231 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
92b96797
FB
232}
233
92b96797
FB
234/*+
235 *
236 * Routine Description:
237 * Decode Disassociation
238 *
239 *
240 * Return Value:
241 * None.
242 *
243-*/
244
8611a29a 245void
92b96797 246vMgrDecodeDisassociation(
592ccfeb 247 PWLAN_FR_DISASSOC pFrame
92b96797
FB
248 )
249{
250 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
251
2555cd9f 252 /* Fixed Fields */
3eaca0d2 253 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 254 + WLAN_DISASSOC_OFF_REASON);
92b96797
FB
255}
256
257/*+
258 *
259 * Routine Description:
260 * Encode Association Request
261 *
262 *
263 * Return Value:
264 * None.
265 *
266-*/
267
8611a29a 268void
92b96797 269vMgrEncodeAssocRequest(
592ccfeb 270 PWLAN_FR_ASSOCREQ pFrame
92b96797
FB
271 )
272{
273 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
2555cd9f 274 /* Fixed Fields */
3eaca0d2 275 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 276 + WLAN_ASSOCREQ_OFF_CAP_INFO);
3eaca0d2 277 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
278 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
279 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
92b96797
FB
280}
281
92b96797
FB
282/*+
283 *
284 * Routine Description: (AP)
285 * Decode Association Request
286 *
287 *
288 * Return Value:
289 * None.
290 *
291-*/
292
8611a29a 293void
92b96797 294vMgrDecodeAssocRequest(
592ccfeb 295 PWLAN_FR_ASSOCREQ pFrame
92b96797
FB
296 )
297{
298 PWLAN_IE pItem;
299
300 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
2555cd9f 301 /* Fixed Fields */
3eaca0d2 302 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 303 + WLAN_ASSOCREQ_OFF_CAP_INFO);
3eaca0d2 304 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
305 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
306
2555cd9f 307 /* Information elements */
92b96797
FB
308 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
309 + WLAN_ASSOCREQ_OFF_SSID);
310
b902fbfe 311 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
2555cd9f
TT
312 switch (pItem->byElementID) {
313 case WLAN_EID_SSID:
314 if (pFrame->pSSID == NULL)
315 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
316 break;
317 case WLAN_EID_SUPP_RATES:
318 if (pFrame->pSuppRates == NULL)
319 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
320 break;
321
322 case WLAN_EID_RSN:
323 if (pFrame->pRSN == NULL)
324 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
325 break;
326 case WLAN_EID_RSN_WPA:
327 if (pFrame->pRSNWPA == NULL) {
4e9b5e2b 328 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
2555cd9f
TT
329 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
330 }
331 break;
332 case WLAN_EID_EXTSUPP_RATES:
333 if (pFrame->pExtSuppRates == NULL)
334 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
335 break;
336
337 default:
338 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
339 pItem->byElementID);
340 break;
92b96797 341 }
b902fbfe 342 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
92b96797 343 }
92b96797
FB
344}
345
346/*+
347 *
348 * Routine Description: (AP)
349 * Encode Association Response
350 *
351 *
352 * Return Value:
353 * None.
354 *
355-*/
356
8611a29a 357void
92b96797 358vMgrEncodeAssocResponse(
592ccfeb 359 PWLAN_FR_ASSOCRESP pFrame
92b96797
FB
360 )
361{
362 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
363
2555cd9f 364 /* Fixed Fields */
3eaca0d2 365 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 366 + WLAN_ASSOCRESP_OFF_CAP_INFO);
3eaca0d2 367 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 368 + WLAN_ASSOCRESP_OFF_STATUS);
3eaca0d2 369 pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
370 + WLAN_ASSOCRESP_OFF_AID);
371 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
372 + sizeof(*(pFrame->pwAid));
92b96797
FB
373}
374
92b96797
FB
375/*+
376 *
377 * Routine Description:
378 * Decode Association Response
379 *
380 *
381 * Return Value:
382 * None.
383 *
384-*/
385
8611a29a 386void
92b96797 387vMgrDecodeAssocResponse(
592ccfeb 388 PWLAN_FR_ASSOCRESP pFrame
92b96797
FB
389 )
390{
391 PWLAN_IE pItem;
392
393 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
394
2555cd9f 395 /* Fixed Fields */
3eaca0d2 396 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 397 + WLAN_ASSOCRESP_OFF_CAP_INFO);
3eaca0d2 398 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 399 + WLAN_ASSOCRESP_OFF_STATUS);
3eaca0d2 400 pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
401 + WLAN_ASSOCRESP_OFF_AID);
402
2555cd9f 403 /* Information elements */
92b96797
FB
404 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
405 + WLAN_ASSOCRESP_OFF_SUPP_RATES);
406
407 pItem = (PWLAN_IE)(pFrame->pSuppRates);
b902fbfe 408 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
92b96797 409
b902fbfe 410 if ((((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
92b96797
FB
411 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
412 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
63182376 413 } else
92b96797 414 pFrame->pExtSuppRates = NULL;
92b96797
FB
415}
416
92b96797
FB
417/*+
418 *
419 * Routine Description:
420 * Encode Reassociation Request
421 *
422 *
423 * Return Value:
424 * None.
425 *
426-*/
427
8611a29a 428void
92b96797 429vMgrEncodeReassocRequest(
592ccfeb 430 PWLAN_FR_REASSOCREQ pFrame
92b96797
FB
431 )
432{
433 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
434
2555cd9f 435 /* Fixed Fields */
3eaca0d2 436 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 437 + WLAN_REASSOCREQ_OFF_CAP_INFO);
3eaca0d2 438 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
439 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
440 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
441 + WLAN_REASSOCREQ_OFF_CURR_AP);
442 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
92b96797
FB
443}
444
92b96797
FB
445/*+
446 *
447 * Routine Description: (AP)
448 * Decode Reassociation Request
449 *
450 *
451 * Return Value:
452 * None.
453 *
454-*/
455
8611a29a 456void
92b96797 457vMgrDecodeReassocRequest(
592ccfeb 458 PWLAN_FR_REASSOCREQ pFrame
92b96797
FB
459 )
460{
461 PWLAN_IE pItem;
462 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
463
2555cd9f 464 /* Fixed Fields */
3eaca0d2 465 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 466 + WLAN_REASSOCREQ_OFF_CAP_INFO);
3eaca0d2 467 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
468 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
469 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
470 + WLAN_REASSOCREQ_OFF_CURR_AP);
471
2555cd9f 472 /* Information elements */
92b96797
FB
473 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
474 + WLAN_REASSOCREQ_OFF_SSID);
475
b902fbfe 476 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
92b96797 477
2555cd9f
TT
478 switch (pItem->byElementID) {
479 case WLAN_EID_SSID:
480 if (pFrame->pSSID == NULL)
481 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
482 break;
483 case WLAN_EID_SUPP_RATES:
484 if (pFrame->pSuppRates == NULL)
485 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
486 break;
487
488 case WLAN_EID_RSN:
489 if (pFrame->pRSN == NULL)
490 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
491 break;
492 case WLAN_EID_RSN_WPA:
63182376 493 if (pFrame->pRSNWPA == NULL)
4e9b5e2b 494 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
2555cd9f 495 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
2555cd9f
TT
496 break;
497
498 case WLAN_EID_EXTSUPP_RATES:
499 if (pFrame->pExtSuppRates == NULL)
500 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
501 break;
502 default:
503 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n",
504 pItem->byElementID);
505 break;
92b96797 506 }
b902fbfe 507 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
92b96797 508 }
92b96797
FB
509}
510
92b96797
FB
511/*+
512 *
513 * Routine Description:
514 * Encode Probe Request
515 *
516 *
517 * Return Value:
518 * None.
519 *
520-*/
521
8611a29a 522void
92b96797 523vMgrEncodeProbeRequest(
592ccfeb 524 PWLAN_FR_PROBEREQ pFrame
92b96797
FB
525 )
526{
527 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
528 pFrame->len = WLAN_HDR_ADDR3_LEN;
92b96797
FB
529}
530
531/*+
532 *
533 * Routine Description:
534 * Decode Probe Request
535 *
536 *
537 * Return Value:
538 * None.
539 *
540-*/
541
8611a29a 542void
92b96797 543vMgrDecodeProbeRequest(
592ccfeb 544 PWLAN_FR_PROBEREQ pFrame
92b96797
FB
545 )
546{
547 PWLAN_IE pItem;
548
549 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
550
2555cd9f 551 /* Information elements */
92b96797
FB
552 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
553
b902fbfe 554 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
92b96797
FB
555
556 switch (pItem->byElementID) {
2555cd9f
TT
557 case WLAN_EID_SSID:
558 if (pFrame->pSSID == NULL)
559 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
560 break;
92b96797 561
2555cd9f
TT
562 case WLAN_EID_SUPP_RATES:
563 if (pFrame->pSuppRates == NULL)
564 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
565 break;
92b96797 566
2555cd9f
TT
567 case WLAN_EID_EXTSUPP_RATES:
568 if (pFrame->pExtSuppRates == NULL)
569 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
570 break;
92b96797 571
2555cd9f
TT
572 default:
573 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
574 break;
92b96797
FB
575 }
576
b902fbfe 577 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
92b96797 578 }
92b96797
FB
579}
580
92b96797
FB
581/*+
582 *
583 * Routine Description:
584 * Encode Probe Response
585 *
586 *
587 * Return Value:
588 * None.
589 *
590-*/
591
8611a29a 592void
92b96797 593vMgrEncodeProbeResponse(
592ccfeb 594 PWLAN_FR_PROBERESP pFrame
92b96797
FB
595 )
596{
597 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
598
7c65fa2a
MP
599 /* Fixed Fields */
600 pFrame->pqwTimestamp =
601 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
602 WLAN_PROBERESP_OFF_TS);
3eaca0d2 603 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 604 + WLAN_PROBERESP_OFF_BCN_INT);
3eaca0d2 605 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
606 + WLAN_PROBERESP_OFF_CAP_INFO);
607
608 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
609 sizeof(*(pFrame->pwCapInfo));
92b96797
FB
610}
611
92b96797
FB
612/*+
613 *
614 * Routine Description:
615 * Decode Probe Response
616 *
617 *
618 * Return Value:
619 * None.
620 *
621-*/
622
8611a29a 623void
92b96797 624vMgrDecodeProbeResponse(
592ccfeb 625 PWLAN_FR_PROBERESP pFrame
92b96797
FB
626 )
627{
628 PWLAN_IE pItem;
92b96797 629
92b96797
FB
630 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
631
7c65fa2a
MP
632 /* Fixed Fields */
633 pFrame->pqwTimestamp =
634 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
635 WLAN_PROBERESP_OFF_TS);
3eaca0d2 636 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 637 + WLAN_PROBERESP_OFF_BCN_INT);
3eaca0d2 638 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
639 + WLAN_PROBERESP_OFF_CAP_INFO);
640
2555cd9f 641 /* Information elements */
92b96797
FB
642 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
643 + WLAN_PROBERESP_OFF_SSID);
644
b902fbfe 645 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
92b96797 646 switch (pItem->byElementID) {
2555cd9f
TT
647 case WLAN_EID_SSID:
648 if (pFrame->pSSID == NULL)
92b96797 649 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
2555cd9f
TT
650 break;
651 case WLAN_EID_SUPP_RATES:
652 if (pFrame->pSuppRates == NULL)
92b96797 653 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
2555cd9f
TT
654 break;
655 case WLAN_EID_FH_PARMS:
656 break;
657 case WLAN_EID_DS_PARMS:
658 if (pFrame->pDSParms == NULL)
659 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
660 break;
661 case WLAN_EID_CF_PARMS:
662 if (pFrame->pCFParms == NULL)
663 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
664 break;
665 case WLAN_EID_IBSS_PARMS:
666 if (pFrame->pIBSSParms == NULL)
667 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
668 break;
669
670 case WLAN_EID_RSN:
671 if (pFrame->pRSN == NULL)
672 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
673 break;
674 case WLAN_EID_RSN_WPA:
675 if (pFrame->pRSNWPA == NULL) {
4e9b5e2b 676 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
2555cd9f
TT
677 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
678 }
679 break;
680 case WLAN_EID_ERP:
681 if (pFrame->pERP == NULL)
682 pFrame->pERP = (PWLAN_IE_ERP)pItem;
683 break;
684 case WLAN_EID_EXTSUPP_RATES:
685 if (pFrame->pExtSuppRates == NULL)
686 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
687 break;
688
689 case WLAN_EID_COUNTRY: /* 7 */
690 if (pFrame->pIE_Country == NULL)
691 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
692 break;
693
694 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
695 if (pFrame->pIE_PowerConstraint == NULL)
696 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
697 break;
698
699 case WLAN_EID_CH_SWITCH: /* 37 */
700 if (pFrame->pIE_CHSW == NULL)
701 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
702 break;
703
704 case WLAN_EID_QUIET: /* 40 */
705 if (pFrame->pIE_Quiet == NULL)
706 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
707 break;
708
709 case WLAN_EID_IBSS_DFS:
710 if (pFrame->pIE_IBSSDFS == NULL)
711 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
712 break;
713
714 default:
715 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
716 break;
92b96797
FB
717 }
718
b902fbfe 719 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
92b96797 720 }
92b96797
FB
721}
722
92b96797
FB
723/*+
724 *
725 * Routine Description:
726 * Encode Authentication frame
727 *
728 *
729 * Return Value:
730 * None.
731 *
732-*/
733
8611a29a 734void
92b96797 735vMgrEncodeAuthen(
592ccfeb 736 PWLAN_FR_AUTHEN pFrame
92b96797
FB
737 )
738{
739 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
740
2555cd9f 741 /* Fixed Fields */
3eaca0d2 742 pFrame->pwAuthAlgorithm = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 743 + WLAN_AUTHEN_OFF_AUTH_ALG);
3eaca0d2 744 pFrame->pwAuthSequence = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 745 + WLAN_AUTHEN_OFF_AUTH_SEQ);
3eaca0d2 746 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
747 + WLAN_AUTHEN_OFF_STATUS);
748 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
92b96797
FB
749}
750
92b96797
FB
751/*+
752 *
753 * Routine Description:
754 * Decode Authentication
755 *
756 *
757 * Return Value:
758 * None.
759 *
760-*/
761
8611a29a 762void
92b96797 763vMgrDecodeAuthen(
592ccfeb 764 PWLAN_FR_AUTHEN pFrame
92b96797
FB
765 )
766{
767 PWLAN_IE pItem;
768
769 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
770
2555cd9f 771 /* Fixed Fields */
3eaca0d2 772 pFrame->pwAuthAlgorithm = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 773 + WLAN_AUTHEN_OFF_AUTH_ALG);
3eaca0d2 774 pFrame->pwAuthSequence = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 775 + WLAN_AUTHEN_OFF_AUTH_SEQ);
3eaca0d2 776 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
777 + WLAN_AUTHEN_OFF_STATUS);
778
2555cd9f 779 /* Information elements */
92b96797
FB
780 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
781 + WLAN_AUTHEN_OFF_CHALLENGE);
782
b902fbfe 783 if ((((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE))
92b96797 784 pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
92b96797
FB
785}
786
92b96797
FB
787/*+
788 *
789 * Routine Description:
790 * Encode Authentication
791 *
792 *
793 * Return Value:
794 * None.
795 *
796-*/
797
8611a29a 798void
92b96797 799vMgrEncodeDeauthen(
592ccfeb 800 PWLAN_FR_DEAUTHEN pFrame
92b96797
FB
801 )
802{
803 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
804
2555cd9f 805 /* Fixed Fields */
3eaca0d2 806 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
807 + WLAN_DEAUTHEN_OFF_REASON);
808 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
92b96797
FB
809}
810
92b96797
FB
811/*+
812 *
813 * Routine Description:
814 * Decode Deauthentication
815 *
816 *
817 * Return Value:
818 * None.
819 *
820-*/
821
8611a29a 822void
92b96797 823vMgrDecodeDeauthen(
592ccfeb 824 PWLAN_FR_DEAUTHEN pFrame
92b96797
FB
825 )
826{
827 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
828
2555cd9f 829 /* Fixed Fields */
3eaca0d2 830 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 831 + WLAN_DEAUTHEN_OFF_REASON);
92b96797
FB
832}
833
92b96797
FB
834/*+
835 *
836 * Routine Description: (AP)
837 * Encode Reassociation Response
838 *
839 *
840 * Return Value:
841 * None.
842 *
843-*/
844
8611a29a 845void
92b96797 846vMgrEncodeReassocResponse(
592ccfeb 847 PWLAN_FR_REASSOCRESP pFrame
92b96797
FB
848 )
849{
850 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
851
2555cd9f 852 /* Fixed Fields */
3eaca0d2 853 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 854 + WLAN_REASSOCRESP_OFF_CAP_INFO);
3eaca0d2 855 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797 856 + WLAN_REASSOCRESP_OFF_STATUS);
3eaca0d2 857 pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
92b96797
FB
858 + WLAN_REASSOCRESP_OFF_AID);
859
860 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
92b96797 861}
This page took 0.435617 seconds and 5 git commands to generate.