15449c685a4b39534f18869a93896370224463715Forest Bond/*
25449c685a4b39534f18869a93896370224463715Forest Bond * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
35449c685a4b39534f18869a93896370224463715Forest Bond * All rights reserved.
45449c685a4b39534f18869a93896370224463715Forest Bond *
55449c685a4b39534f18869a93896370224463715Forest Bond * This program is free software; you can redistribute it and/or modify
65449c685a4b39534f18869a93896370224463715Forest Bond * it under the terms of the GNU General Public License as published by
75449c685a4b39534f18869a93896370224463715Forest Bond * the Free Software Foundation; either version 2 of the License, or
85449c685a4b39534f18869a93896370224463715Forest Bond * (at your option) any later version.
95449c685a4b39534f18869a93896370224463715Forest Bond *
105449c685a4b39534f18869a93896370224463715Forest Bond * This program is distributed in the hope that it will be useful,
115449c685a4b39534f18869a93896370224463715Forest Bond * but WITHOUT ANY WARRANTY; without even the implied warranty of
125449c685a4b39534f18869a93896370224463715Forest Bond * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
135449c685a4b39534f18869a93896370224463715Forest Bond * GNU General Public License for more details.
145449c685a4b39534f18869a93896370224463715Forest Bond *
155449c685a4b39534f18869a93896370224463715Forest Bond * You should have received a copy of the GNU General Public License along
165449c685a4b39534f18869a93896370224463715Forest Bond * with this program; if not, write to the Free Software Foundation, Inc.,
175449c685a4b39534f18869a93896370224463715Forest Bond * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
185449c685a4b39534f18869a93896370224463715Forest Bond *
195449c685a4b39534f18869a93896370224463715Forest Bond *
205449c685a4b39534f18869a93896370224463715Forest Bond * File: vntwifi.c
215449c685a4b39534f18869a93896370224463715Forest Bond *
225449c685a4b39534f18869a93896370224463715Forest Bond * Purpose: export functions for vntwifi lib
235449c685a4b39534f18869a93896370224463715Forest Bond *
245449c685a4b39534f18869a93896370224463715Forest Bond * Functions:
255449c685a4b39534f18869a93896370224463715Forest Bond *
265449c685a4b39534f18869a93896370224463715Forest Bond * Revision History:
275449c685a4b39534f18869a93896370224463715Forest Bond *
285449c685a4b39534f18869a93896370224463715Forest Bond * Author: Yiching Chen
295449c685a4b39534f18869a93896370224463715Forest Bond *
305449c685a4b39534f18869a93896370224463715Forest Bond * Date: feb. 2, 2005
315449c685a4b39534f18869a93896370224463715Forest Bond *
325449c685a4b39534f18869a93896370224463715Forest Bond */
335449c685a4b39534f18869a93896370224463715Forest Bond
345449c685a4b39534f18869a93896370224463715Forest Bond#include "vntwifi.h"
355449c685a4b39534f18869a93896370224463715Forest Bond#include "IEEE11h.h"
365449c685a4b39534f18869a93896370224463715Forest Bond#include "country.h"
375449c685a4b39534f18869a93896370224463715Forest Bond#include "device.h"
385449c685a4b39534f18869a93896370224463715Forest Bond#include "wmgr.h"
395449c685a4b39534f18869a93896370224463715Forest Bond#include "datarate.h"
40a7ad322a46663755718a214a9a34e5cfe64d07f7Jim Lieb
415449c685a4b39534f18869a93896370224463715Forest Bond/*---------------------  Static Definitions -------------------------*/
425449c685a4b39534f18869a93896370224463715Forest Bond
435449c685a4b39534f18869a93896370224463715Forest Bond/*---------------------  Static Classes  ----------------------------*/
445449c685a4b39534f18869a93896370224463715Forest Bond
455449c685a4b39534f18869a93896370224463715Forest Bond/*---------------------  Static Variables  --------------------------*/
465449c685a4b39534f18869a93896370224463715Forest Bond
475449c685a4b39534f18869a93896370224463715Forest Bond/*---------------------  Static Functions  --------------------------*/
485449c685a4b39534f18869a93896370224463715Forest Bond
495449c685a4b39534f18869a93896370224463715Forest Bond/*---------------------  Export Variables  --------------------------*/
505449c685a4b39534f18869a93896370224463715Forest Bond
515449c685a4b39534f18869a93896370224463715Forest Bond/*---------------------  Export Functions  --------------------------*/
525449c685a4b39534f18869a93896370224463715Forest Bond
535449c685a4b39534f18869a93896370224463715Forest Bond/*+
545449c685a4b39534f18869a93896370224463715Forest Bond *
555449c685a4b39534f18869a93896370224463715Forest Bond * Description:
565449c685a4b39534f18869a93896370224463715Forest Bond *    Set Operation Mode
575449c685a4b39534f18869a93896370224463715Forest Bond *
585449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
595449c685a4b39534f18869a93896370224463715Forest Bond *  In:
605449c685a4b39534f18869a93896370224463715Forest Bond *      pMgmtHandle - pointer to management object
61789d1aef176e720fce4a8a5a9ab07f093ddb9086Justin P. Mattock *      eOPMode     - Operation Mode
625449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
635449c685a4b39534f18869a93896370224463715Forest Bond *      none
645449c685a4b39534f18869a93896370224463715Forest Bond *
655449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: none
665449c685a4b39534f18869a93896370224463715Forest Bond *
67d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
686b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
69d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIvSetOPMode(
70d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
71d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	WMAC_CONFIG_MODE eOPMode
72d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
735449c685a4b39534f18869a93896370224463715Forest Bond{
74d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
755449c685a4b39534f18869a93896370224463715Forest Bond
76d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->eConfigMode = eOPMode;
775449c685a4b39534f18869a93896370224463715Forest Bond}
785449c685a4b39534f18869a93896370224463715Forest Bond
795449c685a4b39534f18869a93896370224463715Forest Bond/*+
805449c685a4b39534f18869a93896370224463715Forest Bond *
815449c685a4b39534f18869a93896370224463715Forest Bond * Description:
825449c685a4b39534f18869a93896370224463715Forest Bond *    Set Operation Mode
835449c685a4b39534f18869a93896370224463715Forest Bond *
845449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
855449c685a4b39534f18869a93896370224463715Forest Bond *  In:
865449c685a4b39534f18869a93896370224463715Forest Bond *      pMgmtHandle - pointer to management object
875449c685a4b39534f18869a93896370224463715Forest Bond *      wBeaconPeriod - Beacon Period
885449c685a4b39534f18869a93896370224463715Forest Bond *      wATIMWindow - ATIM window
895449c685a4b39534f18869a93896370224463715Forest Bond *      uChannel - channel number
905449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
915449c685a4b39534f18869a93896370224463715Forest Bond *      none
925449c685a4b39534f18869a93896370224463715Forest Bond *
935449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: none
945449c685a4b39534f18869a93896370224463715Forest Bond *
95d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
966b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
97d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIvSetIBSSParameter(
98d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
99d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned short wBeaconPeriod,
100d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned short wATIMWindow,
101d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned int uChannel
102d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
1035449c685a4b39534f18869a93896370224463715Forest Bond{
104d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
1055449c685a4b39534f18869a93896370224463715Forest Bond
106d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->wIBSSBeaconPeriod = wBeaconPeriod;
107d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->wIBSSATIMWindow = wATIMWindow;
108d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->uIBSSChannel = uChannel;
1095449c685a4b39534f18869a93896370224463715Forest Bond}
1105449c685a4b39534f18869a93896370224463715Forest Bond
1115449c685a4b39534f18869a93896370224463715Forest Bond/*+
1125449c685a4b39534f18869a93896370224463715Forest Bond *
1135449c685a4b39534f18869a93896370224463715Forest Bond * Description:
1145449c685a4b39534f18869a93896370224463715Forest Bond *    Get current SSID
1155449c685a4b39534f18869a93896370224463715Forest Bond *
1165449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
1175449c685a4b39534f18869a93896370224463715Forest Bond *  In:
1185449c685a4b39534f18869a93896370224463715Forest Bond *      pMgmtHandle - pointer to management object
1195449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
1205449c685a4b39534f18869a93896370224463715Forest Bond *      none
1215449c685a4b39534f18869a93896370224463715Forest Bond *
1225449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: current SSID pointer.
1235449c685a4b39534f18869a93896370224463715Forest Bond *
124d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
1255449c685a4b39534f18869a93896370224463715Forest BondPWLAN_IE_SSID
126d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIpGetCurrentSSID(
127d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle
128d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
1295449c685a4b39534f18869a93896370224463715Forest Bond{
130d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
1316b7112719fd48c29f35333ef152a5a450f01dc83Guillaume Clement
132a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches	return (PWLAN_IE_SSID) pMgmt->abyCurrSSID;
1335449c685a4b39534f18869a93896370224463715Forest Bond}
1345449c685a4b39534f18869a93896370224463715Forest Bond
1355449c685a4b39534f18869a93896370224463715Forest Bond/*+
1365449c685a4b39534f18869a93896370224463715Forest Bond *
1375449c685a4b39534f18869a93896370224463715Forest Bond * Description:
1385449c685a4b39534f18869a93896370224463715Forest Bond *    Get current link channel
1395449c685a4b39534f18869a93896370224463715Forest Bond *
1405449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
1415449c685a4b39534f18869a93896370224463715Forest Bond *  In:
1425449c685a4b39534f18869a93896370224463715Forest Bond *      pMgmtHandle - pointer to management object
1435449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
1445449c685a4b39534f18869a93896370224463715Forest Bond *      none
1455449c685a4b39534f18869a93896370224463715Forest Bond *
1465449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: current Channel.
1475449c685a4b39534f18869a93896370224463715Forest Bond *
148d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
149b6e95cd52a81079abc1def7867e27bf541953089Charles Clémentunsigned int
150d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIpGetCurrentChannel(
151d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle
152d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
1535449c685a4b39534f18869a93896370224463715Forest Bond{
154d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
1556b7112719fd48c29f35333ef152a5a450f01dc83Guillaume Clement
156bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez	if (pMgmtHandle != NULL)
157a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches		return pMgmt->uCurrChannel;
158bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
159d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	return 0;
1605449c685a4b39534f18869a93896370224463715Forest Bond}
1615449c685a4b39534f18869a93896370224463715Forest Bond
1625449c685a4b39534f18869a93896370224463715Forest Bond/*+
1635449c685a4b39534f18869a93896370224463715Forest Bond *
1645449c685a4b39534f18869a93896370224463715Forest Bond * Description:
1655449c685a4b39534f18869a93896370224463715Forest Bond *    Get current Assoc ID
1665449c685a4b39534f18869a93896370224463715Forest Bond *
1675449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
1685449c685a4b39534f18869a93896370224463715Forest Bond *  In:
1695449c685a4b39534f18869a93896370224463715Forest Bond *      pMgmtHandle - pointer to management object
1705449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
1715449c685a4b39534f18869a93896370224463715Forest Bond *      none
1725449c685a4b39534f18869a93896370224463715Forest Bond *
1735449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: current Assoc ID
1745449c685a4b39534f18869a93896370224463715Forest Bond *
175d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
1762986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clémentunsigned short
177d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIwGetAssocID(
178d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle
179d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
1805449c685a4b39534f18869a93896370224463715Forest Bond{
181d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
1826b7112719fd48c29f35333ef152a5a450f01dc83Guillaume Clement
183a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches	return pMgmt->wCurrAID;
1845449c685a4b39534f18869a93896370224463715Forest Bond}
1855449c685a4b39534f18869a93896370224463715Forest Bond
1865449c685a4b39534f18869a93896370224463715Forest Bond/*+
1875449c685a4b39534f18869a93896370224463715Forest Bond *
1885449c685a4b39534f18869a93896370224463715Forest Bond * Description:
1895449c685a4b39534f18869a93896370224463715Forest Bond *    This routine return max support rate of IES
1905449c685a4b39534f18869a93896370224463715Forest Bond *
1915449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
1925449c685a4b39534f18869a93896370224463715Forest Bond *  In:
1935449c685a4b39534f18869a93896370224463715Forest Bond *      pSupportRateIEs
1945449c685a4b39534f18869a93896370224463715Forest Bond *      pExtSupportRateIEs
1955449c685a4b39534f18869a93896370224463715Forest Bond *
1965449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
1975449c685a4b39534f18869a93896370224463715Forest Bond *
1985449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: max support rate
1995449c685a4b39534f18869a93896370224463715Forest Bond *
200d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
2013fc9b584c28095fe0d46cfb8bddafdf93947042eCharles Clémentunsigned char
202d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIbyGetMaxSupportRate(
203d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PWLAN_IE_SUPP_RATES pSupportRateIEs,
204d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PWLAN_IE_SUPP_RATES pExtSupportRateIEs
205d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
2065449c685a4b39534f18869a93896370224463715Forest Bond{
207d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byMaxSupportRate = RATE_1M;
208d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char bySupportRate = RATE_1M;
209d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned int ii = 0;
210d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
211d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if (pSupportRateIEs) {
212d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		for (ii = 0; ii < pSupportRateIEs->len; ii++) {
213d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
214bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez			if (bySupportRate > byMaxSupportRate)
215d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				byMaxSupportRate = bySupportRate;
216bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
217d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		}
218d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
219d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if (pExtSupportRateIEs) {
220d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
221d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
222bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez			if (bySupportRate > byMaxSupportRate)
223d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				byMaxSupportRate = bySupportRate;
224bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
225d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		}
226d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
227d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
228d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	return byMaxSupportRate;
2295449c685a4b39534f18869a93896370224463715Forest Bond}
2305449c685a4b39534f18869a93896370224463715Forest Bond
2315449c685a4b39534f18869a93896370224463715Forest Bond/*+
2325449c685a4b39534f18869a93896370224463715Forest Bond *
2335449c685a4b39534f18869a93896370224463715Forest Bond * Description:
2345449c685a4b39534f18869a93896370224463715Forest Bond *    This routine return data rate of ACK packtet
2355449c685a4b39534f18869a93896370224463715Forest Bond *
2365449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
2375449c685a4b39534f18869a93896370224463715Forest Bond *  In:
2385449c685a4b39534f18869a93896370224463715Forest Bond *      byRxDataRate
2395449c685a4b39534f18869a93896370224463715Forest Bond *      pSupportRateIEs
2405449c685a4b39534f18869a93896370224463715Forest Bond *      pExtSupportRateIEs
2415449c685a4b39534f18869a93896370224463715Forest Bond *
2425449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
2435449c685a4b39534f18869a93896370224463715Forest Bond *
2445449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: max support rate
2455449c685a4b39534f18869a93896370224463715Forest Bond *
246d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
2473fc9b584c28095fe0d46cfb8bddafdf93947042eCharles Clémentunsigned char
248d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIbyGetACKTxRate(
249d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byRxDataRate,
250d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PWLAN_IE_SUPP_RATES pSupportRateIEs,
251d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PWLAN_IE_SUPP_RATES pExtSupportRateIEs
252d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
2535449c685a4b39534f18869a93896370224463715Forest Bond{
254d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byMaxAckRate;
255d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byBasicRate;
256d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned int ii;
257d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
258d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if (byRxDataRate <= RATE_11M) {
259d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		byMaxAckRate = RATE_1M;
260d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	} else  {
2615c3ddb3a4c3ef5edea7376ed80b032cf2e4afb71Merlin Chlosta		/* 24M is mandatory for 802.11a and 802.11g */
262d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		byMaxAckRate = RATE_24M;
263d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
264d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if (pSupportRateIEs) {
265d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		for (ii = 0; ii < pSupportRateIEs->len; ii++) {
266d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			if (pSupportRateIEs->abyRates[ii] & 0x80) {
267d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				byBasicRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
268d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				if ((byBasicRate <= byRxDataRate) &&
269d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				    (byBasicRate > byMaxAckRate))  {
270d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches					byMaxAckRate = byBasicRate;
271d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				}
272d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			}
273d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		}
274d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
275d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if (pExtSupportRateIEs) {
276d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
277d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			if (pExtSupportRateIEs->abyRates[ii] & 0x80) {
278d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				byBasicRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
279d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				if ((byBasicRate <= byRxDataRate) &&
280d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				    (byBasicRate > byMaxAckRate))  {
281d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches					byMaxAckRate = byBasicRate;
282d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				}
283d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			}
284d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		}
285d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
286d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
287d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	return byMaxAckRate;
2885449c685a4b39534f18869a93896370224463715Forest Bond}
2895449c685a4b39534f18869a93896370224463715Forest Bond
2905449c685a4b39534f18869a93896370224463715Forest Bond/*+
2915449c685a4b39534f18869a93896370224463715Forest Bond *
2925449c685a4b39534f18869a93896370224463715Forest Bond * Description:
2935449c685a4b39534f18869a93896370224463715Forest Bond *    Set Authentication Mode
2945449c685a4b39534f18869a93896370224463715Forest Bond *
2955449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
2965449c685a4b39534f18869a93896370224463715Forest Bond *  In:
2975449c685a4b39534f18869a93896370224463715Forest Bond *      pMgmtHandle - pointer to management object
2985449c685a4b39534f18869a93896370224463715Forest Bond *      eAuthMode   - Authentication mode
2995449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
3005449c685a4b39534f18869a93896370224463715Forest Bond *      none
3015449c685a4b39534f18869a93896370224463715Forest Bond *
3025449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: none
3035449c685a4b39534f18869a93896370224463715Forest Bond *
304d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
3056b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
306d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIvSetAuthenticationMode(
307d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
308d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	WMAC_AUTHENTICATION_MODE eAuthMode
309d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
3105449c685a4b39534f18869a93896370224463715Forest Bond{
311d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
312d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
313d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->eAuthenMode = eAuthMode;
314d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if ((eAuthMode == WMAC_AUTH_SHAREKEY) ||
315d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	    (eAuthMode == WMAC_AUTH_AUTO)) {
316d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->bShareKeyAlgorithm = true;
317d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	} else {
318d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->bShareKeyAlgorithm = false;
319d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
3205449c685a4b39534f18869a93896370224463715Forest Bond}
3215449c685a4b39534f18869a93896370224463715Forest Bond
3225449c685a4b39534f18869a93896370224463715Forest Bond/*+
3235449c685a4b39534f18869a93896370224463715Forest Bond *
3245449c685a4b39534f18869a93896370224463715Forest Bond * Description:
3255449c685a4b39534f18869a93896370224463715Forest Bond *    Set Encryption Mode
3265449c685a4b39534f18869a93896370224463715Forest Bond *
3275449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
3285449c685a4b39534f18869a93896370224463715Forest Bond *  In:
3295449c685a4b39534f18869a93896370224463715Forest Bond *      pMgmtHandle - pointer to management object
3305449c685a4b39534f18869a93896370224463715Forest Bond *      eAuthMode   - Authentication mode
3315449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
3325449c685a4b39534f18869a93896370224463715Forest Bond *      none
3335449c685a4b39534f18869a93896370224463715Forest Bond *
3345449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: none
3355449c685a4b39534f18869a93896370224463715Forest Bond *
336d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
3376b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
338d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIvSetEncryptionMode(
339d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
340d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	WMAC_ENCRYPTION_MODE eEncryptionMode
341d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
3425449c685a4b39534f18869a93896370224463715Forest Bond{
343d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
344d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
345d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->eEncryptionMode = eEncryptionMode;
346d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if ((eEncryptionMode == WMAC_ENCRYPTION_WEPEnabled) ||
347d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	    (eEncryptionMode == WMAC_ENCRYPTION_TKIPEnabled) ||
348d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	    (eEncryptionMode == WMAC_ENCRYPTION_AESEnabled)) {
349d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->bPrivacyInvoked = true;
350d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	} else {
351d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->bPrivacyInvoked = false;
352d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
3535449c685a4b39534f18869a93896370224463715Forest Bond}
3545449c685a4b39534f18869a93896370224463715Forest Bond
3557b6a001313a9b11a1f0985de05fff514db41d72dCharles Clémentbool
356d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIbConfigPhyMode(
357d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
358d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	CARD_PHY_TYPE ePhyType
359d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
3605449c685a4b39534f18869a93896370224463715Forest Bond{
361d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
362d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
363d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if ((ePhyType != PHY_TYPE_AUTO) &&
364d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	    (ePhyType != pMgmt->eCurrentPHYMode)) {
365bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez		if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL) == true)
366d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pMgmt->eCurrentPHYMode = ePhyType;
367bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez		else
368a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches			return false;
369d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
370d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->eConfigPHYMode = ePhyType;
371a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches	return true;
3725449c685a4b39534f18869a93896370224463715Forest Bond}
3735449c685a4b39534f18869a93896370224463715Forest Bond
3746b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
375d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIbGetConfigPhyMode(
376d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
377d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pePhyType
378d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
3795449c685a4b39534f18869a93896370224463715Forest Bond{
380d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
3815449c685a4b39534f18869a93896370224463715Forest Bond
382bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez	if ((pMgmt != NULL) && (pePhyType != NULL))
383d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		*(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode;
3845449c685a4b39534f18869a93896370224463715Forest Bond}
3855449c685a4b39534f18869a93896370224463715Forest Bond
3865449c685a4b39534f18869a93896370224463715Forest Bond/*+
3875449c685a4b39534f18869a93896370224463715Forest Bond *
3885449c685a4b39534f18869a93896370224463715Forest Bond * Description:
3895449c685a4b39534f18869a93896370224463715Forest Bond *      Clear BSS List Database except current assoc BSS
3905449c685a4b39534f18869a93896370224463715Forest Bond *
3915449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
3925449c685a4b39534f18869a93896370224463715Forest Bond *  In:
3935449c685a4b39534f18869a93896370224463715Forest Bond *      pMgmtHandle     - Management Object structure
3945449c685a4b39534f18869a93896370224463715Forest Bond *      bLinkPass       - Current Link status
3955449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
3965449c685a4b39534f18869a93896370224463715Forest Bond *
3975449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: None.
3985449c685a4b39534f18869a93896370224463715Forest Bond *
399d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
4005449c685a4b39534f18869a93896370224463715Forest Bond
4015449c685a4b39534f18869a93896370224463715Forest Bond/*+
4025449c685a4b39534f18869a93896370224463715Forest Bond *
4035449c685a4b39534f18869a93896370224463715Forest Bond * Description:
4045449c685a4b39534f18869a93896370224463715Forest Bond *      Query BSS List in management database
4055449c685a4b39534f18869a93896370224463715Forest Bond *
4065449c685a4b39534f18869a93896370224463715Forest Bond * Parameters:
4075449c685a4b39534f18869a93896370224463715Forest Bond *  In:
4085449c685a4b39534f18869a93896370224463715Forest Bond *      pMgmtHandle     - Management Object structure
4095449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
4105449c685a4b39534f18869a93896370224463715Forest Bond *      puBSSCount      - BSS count
4115449c685a4b39534f18869a93896370224463715Forest Bond *      pvFirstBSS      - pointer to first BSS
4125449c685a4b39534f18869a93896370224463715Forest Bond *
4135449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: None.
4145449c685a4b39534f18869a93896370224463715Forest Bond *
415d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
4165449c685a4b39534f18869a93896370224463715Forest Bond
4176b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
418fe4f34bde28f5a9f3793cced5b4029eda5b78be2Charles ClémentVNTWIFIvQueryBSSList(void *pMgmtHandle, unsigned int *puBSSCount, void **pvFirstBSS)
4195449c685a4b39534f18869a93896370224463715Forest Bond{
420d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned int ii = 0;
421d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
422d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PKnownBSS       pBSS = NULL;
423d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned int uCount = 0;
424d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
425d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	*pvFirstBSS = NULL;
426d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
427d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	for (ii = 0; ii < MAX_BSS_NUM; ii++) {
428d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pBSS = &(pMgmt->sBSSList[ii]);
429bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez		if (!pBSS->bActive)
430d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			continue;
431bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
432bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez		if (*pvFirstBSS == NULL)
433d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			*pvFirstBSS = &(pMgmt->sBSSList[ii]);
434bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
435d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		uCount++;
436d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
437d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	*puBSSCount = uCount;
4385449c685a4b39534f18869a93896370224463715Forest Bond}
4395449c685a4b39534f18869a93896370224463715Forest Bond
4406b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
441d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIvGetNextBSS(
442d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
443d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pvCurrentBSS,
444d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void **pvNextBSS
445d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
4465449c685a4b39534f18869a93896370224463715Forest Bond{
447d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PKnownBSS       pBSS = (PKnownBSS) pvCurrentBSS;
448d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
449d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
450d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	*pvNextBSS = NULL;
451d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
452d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	while (*pvNextBSS == NULL) {
453d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pBSS++;
454bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez		if (pBSS > &(pMgmt->sBSSList[MAX_BSS_NUM]))
455d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			return;
456bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
457d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		if (pBSS->bActive == true) {
458d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			*pvNextBSS = pBSS;
459d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			return;
460d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		}
461d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
4625449c685a4b39534f18869a93896370224463715Forest Bond}
4635449c685a4b39534f18869a93896370224463715Forest Bond
4645449c685a4b39534f18869a93896370224463715Forest Bond/*+
4655449c685a4b39534f18869a93896370224463715Forest Bond *
4665449c685a4b39534f18869a93896370224463715Forest Bond * Description:
4675449c685a4b39534f18869a93896370224463715Forest Bond *      Update Tx attemps, Tx failure counter in Node DB
4685449c685a4b39534f18869a93896370224463715Forest Bond *
4695449c685a4b39534f18869a93896370224463715Forest Bond *  In:
4705449c685a4b39534f18869a93896370224463715Forest Bond *  Out:
4715449c685a4b39534f18869a93896370224463715Forest Bond *      none
4725449c685a4b39534f18869a93896370224463715Forest Bond *
4735449c685a4b39534f18869a93896370224463715Forest Bond * Return Value: none
4745449c685a4b39534f18869a93896370224463715Forest Bond *
475d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches -*/
4766b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
4775449c685a4b39534f18869a93896370224463715Forest BondVNTWIFIvUpdateNodeTxCounter(
478d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
479d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char *pbyDestAddress,
480d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	bool bTxOk,
481d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned short wRate,
482d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char *pbyTxFailCount
483d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
4845449c685a4b39534f18869a93896370224463715Forest Bond{
485d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
486d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned int uNodeIndex = 0;
487d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned int ii;
488d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
489d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
490d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	    (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
491bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez		if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex) == false)
492d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			return;
493d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
494bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
495d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts++;
4961208f14a37fde2669b86bf1b1cd1122ad2ba3579Teodora Baluta	if (bTxOk) {
4975c3ddb3a4c3ef5edea7376ed80b032cf2e4afb71Merlin Chlosta		/* transmit success, TxAttempts at least plus one */
498d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->sNodeDBTable[uNodeIndex].uTxOk[MAX_RATE]++;
499d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->sNodeDBTable[uNodeIndex].uTxOk[wRate]++;
500d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	} else {
501d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->sNodeDBTable[uNodeIndex].uTxFailures++;
502d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
503d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->sNodeDBTable[uNodeIndex].uTxRetry += pbyTxFailCount[MAX_RATE];
504bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez	for (ii = 0; ii < MAX_RATE; ii++)
505d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->sNodeDBTable[uNodeIndex].uTxFail[ii] += pbyTxFailCount[ii];
5065449c685a4b39534f18869a93896370224463715Forest Bond}
5075449c685a4b39534f18869a93896370224463715Forest Bond
5086b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
5095449c685a4b39534f18869a93896370224463715Forest BondVNTWIFIvGetTxRate(
510d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
511d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char *pbyDestAddress,
512d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned short *pwTxDataRate,
513d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char *pbyACKRate,
514d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char *pbyCCKBasicRate,
515d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char *pbyOFDMBasicRate
516d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
5175449c685a4b39534f18869a93896370224463715Forest Bond{
518d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject        pMgmt = (PSMgmtObject)pMgmtHandle;
519d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned int uNodeIndex = 0;
520d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned short wTxDataRate = RATE_1M;
521d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byACKRate = RATE_1M;
522d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byCCKBasicRate = RATE_1M;
523d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byOFDMBasicRate = RATE_24M;
524d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PWLAN_IE_SUPP_RATES pSupportRateIEs = NULL;
525d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PWLAN_IE_SUPP_RATES pExtSupportRateIEs = NULL;
526d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
527d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) ||
528d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	    (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) {
5295c3ddb3a4c3ef5edea7376ed80b032cf2e4afb71Merlin Chlosta		/* Adhoc Tx rate decided from node DB */
530d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		if (BSSDBbIsSTAInNodeDB(pMgmt, pbyDestAddress, &uNodeIndex)) {
531d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			wTxDataRate = (pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate);
532d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrSuppRates);
533d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) (pMgmt->sNodeDBTable[uNodeIndex].abyCurrExtSuppRates);
534d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		} else {
535bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez			if (pMgmt->eCurrentPHYMode != PHY_TYPE_11A)
536d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				wTxDataRate = RATE_2M;
537bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez			else
538d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches				wTxDataRate = RATE_24M;
539bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
540d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
541d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
542d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		}
5435c3ddb3a4c3ef5edea7376ed80b032cf2e4afb71Merlin Chlosta	} else { /* Infrastructure: rate decided from AP Node, index = 0 */
5445449c685a4b39534f18869a93896370224463715Forest Bond
5455449c685a4b39534f18869a93896370224463715Forest Bond		wTxDataRate = (pMgmt->sNodeDBTable[0].wTxDataRate);
5465449c685a4b39534f18869a93896370224463715Forest Bond
547d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrSuppRates;
548d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pExtSupportRateIEs = (PWLAN_IE_SUPP_RATES) pMgmt->abyCurrExtSuppRates;
549d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
550d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	byACKRate = VNTWIFIbyGetACKTxRate((unsigned char) wTxDataRate,
551d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches					    pSupportRateIEs,
552d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches					    pExtSupportRateIEs
553d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches);
554bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez	if (byACKRate > (unsigned char) wTxDataRate)
555d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		byACKRate = (unsigned char) wTxDataRate;
556bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
557d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	byCCKBasicRate = VNTWIFIbyGetACKTxRate(RATE_11M,
558d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches						pSupportRateIEs,
559d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches						pExtSupportRateIEs
560d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches);
561d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	byOFDMBasicRate = VNTWIFIbyGetACKTxRate(RATE_54M,
562d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches						pSupportRateIEs,
563d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches						pExtSupportRateIEs
564d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches);
565d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	*pwTxDataRate = wTxDataRate;
566d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	*pbyACKRate = byACKRate;
567d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	*pbyCCKBasicRate = byCCKBasicRate;
568d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	*pbyOFDMBasicRate = byOFDMBasicRate;
5695449c685a4b39534f18869a93896370224463715Forest Bond}
5705449c685a4b39534f18869a93896370224463715Forest Bond
5713fc9b584c28095fe0d46cfb8bddafdf93947042eCharles Clémentunsigned char
5725449c685a4b39534f18869a93896370224463715Forest BondVNTWIFIbyGetKeyCypher(
573d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtHandle,
574d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	bool bGroupKey
575d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
5765449c685a4b39534f18869a93896370224463715Forest Bond{
577d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject    pMgmt = (PSMgmtObject)pMgmtHandle;
5785449c685a4b39534f18869a93896370224463715Forest Bond
579bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez	if (bGroupKey)
580a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches		return pMgmt->byCSSGK;
581bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez	else
582a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches		return pMgmt->byCSSPK;
5835449c685a4b39534f18869a93896370224463715Forest Bond}
5845449c685a4b39534f18869a93896370224463715Forest Bond
5857b6a001313a9b11a1f0985de05fff514db41d72dCharles Clémentbool
586d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIbSetPMKIDCache(
587d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtObject,
588d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned long ulCount,
589d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pPMKIDInfo
590d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
5915449c685a4b39534f18869a93896370224463715Forest Bond{
592d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
593d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
594bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez	if (ulCount > MAX_PMKID_CACHE)
595a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches		return false;
596bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
597d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->gsPMKIDCache.BSSIDInfoCount = ulCount;
598d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	memcpy(pMgmt->gsPMKIDCache.BSSIDInfo, pPMKIDInfo, (ulCount*sizeof(PMKIDInfo)));
599a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches	return true;
6005449c685a4b39534f18869a93896370224463715Forest Bond}
6015449c685a4b39534f18869a93896370224463715Forest Bond
6022986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clémentunsigned short
6035449c685a4b39534f18869a93896370224463715Forest BondVNTWIFIwGetMaxSupportRate(
604d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtObject
605d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
6065449c685a4b39534f18869a93896370224463715Forest Bond{
607d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned short wRate = RATE_54M;
608d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
609d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
610d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	for (wRate = RATE_54M; wRate > RATE_1M; wRate--) {
611bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez		if (pMgmt->sNodeDBTable[0].wSuppRate & (1<<wRate))
612a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches			return wRate;
613d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
614bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez
615bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez	if (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)
616a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches		return RATE_6M;
617bc5cf6563576bb36baa7e93417b9a2e29999a5c6Guido Martínez	else
618a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches		return RATE_1M;
6195449c685a4b39534f18869a93896370224463715Forest Bond}
6205449c685a4b39534f18869a93896370224463715Forest Bond
6216b35b7b3798b652a57fbce480f350aac851431c4Charles Clémentvoid
622d9d644edc358b854a63a28bc4601c4268d5c8344Joe PerchesVNTWIFIvSet11h(
623d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtObject,
624d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	bool b11hEnable
625d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
6265449c685a4b39534f18869a93896370224463715Forest Bond{
627d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
6285449c685a4b39534f18869a93896370224463715Forest Bond
629d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->b11hEnable = b11hEnable;
6305449c685a4b39534f18869a93896370224463715Forest Bond}
6315449c685a4b39534f18869a93896370224463715Forest Bond
6327b6a001313a9b11a1f0985de05fff514db41d72dCharles Clémentbool
6335449c685a4b39534f18869a93896370224463715Forest BondVNTWIFIbMeasureReport(
634d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtObject,
635d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	bool bEndOfReport,
636d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pvMeasureEID,
637d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byReportMode,
638d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byBasicMap,
639d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byCCAFraction,
640d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char *pbyRPIs
641d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
6425449c685a4b39534f18869a93896370224463715Forest Bond{
643d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
644d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char *pbyCurrentEID = (unsigned char *)(pMgmt->pCurrMeasureEIDRep);
645d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches
646d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	if ((pvMeasureEID != NULL) &&
647d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	    (pMgmt->uLengthOfRepEIDs < (WLAN_A3FR_MAXLEN - sizeof(MEASEURE_REP) - sizeof(WLAN_80211HDR_A3) - 3))
648d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches) {
649d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->pCurrMeasureEIDRep->byElementID = WLAN_EID_MEASURE_REP;
650d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->pCurrMeasureEIDRep->len = 3;
651d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->pCurrMeasureEIDRep->byToken = ((PWLAN_IE_MEASURE_REQ)pvMeasureEID)->byToken;
652d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->pCurrMeasureEIDRep->byMode = byReportMode;
653d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->pCurrMeasureEIDRep->byType = ((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->byType;
654d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		switch (pMgmt->pCurrMeasureEIDRep->byType) {
655d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		case MEASURE_TYPE_BASIC:
656d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_BASIC);
657d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sBasic),
658d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			       &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
659d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			       sizeof(MEASEURE_REQ));
660d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pMgmt->pCurrMeasureEIDRep->sRep.sBasic.byMap = byBasicMap;
661d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			break;
662d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		case MEASURE_TYPE_CCA:
663d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_CCA);
664d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sCCA),
665d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			       &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
666d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			       sizeof(MEASEURE_REQ));
667d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pMgmt->pCurrMeasureEIDRep->sRep.sCCA.byCCABusyFraction = byCCAFraction;
668d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			break;
669d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		case MEASURE_TYPE_RPI:
670d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			pMgmt->pCurrMeasureEIDRep->len += sizeof(MEASEURE_REP_RPI);
671d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			memcpy(&(pMgmt->pCurrMeasureEIDRep->sRep.sRPI),
672d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			       &(((PWLAN_IE_MEASURE_REQ) pvMeasureEID)->sReq),
673d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			       sizeof(MEASEURE_REQ));
674d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			memcpy(pMgmt->pCurrMeasureEIDRep->sRep.sRPI.abyRPIdensity, pbyRPIs, 8);
675d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			break;
676d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		default:
677d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches			break;
678d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		}
679d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pbyCurrentEID += (2 + pMgmt->pCurrMeasureEIDRep->len);
680d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->uLengthOfRepEIDs += (2 + pMgmt->pCurrMeasureEIDRep->len);
681d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		pMgmt->pCurrMeasureEIDRep = (PWLAN_IE_MEASURE_REP) pbyCurrentEID;
682d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	}
683cba60905f19f70858556c081571cdd8fca546851Guillaume Clement	if (bEndOfReport)
684d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches		IEEE11hbMSRRepTx(pMgmt);
6854e8a7e5fc29697f881f5c358f84df52914908703Guido Martínez
686a4ef27ad02e0bfd165e81d6a4f3771ace42ebe41Joe Perches	return true;
6875449c685a4b39534f18869a93896370224463715Forest Bond}
6885449c685a4b39534f18869a93896370224463715Forest Bond
6897b6a001313a9b11a1f0985de05fff514db41d72dCharles Clémentbool
6905449c685a4b39534f18869a93896370224463715Forest BondVNTWIFIbChannelSwitch(
691d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	void *pMgmtObject,
692d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	unsigned char byNewChannel
693d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches)
6945449c685a4b39534f18869a93896370224463715Forest Bond{
695d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	PSMgmtObject    pMgmt = (PSMgmtObject) pMgmtObject;
6965449c685a4b39534f18869a93896370224463715Forest Bond
697d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->uCurrChannel = byNewChannel;
698d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	pMgmt->bSwitchChannel = false;
699d9d644edc358b854a63a28bc4601c4268d5c8344Joe Perches	return true;
7005449c685a4b39534f18869a93896370224463715Forest Bond}
701