📄 wcmd.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: wcmd.c
*
* Purpose: Handles the management command interface functions
*
* Author: Lyndon Chen
*
* Date: May 8, 2003
*
* Functions:
* s_vProbeChannel - Active scan channel
* s_MgrMakeProbeRequest - Make ProbeRequest packet
* CommandTimer - Timer function to handle command
* s_bCommandComplete - Command Complete function
* bScheduleCommand - Push Command and wait Command Scheduler to do
* vCommandTimer- Command call back functions
* vCommandTimerWait- Call back timer
* bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
*
* Revision History:
*
*/
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__TMACRO_H__)
#include "tmacro.h"
#endif
#if !defined(__DEVICE_H__)
#include "device.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
#if !defined(__WCMD_H__)
#include "wcmd.h"
#endif
#if !defined(__WMGR_H__)
#include "wmgr.h"
#endif
#if !defined(__POWER_H__)
#include "power.h"
#endif
#if !defined(__WCTL_H__)
#include "wctl.h"
#endif
#if !defined(__CARD_H__)
#include "card.h"
#endif
#if !defined(__BASEBAND_H__)
#include "baseband.h"
#endif
#if !defined(__UMEM_H__)
#include "umem.h"
#endif
#if !defined(__RXTX_H__)
#include "rxtx.h"
#endif
#if !defined(__RF_H__)
#include "rf.h"
#endif
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
static int msglevel =MSG_LEVEL_INFO;
//static int msglevel =MSG_LEVEL_DEBUG;
/*--------------------- Static Functions --------------------------*/
static
VOID
s_vProbeChannel(
IN PSDevice pDevice
);
static
PSTxMgmtPacket
s_MgrMakeProbeRequest(
IN PSDevice pDevice,
IN PSMgmtObject pMgmt,
IN PBYTE pScanBSSID,
IN PWLAN_IE_SSID pSSID,
IN PWLAN_IE_SUPP_RATES pCurrRates,
IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
);
static
BOOL
s_bCommandComplete (
PSDevice pDevice
);
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
/*
* Description:
* Stop AdHoc beacon during scan process
*
* Parameters:
* In:
* pDevice - Pointer to the adapter
* Out:
* none
*
* Return Value: none
*
*/
static
void
vAdHocBeaconStop(PSDevice pDevice)
{
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
BOOL bStop;
/*
* temporarily stop Beacon packet for AdHoc Server
* if all of the following coditions are met:
* (1) STA is in AdHoc mode
* (2) VT3253 is programmed as automatic Beacon Transmitting
* (3) One of the following conditions is met
* (3.1) AdHoc channel is in B/G band and the
* current scan channel is in A band
* or
* (3.2) AdHoc channel is in A mode
*/
bStop = FALSE;
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
(pMgmt->eCurrState >= WMAC_STATE_STARTED))
{
if ((pMgmt->uIBSSChannel <= CB_MAX_CHANNEL_24G) &&
(pMgmt->uScanChannel > CB_MAX_CHANNEL_24G))
{
bStop = TRUE;
}
if (pMgmt->uIBSSChannel > CB_MAX_CHANNEL_24G)
{
bStop = TRUE;
}
}
if (bStop)
{
MACvRegBitsOff(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
}
}
/*
* Description:
* Restart AdHoc beacon after scan process complete
*
* Parameters:
* In:
* pDevice - Pointer to the adapter
* Out:
* none
*
* Return Value: none
*
*/
static
void
vAdHocBeaconRestart(PSDevice pDevice)
{
PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
/*
* Restart Beacon packet for AdHoc Server
* if all of the following coditions are met:
* (1) STA is in AdHoc mode
* (2) VT3253 is programmed as automatic Beacon Transmitting
*/
if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) &&
(pMgmt->eCurrState >= WMAC_STATE_STARTED))
{
MACvRegBitsOn(pDevice->PortOffset, MAC_REG_TCR, TCR_AUTOBCNTX);
}
}
/*+
*
* Routine Description:
* Prepare and send probe request management frames.
*
*
* Return Value:
* none.
*
-*/
static
VOID
s_vProbeChannel(
IN PSDevice pDevice
)
{
//1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M
BYTE abyCurrSuppRatesG[] = {WLAN_EID_SUPP_RATES, 8, 0x02, 0x04, 0x0B, 0x16, 0x24, 0x30, 0x48, 0x6C};
BYTE abyCurrExtSuppRatesG[] = {WLAN_EID_EXTSUPP_RATES, 4, 0x0C, 0x12, 0x18, 0x60};
//6M, 9M, 12M, 48M
BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C};
BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16};
PBYTE pbyRate;
PSTxMgmtPacket pTxPacket;
PSMgmtObject pMgmt = pDevice->pMgmt;
UINT ii;
if (pDevice->eCurrentPHYType == PHY_TYPE_11A) {
pbyRate = &abyCurrSuppRatesA[0];
} else if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
pbyRate = &abyCurrSuppRatesB[0];
} else {
pbyRate = &abyCurrSuppRatesG[0];
}
// build an assocreq frame and send it
pTxPacket = s_MgrMakeProbeRequest
(
pDevice,
pMgmt,
pMgmt->abyScanBSSID,
(PWLAN_IE_SSID)pMgmt->abyScanSSID,
(PWLAN_IE_SUPP_RATES)pbyRate,
(PWLAN_IE_SUPP_RATES)abyCurrExtSuppRatesG
);
if (pTxPacket != NULL ){
for (ii = 0; ii < 2 ; ii++) {
if (csMgmt_xmit(pDevice, pTxPacket) != CMD_STATUS_PENDING) {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request sending fail.. \n");
}
else {
DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request is sending.. \n");
}
}
}
}
/*+
*
* Routine Description:
* Constructs an probe request frame
*
*
* Return Value:
* A ptr to Tx frame or NULL on allocation failue
*
-*/
PSTxMgmtPacket
s_MgrMakeProbeRequest(
IN PSDevice pDevice,
IN PSMgmtObject pMgmt,
IN PBYTE pScanBSSID,
IN PWLAN_IE_SSID pSSID,
IN PWLAN_IE_SUPP_RATES pCurrRates,
IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates
)
{
PSTxMgmtPacket pTxPacket = NULL;
WLAN_FR_PROBEREQ sFrame;
pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool;
memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN);
pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket));
sFrame.pBuf = (PBYTE)pTxPacket->p80211Header;
sFrame.len = WLAN_PROBEREQ_FR_MAXLEN;
vMgrEncodeProbeRequest(&sFrame);
sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16(
(
WLAN_SET_FC_FTYPE(WLAN_TYPE_MGR) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_PROBEREQ)
));
memcpy( sFrame.pHdr->sA3.abyAddr1, pScanBSSID, WLAN_ADDR_LEN);
memcpy( sFrame.pHdr->sA3.abyAddr2, pMgmt->abyMACAddr, WLAN_ADDR_LEN);
memcpy( sFrame.pHdr->sA3.abyAddr3, pScanBSSID, WLAN_BSSID_LEN);
// Copy the SSID, pSSID->len=0 indicate broadcast SSID
sFrame.pSSID = (PWLAN_IE_SSID)(sFrame.pBuf + sFrame.len);
sFrame.len += pSSID->len + WLAN_IEHDR_LEN;
memcpy(sFrame.pSSID, pSSID, pSSID->len + WLAN_IEHDR_LEN);
sFrame.pSuppRates = (PWLAN_IE_SUPP_RATES)(sFrame.pBuf + sFrame.len);
sFrame.len += pCurrRates->len + WLAN_IEHDR_LEN;
memcpy(sFrame.pSuppRates, pCurrRates, pCurrRates->len + WLAN_IEHDR_LEN);
// Copy the extension rate set
if (pDevice->eCurrentPHYType == PHY_TYPE_11G) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -