blob: 180a27cc74d77ed25ffe2770730c94250dfce707 [file] [log] [blame]
Forest Bond5449c682009-04-25 10:30:44 -04001/*
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 Bond5449c682009-04-25 10:30:44 -040034#include "ttype.h"
Forest Bond5449c682009-04-25 10:30:44 -040035#include "tmacro.h"
Forest Bond5449c682009-04-25 10:30:44 -040036#include "tether.h"
Forest Bond5449c682009-04-25 10:30:44 -040037#include "IEEE11h.h"
Forest Bond5449c682009-04-25 10:30:44 -040038#include "device.h"
Forest Bond5449c682009-04-25 10:30:44 -040039#include "wmgr.h"
Forest Bond5449c682009-04-25 10:30:44 -040040#include "rxtx.h"
Charles Clément79566eb2010-06-21 10:39:51 -070041#include "channel.h"
Forest Bond5449c682009-04-25 10:30:44 -040042
43/*--------------------- Static Definitions -------------------------*/
Forest Bond5449c682009-04-25 10:30:44 -040044
45#pragma pack(1)
46
47typedef struct _WLAN_FRAME_ACTION {
Toon Schoenmakers51ce0682011-07-17 01:38:29 +020048 WLAN_80211HDR_A3 Header;
49 unsigned char byCategory;
50 unsigned char byAction;
51 unsigned char abyVars[1];
Forest Bond5449c682009-04-25 10:30:44 -040052} WLAN_FRAME_ACTION, *PWLAN_FRAME_ACTION;
53
54typedef struct _WLAN_FRAME_MSRREQ {
Toon Schoenmakers51ce0682011-07-17 01:38:29 +020055 WLAN_80211HDR_A3 Header;
56 unsigned char byCategory;
57 unsigned char byAction;
58 unsigned char byDialogToken;
59 WLAN_IE_MEASURE_REQ sMSRReqEIDs[1];
Forest Bond5449c682009-04-25 10:30:44 -040060} WLAN_FRAME_MSRREQ, *PWLAN_FRAME_MSRREQ;
61
62typedef struct _WLAN_FRAME_MSRREP {
Toon Schoenmakers51ce0682011-07-17 01:38:29 +020063 WLAN_80211HDR_A3 Header;
64 unsigned char byCategory;
65 unsigned char byAction;
66 unsigned char byDialogToken;
67 WLAN_IE_MEASURE_REP sMSRRepEIDs[1];
Forest Bond5449c682009-04-25 10:30:44 -040068} WLAN_FRAME_MSRREP, *PWLAN_FRAME_MSRREP;
69
70typedef struct _WLAN_FRAME_TPCREQ {
Toon Schoenmakers51ce0682011-07-17 01:38:29 +020071 WLAN_80211HDR_A3 Header;
72 unsigned char byCategory;
73 unsigned char byAction;
74 unsigned char byDialogToken;
75 WLAN_IE_TPC_REQ sTPCReqEIDs;
Forest Bond5449c682009-04-25 10:30:44 -040076} WLAN_FRAME_TPCREQ, *PWLAN_FRAME_TPCREQ;
77
78typedef struct _WLAN_FRAME_TPCREP {
Toon Schoenmakers51ce0682011-07-17 01:38:29 +020079 WLAN_80211HDR_A3 Header;
80 unsigned char byCategory;
81 unsigned char byAction;
82 unsigned char byDialogToken;
83 WLAN_IE_TPC_REP sTPCRepEIDs;
Forest Bond5449c682009-04-25 10:30:44 -040084} WLAN_FRAME_TPCREP, *PWLAN_FRAME_TPCREP;
85
86#pragma pack()
87
Toon Schoenmakers51ce0682011-07-17 01:38:29 +020088/* action field reference ieee 802.11h Table 20e */
Forest Bond5449c682009-04-25 10:30:44 -040089#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 Bond5449c682009-04-25 10:30:44 -0400100
Forest Bond5449c682009-04-25 10:30:44 -0400101/*--------------------- Export Variables --------------------------*/
102
103/*--------------------- Export Functions --------------------------*/
104
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200105bool IEEE11hbMSRRepTx(void *pMgmtHandle)
Forest Bond5449c682009-04-25 10:30:44 -0400106{
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200107 PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle;
108 PWLAN_FRAME_MSRREP pMSRRep = (PWLAN_FRAME_MSRREP)
Joe Perchesb7760002013-03-18 10:44:36 -0700109 (pMgmt->abyCurrentMSRRep + sizeof(STxMgmtPacket));
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200110 size_t uLength = 0;
111 PSTxMgmtPacket pTxPacket = NULL;
Forest Bond5449c682009-04-25 10:30:44 -0400112
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200113 pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep;
114 memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN);
115 pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket +
Joe Perchesb7760002013-03-18 10:44:36 -0700116 sizeof(STxMgmtPacket));
Forest Bond5449c682009-04-25 10:30:44 -0400117
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200118 pMSRRep->Header.wFrameCtl = (WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) |
Joe Perchesb7760002013-03-18 10:44:36 -0700119 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION)
120);
Forest Bond5449c682009-04-25 10:30:44 -0400121
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200122 memcpy(pMSRRep->Header.abyAddr1, ((PWLAN_FRAME_MSRREQ)
Joe Perchesb7760002013-03-18 10:44:36 -0700123 (pMgmt->abyCurrentMSRReq))->Header.abyAddr2, WLAN_ADDR_LEN);
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200124 memcpy(pMSRRep->Header.abyAddr2,
Joe Perchesb7760002013-03-18 10:44:36 -0700125 CARDpGetCurrentAddress(pMgmt->pAdapter), WLAN_ADDR_LEN);
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200126 memcpy(pMSRRep->Header.abyAddr3, pMgmt->abyCurrBSSID, WLAN_BSSID_LEN);
Forest Bond5449c682009-04-25 10:30:44 -0400127
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200128 pMSRRep->byCategory = 0;
129 pMSRRep->byAction = 1;
130 pMSRRep->byDialogToken = ((PWLAN_FRAME_MSRREQ)
Joe Perchesb7760002013-03-18 10:44:36 -0700131 (pMgmt->abyCurrentMSRReq))->byDialogToken;
Forest Bond5449c682009-04-25 10:30:44 -0400132
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200133 uLength = pMgmt->uLengthOfRepEIDs + offsetof(WLAN_FRAME_MSRREP,
134 sMSRRepEIDs);
Forest Bond5449c682009-04-25 10:30:44 -0400135
Toon Schoenmakers51ce0682011-07-17 01:38:29 +0200136 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 Bond5449c682009-04-25 10:30:44 -0400141}