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
42 /*--------------------- Static Definitions -------------------------*/
43 static int msglevel
=MSG_LEVEL_INFO
;
47 typedef struct _WLAN_FRAME_ACTION
{
48 WLAN_80211HDR_A3 Header
;
52 } WLAN_FRAME_ACTION
, *PWLAN_FRAME_ACTION
;
54 typedef struct _WLAN_FRAME_MSRREQ
{
55 WLAN_80211HDR_A3 Header
;
59 WLAN_IE_MEASURE_REQ sMSRReqEIDs
[1];
60 } WLAN_FRAME_MSRREQ
, *PWLAN_FRAME_MSRREQ
;
62 typedef struct _WLAN_FRAME_MSRREP
{
63 WLAN_80211HDR_A3 Header
;
67 WLAN_IE_MEASURE_REP sMSRRepEIDs
[1];
68 } WLAN_FRAME_MSRREP
, *PWLAN_FRAME_MSRREP
;
70 typedef struct _WLAN_FRAME_TPCREQ
{
71 WLAN_80211HDR_A3 Header
;
75 WLAN_IE_TPC_REQ sTPCReqEIDs
;
76 } WLAN_FRAME_TPCREQ
, *PWLAN_FRAME_TPCREQ
;
78 typedef struct _WLAN_FRAME_TPCREP
{
79 WLAN_80211HDR_A3 Header
;
83 WLAN_IE_TPC_REP sTPCRepEIDs
;
84 } WLAN_FRAME_TPCREP
, *PWLAN_FRAME_TPCREP
;
88 // action field reference ieee 802.11h Table 20e
89 #define ACTION_MSRREQ 0
90 #define ACTION_MSRREP 1
91 #define ACTION_TPCREQ 2
92 #define ACTION_TPCREP 3
95 /*--------------------- Static Classes ----------------------------*/
97 /*--------------------- Static Variables --------------------------*/
99 /*--------------------- Static Functions --------------------------*/
100 static BOOL
s_bRxMSRReq(PSMgmtObject pMgmt
, PWLAN_FRAME_MSRREQ pMSRReq
, UINT uLength
)
102 size_t uNumOfEIDs
= 0;
105 if (uLength
<= WLAN_A3FR_MAXLEN
) {
106 memcpy(pMgmt
->abyCurrentMSRReq
, pMSRReq
, uLength
);
108 uNumOfEIDs
= ((uLength
- offsetof(WLAN_FRAME_MSRREQ
, sMSRReqEIDs
))/ (sizeof(WLAN_IE_MEASURE_REQ
)));
109 pMgmt
->pCurrMeasureEIDRep
= &(((PWLAN_FRAME_MSRREP
) (pMgmt
->abyCurrentMSRRep
))->sMSRRepEIDs
[0]);
110 pMgmt
->uLengthOfRepEIDs
= 0;
111 bResult
= CARDbStartMeasure(pMgmt
->pAdapter
,
112 ((PWLAN_FRAME_MSRREQ
) (pMgmt
->abyCurrentMSRReq
))->sMSRReqEIDs
,
119 static BOOL
s_bRxTPCReq(PSMgmtObject pMgmt
, PWLAN_FRAME_TPCREQ pTPCReq
, BYTE byRate
, BYTE byRSSI
)
121 PWLAN_FRAME_TPCREP pFrame
;
122 PSTxMgmtPacket pTxPacket
= NULL
;
125 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->pbyMgmtPacketPool
;
126 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_A3FR_MAXLEN
);
127 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
129 pFrame
= (PWLAN_FRAME_TPCREP
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
131 pFrame
->Header
.wFrameCtl
= ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT
) |
132 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION
)
135 memcpy( pFrame
->Header
.abyAddr1
, pTPCReq
->Header
.abyAddr2
, WLAN_ADDR_LEN
);
136 memcpy( pFrame
->Header
.abyAddr2
, CARDpGetCurrentAddress(pMgmt
->pAdapter
), WLAN_ADDR_LEN
);
137 memcpy( pFrame
->Header
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
139 pFrame
->byCategory
= 0;
140 pFrame
->byAction
= 3;
141 pFrame
->byDialogToken
= ((PWLAN_FRAME_MSRREQ
) (pMgmt
->abyCurrentMSRReq
))->byDialogToken
;
143 pFrame
->sTPCRepEIDs
.byElementID
= WLAN_EID_TPC_REP
;
144 pFrame
->sTPCRepEIDs
.len
= 2;
145 pFrame
->sTPCRepEIDs
.byTxPower
= CARDbyGetTransmitPower(pMgmt
->pAdapter
);
148 pFrame
->sTPCRepEIDs
.byLinkMargin
= 65 - byRSSI
;
151 pFrame
->sTPCRepEIDs
.byLinkMargin
= 66 - byRSSI
;
154 pFrame
->sTPCRepEIDs
.byLinkMargin
= 70 - byRSSI
;
157 pFrame
->sTPCRepEIDs
.byLinkMargin
= 74 - byRSSI
;
160 pFrame
->sTPCRepEIDs
.byLinkMargin
= 77 - byRSSI
;
163 pFrame
->sTPCRepEIDs
.byLinkMargin
= 79 - byRSSI
;
166 pFrame
->sTPCRepEIDs
.byLinkMargin
= 81 - byRSSI
;
170 pFrame
->sTPCRepEIDs
.byLinkMargin
= 82 - byRSSI
;
174 pTxPacket
->cbMPDULen
= sizeof(WLAN_FRAME_TPCREP
);
175 pTxPacket
->cbPayloadLen
= sizeof(WLAN_FRAME_TPCREP
) - WLAN_HDR_ADDR3_LEN
;
176 if (csMgmt_xmit(pMgmt
->pAdapter
, pTxPacket
) != CMD_STATUS_PENDING
)
179 // return (CARDbSendPacket(pMgmt->pAdapter, pFrame, PKT_TYPE_802_11_MNG, sizeof(WLAN_FRAME_TPCREP)));
184 /*--------------------- Export Variables --------------------------*/
186 /*--------------------- Export Functions --------------------------*/
192 * Handles action management frames.
196 * pMgmt - Management Object structure
197 * pRxPacket - Received packet
201 * Return Value: None.
205 IEEE11hbMgrRxAction (
206 IN PVOID pMgmtHandle
,
210 PSMgmtObject pMgmt
= (PSMgmtObject
) pMgmtHandle
;
211 PWLAN_FRAME_ACTION pAction
= NULL
;
213 PWLAN_IE_CH_SW pChannelSwitch
= NULL
;
217 uLength
= ((PSRxMgmtPacket
)pRxPacket
)->cbMPDULen
;
218 if (uLength
> WLAN_A3FR_MAXLEN
) {
223 pAction
= (PWLAN_FRAME_ACTION
) (((PSRxMgmtPacket
)pRxPacket
)->p80211Header
);
225 if (pAction
->byCategory
== 0) {
226 switch (pAction
->byAction
) {
228 return (s_bRxMSRReq(pMgmt
, (PWLAN_FRAME_MSRREQ
) pAction
, uLength
));
233 return (s_bRxTPCReq(pMgmt
,
234 (PWLAN_FRAME_TPCREQ
) pAction
,
235 ((PSRxMgmtPacket
)pRxPacket
)->byRxRate
,
236 (BYTE
) ((PSRxMgmtPacket
)pRxPacket
)->uRSSI
));
241 pChannelSwitch
= (PWLAN_IE_CH_SW
) (pAction
->abyVars
);
242 if ((pChannelSwitch
->byElementID
== WLAN_EID_CH_SWITCH
) &&
243 (pChannelSwitch
->len
== 3)) {
245 CARDbChannelSwitch( pMgmt
->pAdapter
,
246 pChannelSwitch
->byMode
,
247 CARDbyGetChannelMapping(pMgmt
->pAdapter
, pChannelSwitch
->byChannel
, pMgmt
->eCurrentPHYMode
),
248 pChannelSwitch
->byCount
253 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Unknown Action = %d\n", pAction
->byAction
);
257 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Unknown Category = %d\n", pAction
->byCategory
);
258 pAction
->byCategory
|= 0x80;
260 //return (CARDbSendPacket(pMgmt->pAdapter, pAction, PKT_TYPE_802_11_MNG, uLength));
267 BOOL
IEEE11hbMSRRepTx (
271 PSMgmtObject pMgmt
= (PSMgmtObject
) pMgmtHandle
;
272 PWLAN_FRAME_MSRREP pMSRRep
= (PWLAN_FRAME_MSRREP
) (pMgmt
->abyCurrentMSRRep
+ sizeof(STxMgmtPacket
));
274 PSTxMgmtPacket pTxPacket
= NULL
;
276 pTxPacket
= (PSTxMgmtPacket
)pMgmt
->abyCurrentMSRRep
;
277 memset(pTxPacket
, 0, sizeof(STxMgmtPacket
) + WLAN_A3FR_MAXLEN
);
278 pTxPacket
->p80211Header
= (PUWLAN_80211HDR
)((PBYTE
)pTxPacket
+ sizeof(STxMgmtPacket
));
281 pMSRRep
->Header
.wFrameCtl
= ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT
) |
282 WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION
)
285 memcpy( pMSRRep
->Header
.abyAddr1
, ((PWLAN_FRAME_MSRREQ
) (pMgmt
->abyCurrentMSRReq
))->Header
.abyAddr2
, WLAN_ADDR_LEN
);
286 memcpy( pMSRRep
->Header
.abyAddr2
, CARDpGetCurrentAddress(pMgmt
->pAdapter
), WLAN_ADDR_LEN
);
287 memcpy( pMSRRep
->Header
.abyAddr3
, pMgmt
->abyCurrBSSID
, WLAN_BSSID_LEN
);
289 pMSRRep
->byCategory
= 0;
290 pMSRRep
->byAction
= 1;
291 pMSRRep
->byDialogToken
= ((PWLAN_FRAME_MSRREQ
) (pMgmt
->abyCurrentMSRReq
))->byDialogToken
;
293 uLength
= pMgmt
->uLengthOfRepEIDs
+ offsetof(WLAN_FRAME_MSRREP
, sMSRRepEIDs
);
295 pTxPacket
->cbMPDULen
= uLength
;
296 pTxPacket
->cbPayloadLen
= uLength
- WLAN_HDR_ADDR3_LEN
;
297 if (csMgmt_xmit(pMgmt
->pAdapter
, pTxPacket
) != CMD_STATUS_PENDING
)
300 // return (CARDbSendPacket(pMgmt->pAdapter, pMSRRep, PKT_TYPE_802_11_MNG, uLength));