📄 vntwifi.c
字号:
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This software is copyrighted by and is the sole property of
* VIA Networking Technologies, Inc. This software may only be used
* in accordance with the corresponding license agreement. Any unauthorized
* use, duplication, transmission, distribution, or disclosure of this
* software is expressly forbidden.
*
* This software is provided by VIA Networking Technologies, Inc. "as is"
* and any express or implied warranties, including, but not limited to, the
* implied warranties of merchantability and fitness for a particular purpose
* are disclaimed. In no event shall VIA Networking Technologies, Inc.
* be liable for any direct, indirect, incidental, special, exemplary, or
* consequential damages.
*
*
* File: vntwifi.c
*
* Purpose: export functions for vntwifi lib
*
* Functions:
*
* Revision History:
*
* Author: Yiching Chen
*
* Date: feb. 2, 2005
*
*/
#if !defined(__VNTWIFI_H__)
#include "vntwifi.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__WMGR_H__)
#include "wmgr.h"
#endif
#if !defined(__DATARATE_H__)
#include "datarate.h"
#endif
#if !defined(__TBIT_H__)
#include "tbit.h"
#endif
#if !defined(__IEEE11h_H__)
#include "IEEE11h.h"
#endif
#if !defined(__COUNTRY_H__)
#include "country.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
/*--------------------- Static Definitions -------------------------*/
//static int msglevel =MSG_LEVEL_DEBUG;
//static int msglevel =MSG_LEVEL_INFO;
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*+
*
* Description:
* Set Operation Mode
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* eOPMode - Opreation Mode
* Out:
* none
*
* Return Value: none
*
-*/
VOID
VNTWIFIvSetOPMode (
IN PVOID pMgmtHandle,
IN WMAC_CONFIG_MODE eOPMode
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
pMgmt->eConfigMode = eOPMode;
}
/*+
*
* Description:
* Set Operation Mode
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* wBeaconPeriod - Beacon Period
* wATIMWindow - ATIM window
* uChannel - channel number
* Out:
* none
*
* Return Value: none
*
-*/
VOID
VNTWIFIvSetIBSSParameter (
IN PVOID pMgmtHandle,
IN WORD wBeaconPeriod,
IN WORD wATIMWindow,
IN UINT uChannel
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
pMgmt->wIBSSBeaconPeriod = wBeaconPeriod;
pMgmt->wIBSSATIMWindow = wATIMWindow;
pMgmt->uIBSSChannel = uChannel;
}
/*+
*
* Description:
* Get current SSID
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* Out:
* none
*
* Return Value: current SSID pointer.
*
-*/
PWLAN_IE_SSID
VNTWIFIpGetCurrentSSID (
IN PVOID pMgmtHandle
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
return((PWLAN_IE_SSID) pMgmt->abyCurrSSID);
}
/*+
*
* Description:
* Get current link channel
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* Out:
* none
*
* Return Value: current Channel.
*
-*/
UINT
VNTWIFIpGetCurrentChannel (
IN PVOID pMgmtHandle
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
if (pMgmtHandle != NULL) {
return (pMgmt->uCurrChannel);
}
return 0;
}
/*+
*
* Description:
* Get current Assoc ID
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* Out:
* none
*
* Return Value: current Assoc ID
*
-*/
WORD
VNTWIFIwGetAssocID (
IN PVOID pMgmtHandle
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
return(pMgmt->wCurrAID);
}
/*+
*
* Description:
* This routine return max support rate of IES
*
* Parameters:
* In:
* pSupportRateIEs
* pExtSupportRateIEs
*
* Out:
*
* Return Value: max support rate
*
-*/
BYTE
VNTWIFIbyGetMaxSupportRate (
IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
)
{
BYTE byMaxSupportRate = RATE_1M;
BYTE bySupportRate = RATE_1M;
UINT ii = 0;
if (pSupportRateIEs) {
for (ii = 0; ii < pSupportRateIEs->len; ii++) {
bySupportRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
if (bySupportRate > byMaxSupportRate) {
byMaxSupportRate = bySupportRate;
}
}
}
if (pExtSupportRateIEs) {
for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
bySupportRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
if (bySupportRate > byMaxSupportRate) {
byMaxSupportRate = bySupportRate;
}
}
}
return byMaxSupportRate;
}
/*+
*
* Description:
* This routine return data rate of ACK packtet
*
* Parameters:
* In:
* byRxDataRate
* pSupportRateIEs
* pExtSupportRateIEs
*
* Out:
*
* Return Value: max support rate
*
-*/
BYTE
VNTWIFIbyGetACKTxRate (
IN BYTE byRxDataRate,
IN PWLAN_IE_SUPP_RATES pSupportRateIEs,
IN PWLAN_IE_SUPP_RATES pExtSupportRateIEs
)
{
BYTE byMaxAckRate;
BYTE byBasicRate;
UINT ii;
if (byRxDataRate <= RATE_11M) {
byMaxAckRate = RATE_1M;
} else {
// 24M is mandatory for 802.11a and 802.11g
byMaxAckRate = RATE_24M;
}
if (pSupportRateIEs) {
for (ii = 0; ii < pSupportRateIEs->len; ii++) {
if (pSupportRateIEs->abyRates[ii] & 0x80) {
byBasicRate = DATARATEbyGetRateIdx(pSupportRateIEs->abyRates[ii]);
if ((byBasicRate <= byRxDataRate) &&
(byBasicRate > byMaxAckRate)) {
byMaxAckRate = byBasicRate;
}
}
}
}
if (pExtSupportRateIEs) {
for (ii = 0; ii < pExtSupportRateIEs->len; ii++) {
if (pExtSupportRateIEs->abyRates[ii] & 0x80) {
byBasicRate = DATARATEbyGetRateIdx(pExtSupportRateIEs->abyRates[ii]);
if ((byBasicRate <= byRxDataRate) &&
(byBasicRate > byMaxAckRate)) {
byMaxAckRate = byBasicRate;
}
}
}
}
return byMaxAckRate;
}
/*+
*
* Description:
* Set Authentication Mode
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* eAuthMode - Authentication mode
* Out:
* none
*
* Return Value: none
*
-*/
VOID
VNTWIFIvSetAuthenticationMode (
IN PVOID pMgmtHandle,
IN WMAC_AUTHENTICATION_MODE eAuthMode
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
pMgmt->eAuthenMode = eAuthMode;
if ((eAuthMode == WMAC_AUTH_SHAREKEY) ||
(eAuthMode == WMAC_AUTH_AUTO)) {
pMgmt->bShareKeyAlgorithm = TRUE;
} else {
pMgmt->bShareKeyAlgorithm = FALSE;
}
}
/*+
*
* Description:
* Set Encryption Mode
*
* Parameters:
* In:
* pMgmtHandle - pointer to management object
* eAuthMode - Authentication mode
* Out:
* none
*
* Return Value: none
*
-*/
VOID
VNTWIFIvSetEncryptionMode (
IN PVOID pMgmtHandle,
IN WMAC_ENCRYPTION_MODE eEncryptionMode
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
pMgmt->eEncryptionMode = eEncryptionMode;
if ((eEncryptionMode == WMAC_ENCRYPTION_WEPEnabled) ||
(eEncryptionMode == WMAC_ENCRYPTION_TKIPEnabled) ||
(eEncryptionMode == WMAC_ENCRYPTION_AESEnabled) ) {
pMgmt->bPrivacyInvoked = TRUE;
} else {
pMgmt->bPrivacyInvoked = FALSE;
}
}
BOOL
VNTWIFIbConfigPhyMode (
IN PVOID pMgmtHandle,
IN CARD_PHY_TYPE ePhyType
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
if ((ePhyType != PHY_TYPE_AUTO) &&
(ePhyType != pMgmt->eCurrentPHYMode)) {
if (CARDbSetPhyParameter(pMgmt->pAdapter, ePhyType, 0, 0, NULL, NULL)==TRUE) {
pMgmt->eCurrentPHYMode = ePhyType;
} else {
return(FALSE);
}
}
pMgmt->eConfigPHYMode = ePhyType;
return(TRUE);
}
VOID
VNTWIFIbGetConfigPhyMode (
IN PVOID pMgmtHandle,
OUT PVOID pePhyType
)
{
PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle;
if ((pMgmt != NULL) && (pePhyType != NULL)) {
*(PCARD_PHY_TYPE)pePhyType = pMgmt->eConfigPHYMode;
}
}
/*+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -