Merge tag 'for-linus-3.16-merge-window' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / drivers / staging / vt6656 / 80211mgr.c
1 /*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * File: 80211mgr.c
20 *
21 * Purpose: Handles the 802.11 management support functions
22 *
23 * Author: Lyndon Chen
24 *
25 * Date: May 8, 2002
26 *
27 * Functions:
28 * vMgrEncodeBeacon - Encode the Beacon frame
29 * vMgrDecodeBeacon - Decode the Beacon frame
30 * 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
47 *
48 * Revision History:
49 *
50 */
51
52 #include "device.h"
53 #include "tmacro.h"
54 #include "tether.h"
55 #include "80211mgr.h"
56 #include "80211hdr.h"
57 #include "wpa.h"
58
59 static int msglevel = MSG_LEVEL_INFO;
60 /*static int msglevel =MSG_LEVEL_DEBUG;*/
61
62 /*+
63 *
64 * Routine Description:
65 * Encode Beacon frame body offset
66 *
67 * Return Value:
68 * None.
69 *
70 -*/
71
72 void
73 vMgrEncodeBeacon(
74 PWLAN_FR_BEACON pFrame
75 )
76 {
77 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
78
79 /* Fixed Fields */
80 pFrame->pqwTimestamp =
81 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
82 WLAN_BEACON_OFF_TS);
83 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
84 + WLAN_BEACON_OFF_BCN_INT);
85 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
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
104 void
105 vMgrDecodeBeacon(
106 PWLAN_FR_BEACON pFrame
107 )
108 {
109 PWLAN_IE pItem;
110
111 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
112
113 /* Fixed Fields */
114 pFrame->pqwTimestamp =
115 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
116 WLAN_BEACON_OFF_TS);
117 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
118 + WLAN_BEACON_OFF_BCN_INT);
119 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
120 + WLAN_BEACON_OFF_CAPINFO);
121
122 /* Information elements */
123 pItem = (PWLAN_IE)((u8 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
124 + WLAN_BEACON_OFF_SSID);
125 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
126
127 switch (pItem->byElementID) {
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) {
162 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
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);
203 break;
204
205 }
206 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
207 }
208 }
209
210 /*+
211 *
212 * Routine Description:
213 * Encode Disassociation
214 *
215 *
216 * Return Value:
217 * None.
218 *
219 -*/
220
221 void
222 vMgrEncodeDisassociation(
223 PWLAN_FR_DISASSOC pFrame
224 )
225 {
226 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
227
228 /* Fixed Fields */
229 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
230 + WLAN_DISASSOC_OFF_REASON);
231 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
232 }
233
234 /*+
235 *
236 * Routine Description:
237 * Decode Disassociation
238 *
239 *
240 * Return Value:
241 * None.
242 *
243 -*/
244
245 void
246 vMgrDecodeDisassociation(
247 PWLAN_FR_DISASSOC pFrame
248 )
249 {
250 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
251
252 /* Fixed Fields */
253 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
254 + WLAN_DISASSOC_OFF_REASON);
255 }
256
257 /*+
258 *
259 * Routine Description:
260 * Encode Association Request
261 *
262 *
263 * Return Value:
264 * None.
265 *
266 -*/
267
268 void
269 vMgrEncodeAssocRequest(
270 PWLAN_FR_ASSOCREQ pFrame
271 )
272 {
273 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
274 /* Fixed Fields */
275 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
276 + WLAN_ASSOCREQ_OFF_CAP_INFO);
277 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
278 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
279 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
280 }
281
282 /*+
283 *
284 * Routine Description: (AP)
285 * Decode Association Request
286 *
287 *
288 * Return Value:
289 * None.
290 *
291 -*/
292
293 void
294 vMgrDecodeAssocRequest(
295 PWLAN_FR_ASSOCREQ pFrame
296 )
297 {
298 PWLAN_IE pItem;
299
300 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
301 /* Fixed Fields */
302 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
303 + WLAN_ASSOCREQ_OFF_CAP_INFO);
304 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
305 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
306
307 /* Information elements */
308 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
309 + WLAN_ASSOCREQ_OFF_SSID);
310
311 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
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) {
328 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
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;
341 }
342 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
343 }
344 }
345
346 /*+
347 *
348 * Routine Description: (AP)
349 * Encode Association Response
350 *
351 *
352 * Return Value:
353 * None.
354 *
355 -*/
356
357 void
358 vMgrEncodeAssocResponse(
359 PWLAN_FR_ASSOCRESP pFrame
360 )
361 {
362 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
363
364 /* Fixed Fields */
365 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
366 + WLAN_ASSOCRESP_OFF_CAP_INFO);
367 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
368 + WLAN_ASSOCRESP_OFF_STATUS);
369 pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
370 + WLAN_ASSOCRESP_OFF_AID);
371 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
372 + sizeof(*(pFrame->pwAid));
373 }
374
375 /*+
376 *
377 * Routine Description:
378 * Decode Association Response
379 *
380 *
381 * Return Value:
382 * None.
383 *
384 -*/
385
386 void
387 vMgrDecodeAssocResponse(
388 PWLAN_FR_ASSOCRESP pFrame
389 )
390 {
391 PWLAN_IE pItem;
392
393 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
394
395 /* Fixed Fields */
396 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
397 + WLAN_ASSOCRESP_OFF_CAP_INFO);
398 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
399 + WLAN_ASSOCRESP_OFF_STATUS);
400 pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
401 + WLAN_ASSOCRESP_OFF_AID);
402
403 /* Information elements */
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);
408 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
409
410 if ((((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
411 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
412 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
413 } else
414 pFrame->pExtSuppRates = NULL;
415 }
416
417 /*+
418 *
419 * Routine Description:
420 * Encode Reassociation Request
421 *
422 *
423 * Return Value:
424 * None.
425 *
426 -*/
427
428 void
429 vMgrEncodeReassocRequest(
430 PWLAN_FR_REASSOCREQ pFrame
431 )
432 {
433 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
434
435 /* Fixed Fields */
436 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
437 + WLAN_REASSOCREQ_OFF_CAP_INFO);
438 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
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));
443 }
444
445 /*+
446 *
447 * Routine Description: (AP)
448 * Decode Reassociation Request
449 *
450 *
451 * Return Value:
452 * None.
453 *
454 -*/
455
456 void
457 vMgrDecodeReassocRequest(
458 PWLAN_FR_REASSOCREQ pFrame
459 )
460 {
461 PWLAN_IE pItem;
462 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
463
464 /* Fixed Fields */
465 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
466 + WLAN_REASSOCREQ_OFF_CAP_INFO);
467 pFrame->pwListenInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
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
472 /* Information elements */
473 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
474 + WLAN_REASSOCREQ_OFF_SSID);
475
476 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
477
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:
493 if (pFrame->pRSNWPA == NULL)
494 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
495 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
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;
506 }
507 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
508 }
509 }
510
511 /*+
512 *
513 * Routine Description:
514 * Encode Probe Request
515 *
516 *
517 * Return Value:
518 * None.
519 *
520 -*/
521
522 void
523 vMgrEncodeProbeRequest(
524 PWLAN_FR_PROBEREQ pFrame
525 )
526 {
527 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
528 pFrame->len = WLAN_HDR_ADDR3_LEN;
529 }
530
531 /*+
532 *
533 * Routine Description:
534 * Decode Probe Request
535 *
536 *
537 * Return Value:
538 * None.
539 *
540 -*/
541
542 void
543 vMgrDecodeProbeRequest(
544 PWLAN_FR_PROBEREQ pFrame
545 )
546 {
547 PWLAN_IE pItem;
548
549 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
550
551 /* Information elements */
552 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
553
554 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
555
556 switch (pItem->byElementID) {
557 case WLAN_EID_SSID:
558 if (pFrame->pSSID == NULL)
559 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
560 break;
561
562 case WLAN_EID_SUPP_RATES:
563 if (pFrame->pSuppRates == NULL)
564 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
565 break;
566
567 case WLAN_EID_EXTSUPP_RATES:
568 if (pFrame->pExtSuppRates == NULL)
569 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
570 break;
571
572 default:
573 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
574 break;
575 }
576
577 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
578 }
579 }
580
581 /*+
582 *
583 * Routine Description:
584 * Encode Probe Response
585 *
586 *
587 * Return Value:
588 * None.
589 *
590 -*/
591
592 void
593 vMgrEncodeProbeResponse(
594 PWLAN_FR_PROBERESP pFrame
595 )
596 {
597 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
598
599 /* Fixed Fields */
600 pFrame->pqwTimestamp =
601 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
602 WLAN_PROBERESP_OFF_TS);
603 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
604 + WLAN_PROBERESP_OFF_BCN_INT);
605 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
606 + WLAN_PROBERESP_OFF_CAP_INFO);
607
608 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
609 sizeof(*(pFrame->pwCapInfo));
610 }
611
612 /*+
613 *
614 * Routine Description:
615 * Decode Probe Response
616 *
617 *
618 * Return Value:
619 * None.
620 *
621 -*/
622
623 void
624 vMgrDecodeProbeResponse(
625 PWLAN_FR_PROBERESP pFrame
626 )
627 {
628 PWLAN_IE pItem;
629
630 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
631
632 /* Fixed Fields */
633 pFrame->pqwTimestamp =
634 (u64 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) +
635 WLAN_PROBERESP_OFF_TS);
636 pFrame->pwBeaconInterval = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
637 + WLAN_PROBERESP_OFF_BCN_INT);
638 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
639 + WLAN_PROBERESP_OFF_CAP_INFO);
640
641 /* Information elements */
642 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
643 + WLAN_PROBERESP_OFF_SSID);
644
645 while (((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) {
646 switch (pItem->byElementID) {
647 case WLAN_EID_SSID:
648 if (pFrame->pSSID == NULL)
649 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
650 break;
651 case WLAN_EID_SUPP_RATES:
652 if (pFrame->pSuppRates == NULL)
653 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
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) {
676 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
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;
717 }
718
719 pItem = (PWLAN_IE)(((u8 *)pItem) + 2 + pItem->len);
720 }
721 }
722
723 /*+
724 *
725 * Routine Description:
726 * Encode Authentication frame
727 *
728 *
729 * Return Value:
730 * None.
731 *
732 -*/
733
734 void
735 vMgrEncodeAuthen(
736 PWLAN_FR_AUTHEN pFrame
737 )
738 {
739 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
740
741 /* Fixed Fields */
742 pFrame->pwAuthAlgorithm = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
743 + WLAN_AUTHEN_OFF_AUTH_ALG);
744 pFrame->pwAuthSequence = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
745 + WLAN_AUTHEN_OFF_AUTH_SEQ);
746 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
747 + WLAN_AUTHEN_OFF_STATUS);
748 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
749 }
750
751 /*+
752 *
753 * Routine Description:
754 * Decode Authentication
755 *
756 *
757 * Return Value:
758 * None.
759 *
760 -*/
761
762 void
763 vMgrDecodeAuthen(
764 PWLAN_FR_AUTHEN pFrame
765 )
766 {
767 PWLAN_IE pItem;
768
769 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
770
771 /* Fixed Fields */
772 pFrame->pwAuthAlgorithm = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
773 + WLAN_AUTHEN_OFF_AUTH_ALG);
774 pFrame->pwAuthSequence = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
775 + WLAN_AUTHEN_OFF_AUTH_SEQ);
776 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
777 + WLAN_AUTHEN_OFF_STATUS);
778
779 /* Information elements */
780 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
781 + WLAN_AUTHEN_OFF_CHALLENGE);
782
783 if ((((u8 *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE))
784 pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
785 }
786
787 /*+
788 *
789 * Routine Description:
790 * Encode Authentication
791 *
792 *
793 * Return Value:
794 * None.
795 *
796 -*/
797
798 void
799 vMgrEncodeDeauthen(
800 PWLAN_FR_DEAUTHEN pFrame
801 )
802 {
803 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
804
805 /* Fixed Fields */
806 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
807 + WLAN_DEAUTHEN_OFF_REASON);
808 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
809 }
810
811 /*+
812 *
813 * Routine Description:
814 * Decode Deauthentication
815 *
816 *
817 * Return Value:
818 * None.
819 *
820 -*/
821
822 void
823 vMgrDecodeDeauthen(
824 PWLAN_FR_DEAUTHEN pFrame
825 )
826 {
827 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
828
829 /* Fixed Fields */
830 pFrame->pwReason = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
831 + WLAN_DEAUTHEN_OFF_REASON);
832 }
833
834 /*+
835 *
836 * Routine Description: (AP)
837 * Encode Reassociation Response
838 *
839 *
840 * Return Value:
841 * None.
842 *
843 -*/
844
845 void
846 vMgrEncodeReassocResponse(
847 PWLAN_FR_REASSOCRESP pFrame
848 )
849 {
850 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
851
852 /* Fixed Fields */
853 pFrame->pwCapInfo = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
854 + WLAN_REASSOCRESP_OFF_CAP_INFO);
855 pFrame->pwStatus = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
856 + WLAN_REASSOCRESP_OFF_STATUS);
857 pFrame->pwAid = (u16 *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
858 + WLAN_REASSOCRESP_OFF_AID);
859
860 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
861 }
This page took 0.048831 seconds and 5 git commands to generate.