Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1996, 2005 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 | * |
| 20 | * File: IEEE11h.c |
| 21 | * |
| 22 | * Purpose: |
| 23 | * |
| 24 | * Functions: |
| 25 | * |
| 26 | * Revision History: |
| 27 | * |
| 28 | * Author: Yiching Chen |
| 29 | * |
| 30 | * Date: Mar. 31, 2005 |
| 31 | * |
| 32 | */ |
| 33 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 34 | #include "ttype.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 35 | #include "tmacro.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 36 | #include "tether.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 37 | #include "IEEE11h.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 38 | #include "device.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 39 | #include "wmgr.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 40 | #include "rxtx.h" |
Charles Clément | 79566eb | 2010-06-21 10:39:51 -0700 | [diff] [blame] | 41 | #include "channel.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 42 | |
| 43 | /*--------------------- Static Definitions -------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 44 | |
| 45 | #pragma pack(1) |
| 46 | |
| 47 | typedef struct _WLAN_FRAME_ACTION { |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 48 | WLAN_80211HDR_A3 Header; |
| 49 | unsigned char byCategory; |
| 50 | unsigned char byAction; |
| 51 | unsigned char abyVars[1]; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 52 | } WLAN_FRAME_ACTION, *PWLAN_FRAME_ACTION; |
| 53 | |
| 54 | typedef struct _WLAN_FRAME_MSRREQ { |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 55 | WLAN_80211HDR_A3 Header; |
| 56 | unsigned char byCategory; |
| 57 | unsigned char byAction; |
| 58 | unsigned char byDialogToken; |
| 59 | WLAN_IE_MEASURE_REQ sMSRReqEIDs[1]; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 60 | } WLAN_FRAME_MSRREQ, *PWLAN_FRAME_MSRREQ; |
| 61 | |
| 62 | typedef struct _WLAN_FRAME_MSRREP { |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 63 | WLAN_80211HDR_A3 Header; |
| 64 | unsigned char byCategory; |
| 65 | unsigned char byAction; |
| 66 | unsigned char byDialogToken; |
| 67 | WLAN_IE_MEASURE_REP sMSRRepEIDs[1]; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 68 | } WLAN_FRAME_MSRREP, *PWLAN_FRAME_MSRREP; |
| 69 | |
| 70 | typedef struct _WLAN_FRAME_TPCREQ { |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 71 | WLAN_80211HDR_A3 Header; |
| 72 | unsigned char byCategory; |
| 73 | unsigned char byAction; |
| 74 | unsigned char byDialogToken; |
| 75 | WLAN_IE_TPC_REQ sTPCReqEIDs; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 76 | } WLAN_FRAME_TPCREQ, *PWLAN_FRAME_TPCREQ; |
| 77 | |
| 78 | typedef struct _WLAN_FRAME_TPCREP { |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 79 | WLAN_80211HDR_A3 Header; |
| 80 | unsigned char byCategory; |
| 81 | unsigned char byAction; |
| 82 | unsigned char byDialogToken; |
| 83 | WLAN_IE_TPC_REP sTPCRepEIDs; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 84 | } WLAN_FRAME_TPCREP, *PWLAN_FRAME_TPCREP; |
| 85 | |
| 86 | #pragma pack() |
| 87 | |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 88 | /* action field reference ieee 802.11h Table 20e */ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 89 | #define ACTION_MSRREQ 0 |
| 90 | #define ACTION_MSRREP 1 |
| 91 | #define ACTION_TPCREQ 2 |
| 92 | #define ACTION_TPCREP 3 |
| 93 | #define ACTION_CHSW 4 |
| 94 | |
| 95 | /*--------------------- Static Classes ----------------------------*/ |
| 96 | |
| 97 | /*--------------------- Static Variables --------------------------*/ |
| 98 | |
| 99 | /*--------------------- Static Functions --------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 100 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 101 | /*--------------------- Export Variables --------------------------*/ |
| 102 | |
| 103 | /*--------------------- Export Functions --------------------------*/ |
| 104 | |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 105 | bool IEEE11hbMSRRepTx(void *pMgmtHandle) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 106 | { |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 107 | PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; |
| 108 | PWLAN_FRAME_MSRREP pMSRRep = (PWLAN_FRAME_MSRREP) |
Joe Perches | b776000 | 2013-03-18 10:44:36 -0700 | [diff] [blame] | 109 | (pMgmt->abyCurrentMSRRep + sizeof(STxMgmtPacket)); |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 110 | size_t uLength = 0; |
| 111 | PSTxMgmtPacket pTxPacket = NULL; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 112 | |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 113 | pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep; |
| 114 | memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN); |
| 115 | pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + |
Joe Perches | b776000 | 2013-03-18 10:44:36 -0700 | [diff] [blame] | 116 | sizeof(STxMgmtPacket)); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 117 | |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 118 | pMSRRep->Header.wFrameCtl = (WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) | |
Joe Perches | b776000 | 2013-03-18 10:44:36 -0700 | [diff] [blame] | 119 | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION) |
| 120 | ); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 121 | |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 122 | memcpy(pMSRRep->Header.abyAddr1, ((PWLAN_FRAME_MSRREQ) |
Joe Perches | b776000 | 2013-03-18 10:44:36 -0700 | [diff] [blame] | 123 | (pMgmt->abyCurrentMSRReq))->Header.abyAddr2, WLAN_ADDR_LEN); |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 124 | memcpy(pMSRRep->Header.abyAddr2, |
Joe Perches | b776000 | 2013-03-18 10:44:36 -0700 | [diff] [blame] | 125 | CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN); |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 126 | memcpy(pMSRRep->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 127 | |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 128 | pMSRRep->byCategory = 0; |
| 129 | pMSRRep->byAction = 1; |
| 130 | pMSRRep->byDialogToken = ((PWLAN_FRAME_MSRREQ) |
Joe Perches | b776000 | 2013-03-18 10:44:36 -0700 | [diff] [blame] | 131 | (pMgmt->abyCurrentMSRReq))->byDialogToken; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 132 | |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 133 | uLength = pMgmt->uLengthOfRepEIDs + offsetof(WLAN_FRAME_MSRREP, |
| 134 | sMSRRepEIDs); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 135 | |
Toon Schoenmakers | 51ce068 | 2011-07-17 01:38:29 +0200 | [diff] [blame] | 136 | pTxPacket->cbMPDULen = uLength; |
| 137 | pTxPacket->cbPayloadLen = uLength - WLAN_HDR_ADDR3_LEN; |
| 138 | if (csMgmt_xmit(pMgmt->pAdapter, pTxPacket) != CMD_STATUS_PENDING) |
| 139 | return false; |
| 140 | return true; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 141 | } |