blob: 76c8490b0734d212297e8fb00583c73bbaa5716b [file] [log] [blame]
Forest Bond5449c682009-04-25 10:30:44 -04001/*
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 *
Forest Bond5449c682009-04-25 10:30:44 -040019 * File: 80211mgr.c
20 *
Uwe Kleine-König658ce9d2009-07-23 08:33:56 +020021 * Purpose: Handles the 802.11 management support functions
Forest Bond5449c682009-04-25 10:30:44 -040022 *
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
Forest Bond5449c682009-04-25 10:30:44 -040055#include "tmacro.h"
Forest Bond5449c682009-04-25 10:30:44 -040056#include "tether.h"
Forest Bond5449c682009-04-25 10:30:44 -040057#include "80211mgr.h"
Forest Bond5449c682009-04-25 10:30:44 -040058#include "80211hdr.h"
Forest Bond5449c682009-04-25 10:30:44 -040059#include "device.h"
Forest Bond5449c682009-04-25 10:30:44 -040060#include "wpa.h"
Forest Bond5449c682009-04-25 10:30:44 -040061
62/*--------------------- Static Definitions -------------------------*/
63
Forest Bond5449c682009-04-25 10:30:44 -040064/*--------------------- Static Classes ----------------------------*/
65
66/*--------------------- Static Variables --------------------------*/
67
Joe Perchesab4622c2013-03-18 10:44:35 -070068static int msglevel = MSG_LEVEL_INFO;
Tülin İzer1b37f292013-05-15 23:40:30 +030069/* static int msglevel =MSG_LEVEL_DEBUG; */
Forest Bond5449c682009-04-25 10:30:44 -040070/*--------------------- Static Functions --------------------------*/
71
Forest Bond5449c682009-04-25 10:30:44 -040072/*--------------------- Export Variables --------------------------*/
73
Forest Bond5449c682009-04-25 10:30:44 -040074/*--------------------- Export Functions --------------------------*/
75
Forest Bond5449c682009-04-25 10:30:44 -040076/*+
77 *
78 * Routine Description:
79 * Encode Beacon frame body offset
80 *
81 * Return Value:
82 * None.
83 *
Joe Perchesab4622c2013-03-18 10:44:35 -070084 -*/
Forest Bond5449c682009-04-25 10:30:44 -040085
Charles Clément6b35b7b2010-05-07 12:30:19 -070086void
Forest Bond5449c682009-04-25 10:30:44 -040087vMgrEncodeBeacon(
Joe Perchesab4622c2013-03-18 10:44:35 -070088 PWLAN_FR_BEACON pFrame
89)
Forest Bond5449c682009-04-25 10:30:44 -040090{
Joe Perchesab4622c2013-03-18 10:44:35 -070091 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -040092
Tülin İzer1b37f292013-05-15 23:40:30 +030093 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -070094 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
95 + WLAN_BEACON_OFF_TS);
96 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
97 + WLAN_BEACON_OFF_BCN_INT);
98 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
99 + WLAN_BEACON_OFF_CAPINFO);
Forest Bond5449c682009-04-25 10:30:44 -0400100
Joe Perchesab4622c2013-03-18 10:44:35 -0700101 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID;
Forest Bond5449c682009-04-25 10:30:44 -0400102
Joe Perchesab4622c2013-03-18 10:44:35 -0700103 return;
Forest Bond5449c682009-04-25 10:30:44 -0400104}
105
106/*+
107 *
108 * Routine Description:
109 * Decode Beacon frame body offset
110 *
111 *
112 * Return Value:
113 * None.
114 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700115 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400116
Charles Clément6b35b7b2010-05-07 12:30:19 -0700117void
Forest Bond5449c682009-04-25 10:30:44 -0400118vMgrDecodeBeacon(
Joe Perchesab4622c2013-03-18 10:44:35 -0700119 PWLAN_FR_BEACON pFrame
120)
Forest Bond5449c682009-04-25 10:30:44 -0400121{
Joe Perchesab4622c2013-03-18 10:44:35 -0700122 PWLAN_IE pItem;
Forest Bond5449c682009-04-25 10:30:44 -0400123
Joe Perchesab4622c2013-03-18 10:44:35 -0700124 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400125
Tülin İzer1b37f292013-05-15 23:40:30 +0300126 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700127 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
128 + WLAN_BEACON_OFF_TS);
129 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
130 + WLAN_BEACON_OFF_BCN_INT);
131 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
132 + WLAN_BEACON_OFF_CAPINFO);
Forest Bond5449c682009-04-25 10:30:44 -0400133
Tülin İzer1b37f292013-05-15 23:40:30 +0300134 /* Information elements */
Joe Perchesab4622c2013-03-18 10:44:35 -0700135 pItem = (PWLAN_IE)((unsigned char *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)))
136 + WLAN_BEACON_OFF_SSID);
137 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
Joe Perchesab4622c2013-03-18 10:44:35 -0700138 switch (pItem->byElementID) {
139 case WLAN_EID_SSID:
140 if (pFrame->pSSID == NULL)
141 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
142 break;
143 case WLAN_EID_SUPP_RATES:
144 if (pFrame->pSuppRates == NULL)
145 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
146 break;
147 case WLAN_EID_FH_PARMS:
Tülin İzer1b37f292013-05-15 23:40:30 +0300148 /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */
Joe Perchesab4622c2013-03-18 10:44:35 -0700149 break;
150 case WLAN_EID_DS_PARMS:
151 if (pFrame->pDSParms == NULL)
152 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
153 break;
154 case WLAN_EID_CF_PARMS:
155 if (pFrame->pCFParms == NULL)
156 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
157 break;
158 case WLAN_EID_IBSS_PARMS:
159 if (pFrame->pIBSSParms == NULL)
160 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
161 break;
162 case WLAN_EID_TIM:
163 if (pFrame->pTIM == NULL)
164 pFrame->pTIM = (PWLAN_IE_TIM)pItem;
165 break;
Forest Bond5449c682009-04-25 10:30:44 -0400166
Joe Perchesab4622c2013-03-18 10:44:35 -0700167 case WLAN_EID_RSN:
168 if (pFrame->pRSN == NULL) {
169 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
170 }
171 break;
172 case WLAN_EID_RSN_WPA:
173 if (pFrame->pRSNWPA == NULL) {
174 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
175 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
176 }
177 break;
Forest Bond5449c682009-04-25 10:30:44 -0400178
Joe Perchesab4622c2013-03-18 10:44:35 -0700179 case WLAN_EID_ERP:
180 if (pFrame->pERP == NULL)
181 pFrame->pERP = (PWLAN_IE_ERP)pItem;
182 break;
183 case WLAN_EID_EXTSUPP_RATES:
184 if (pFrame->pExtSuppRates == NULL)
185 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
186 break;
Forest Bond5449c682009-04-25 10:30:44 -0400187
Tülin İzer1b37f292013-05-15 23:40:30 +0300188 case WLAN_EID_COUNTRY: /* 7 */
Joe Perchesab4622c2013-03-18 10:44:35 -0700189 if (pFrame->pIE_Country == NULL)
190 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
191 break;
Forest Bond5449c682009-04-25 10:30:44 -0400192
Tülin İzer1b37f292013-05-15 23:40:30 +0300193 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
Joe Perchesab4622c2013-03-18 10:44:35 -0700194 if (pFrame->pIE_PowerConstraint == NULL)
195 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
196 break;
Forest Bond5449c682009-04-25 10:30:44 -0400197
Tülin İzer1b37f292013-05-15 23:40:30 +0300198 case WLAN_EID_CH_SWITCH: /* 37 */
Joe Perchesab4622c2013-03-18 10:44:35 -0700199 if (pFrame->pIE_CHSW == NULL)
200 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
201 break;
Forest Bond5449c682009-04-25 10:30:44 -0400202
Tülin İzer1b37f292013-05-15 23:40:30 +0300203 case WLAN_EID_QUIET: /* 40 */
Joe Perchesab4622c2013-03-18 10:44:35 -0700204 if (pFrame->pIE_Quiet == NULL)
205 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
206 break;
Forest Bond5449c682009-04-25 10:30:44 -0400207
Joe Perchesab4622c2013-03-18 10:44:35 -0700208 case WLAN_EID_IBSS_DFS:
209 if (pFrame->pIE_IBSSDFS == NULL)
210 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
211 break;
Forest Bond5449c682009-04-25 10:30:44 -0400212
Joe Perchesab4622c2013-03-18 10:44:35 -0700213 default:
214 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID);
215 break;
Forest Bond5449c682009-04-25 10:30:44 -0400216
Joe Perchesab4622c2013-03-18 10:44:35 -0700217 }
218 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
219 }
Forest Bond5449c682009-04-25 10:30:44 -0400220
Joe Perchesab4622c2013-03-18 10:44:35 -0700221 return;
Forest Bond5449c682009-04-25 10:30:44 -0400222}
223
Forest Bond5449c682009-04-25 10:30:44 -0400224/*+
225 *
226 * Routine Description:
227 * Encode IBSS ATIM
228 *
229 *
230 * Return Value:
231 * None.
232 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700233 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400234
Charles Clément6b35b7b2010-05-07 12:30:19 -0700235void
Forest Bond5449c682009-04-25 10:30:44 -0400236vMgrEncodeIBSSATIM(
Joe Perchesab4622c2013-03-18 10:44:35 -0700237 PWLAN_FR_IBSSATIM pFrame
238)
Forest Bond5449c682009-04-25 10:30:44 -0400239{
Joe Perchesab4622c2013-03-18 10:44:35 -0700240 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
241 pFrame->len = WLAN_HDR_ADDR3_LEN;
Forest Bond5449c682009-04-25 10:30:44 -0400242
Joe Perchesab4622c2013-03-18 10:44:35 -0700243 return;
Forest Bond5449c682009-04-25 10:30:44 -0400244}
245
Forest Bond5449c682009-04-25 10:30:44 -0400246/*+
247 *
248 * Routine Description:
249 * Decode IBSS ATIM
250 *
251 *
252 * Return Value:
253 * None.
254 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700255 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400256
Charles Clément6b35b7b2010-05-07 12:30:19 -0700257void
Forest Bond5449c682009-04-25 10:30:44 -0400258vMgrDecodeIBSSATIM(
Joe Perchesab4622c2013-03-18 10:44:35 -0700259 PWLAN_FR_IBSSATIM pFrame
260)
Forest Bond5449c682009-04-25 10:30:44 -0400261{
Joe Perchesab4622c2013-03-18 10:44:35 -0700262 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400263
Joe Perchesab4622c2013-03-18 10:44:35 -0700264 return;
Forest Bond5449c682009-04-25 10:30:44 -0400265}
266
Forest Bond5449c682009-04-25 10:30:44 -0400267/*+
268 *
269 * Routine Description:
270 * Encode Disassociation
271 *
272 *
273 * Return Value:
274 * None.
275 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700276 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400277
Charles Clément6b35b7b2010-05-07 12:30:19 -0700278void
Forest Bond5449c682009-04-25 10:30:44 -0400279vMgrEncodeDisassociation(
Joe Perchesab4622c2013-03-18 10:44:35 -0700280 PWLAN_FR_DISASSOC pFrame
281)
Forest Bond5449c682009-04-25 10:30:44 -0400282{
Joe Perchesab4622c2013-03-18 10:44:35 -0700283 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400284
Tülin İzer1b37f292013-05-15 23:40:30 +0300285 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700286 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
287 + WLAN_DISASSOC_OFF_REASON);
288 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason));
Forest Bond5449c682009-04-25 10:30:44 -0400289
Joe Perchesab4622c2013-03-18 10:44:35 -0700290 return;
Forest Bond5449c682009-04-25 10:30:44 -0400291}
292
Forest Bond5449c682009-04-25 10:30:44 -0400293/*+
294 *
295 * Routine Description:
296 * Decode Disassociation
297 *
298 *
299 * Return Value:
300 * None.
301 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700302 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400303
Charles Clément6b35b7b2010-05-07 12:30:19 -0700304void
Forest Bond5449c682009-04-25 10:30:44 -0400305vMgrDecodeDisassociation(
Joe Perchesab4622c2013-03-18 10:44:35 -0700306 PWLAN_FR_DISASSOC pFrame
307)
Forest Bond5449c682009-04-25 10:30:44 -0400308{
Joe Perchesab4622c2013-03-18 10:44:35 -0700309 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400310
Tülin İzer1b37f292013-05-15 23:40:30 +0300311 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700312 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
313 + WLAN_DISASSOC_OFF_REASON);
Forest Bond5449c682009-04-25 10:30:44 -0400314
Joe Perchesab4622c2013-03-18 10:44:35 -0700315 return;
Forest Bond5449c682009-04-25 10:30:44 -0400316}
317
318/*+
319 *
320 * Routine Description:
321 * Encode Association Request
322 *
323 *
324 * Return Value:
325 * None.
326 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700327 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400328
Charles Clément6b35b7b2010-05-07 12:30:19 -0700329void
Forest Bond5449c682009-04-25 10:30:44 -0400330vMgrEncodeAssocRequest(
Joe Perchesab4622c2013-03-18 10:44:35 -0700331 PWLAN_FR_ASSOCREQ pFrame
332)
Forest Bond5449c682009-04-25 10:30:44 -0400333{
Joe Perchesab4622c2013-03-18 10:44:35 -0700334 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Tülin İzer1b37f292013-05-15 23:40:30 +0300335 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700336 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
337 + WLAN_ASSOCREQ_OFF_CAP_INFO);
338 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
339 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
340 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval));
341 return;
Forest Bond5449c682009-04-25 10:30:44 -0400342}
343
Forest Bond5449c682009-04-25 10:30:44 -0400344/*+
345 *
346 * Routine Description: (AP)
347 * Decode Association Request
348 *
349 *
350 * Return Value:
351 * None.
352 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700353 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400354
Charles Clément6b35b7b2010-05-07 12:30:19 -0700355void
Forest Bond5449c682009-04-25 10:30:44 -0400356vMgrDecodeAssocRequest(
Joe Perchesab4622c2013-03-18 10:44:35 -0700357 PWLAN_FR_ASSOCREQ pFrame
358)
Forest Bond5449c682009-04-25 10:30:44 -0400359{
Joe Perchesab4622c2013-03-18 10:44:35 -0700360 PWLAN_IE pItem;
Forest Bond5449c682009-04-25 10:30:44 -0400361
Joe Perchesab4622c2013-03-18 10:44:35 -0700362 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Tülin İzer1b37f292013-05-15 23:40:30 +0300363 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700364 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
365 + WLAN_ASSOCREQ_OFF_CAP_INFO);
366 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
367 + WLAN_ASSOCREQ_OFF_LISTEN_INT);
Forest Bond5449c682009-04-25 10:30:44 -0400368
Tülin İzer1b37f292013-05-15 23:40:30 +0300369 /* Information elements */
Joe Perchesab4622c2013-03-18 10:44:35 -0700370 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
371 + WLAN_ASSOCREQ_OFF_SSID);
Forest Bond5449c682009-04-25 10:30:44 -0400372
Joe Perchesab4622c2013-03-18 10:44:35 -0700373 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
374 switch (pItem->byElementID) {
375 case WLAN_EID_SSID:
376 if (pFrame->pSSID == NULL)
377 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
378 break;
379 case WLAN_EID_SUPP_RATES:
380 if (pFrame->pSuppRates == NULL)
381 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
382 break;
Forest Bond5449c682009-04-25 10:30:44 -0400383
Joe Perchesab4622c2013-03-18 10:44:35 -0700384 case WLAN_EID_RSN:
385 if (pFrame->pRSN == NULL) {
386 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
387 }
388 break;
389 case WLAN_EID_RSN_WPA:
390 if (pFrame->pRSNWPA == NULL) {
391 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
392 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
393 }
394 break;
395 case WLAN_EID_EXTSUPP_RATES:
396 if (pFrame->pExtSuppRates == NULL)
397 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
398 break;
Forest Bond5449c682009-04-25 10:30:44 -0400399
Joe Perchesab4622c2013-03-18 10:44:35 -0700400 default:
401 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n",
402 pItem->byElementID);
403 break;
404 }
405 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
406 }
407 return;
Forest Bond5449c682009-04-25 10:30:44 -0400408}
409
410/*+
411 *
412 * Routine Description: (AP)
413 * Encode Association Response
414 *
415 *
416 * Return Value:
417 * None.
418 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700419 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400420
Charles Clément6b35b7b2010-05-07 12:30:19 -0700421void
Forest Bond5449c682009-04-25 10:30:44 -0400422vMgrEncodeAssocResponse(
Joe Perchesab4622c2013-03-18 10:44:35 -0700423 PWLAN_FR_ASSOCRESP pFrame
424)
Forest Bond5449c682009-04-25 10:30:44 -0400425{
Joe Perchesab4622c2013-03-18 10:44:35 -0700426 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400427
Tülin İzer1b37f292013-05-15 23:40:30 +0300428 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700429 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
430 + WLAN_ASSOCRESP_OFF_CAP_INFO);
431 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
432 + WLAN_ASSOCRESP_OFF_STATUS);
433 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
434 + WLAN_ASSOCRESP_OFF_AID);
435 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID
436 + sizeof(*(pFrame->pwAid));
Forest Bond5449c682009-04-25 10:30:44 -0400437
Joe Perchesab4622c2013-03-18 10:44:35 -0700438 return;
Forest Bond5449c682009-04-25 10:30:44 -0400439}
440
Forest Bond5449c682009-04-25 10:30:44 -0400441/*+
442 *
443 * Routine Description:
444 * Decode Association Response
445 *
446 *
447 * Return Value:
448 * None.
449 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700450 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400451
Charles Clément6b35b7b2010-05-07 12:30:19 -0700452void
Forest Bond5449c682009-04-25 10:30:44 -0400453vMgrDecodeAssocResponse(
Joe Perchesab4622c2013-03-18 10:44:35 -0700454 PWLAN_FR_ASSOCRESP pFrame
455)
Forest Bond5449c682009-04-25 10:30:44 -0400456{
Joe Perchesab4622c2013-03-18 10:44:35 -0700457 PWLAN_IE pItem;
Forest Bond5449c682009-04-25 10:30:44 -0400458
Joe Perchesab4622c2013-03-18 10:44:35 -0700459 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400460
Tülin İzer1b37f292013-05-15 23:40:30 +0300461 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700462 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
463 + WLAN_ASSOCRESP_OFF_CAP_INFO);
464 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
465 + WLAN_ASSOCRESP_OFF_STATUS);
466 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
467 + WLAN_ASSOCRESP_OFF_AID);
Forest Bond5449c682009-04-25 10:30:44 -0400468
Tülin İzer1b37f292013-05-15 23:40:30 +0300469 /* Information elements */
Joe Perchesab4622c2013-03-18 10:44:35 -0700470 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
471 + WLAN_ASSOCRESP_OFF_SUPP_RATES);
Forest Bond5449c682009-04-25 10:30:44 -0400472
Joe Perchesab4622c2013-03-18 10:44:35 -0700473 pItem = (PWLAN_IE)(pFrame->pSuppRates);
474 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
Forest Bond5449c682009-04-25 10:30:44 -0400475
Joe Perchesab4622c2013-03-18 10:44:35 -0700476 if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) &&
477 (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);
Joe Perches5e0cc8a2013-03-18 20:55:37 -0700480 } else {
Joe Perchesab4622c2013-03-18 10:44:35 -0700481 pFrame->pExtSuppRates = NULL;
482 }
483 return;
Forest Bond5449c682009-04-25 10:30:44 -0400484}
485
Forest Bond5449c682009-04-25 10:30:44 -0400486/*+
487 *
488 * Routine Description:
489 * Encode Reassociation Request
490 *
491 *
492 * Return Value:
493 * None.
494 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700495 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400496
Charles Clément6b35b7b2010-05-07 12:30:19 -0700497void
Forest Bond5449c682009-04-25 10:30:44 -0400498vMgrEncodeReassocRequest(
Joe Perchesab4622c2013-03-18 10:44:35 -0700499 PWLAN_FR_REASSOCREQ pFrame
500)
Forest Bond5449c682009-04-25 10:30:44 -0400501{
Joe Perchesab4622c2013-03-18 10:44:35 -0700502 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400503
Tülin İzer1b37f292013-05-15 23:40:30 +0300504 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700505 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
506 + WLAN_REASSOCREQ_OFF_CAP_INFO);
507 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
508 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
509 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
510 + WLAN_REASSOCREQ_OFF_CURR_AP);
511 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP));
Forest Bond5449c682009-04-25 10:30:44 -0400512
Joe Perchesab4622c2013-03-18 10:44:35 -0700513 return;
Forest Bond5449c682009-04-25 10:30:44 -0400514}
515
Forest Bond5449c682009-04-25 10:30:44 -0400516/*+
517 *
518 * Routine Description: (AP)
519 * Decode Reassociation Request
520 *
521 *
522 * Return Value:
523 * None.
524 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700525 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400526
Charles Clément6b35b7b2010-05-07 12:30:19 -0700527void
Forest Bond5449c682009-04-25 10:30:44 -0400528vMgrDecodeReassocRequest(
Joe Perchesab4622c2013-03-18 10:44:35 -0700529 PWLAN_FR_REASSOCREQ pFrame
530)
Forest Bond5449c682009-04-25 10:30:44 -0400531{
Joe Perchesab4622c2013-03-18 10:44:35 -0700532 PWLAN_IE pItem;
533 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400534
Tülin İzer1b37f292013-05-15 23:40:30 +0300535 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700536 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
537 + WLAN_REASSOCREQ_OFF_CAP_INFO);
538 pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
539 + WLAN_REASSOCREQ_OFF_LISTEN_INT);
540 pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
541 + WLAN_REASSOCREQ_OFF_CURR_AP);
Forest Bond5449c682009-04-25 10:30:44 -0400542
Tülin İzer1b37f292013-05-15 23:40:30 +0300543 /* Information elements */
Joe Perchesab4622c2013-03-18 10:44:35 -0700544 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
545 + WLAN_REASSOCREQ_OFF_SSID);
Forest Bond5449c682009-04-25 10:30:44 -0400546
Joe Perchesab4622c2013-03-18 10:44:35 -0700547 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
Joe Perchesab4622c2013-03-18 10:44:35 -0700548 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;
Forest Bond5449c682009-04-25 10:30:44 -0400557
Joe Perchesab4622c2013-03-18 10:44:35 -0700558 case WLAN_EID_RSN:
559 if (pFrame->pRSN == NULL) {
560 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
561 }
562 break;
563 case WLAN_EID_RSN_WPA:
564 if (pFrame->pRSNWPA == NULL) {
565 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
566 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
567 }
568 break;
Forest Bond5449c682009-04-25 10:30:44 -0400569
Joe Perchesab4622c2013-03-18 10:44:35 -0700570 case WLAN_EID_EXTSUPP_RATES:
571 if (pFrame->pExtSuppRates == NULL)
572 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
573 break;
574 default:
575 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n",
576 pItem->byElementID);
577 break;
578 }
579 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
580 }
581 return;
Forest Bond5449c682009-04-25 10:30:44 -0400582}
583
Forest Bond5449c682009-04-25 10:30:44 -0400584/*+
585 *
586 * Routine Description:
587 * Encode Probe Request
588 *
589 *
590 * Return Value:
591 * None.
592 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700593 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400594
Charles Clément6b35b7b2010-05-07 12:30:19 -0700595void
Forest Bond5449c682009-04-25 10:30:44 -0400596vMgrEncodeProbeRequest(
Joe Perchesab4622c2013-03-18 10:44:35 -0700597 PWLAN_FR_PROBEREQ pFrame
598)
Forest Bond5449c682009-04-25 10:30:44 -0400599{
Joe Perchesab4622c2013-03-18 10:44:35 -0700600 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
601 pFrame->len = WLAN_HDR_ADDR3_LEN;
602 return;
Forest Bond5449c682009-04-25 10:30:44 -0400603}
604
605/*+
606 *
607 * Routine Description:
608 * Decode Probe Request
609 *
610 *
611 * Return Value:
612 * None.
613 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700614 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400615
Charles Clément6b35b7b2010-05-07 12:30:19 -0700616void
Forest Bond5449c682009-04-25 10:30:44 -0400617vMgrDecodeProbeRequest(
Joe Perchesab4622c2013-03-18 10:44:35 -0700618 PWLAN_FR_PROBEREQ pFrame
619)
Forest Bond5449c682009-04-25 10:30:44 -0400620{
Joe Perchesab4622c2013-03-18 10:44:35 -0700621 PWLAN_IE pItem;
Forest Bond5449c682009-04-25 10:30:44 -0400622
Joe Perchesab4622c2013-03-18 10:44:35 -0700623 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400624
Tülin İzer1b37f292013-05-15 23:40:30 +0300625 /* Information elements */
Joe Perchesab4622c2013-03-18 10:44:35 -0700626 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)));
Forest Bond5449c682009-04-25 10:30:44 -0400627
Joe Perchesab4622c2013-03-18 10:44:35 -0700628 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
Joe Perchesab4622c2013-03-18 10:44:35 -0700629 switch (pItem->byElementID) {
630 case WLAN_EID_SSID:
631 if (pFrame->pSSID == NULL)
632 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
633 break;
Forest Bond5449c682009-04-25 10:30:44 -0400634
Joe Perchesab4622c2013-03-18 10:44:35 -0700635 case WLAN_EID_SUPP_RATES:
636 if (pFrame->pSuppRates == NULL)
637 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
638 break;
Forest Bond5449c682009-04-25 10:30:44 -0400639
Joe Perchesab4622c2013-03-18 10:44:35 -0700640 case WLAN_EID_EXTSUPP_RATES:
641 if (pFrame->pExtSuppRates == NULL)
642 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
643 break;
Forest Bond5449c682009-04-25 10:30:44 -0400644
Joe Perchesab4622c2013-03-18 10:44:35 -0700645 default:
646 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID);
647 break;
648 }
Forest Bond5449c682009-04-25 10:30:44 -0400649
Joe Perchesab4622c2013-03-18 10:44:35 -0700650 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
651 }
652 return;
Forest Bond5449c682009-04-25 10:30:44 -0400653}
654
Forest Bond5449c682009-04-25 10:30:44 -0400655/*+
656 *
657 * Routine Description:
658 * Encode Probe Response
659 *
660 *
661 * Return Value:
662 * None.
663 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700664 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400665
Charles Clément6b35b7b2010-05-07 12:30:19 -0700666void
Forest Bond5449c682009-04-25 10:30:44 -0400667vMgrEncodeProbeResponse(
Joe Perchesab4622c2013-03-18 10:44:35 -0700668 PWLAN_FR_PROBERESP pFrame
669)
Forest Bond5449c682009-04-25 10:30:44 -0400670{
Joe Perchesab4622c2013-03-18 10:44:35 -0700671 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400672
Tülin İzer1b37f292013-05-15 23:40:30 +0300673 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700674 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
675 + WLAN_PROBERESP_OFF_TS);
676 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
677 + WLAN_PROBERESP_OFF_BCN_INT);
678 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
679 + WLAN_PROBERESP_OFF_CAP_INFO);
Forest Bond5449c682009-04-25 10:30:44 -0400680
Joe Perchesab4622c2013-03-18 10:44:35 -0700681 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO +
682 sizeof(*(pFrame->pwCapInfo));
Forest Bond5449c682009-04-25 10:30:44 -0400683
Joe Perchesab4622c2013-03-18 10:44:35 -0700684 return;
Forest Bond5449c682009-04-25 10:30:44 -0400685}
686
Forest Bond5449c682009-04-25 10:30:44 -0400687/*+
688 *
689 * Routine Description:
690 * Decode Probe Response
691 *
692 *
693 * Return Value:
694 * None.
695 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700696 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400697
Charles Clément6b35b7b2010-05-07 12:30:19 -0700698void
Forest Bond5449c682009-04-25 10:30:44 -0400699vMgrDecodeProbeResponse(
Joe Perchesab4622c2013-03-18 10:44:35 -0700700 PWLAN_FR_PROBERESP pFrame
701)
Forest Bond5449c682009-04-25 10:30:44 -0400702{
Joe Perchesab4622c2013-03-18 10:44:35 -0700703 PWLAN_IE pItem;
Forest Bond5449c682009-04-25 10:30:44 -0400704
Joe Perchesab4622c2013-03-18 10:44:35 -0700705 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400706
Tülin İzer1b37f292013-05-15 23:40:30 +0300707 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700708 pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
709 + WLAN_PROBERESP_OFF_TS);
710 pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
711 + WLAN_PROBERESP_OFF_BCN_INT);
712 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
713 + WLAN_PROBERESP_OFF_CAP_INFO);
Forest Bond5449c682009-04-25 10:30:44 -0400714
Tülin İzer1b37f292013-05-15 23:40:30 +0300715 /* Information elements */
Joe Perchesab4622c2013-03-18 10:44:35 -0700716 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
717 + WLAN_PROBERESP_OFF_SSID);
Forest Bond5449c682009-04-25 10:30:44 -0400718
Joe Perchesab4622c2013-03-18 10:44:35 -0700719 while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) {
720 switch (pItem->byElementID) {
721 case WLAN_EID_SSID:
722 if (pFrame->pSSID == NULL)
723 pFrame->pSSID = (PWLAN_IE_SSID)pItem;
724 break;
725 case WLAN_EID_SUPP_RATES:
726 if (pFrame->pSuppRates == NULL)
727 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
728 break;
729 case WLAN_EID_FH_PARMS:
730 break;
731 case WLAN_EID_DS_PARMS:
732 if (pFrame->pDSParms == NULL)
733 pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem;
734 break;
735 case WLAN_EID_CF_PARMS:
736 if (pFrame->pCFParms == NULL)
737 pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem;
738 break;
739 case WLAN_EID_IBSS_PARMS:
740 if (pFrame->pIBSSParms == NULL)
741 pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem;
742 break;
Forest Bond5449c682009-04-25 10:30:44 -0400743
Joe Perchesab4622c2013-03-18 10:44:35 -0700744 case WLAN_EID_RSN:
745 if (pFrame->pRSN == NULL) {
746 pFrame->pRSN = (PWLAN_IE_RSN)pItem;
747 }
748 break;
749 case WLAN_EID_RSN_WPA:
750 if (pFrame->pRSNWPA == NULL) {
751 if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == true)
752 pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem;
753 }
754 break;
755 case WLAN_EID_ERP:
756 if (pFrame->pERP == NULL)
757 pFrame->pERP = (PWLAN_IE_ERP)pItem;
758 break;
759 case WLAN_EID_EXTSUPP_RATES:
760 if (pFrame->pExtSuppRates == NULL)
761 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
762 break;
Forest Bond5449c682009-04-25 10:30:44 -0400763
Tülin İzer1b37f292013-05-15 23:40:30 +0300764 case WLAN_EID_COUNTRY: /* 7 */
Joe Perchesab4622c2013-03-18 10:44:35 -0700765 if (pFrame->pIE_Country == NULL)
766 pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem;
767 break;
Forest Bond5449c682009-04-25 10:30:44 -0400768
Tülin İzer1b37f292013-05-15 23:40:30 +0300769 case WLAN_EID_PWR_CONSTRAINT: /* 32 */
Joe Perchesab4622c2013-03-18 10:44:35 -0700770 if (pFrame->pIE_PowerConstraint == NULL)
771 pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem;
772 break;
Forest Bond5449c682009-04-25 10:30:44 -0400773
Tülin İzer1b37f292013-05-15 23:40:30 +0300774 case WLAN_EID_CH_SWITCH: /* 37 */
Joe Perchesab4622c2013-03-18 10:44:35 -0700775 if (pFrame->pIE_CHSW == NULL)
776 pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem;
777 break;
Forest Bond5449c682009-04-25 10:30:44 -0400778
Tülin İzer1b37f292013-05-15 23:40:30 +0300779 case WLAN_EID_QUIET: /* 40 */
Joe Perchesab4622c2013-03-18 10:44:35 -0700780 if (pFrame->pIE_Quiet == NULL)
781 pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem;
782 break;
Forest Bond5449c682009-04-25 10:30:44 -0400783
Joe Perchesab4622c2013-03-18 10:44:35 -0700784 case WLAN_EID_IBSS_DFS:
785 if (pFrame->pIE_IBSSDFS == NULL)
786 pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem;
787 break;
Forest Bond5449c682009-04-25 10:30:44 -0400788
Joe Perchesab4622c2013-03-18 10:44:35 -0700789 default:
790 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID);
791 break;
792 }
Forest Bond5449c682009-04-25 10:30:44 -0400793
Joe Perchesab4622c2013-03-18 10:44:35 -0700794 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
795 }
796 return;
Forest Bond5449c682009-04-25 10:30:44 -0400797}
798
Forest Bond5449c682009-04-25 10:30:44 -0400799/*+
800 *
801 * Routine Description:
802 * Encode Authentication frame
803 *
804 *
805 * Return Value:
806 * None.
807 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700808 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400809
Charles Clément6b35b7b2010-05-07 12:30:19 -0700810void
Forest Bond5449c682009-04-25 10:30:44 -0400811vMgrEncodeAuthen(
Joe Perchesab4622c2013-03-18 10:44:35 -0700812 PWLAN_FR_AUTHEN pFrame
813)
Forest Bond5449c682009-04-25 10:30:44 -0400814{
Joe Perchesab4622c2013-03-18 10:44:35 -0700815 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400816
Tülin İzer1b37f292013-05-15 23:40:30 +0300817 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700818 pFrame->pwAuthAlgorithm = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
819 + WLAN_AUTHEN_OFF_AUTH_ALG);
820 pFrame->pwAuthSequence = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
821 + WLAN_AUTHEN_OFF_AUTH_SEQ);
822 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
823 + WLAN_AUTHEN_OFF_STATUS);
824 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus));
Forest Bond5449c682009-04-25 10:30:44 -0400825
Joe Perchesab4622c2013-03-18 10:44:35 -0700826 return;
Forest Bond5449c682009-04-25 10:30:44 -0400827}
828
Forest Bond5449c682009-04-25 10:30:44 -0400829/*+
830 *
831 * Routine Description:
832 * Decode Authentication
833 *
834 *
835 * Return Value:
836 * None.
837 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700838 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400839
Charles Clément6b35b7b2010-05-07 12:30:19 -0700840void
Forest Bond5449c682009-04-25 10:30:44 -0400841vMgrDecodeAuthen(
Joe Perchesab4622c2013-03-18 10:44:35 -0700842 PWLAN_FR_AUTHEN pFrame
843)
Forest Bond5449c682009-04-25 10:30:44 -0400844{
Joe Perchesab4622c2013-03-18 10:44:35 -0700845 PWLAN_IE pItem;
Forest Bond5449c682009-04-25 10:30:44 -0400846
Joe Perchesab4622c2013-03-18 10:44:35 -0700847 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400848
Tülin İzer1b37f292013-05-15 23:40:30 +0300849 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700850 pFrame->pwAuthAlgorithm = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
851 + WLAN_AUTHEN_OFF_AUTH_ALG);
852 pFrame->pwAuthSequence = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
853 + WLAN_AUTHEN_OFF_AUTH_SEQ);
854 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
855 + WLAN_AUTHEN_OFF_STATUS);
Forest Bond5449c682009-04-25 10:30:44 -0400856
Tülin İzer1b37f292013-05-15 23:40:30 +0300857 /* Information elements */
Joe Perchesab4622c2013-03-18 10:44:35 -0700858 pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
859 + WLAN_AUTHEN_OFF_CHALLENGE);
Forest Bond5449c682009-04-25 10:30:44 -0400860
Joe Perchesab4622c2013-03-18 10:44:35 -0700861 if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) {
862 pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem;
863 }
Forest Bond5449c682009-04-25 10:30:44 -0400864
Joe Perchesab4622c2013-03-18 10:44:35 -0700865 return;
Forest Bond5449c682009-04-25 10:30:44 -0400866}
867
Forest Bond5449c682009-04-25 10:30:44 -0400868/*+
869 *
870 * Routine Description:
871 * Encode Authentication
872 *
873 *
874 * Return Value:
875 * None.
876 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700877 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400878
Charles Clément6b35b7b2010-05-07 12:30:19 -0700879void
Forest Bond5449c682009-04-25 10:30:44 -0400880vMgrEncodeDeauthen(
Joe Perchesab4622c2013-03-18 10:44:35 -0700881 PWLAN_FR_DEAUTHEN pFrame
882)
Forest Bond5449c682009-04-25 10:30:44 -0400883{
Joe Perchesab4622c2013-03-18 10:44:35 -0700884 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400885
Tülin İzer1b37f292013-05-15 23:40:30 +0300886 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700887 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
888 + WLAN_DEAUTHEN_OFF_REASON);
889 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason));
Forest Bond5449c682009-04-25 10:30:44 -0400890
Joe Perchesab4622c2013-03-18 10:44:35 -0700891 return;
Forest Bond5449c682009-04-25 10:30:44 -0400892}
893
Forest Bond5449c682009-04-25 10:30:44 -0400894/*+
895 *
896 * Routine Description:
897 * Decode Deauthentication
898 *
899 *
900 * Return Value:
901 * None.
902 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700903 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400904
Charles Clément6b35b7b2010-05-07 12:30:19 -0700905void
Forest Bond5449c682009-04-25 10:30:44 -0400906vMgrDecodeDeauthen(
Joe Perchesab4622c2013-03-18 10:44:35 -0700907 PWLAN_FR_DEAUTHEN pFrame
908)
Forest Bond5449c682009-04-25 10:30:44 -0400909{
Joe Perchesab4622c2013-03-18 10:44:35 -0700910 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400911
Tülin İzer1b37f292013-05-15 23:40:30 +0300912 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700913 pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
914 + WLAN_DEAUTHEN_OFF_REASON);
Forest Bond5449c682009-04-25 10:30:44 -0400915
Joe Perchesab4622c2013-03-18 10:44:35 -0700916 return;
Forest Bond5449c682009-04-25 10:30:44 -0400917}
918
Forest Bond5449c682009-04-25 10:30:44 -0400919/*+
920 *
921 * Routine Description: (AP)
922 * Encode Reassociation Response
923 *
924 *
925 * Return Value:
926 * None.
927 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700928 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400929
Charles Clément6b35b7b2010-05-07 12:30:19 -0700930void
Forest Bond5449c682009-04-25 10:30:44 -0400931vMgrEncodeReassocResponse(
Joe Perchesab4622c2013-03-18 10:44:35 -0700932 PWLAN_FR_REASSOCRESP pFrame
933)
Forest Bond5449c682009-04-25 10:30:44 -0400934{
Joe Perchesab4622c2013-03-18 10:44:35 -0700935 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400936
Tülin İzer1b37f292013-05-15 23:40:30 +0300937 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700938 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
939 + WLAN_REASSOCRESP_OFF_CAP_INFO);
940 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
941 + WLAN_REASSOCRESP_OFF_STATUS);
942 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
943 + WLAN_REASSOCRESP_OFF_AID);
Forest Bond5449c682009-04-25 10:30:44 -0400944
Joe Perchesab4622c2013-03-18 10:44:35 -0700945 pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid));
Forest Bond5449c682009-04-25 10:30:44 -0400946
Joe Perchesab4622c2013-03-18 10:44:35 -0700947 return;
Forest Bond5449c682009-04-25 10:30:44 -0400948}
949
Forest Bond5449c682009-04-25 10:30:44 -0400950/*+
951 *
952 * Routine Description:
953 * Decode Reassociation Response
954 *
955 *
956 * Return Value:
957 * None.
958 *
Joe Perchesab4622c2013-03-18 10:44:35 -0700959 -*/
Forest Bond5449c682009-04-25 10:30:44 -0400960
Charles Clément6b35b7b2010-05-07 12:30:19 -0700961void
Forest Bond5449c682009-04-25 10:30:44 -0400962vMgrDecodeReassocResponse(
Joe Perchesab4622c2013-03-18 10:44:35 -0700963 PWLAN_FR_REASSOCRESP pFrame
964)
Forest Bond5449c682009-04-25 10:30:44 -0400965{
Joe Perchesab4622c2013-03-18 10:44:35 -0700966 PWLAN_IE pItem;
Forest Bond5449c682009-04-25 10:30:44 -0400967
Joe Perchesab4622c2013-03-18 10:44:35 -0700968 pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf;
Forest Bond5449c682009-04-25 10:30:44 -0400969
Tülin İzer1b37f292013-05-15 23:40:30 +0300970 /* Fixed Fields */
Joe Perchesab4622c2013-03-18 10:44:35 -0700971 pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
972 + WLAN_REASSOCRESP_OFF_CAP_INFO);
973 pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
974 + WLAN_REASSOCRESP_OFF_STATUS);
975 pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
976 + WLAN_REASSOCRESP_OFF_AID);
Forest Bond5449c682009-04-25 10:30:44 -0400977
Tülin İzer1b37f292013-05-15 23:40:30 +0300978 /* Information elements */
Joe Perchesab4622c2013-03-18 10:44:35 -0700979 pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))
980 + WLAN_REASSOCRESP_OFF_SUPP_RATES);
Forest Bond5449c682009-04-25 10:30:44 -0400981
Joe Perchesab4622c2013-03-18 10:44:35 -0700982 pItem = (PWLAN_IE)(pFrame->pSuppRates);
983 pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len);
Forest Bond5449c682009-04-25 10:30:44 -0400984
Joe Perchesab4622c2013-03-18 10:44:35 -0700985 if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) &&
986 (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) {
987 pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem;
988 }
989 return;
Forest Bond5449c682009-04-25 10:30:44 -0400990}