Forest Bond | 92b9679 | 2009-06-13 07:38:31 -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 | * |
| 19 | * File: 80211mgr.c |
| 20 | * |
Uwe Kleine-König | 0d74395 | 2010-06-11 12:17:04 +0200 | [diff] [blame] | 21 | * Purpose: Handles the 802.11 management support functions |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -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 | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 55 | #include "tmacro.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 56 | #include "tether.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 57 | #include "80211mgr.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 58 | #include "80211hdr.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 59 | #include "device.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 60 | #include "wpa.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 61 | |
| 62 | /*--------------------- Static Definitions -------------------------*/ |
| 63 | |
| 64 | |
| 65 | |
| 66 | /*--------------------- Static Classes ----------------------------*/ |
| 67 | |
| 68 | /*--------------------- Static Variables --------------------------*/ |
| 69 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 70 | static int msglevel = MSG_LEVEL_INFO; |
| 71 | /*static int msglevel =MSG_LEVEL_DEBUG;*/ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 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 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 92 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 93 | vMgrEncodeBeacon( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 94 | PWLAN_FR_BEACON pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 95 | ) |
| 96 | { |
| 97 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 98 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 99 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 100 | pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 101 | + WLAN_BEACON_OFF_TS); |
| 102 | pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 103 | + WLAN_BEACON_OFF_BCN_INT); |
| 104 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 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 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 124 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 125 | vMgrDecodeBeacon( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 126 | PWLAN_FR_BEACON pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 127 | ) |
| 128 | { |
| 129 | PWLAN_IE pItem; |
| 130 | |
| 131 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 132 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 133 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 134 | pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 135 | + WLAN_BEACON_OFF_TS); |
| 136 | pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 137 | + WLAN_BEACON_OFF_BCN_INT); |
| 138 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 139 | + WLAN_BEACON_OFF_CAPINFO); |
| 140 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 141 | /* Information elements */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 142 | pItem = (PWLAN_IE)((PBYTE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))) |
| 143 | + WLAN_BEACON_OFF_SSID); |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 144 | while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 145 | |
| 146 | switch (pItem->byElementID) { |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 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; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 174 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 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; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 185 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 186 | case WLAN_EID_ERP: |
| 187 | if (pFrame->pERP == NULL) |
| 188 | pFrame->pERP = (PWLAN_IE_ERP)pItem; |
| 189 | break; |
| 190 | case WLAN_EID_EXTSUPP_RATES: |
| 191 | if (pFrame->pExtSuppRates == NULL) |
| 192 | pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; |
| 193 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 194 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 195 | case WLAN_EID_COUNTRY: /* 7 */ |
| 196 | if (pFrame->pIE_Country == NULL) |
| 197 | pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; |
| 198 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 199 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 200 | case WLAN_EID_PWR_CONSTRAINT: /* 32 */ |
| 201 | if (pFrame->pIE_PowerConstraint == NULL) |
| 202 | pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem; |
| 203 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 204 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 205 | case WLAN_EID_CH_SWITCH: /* 37 */ |
| 206 | if (pFrame->pIE_CHSW == NULL) |
| 207 | pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; |
| 208 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 209 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 210 | case WLAN_EID_QUIET: /* 40 */ |
| 211 | if (pFrame->pIE_Quiet == NULL) |
| 212 | pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; |
| 213 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 214 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 215 | case WLAN_EID_IBSS_DFS: |
| 216 | if (pFrame->pIE_IBSSDFS == NULL) |
| 217 | pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; |
| 218 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 219 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 220 | default: |
| 221 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 222 | break; |
| 223 | |
| 224 | } |
| 225 | pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); |
| 226 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | |
| 230 | /*+ |
| 231 | * |
| 232 | * Routine Description: |
| 233 | * Encode IBSS ATIM |
| 234 | * |
| 235 | * |
| 236 | * Return Value: |
| 237 | * None. |
| 238 | * |
| 239 | -*/ |
| 240 | |
| 241 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 242 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 243 | vMgrEncodeIBSSATIM( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 244 | PWLAN_FR_IBSSATIM pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 245 | ) |
| 246 | { |
| 247 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 248 | pFrame->len = WLAN_HDR_ADDR3_LEN; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | |
| 252 | /*+ |
| 253 | * |
| 254 | * Routine Description: |
| 255 | * Decode IBSS ATIM |
| 256 | * |
| 257 | * |
| 258 | * Return Value: |
| 259 | * None. |
| 260 | * |
| 261 | -*/ |
| 262 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 263 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 264 | vMgrDecodeIBSSATIM( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 265 | PWLAN_FR_IBSSATIM pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 266 | ) |
| 267 | { |
| 268 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | |
| 272 | /*+ |
| 273 | * |
| 274 | * Routine Description: |
| 275 | * Encode Disassociation |
| 276 | * |
| 277 | * |
| 278 | * Return Value: |
| 279 | * None. |
| 280 | * |
| 281 | -*/ |
| 282 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 283 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 284 | vMgrEncodeDisassociation( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 285 | PWLAN_FR_DISASSOC pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 286 | ) |
| 287 | { |
| 288 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 289 | |
| 290 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 291 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 292 | pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 293 | + WLAN_DISASSOC_OFF_REASON); |
| 294 | pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | |
| 298 | /*+ |
| 299 | * |
| 300 | * Routine Description: |
| 301 | * Decode Disassociation |
| 302 | * |
| 303 | * |
| 304 | * Return Value: |
| 305 | * None. |
| 306 | * |
| 307 | -*/ |
| 308 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 309 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 310 | vMgrDecodeDisassociation( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 311 | PWLAN_FR_DISASSOC pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 312 | ) |
| 313 | { |
| 314 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 315 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 316 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 317 | pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 318 | + WLAN_DISASSOC_OFF_REASON); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | /*+ |
| 322 | * |
| 323 | * Routine Description: |
| 324 | * Encode Association Request |
| 325 | * |
| 326 | * |
| 327 | * Return Value: |
| 328 | * None. |
| 329 | * |
| 330 | -*/ |
| 331 | |
| 332 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 333 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 334 | vMgrEncodeAssocRequest( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 335 | PWLAN_FR_ASSOCREQ pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 336 | ) |
| 337 | { |
| 338 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 339 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 340 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 341 | + WLAN_ASSOCREQ_OFF_CAP_INFO); |
| 342 | pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 343 | + WLAN_ASSOCREQ_OFF_LISTEN_INT); |
| 344 | pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | |
| 348 | /*+ |
| 349 | * |
| 350 | * Routine Description: (AP) |
| 351 | * Decode Association Request |
| 352 | * |
| 353 | * |
| 354 | * Return Value: |
| 355 | * None. |
| 356 | * |
| 357 | -*/ |
| 358 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 359 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 360 | vMgrDecodeAssocRequest( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 361 | PWLAN_FR_ASSOCREQ pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 362 | ) |
| 363 | { |
| 364 | PWLAN_IE pItem; |
| 365 | |
| 366 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 367 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 368 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 369 | + WLAN_ASSOCREQ_OFF_CAP_INFO); |
| 370 | pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 371 | + WLAN_ASSOCREQ_OFF_LISTEN_INT); |
| 372 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 373 | /* Information elements */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 374 | pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 375 | + WLAN_ASSOCREQ_OFF_SSID); |
| 376 | |
| 377 | while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 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; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 387 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 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; |
| 398 | case WLAN_EID_EXTSUPP_RATES: |
| 399 | if (pFrame->pExtSuppRates == NULL) |
| 400 | pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; |
| 401 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 402 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 403 | default: |
| 404 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n", |
| 405 | pItem->byElementID); |
| 406 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 407 | } |
| 408 | pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); |
| 409 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | /*+ |
| 413 | * |
| 414 | * Routine Description: (AP) |
| 415 | * Encode Association Response |
| 416 | * |
| 417 | * |
| 418 | * Return Value: |
| 419 | * None. |
| 420 | * |
| 421 | -*/ |
| 422 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 423 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 424 | vMgrEncodeAssocResponse( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 425 | PWLAN_FR_ASSOCRESP pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 426 | ) |
| 427 | { |
| 428 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 429 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 430 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 431 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 432 | + WLAN_ASSOCRESP_OFF_CAP_INFO); |
| 433 | pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 434 | + WLAN_ASSOCRESP_OFF_STATUS); |
| 435 | pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 436 | + WLAN_ASSOCRESP_OFF_AID); |
| 437 | pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID |
| 438 | + sizeof(*(pFrame->pwAid)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | |
| 442 | /*+ |
| 443 | * |
| 444 | * Routine Description: |
| 445 | * Decode Association Response |
| 446 | * |
| 447 | * |
| 448 | * Return Value: |
| 449 | * None. |
| 450 | * |
| 451 | -*/ |
| 452 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 453 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 454 | vMgrDecodeAssocResponse( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 455 | PWLAN_FR_ASSOCRESP pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 456 | ) |
| 457 | { |
| 458 | PWLAN_IE pItem; |
| 459 | |
| 460 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 461 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 462 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 463 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 464 | + WLAN_ASSOCRESP_OFF_CAP_INFO); |
| 465 | pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 466 | + WLAN_ASSOCRESP_OFF_STATUS); |
| 467 | pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 468 | + WLAN_ASSOCRESP_OFF_AID); |
| 469 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 470 | /* Information elements */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 471 | pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 472 | + WLAN_ASSOCRESP_OFF_SUPP_RATES); |
| 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); |
Marcos Paulo de Souza | 6318237 | 2011-11-30 00:18:07 -0200 | [diff] [blame] | 480 | } else |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 481 | pFrame->pExtSuppRates = NULL; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | |
| 485 | /*+ |
| 486 | * |
| 487 | * Routine Description: |
| 488 | * Encode Reassociation Request |
| 489 | * |
| 490 | * |
| 491 | * Return Value: |
| 492 | * None. |
| 493 | * |
| 494 | -*/ |
| 495 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 496 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 497 | vMgrEncodeReassocRequest( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 498 | PWLAN_FR_REASSOCREQ pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 499 | ) |
| 500 | { |
| 501 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 502 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 503 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 504 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 505 | + WLAN_REASSOCREQ_OFF_CAP_INFO); |
| 506 | pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 507 | + WLAN_REASSOCREQ_OFF_LISTEN_INT); |
| 508 | pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 509 | + WLAN_REASSOCREQ_OFF_CURR_AP); |
| 510 | pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCREQ_OFF_CURR_AP + sizeof(*(pFrame->pAddrCurrAP)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | |
| 514 | /*+ |
| 515 | * |
| 516 | * Routine Description: (AP) |
| 517 | * Decode Reassociation Request |
| 518 | * |
| 519 | * |
| 520 | * Return Value: |
| 521 | * None. |
| 522 | * |
| 523 | -*/ |
| 524 | |
| 525 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 526 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 527 | vMgrDecodeReassocRequest( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 528 | PWLAN_FR_REASSOCREQ pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 529 | ) |
| 530 | { |
| 531 | PWLAN_IE pItem; |
| 532 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 533 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 534 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 535 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 536 | + WLAN_REASSOCREQ_OFF_CAP_INFO); |
| 537 | pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 538 | + WLAN_REASSOCREQ_OFF_LISTEN_INT); |
| 539 | pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 540 | + WLAN_REASSOCREQ_OFF_CURR_AP); |
| 541 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 542 | /* Information elements */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 543 | pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 544 | + WLAN_REASSOCREQ_OFF_SSID); |
| 545 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 546 | while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 547 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 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; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 557 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 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: |
Marcos Paulo de Souza | 6318237 | 2011-11-30 00:18:07 -0200 | [diff] [blame] | 563 | if (pFrame->pRSNWPA == NULL) |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 564 | if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) |
| 565 | pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 566 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 567 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 568 | case WLAN_EID_EXTSUPP_RATES: |
| 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; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 576 | } |
| 577 | pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); |
| 578 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | |
| 582 | |
| 583 | /*+ |
| 584 | * |
| 585 | * Routine Description: |
| 586 | * Encode Probe Request |
| 587 | * |
| 588 | * |
| 589 | * Return Value: |
| 590 | * None. |
| 591 | * |
| 592 | -*/ |
| 593 | |
| 594 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 595 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 596 | vMgrEncodeProbeRequest( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 597 | PWLAN_FR_PROBEREQ pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 598 | ) |
| 599 | { |
| 600 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 601 | pFrame->len = WLAN_HDR_ADDR3_LEN; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | /*+ |
| 605 | * |
| 606 | * Routine Description: |
| 607 | * Decode Probe Request |
| 608 | * |
| 609 | * |
| 610 | * Return Value: |
| 611 | * None. |
| 612 | * |
| 613 | -*/ |
| 614 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 615 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 616 | vMgrDecodeProbeRequest( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 617 | PWLAN_FR_PROBEREQ pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 618 | ) |
| 619 | { |
| 620 | PWLAN_IE pItem; |
| 621 | |
| 622 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 623 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 624 | /* Information elements */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 625 | pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))); |
| 626 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 627 | while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 628 | |
| 629 | switch (pItem->byElementID) { |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 630 | case WLAN_EID_SSID: |
| 631 | if (pFrame->pSSID == NULL) |
| 632 | pFrame->pSSID = (PWLAN_IE_SSID)pItem; |
| 633 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 634 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 635 | case WLAN_EID_SUPP_RATES: |
| 636 | if (pFrame->pSuppRates == NULL) |
| 637 | pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; |
| 638 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 639 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 640 | case WLAN_EID_EXTSUPP_RATES: |
| 641 | if (pFrame->pExtSuppRates == NULL) |
| 642 | pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; |
| 643 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 644 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 645 | default: |
| 646 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID); |
| 647 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); |
| 651 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | |
| 655 | /*+ |
| 656 | * |
| 657 | * Routine Description: |
| 658 | * Encode Probe Response |
| 659 | * |
| 660 | * |
| 661 | * Return Value: |
| 662 | * None. |
| 663 | * |
| 664 | -*/ |
| 665 | |
| 666 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 667 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 668 | vMgrEncodeProbeResponse( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 669 | PWLAN_FR_PROBERESP pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 670 | ) |
| 671 | { |
| 672 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 673 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 674 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 675 | pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 676 | + WLAN_PROBERESP_OFF_TS); |
| 677 | pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 678 | + WLAN_PROBERESP_OFF_BCN_INT); |
| 679 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 680 | + WLAN_PROBERESP_OFF_CAP_INFO); |
| 681 | |
| 682 | pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO + |
| 683 | sizeof(*(pFrame->pwCapInfo)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | |
| 687 | |
| 688 | /*+ |
| 689 | * |
| 690 | * Routine Description: |
| 691 | * Decode Probe Response |
| 692 | * |
| 693 | * |
| 694 | * Return Value: |
| 695 | * None. |
| 696 | * |
| 697 | -*/ |
| 698 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 699 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 700 | vMgrDecodeProbeResponse( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 701 | PWLAN_FR_PROBERESP pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 702 | ) |
| 703 | { |
| 704 | PWLAN_IE pItem; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 705 | |
| 706 | |
| 707 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 708 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 709 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 710 | pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 711 | + WLAN_PROBERESP_OFF_TS); |
| 712 | pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 713 | + WLAN_PROBERESP_OFF_BCN_INT); |
| 714 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 715 | + WLAN_PROBERESP_OFF_CAP_INFO); |
| 716 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 717 | /* Information elements */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 718 | pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 719 | + WLAN_PROBERESP_OFF_SSID); |
| 720 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 721 | while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 722 | switch (pItem->byElementID) { |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 723 | case WLAN_EID_SSID: |
| 724 | if (pFrame->pSSID == NULL) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 725 | pFrame->pSSID = (PWLAN_IE_SSID)pItem; |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 726 | break; |
| 727 | case WLAN_EID_SUPP_RATES: |
| 728 | if (pFrame->pSuppRates == NULL) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 729 | pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 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; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 745 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 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; |
| 760 | case WLAN_EID_EXTSUPP_RATES: |
| 761 | if (pFrame->pExtSuppRates == NULL) |
| 762 | pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; |
| 763 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 764 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 765 | case WLAN_EID_COUNTRY: /* 7 */ |
| 766 | if (pFrame->pIE_Country == NULL) |
| 767 | pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; |
| 768 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 769 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 770 | case WLAN_EID_PWR_CONSTRAINT: /* 32 */ |
| 771 | if (pFrame->pIE_PowerConstraint == NULL) |
| 772 | pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem; |
| 773 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 774 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 775 | case WLAN_EID_CH_SWITCH: /* 37 */ |
| 776 | if (pFrame->pIE_CHSW == NULL) |
| 777 | pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; |
| 778 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 779 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 780 | case WLAN_EID_QUIET: /* 40 */ |
| 781 | if (pFrame->pIE_Quiet == NULL) |
| 782 | pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; |
| 783 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 784 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 785 | case WLAN_EID_IBSS_DFS: |
| 786 | if (pFrame->pIE_IBSSDFS == NULL) |
| 787 | pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; |
| 788 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 789 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 790 | default: |
| 791 | DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID); |
| 792 | break; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); |
| 796 | } |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | |
| 800 | /*+ |
| 801 | * |
| 802 | * Routine Description: |
| 803 | * Encode Authentication frame |
| 804 | * |
| 805 | * |
| 806 | * Return Value: |
| 807 | * None. |
| 808 | * |
| 809 | -*/ |
| 810 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 811 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 812 | vMgrEncodeAuthen( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 813 | PWLAN_FR_AUTHEN pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 814 | ) |
| 815 | { |
| 816 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 817 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 818 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 819 | pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 820 | + WLAN_AUTHEN_OFF_AUTH_ALG); |
| 821 | pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 822 | + WLAN_AUTHEN_OFF_AUTH_SEQ); |
| 823 | pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 824 | + WLAN_AUTHEN_OFF_STATUS); |
| 825 | pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 826 | } |
| 827 | |
| 828 | |
| 829 | /*+ |
| 830 | * |
| 831 | * Routine Description: |
| 832 | * Decode Authentication |
| 833 | * |
| 834 | * |
| 835 | * Return Value: |
| 836 | * None. |
| 837 | * |
| 838 | -*/ |
| 839 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 840 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 841 | vMgrDecodeAuthen( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 842 | PWLAN_FR_AUTHEN pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 843 | ) |
| 844 | { |
| 845 | PWLAN_IE pItem; |
| 846 | |
| 847 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 848 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 849 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 850 | pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 851 | + WLAN_AUTHEN_OFF_AUTH_ALG); |
| 852 | pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 853 | + WLAN_AUTHEN_OFF_AUTH_SEQ); |
| 854 | pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 855 | + WLAN_AUTHEN_OFF_STATUS); |
| 856 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 857 | /* Information elements */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 858 | pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 859 | + WLAN_AUTHEN_OFF_CHALLENGE); |
| 860 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 861 | if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 862 | pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | |
| 866 | /*+ |
| 867 | * |
| 868 | * Routine Description: |
| 869 | * Encode Authentication |
| 870 | * |
| 871 | * |
| 872 | * Return Value: |
| 873 | * None. |
| 874 | * |
| 875 | -*/ |
| 876 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 877 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 878 | vMgrEncodeDeauthen( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 879 | PWLAN_FR_DEAUTHEN pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 880 | ) |
| 881 | { |
| 882 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 883 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 884 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 885 | pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 886 | + WLAN_DEAUTHEN_OFF_REASON); |
| 887 | pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | |
| 891 | /*+ |
| 892 | * |
| 893 | * Routine Description: |
| 894 | * Decode Deauthentication |
| 895 | * |
| 896 | * |
| 897 | * Return Value: |
| 898 | * None. |
| 899 | * |
| 900 | -*/ |
| 901 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 902 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 903 | vMgrDecodeDeauthen( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 904 | PWLAN_FR_DEAUTHEN pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 905 | ) |
| 906 | { |
| 907 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 908 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 909 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 910 | pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 911 | + WLAN_DEAUTHEN_OFF_REASON); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 912 | } |
| 913 | |
| 914 | |
| 915 | /*+ |
| 916 | * |
| 917 | * Routine Description: (AP) |
| 918 | * Encode Reassociation Response |
| 919 | * |
| 920 | * |
| 921 | * Return Value: |
| 922 | * None. |
| 923 | * |
| 924 | -*/ |
| 925 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 926 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 927 | vMgrEncodeReassocResponse( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 928 | PWLAN_FR_REASSOCRESP pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 929 | ) |
| 930 | { |
| 931 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 932 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 933 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 934 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 935 | + WLAN_REASSOCRESP_OFF_CAP_INFO); |
| 936 | pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 937 | + WLAN_REASSOCRESP_OFF_STATUS); |
| 938 | pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 939 | + WLAN_REASSOCRESP_OFF_AID); |
| 940 | |
| 941 | pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid)); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | |
| 945 | /*+ |
| 946 | * |
| 947 | * Routine Description: |
| 948 | * Decode Reassociation Response |
| 949 | * |
| 950 | * |
| 951 | * Return Value: |
| 952 | * None. |
| 953 | * |
| 954 | -*/ |
| 955 | |
| 956 | |
Andres More | 8611a29 | 2010-05-01 14:25:00 -0300 | [diff] [blame] | 957 | void |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 958 | vMgrDecodeReassocResponse( |
Andres More | 592ccfe | 2010-04-17 12:07:42 -0300 | [diff] [blame] | 959 | PWLAN_FR_REASSOCRESP pFrame |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 960 | ) |
| 961 | { |
| 962 | PWLAN_IE pItem; |
| 963 | |
| 964 | pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; |
| 965 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 966 | /* Fixed Fields */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 967 | pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 968 | + WLAN_REASSOCRESP_OFF_CAP_INFO); |
| 969 | pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 970 | + WLAN_REASSOCRESP_OFF_STATUS); |
| 971 | pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 972 | + WLAN_REASSOCRESP_OFF_AID); |
| 973 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 974 | /* Information elements */ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 975 | pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) |
| 976 | + WLAN_REASSOCRESP_OFF_SUPP_RATES); |
| 977 | |
| 978 | pItem = (PWLAN_IE)(pFrame->pSuppRates); |
| 979 | pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); |
| 980 | |
Timofey Trofimov | 2555cd9 | 2010-05-22 20:42:54 +0400 | [diff] [blame] | 981 | if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 982 | pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 983 | } |