Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
80211mgr.c
Go to the documentation of this file.
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  * 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 
55 #include "tmacro.h"
56 #include "tether.h"
57 #include "80211mgr.h"
58 #include "80211hdr.h"
59 #include "device.h"
60 #include "wpa.h"
61 
62 /*--------------------- Static Definitions -------------------------*/
63 
64 
65 
66 /*--------------------- Static Classes ----------------------------*/
67 
68 /*--------------------- Static Variables --------------------------*/
69 
70 static 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 
92 void
94  PWLAN_FR_BEACON pFrame
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))
102  pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
104  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
106 
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 
124 void
126  PWLAN_FR_BEACON pFrame
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))
136  pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
138  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
140 
141  /* Information elements */
142  pItem = (PWLAN_IE)((PBYTE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
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  break;
179  case WLAN_EID_RSN_WPA:
180  if (pFrame->pRSNWPA == NULL) {
181  if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
182  pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
183  }
184  break;
185 
186  case WLAN_EID_ERP:
187  if (pFrame->pERP == NULL)
188  pFrame->pERP = (PWLAN_IE_ERP)pItem;
189  break;
191  if (pFrame->pExtSuppRates == NULL)
192  pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
193  break;
194 
195  case WLAN_EID_COUNTRY: /* 7 */
196  if (pFrame->pIE_Country == NULL)
197  pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
198  break;
199 
200  case WLAN_EID_PWR_CONSTRAINT: /* 32 */
201  if (pFrame->pIE_PowerConstraint == NULL)
202  pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
203  break;
204 
205  case WLAN_EID_CH_SWITCH: /* 37 */
206  if (pFrame->pIE_CHSW == NULL)
207  pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
208  break;
209 
210  case WLAN_EID_QUIET: /* 40 */
211  if (pFrame->pIE_Quiet == NULL)
212  pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
213  break;
214 
215  case WLAN_EID_IBSS_DFS:
216  if (pFrame->pIE_IBSSDFS == NULL)
217  pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
218  break;
219 
220  default:
221  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
222  break;
223 
224  }
225  pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
226  }
227 }
228 
229 
230 /*+
231  *
232  * Routine Description:
233  * Encode IBSS ATIM
234  *
235  *
236  * Return Value:
237  * None.
238  *
239 -*/
240 
241 
242 void
244  PWLAN_FR_IBSSATIM pFrame
245  )
246 {
247  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
248  pFrame->len = WLAN_HDR_ADDR3_LEN;
249 }
250 
251 
252 /*+
253  *
254  * Routine Description:
255  * Decode IBSS ATIM
256  *
257  *
258  * Return Value:
259  * None.
260  *
261 -*/
262 
263 void
265  PWLAN_FR_IBSSATIM pFrame
266  )
267 {
268  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
269 }
270 
271 
272 /*+
273  *
274  * Routine Description:
275  * Encode Disassociation
276  *
277  *
278  * Return Value:
279  * None.
280  *
281 -*/
282 
283 void
285  PWLAN_FR_DISASSOC pFrame
286  )
287 {
288  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
289 
290 
291  /* Fixed Fields */
292  pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
294  pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
295 }
296 
297 
298 /*+
299  *
300  * Routine Description:
301  * Decode Disassociation
302  *
303  *
304  * Return Value:
305  * None.
306  *
307 -*/
308 
309 void
311  PWLAN_FR_DISASSOC pFrame
312  )
313 {
314  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
315 
316  /* Fixed Fields */
317  pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
319 }
320 
321 /*+
322  *
323  * Routine Description:
324  * Encode Association Request
325  *
326  *
327  * Return Value:
328  * None.
329  *
330 -*/
331 
332 
333 void
335  PWLAN_FR_ASSOCREQ pFrame
336  )
337 {
338  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
339  /* Fixed Fields */
340  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
342  pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
344  pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
345 }
346 
347 
348 /*+
349  *
350  * Routine Description: (AP)
351  * Decode Association Request
352  *
353  *
354  * Return Value:
355  * None.
356  *
357 -*/
358 
359 void
361  PWLAN_FR_ASSOCREQ pFrame
362  )
363 {
364  PWLAN_IE pItem;
365 
366  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
367  /* Fixed Fields */
368  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
370  pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
372 
373  /* Information elements */
374  pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
376 
377  while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
378  switch (pItem->byElementID) {
379  case WLAN_EID_SSID:
380  if (pFrame->pSSID == NULL)
381  pFrame->pSSID = (PWLAN_IE_SSID)pItem;
382  break;
383  case WLAN_EID_SUPP_RATES:
384  if (pFrame->pSuppRates == NULL)
385  pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
386  break;
387 
388  case WLAN_EID_RSN:
389  if (pFrame->pRSN == NULL)
390  pFrame->pRSN = (PWLAN_IE_RSN)pItem;
391  break;
392  case WLAN_EID_RSN_WPA:
393  if (pFrame->pRSNWPA == NULL) {
394  if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
395  pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
396  }
397  break;
399  if (pFrame->pExtSuppRates == NULL)
400  pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
401  break;
402 
403  default:
404  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
405  pItem->byElementID);
406  break;
407  }
408  pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
409  }
410 }
411 
412 /*+
413  *
414  * Routine Description: (AP)
415  * Encode Association Response
416  *
417  *
418  * Return Value:
419  * None.
420  *
421 -*/
422 
423 void
425  PWLAN_FR_ASSOCRESP pFrame
426  )
427 {
428  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
429 
430  /* Fixed Fields */
431  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
433  pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
435  pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
438  + sizeof(*(pFrame->pwAid));
439 }
440 
441 
442 /*+
443  *
444  * Routine Description:
445  * Decode Association Response
446  *
447  *
448  * Return Value:
449  * None.
450  *
451 -*/
452 
453 void
455  PWLAN_FR_ASSOCRESP pFrame
456  )
457 {
458  PWLAN_IE pItem;
459 
460  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
461 
462  /* Fixed Fields */
463  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
465  pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
467  pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
469 
470  /* Information elements */
473 
474  pItem = (PWLAN_IE)(pFrame->pSuppRates);
475  pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
476 
477  if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
478  pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
479  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem);
480  } else
481  pFrame->pExtSuppRates = NULL;
482 }
483 
484 
485 /*+
486  *
487  * Routine Description:
488  * Encode Reassociation Request
489  *
490  *
491  * Return Value:
492  * None.
493  *
494 -*/
495 
496 void
498  PWLAN_FR_REASSOCREQ pFrame
499  )
500 {
501  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
502 
503  /* Fixed Fields */
504  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
506  pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
508  pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
510  pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
511 }
512 
513 
514 /*+
515  *
516  * Routine Description: (AP)
517  * Decode Reassociation Request
518  *
519  *
520  * Return Value:
521  * None.
522  *
523 -*/
524 
525 
526 void
528  PWLAN_FR_REASSOCREQ pFrame
529  )
530 {
531  PWLAN_IE pItem;
532  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
533 
534  /* Fixed Fields */
535  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
537  pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
539  pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
541 
542  /* Information elements */
543  pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
545 
546  while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
547 
548  switch (pItem->byElementID) {
549  case WLAN_EID_SSID:
550  if (pFrame->pSSID == NULL)
551  pFrame->pSSID = (PWLAN_IE_SSID)pItem;
552  break;
553  case WLAN_EID_SUPP_RATES:
554  if (pFrame->pSuppRates == NULL)
555  pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
556  break;
557 
558  case WLAN_EID_RSN:
559  if (pFrame->pRSN == NULL)
560  pFrame->pRSN = (PWLAN_IE_RSN)pItem;
561  break;
562  case WLAN_EID_RSN_WPA:
563  if (pFrame->pRSNWPA == NULL)
564  if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
565  pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
566  break;
567 
569  if (pFrame->pExtSuppRates == NULL)
570  pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
571  break;
572  default:
573  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n",
574  pItem->byElementID);
575  break;
576  }
577  pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
578  }
579 }
580 
581 
582 
583 /*+
584  *
585  * Routine Description:
586  * Encode Probe Request
587  *
588  *
589  * Return Value:
590  * None.
591  *
592 -*/
593 
594 
595 void
597  PWLAN_FR_PROBEREQ pFrame
598  )
599 {
600  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
601  pFrame->len = WLAN_HDR_ADDR3_LEN;
602 }
603 
604 /*+
605  *
606  * Routine Description:
607  * Decode Probe Request
608  *
609  *
610  * Return Value:
611  * None.
612  *
613 -*/
614 
615 void
617  PWLAN_FR_PROBEREQ pFrame
618  )
619 {
620  PWLAN_IE pItem;
621 
622  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
623 
624  /* Information elements */
625  pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
626 
627  while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
628 
629  switch (pItem->byElementID) {
630  case WLAN_EID_SSID:
631  if (pFrame->pSSID == NULL)
632  pFrame->pSSID = (PWLAN_IE_SSID)pItem;
633  break;
634 
635  case WLAN_EID_SUPP_RATES:
636  if (pFrame->pSuppRates == NULL)
637  pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
638  break;
639 
641  if (pFrame->pExtSuppRates == NULL)
642  pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
643  break;
644 
645  default:
646  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
647  break;
648  }
649 
650  pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
651  }
652 }
653 
654 
655 /*+
656  *
657  * Routine Description:
658  * Encode Probe Response
659  *
660  *
661  * Return Value:
662  * None.
663  *
664 -*/
665 
666 
667 void
669  PWLAN_FR_PROBERESP pFrame
670  )
671 {
672  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
673 
674  /* Fixed Fields */
675  pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
677  pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
679  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
681 
683  sizeof(*(pFrame->pwCapInfo));
684 }
685 
686 
687 
688 /*+
689  *
690  * Routine Description:
691  * Decode Probe Response
692  *
693  *
694  * Return Value:
695  * None.
696  *
697 -*/
698 
699 void
701  PWLAN_FR_PROBERESP pFrame
702  )
703 {
704  PWLAN_IE pItem;
705 
706 
707  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
708 
709  /* Fixed Fields */
710  pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
712  pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
714  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
716 
717  /* Information elements */
718  pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
720 
721  while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) {
722  switch (pItem->byElementID) {
723  case WLAN_EID_SSID:
724  if (pFrame->pSSID == NULL)
725  pFrame->pSSID = (PWLAN_IE_SSID)pItem;
726  break;
727  case WLAN_EID_SUPP_RATES:
728  if (pFrame->pSuppRates == NULL)
729  pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
730  break;
731  case WLAN_EID_FH_PARMS:
732  break;
733  case WLAN_EID_DS_PARMS:
734  if (pFrame->pDSParms == NULL)
735  pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
736  break;
737  case WLAN_EID_CF_PARMS:
738  if (pFrame->pCFParms == NULL)
739  pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
740  break;
741  case WLAN_EID_IBSS_PARMS:
742  if (pFrame->pIBSSParms == NULL)
743  pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
744  break;
745 
746  case WLAN_EID_RSN:
747  if (pFrame->pRSN == NULL)
748  pFrame->pRSN = (PWLAN_IE_RSN)pItem;
749  break;
750  case WLAN_EID_RSN_WPA:
751  if (pFrame->pRSNWPA == NULL) {
752  if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE)
753  pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
754  }
755  break;
756  case WLAN_EID_ERP:
757  if (pFrame->pERP == NULL)
758  pFrame->pERP = (PWLAN_IE_ERP)pItem;
759  break;
761  if (pFrame->pExtSuppRates == NULL)
762  pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
763  break;
764 
765  case WLAN_EID_COUNTRY: /* 7 */
766  if (pFrame->pIE_Country == NULL)
767  pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
768  break;
769 
770  case WLAN_EID_PWR_CONSTRAINT: /* 32 */
771  if (pFrame->pIE_PowerConstraint == NULL)
772  pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
773  break;
774 
775  case WLAN_EID_CH_SWITCH: /* 37 */
776  if (pFrame->pIE_CHSW == NULL)
777  pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
778  break;
779 
780  case WLAN_EID_QUIET: /* 40 */
781  if (pFrame->pIE_Quiet == NULL)
782  pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
783  break;
784 
785  case WLAN_EID_IBSS_DFS:
786  if (pFrame->pIE_IBSSDFS == NULL)
787  pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
788  break;
789 
790  default:
791  DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
792  break;
793  }
794 
795  pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
796  }
797 }
798 
799 
800 /*+
801  *
802  * Routine Description:
803  * Encode Authentication frame
804  *
805  *
806  * Return Value:
807  * None.
808  *
809 -*/
810 
811 void
813  PWLAN_FR_AUTHEN pFrame
814  )
815 {
816  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
817 
818  /* Fixed Fields */
819  pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
821  pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
823  pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
825  pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
826 }
827 
828 
829 /*+
830  *
831  * Routine Description:
832  * Decode Authentication
833  *
834  *
835  * Return Value:
836  * None.
837  *
838 -*/
839 
840 void
842  PWLAN_FR_AUTHEN pFrame
843  )
844 {
845  PWLAN_IE pItem;
846 
847  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
848 
849  /* Fixed Fields */
850  pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
852  pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
854  pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
856 
857  /* Information elements */
858  pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
860 
861  if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE))
862  pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
863 }
864 
865 
866 /*+
867  *
868  * Routine Description:
869  * Encode Authentication
870  *
871  *
872  * Return Value:
873  * None.
874  *
875 -*/
876 
877 void
879  PWLAN_FR_DEAUTHEN pFrame
880  )
881 {
882  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
883 
884  /* Fixed Fields */
885  pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
887  pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
888 }
889 
890 
891 /*+
892  *
893  * Routine Description:
894  * Decode Deauthentication
895  *
896  *
897  * Return Value:
898  * None.
899  *
900 -*/
901 
902 void
904  PWLAN_FR_DEAUTHEN pFrame
905  )
906 {
907  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
908 
909  /* Fixed Fields */
910  pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
912 }
913 
914 
915 /*+
916  *
917  * Routine Description: (AP)
918  * Encode Reassociation Response
919  *
920  *
921  * Return Value:
922  * None.
923  *
924 -*/
925 
926 void
928  PWLAN_FR_REASSOCRESP pFrame
929  )
930 {
931  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
932 
933  /* Fixed Fields */
934  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
936  pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
938  pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
940 
941  pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
942 }
943 
944 
945 /*+
946  *
947  * Routine Description:
948  * Decode Reassociation Response
949  *
950  *
951  * Return Value:
952  * None.
953  *
954 -*/
955 
956 
957 void
959  PWLAN_FR_REASSOCRESP pFrame
960  )
961 {
962  PWLAN_IE pItem;
963 
964  pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
965 
966  /* Fixed Fields */
967  pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
969  pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
971  pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
973 
974  /* Information elements */
977 
978  pItem = (PWLAN_IE)(pFrame->pSuppRates);
979  pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len);
980 
981  if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES))
982  pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
983 }