📄 pisniff.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: pisniff.c
*
* Purpose: Sniffer module UI callback functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#include "str.h"
#if !defined(__BITOP_H__)
#include "bitop.h"
#endif
#include "swfwd.h"
#include "swsnf.h"
#include "swmsg.h"
#include "pigencfg.h"
#include "pisniff.h"
#include "piportmp.h"
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
static BYTE s_bySetCfgToHW(SSniffPageCfg* pSPageCfg_Sniff) DIRECT_FUNTYPE_REENT;
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Macros -----------------------------*/
/*--------------------- Export Functions --------------------------*/
void PISNF_vInitPage(SSniffPageCfg* pSPageCfg_Sniff) DIRECT_FUNTYPE_REENT
#ifndef __ASIC_VT6524
{
PIEEP_vGetCfgFromEep(EEP_ADDR_SNIFF_CFG, EEP_SIZE_SNIFF_CFG, (PBYTE)pSPageCfg_Sniff);
// If sniffer disabled, show first non-trunked port as destination port
if (pSPageCfg_Sniff->f2Mode == SNIFF_MODE_DISABLE)
pSPageCfg_Sniff->f6DestPort = 0;
// If sniffer enabled, show EEPROM stored config
else
pSPageCfg_Sniff->f6DestPort = PIPORTMP_byPhyIdToLogPtr(pSPageCfg_Sniff->f6DestPort);
if (pSPageCfg_Sniff->f6DestPort >= g_bySingleMegaLogIdNum)
pSPageCfg_Sniff->f6DestPort -= g_byTrunkLogIdNum; // skip trunk ports
PICFGMP_v4BPhyMskTo1bLogPtrMsk(pSPageCfg_Sniff->abySrcPortMsk);
// for ui engine
pSPageCfg_Sniff->SStrTblMap.byListNum = g_bySingleLogIdNum;
STRvMemcpy(pSPageCfg_Sniff->abyDestPortList, g_abyLogIdList, g_bySingleMegaLogIdNum);
// copy module port log id
STRvMemcpy(pSPageCfg_Sniff->abyDestPortList + g_bySingleMegaLogIdNum,
g_abyLogIdList + g_byMegaLogIdNum,
g_byModuleLogIdNum);
pSPageCfg_Sniff->SStrTblMap.abyListIndex = pSPageCfg_Sniff->abyDestPortList;
}
#else // for VT6524
{
PIEEP_vGetCfgFromEep(EEP_ADDR_SNIFF_CFG, EEP_SIZE_SNIFF_CFG, (PBYTE)pSPageCfg_Sniff);
// If sniffer disabled, show first non-trunked port as destination port
if (pSPageCfg_Sniff->f2Mode == SNIFF_MODE_DISABLE)
pSPageCfg_Sniff->f6DestPort = 0;
// If sniffer enabled, show EEPROM stored config
else
pSPageCfg_Sniff->f6DestPort = PIPORTMP_byPhyIdToLogPtr(pSPageCfg_Sniff->f6DestPort);
PICFGMP_v3BPhyMskTo1bLogPtrMsk(pSPageCfg_Sniff->abySrcPortMsk);
}
#endif
void PISNF_vSetEepDefault(SSniffPageCfg* pSPageCfg_Sniff) DIRECT_FUNTYPE_REENT
{
STRvMemset(pSPageCfg_Sniff, 0, EEP_SIZE_SNIFF_CFG);
PIEEP_vSetCfgIntoEep((PBYTE)pSPageCfg_Sniff, EEP_ADDR_SNIFF_CFG, EEP_SIZE_SNIFF_CFG);
PIEEP_vUpdateChecksum();
}
void PISNF_vSetHwFromEep(SSniffPageCfg* pSPageCfg_Sniff) DIRECT_FUNTYPE_REENT
{
PIEEP_vGetCfgFromEep(EEP_ADDR_SNIFF_CFG, EEP_SIZE_SNIFF_CFG, (PBYTE)pSPageCfg_Sniff);
s_bySetCfgToHW(pSPageCfg_Sniff);
}
BYTE PISNF_bySavePage(SSniffPageCfg* pSPageCfg_Sniff) DIRECT_FUNTYPE_REENT
{
SSniffPageCfg SCfgBuf;
BYTE byRes;
STRvMemcpy(&SCfgBuf, pSPageCfg_Sniff, EEP_SIZE_SNIFF_CFG);
// Transfer from config to physical format
#ifndef __ASIC_VT6524
if (SCfgBuf.f6DestPort > g_bySingleMegaLogIdNum)
SCfgBuf.f6DestPort += g_byTrunkLogIdNum;
SCfgBuf.f6DestPort = PIPORTMP_byLogPtrToPhyId(SCfgBuf.f6DestPort);
PICFGMP_v1bLogPtrMskTo4BPhyMsk(SCfgBuf.abySrcPortMsk);
#else
SCfgBuf.f6DestPort = PIPORTMP_byLogPtrToPhyId(SCfgBuf.f6DestPort);
PICFGMP_v1bLogPtrMskTo3BPhyMsk(SCfgBuf.abySrcPortMsk);
#endif
// Set config into HW
byRes = s_bySetCfgToHW(&SCfgBuf);
if (byRes != OP_OK)
return byRes;
// Set config into EEPROM and return
PIEEP_vSetCfgIntoEep((PBYTE)&SCfgBuf, EEP_ADDR_SNIFF_CFG, EEP_SIZE_SNIFF_CFG);
PIEEP_vUpdateChecksum();
return byRes;
}
static BYTE s_bySetCfgToHW(SSniffPageCfg* pSPageCfg_Sniff) DIRECT_FUNTYPE_REENT
{
SSniffCfg SSniffBuf;
SSniffBuf.byMode = pSPageCfg_Sniff->f2Mode;
SSniffBuf.byDestPort = pSPageCfg_Sniff->f6DestPort; // it's phy port id
SSniffBuf.dwSrcPortMsk = 0;
STRvMemcpy( (PBYTE)(&SSniffBuf.dwSrcPortMsk)+BYTE_OFFSET_IN_DWORD_OF_CFGMASK,
pSPageCfg_Sniff->abySrcPortMsk, BYTE_NUM_OF_CFGBUF_BIT_MASK );
// If sniffer enabled, check config valid (dest != source)
if ( (pSPageCfg_Sniff->f2Mode != SNIFF_MODE_DISABLE) &&
((SSniffBuf.dwSrcPortMsk >> SSniffBuf.byDestPort) & 0x01) )
return SNIFF_OP_DEST_AND_SRC_OVERLAP;
// Set config into HW
SWSNF_vSetSniffCfg(&SSniffBuf);
return OP_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -