2 * Copyright (c) 1996, 2005 VIA Networking Technologies, Inc.
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.
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.
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.
28 * Author: Yiching Chen
35 #if !defined(__TTYPE_H__)
38 #if !defined(__UMEM_H__)
41 #if !defined(__TMACRO_H__)
44 #if !defined(__TETHER_H__)
47 #if !defined(__IEEE11h_H__)
51 #if !defined(__DEVICE_H__)
54 #if !defined(__WMGR_H__)
57 #if !defined(__RXTX_H__)
63 /*--------------------- Static Definitions -------------------------*/
64 static int msglevel
=MSG_LEVEL_INFO
;
68 typedef struct _WLAN_FRAME_ACTION
{
69 WLAN_80211HDR_A3 Header
;
73 } WLAN_FRAME_ACTION
, *PWLAN_FRAME_ACTION
;
75 typedef struct _WLAN_FRAME_MSRREQ
{
76 WLAN_80211HDR_A3 Header
;
80 WLAN_IE_MEASURE_REQ sMSRReqEIDs
[1];
81 } WLAN_FRAME_MSRREQ
, *PWLAN_FRAME_MSRREQ
;
83 typedef struct _WLAN_FRAME_MSRREP
{
84 WLAN_80211HDR_A3 Header
;
88 WLAN_IE_MEASURE_REP sMSRRepEIDs
[1];
89 } WLAN_FRAME_MSRREP
, *PWLAN_FRAME_MSRREP
;
91 typedef struct _WLAN_FRAME_TPCREQ
{
92 WLAN_80211HDR_A3 Header
;
96 WLAN_IE_TPC_REQ sTPCReqEIDs
;
97 } WLAN_FRAME_TPCREQ
, *PWLAN_FRAME_TPCREQ
;
99 typedef struct _WLAN_FRAME_TPCREP
{
100 WLAN_80211HDR_A3 Header
;
104 WLAN_IE_TPC_REP sTPCRepEIDs
;
105 } WLAN_FRAME_TPCREP
, *PWLAN_FRAME_TPCREP
;
109 // action field reference ieee 802.11h Table 20e
110 #define ACTION_MSRREQ 0
111 #define ACTION_MSRREP 1
112 #define ACTION_TPCREQ 2
113 #define ACTION_TPCREP 3
114 #define ACTION_CHSW 4
116 /*--------------------- Static Classes ----------------------------*/
118 /*--------------------- Static Variables --------------------------*/
120 /*--------------------- Static Functions --------------------------*/
121 static BOOL
s_bRxMSRReq(PSMgmtObject pMgmt
, PWLAN_FRAME_MSRREQ pMSRReq
, UINT uLength
)
126 if (uLength
<= WLAN_A3FR_MAXLEN
) {
127 MEMvCopy(pMgmt
->abyCurrentMSRReq
, pMSRReq
, uLength
);
129 uNumOfEIDs
= ((uLength
- OFFSET(WLAN_FRAME_MSRREQ
, sMSRReqEIDs
))/ (sizeof(WLAN_IE_MEASURE_REQ
)));
130 pMgmt
->pCurrMeasureEIDRep
= &(((PWLAN_FRAME_MSRREP
) (pMgmt
->abyCurrentMSRRep
))->sMSRRepEIDs
[0]);
131 pMgmt
->uLengthOfRepEIDs
= 0;
132 bResult
= CARDbStartMeasure(pMgmt
->pAdapter
,
133 ((PWLAN_FRAME_MSRREQ
) (pMgmt
->abyCurrentMSRReq
))->sMSRReqEIDs
,
140 static BOOL
s_bRxTPCReq(PSMgmtObject pMgmt
, PWLAN_FRAME_TPCREQ pTPCReq
, BYTE byRate
, BYTE byRSSI
)
142 PWLAN_FRAME_TPCREP pFrame
;
143 PSTxMgmtPacket pTxPacket
= NULL
;
146 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
147 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_A3FR_MAXLEN
);
148 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
150 pFrame
= (PWLAN_FRAME_TPCREP
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
152 pFrame
->Header
.wFrameCtl
= ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT
) |
153 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION
)
156 MEMvCopy( pFrame
->Header
.abyAddr1
, pTPCReq
->Header
.abyAddr2
, WLAN_ADDR_LEN
);
157 MEMvCopy( pFrame
->Header
.abyAddr2
, CARDpGetCurrentAddress(pMgmt
->pAdapter
), WLAN_ADDR_LEN
);
158 MEMvCopy( pFrame
->Header
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
160 pFrame
->byCategory
= 0;
161 pFrame
->byAction
= 3;
162 pFrame
->byDialogToken
= ((PWLAN_FRAME_MSRREQ
) (pMgmt
->abyCurrentMSRReq
))->byDialogToken
;
164 pFrame
->sTPCRepEIDs
.byElementID
= WLAN_EID_TPC_REP
;
165 pFrame
->sTPCRepEIDs
.len
= 2;
166 pFrame
->sTPCRepEIDs
.byTxPower
= CARDbyGetTransmitPower(pMgmt
->pAdapter
);
169 pFrame
->sTPCRepEIDs
.byLinkMargin
= 65 - byRSSI
;
172 pFrame
->sTPCRepEIDs
.byLinkMargin
= 66 - byRSSI
;
175 pFrame
->sTPCRepEIDs
.byLinkMargin
= 70 - byRSSI
;
178 pFrame
->sTPCRepEIDs
.byLinkMargin
= 74 - byRSSI
;
181 pFrame
->sTPCRepEIDs
.byLinkMargin
= 77 - byRSSI
;
184 pFrame
->sTPCRepEIDs
.byLinkMargin
= 79 - byRSSI
;
187 pFrame
->sTPCRepEIDs
.byLinkMargin
= 81 - byRSSI
;
191 pFrame
->sTPCRepEIDs
.byLinkMargin
= 82 - byRSSI
;
195 pTxPacket
->cbMPDULen
= sizeof(WLAN_FRAME_TPCREP
);
196 pTxPacket
->cbPayloadLen
= sizeof(WLAN_FRAME_TPCREP
) - WLAN_HDR_ADDR3_LEN
;
197 if (csMgmt_xmit(pMgmt
->pAdapter
, pTxPacket
) != CMD_STATUS_PENDING
)
200 // return (CARDbSendPacket(pMgmt->pAdapter, pFrame, PKT_TYPE_802_11_MNG, sizeof(WLAN_FRAME_TPCREP)));
205 /*--------------------- Export Variables --------------------------*/
207 /*--------------------- Export Functions --------------------------*/
213 * Handles action management frames.
217 * pMgmt - Management Object structure
218 * pRxPacket - Received packet
222 * Return Value: None.
226 IEEE11hbMgrRxAction (
227 IN PVOID pMgmtHandle
,
231 PSMgmtObject pMgmt
= (PSMgmtObject
) pMgmtHandle
;
232 PWLAN_FRAME_ACTION pAction
= NULL
;
234 PWLAN_IE_CH_SW pChannelSwitch
= NULL
;
238 uLength
= ((PSRxMgmtPacket
)pRxPacket
)->cbMPDULen
;
239 if (uLength
> WLAN_A3FR_MAXLEN
) {
244 pAction
= (PWLAN_FRAME_ACTION
) (((PSRxMgmtPacket
)pRxPacket
)->p80211Header
);
246 if (pAction
->byCategory
== 0) {
247 switch (pAction
->byAction
) {
249 return (s_bRxMSRReq(pMgmt
, (PWLAN_FRAME_MSRREQ
) pAction
, uLength
));
254 return (s_bRxTPCReq(pMgmt
,
255 (PWLAN_FRAME_TPCREQ
) pAction
,
256 ((PSRxMgmtPacket
)pRxPacket
)->byRxRate
,
257 (BYTE
) ((PSRxMgmtPacket
)pRxPacket
)->uRSSI
));
262 pChannelSwitch
= (PWLAN_IE_CH_SW
) (pAction
->abyVars
);
263 if ((pChannelSwitch
->byElementID
== WLAN_EID_CH_SWITCH
) &&
264 (pChannelSwitch
->len
== 3)) {
266 CARDbChannelSwitch( pMgmt
->pAdapter
,
267 pChannelSwitch
->byMode
,
268 CARDbyGetChannelMapping(pMgmt
->pAdapter
, pChannelSwitch
->byChannel
, pMgmt
->eCurrentPHYMode
),
269 pChannelSwitch
->byCount
274 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Unknown Action = %d\n", pAction
->byAction
);
278 DEVICE_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Unknown Category = %d\n", pAction
->byCategory
);
279 pAction
->byCategory
|= 0x80;
281 //return (CARDbSendPacket(pMgmt->pAdapter, pAction, PKT_TYPE_802_11_MNG, uLength));
288 BOOL
IEEE11hbMSRRepTx (
292 PSMgmtObject pMgmt
= (PSMgmtObject
) pMgmtHandle
;
293 PWLAN_FRAME_MSRREP pMSRRep
= (PWLAN_FRAME_MSRREP
) (pMgmt
->abyCurrentMSRRep
+ sizeof(STxMgmtPacket
));
295 PSTxMgmtPacket pTxPacket
= NULL
;
297 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->abyCurrentMSRRep
;
298 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_A3FR_MAXLEN
);
299 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
302 pMSRRep
->Header
.wFrameCtl
= ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT
) |
303 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION
)
306 MEMvCopy( pMSRRep
->Header
.abyAddr1
, ((PWLAN_FRAME_MSRREQ
) (pMgmt
->abyCurrentMSRReq
))->Header
.abyAddr2
, WLAN_ADDR_LEN
);
307 MEMvCopy( pMSRRep
->Header
.abyAddr2
, CARDpGetCurrentAddress(pMgmt
->pAdapter
), WLAN_ADDR_LEN
);
308 MEMvCopy( pMSRRep
->Header
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
310 pMSRRep
->byCategory
= 0;
311 pMSRRep
->byAction
= 1;
312 pMSRRep
->byDialogToken
= ((PWLAN_FRAME_MSRREQ
) (pMgmt
->abyCurrentMSRReq
))->byDialogToken
;
314 uLength
= pMgmt
->uLengthOfRepEIDs
+ OFFSET(WLAN_FRAME_MSRREP
, sMSRRepEIDs
);
316 pTxPacket
->cbMPDULen
= uLength
;
317 pTxPacket
->cbPayloadLen
= uLength
- WLAN_HDR_ADDR3_LEN
;
318 if (csMgmt_xmit(pMgmt
->pAdapter
, pTxPacket
) != CMD_STATUS_PENDING
)
321 // return (CARDbSendPacket(pMgmt->pAdapter, pMSRRep, PKT_TYPE_802_11_MNG, uLength));