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