📄 pimacfltep.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: pimacflteep.c
*
* Purpose: mac table filter function module UI definitions
*
* Author: Tim Feng
*
* Date: Jan 13, 2006
*
* Functions:
*
* Revision History:
*
*/
#include "piportmp.h"
#include "swmsg.h"
#include "pimacfltep.h"
#include "pimacfltmd.h"
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
// Search entry in table
// If search successed, return EEPROM table entry id; else return ENTRY_END_FLAG
// When searching an entry, Must firstly check whether the static bit of Entry is True to
// make sure the entry is a valid entry, not empty entry,
// MAC address 00 00 00 00 00 00 is a valid address, can not be
// used to classify entry(entry in eeprom is valid or empty).
UINT16 PIMACFLTEP_wSearchEntry (UINT8 *abyMacAddr, UINT16 u16Fid)
{
SMacEntry sTblEntry;
PUINT8 pabyMacAddrTmp;
UINT8 si;
STR_pvMemset(&sTblEntry, 0, sizeof(SMacEntry));
pabyMacAddrTmp = sTblEntry.abyMacAddr;
// Find where in EEPROM the current entry is
for (si = 0; si < SWITCH_MAC_FLT_GRP_NUM; si ++ ) {
PIMACFLTEP_vGetEntry(si, &sTblEntry);
//If not static group, It means that the group invalid
if (sTblEntry.bStatic)
// If HIT => return current location
if ( (abyMacAddr[0] == pabyMacAddrTmp[0]) && (abyMacAddr[1] == pabyMacAddrTmp[1]) && (abyMacAddr[2] == pabyMacAddrTmp[2])
&& (abyMacAddr[3] == pabyMacAddrTmp[3]) && (abyMacAddr[4] == pabyMacAddrTmp[4]) && (abyMacAddr[5] == pabyMacAddrTmp[5])
&& (u16Fid == sTblEntry.u16Fid) )
return si;
}
// If entry not exist, return UINT16_MAX
return UINT16_MAX;
}
//search an entry by PORT Id in EEprom
UINT16 PIMACFLTEP_wSearchEntrybyPortId (UINT8 bySrcId)
{
SMacEntry sTblEntry;
UINT8 si;
STR_pvMemset(&sTblEntry, 0, sizeof(SMacEntry));
// Find where in EEPROM the current entry is
for (si = 0; si < SWITCH_MAC_FLT_GRP_NUM; si ++ ) {
PIMACFLTEP_vGetEntry(si, &sTblEntry);
//If not static group, It means that the group invalid
if (sTblEntry.bStatic)
// If HIT => return current location
if ( !sTblEntry.bTrkGrp && (bySrcId == sTblEntry.u8SrcId))
return si;
}
// If entry not exist, return UINT16_MAX
return UINT16_MAX;
}
UINT8 PIMACFLTEP_byInsEntry (SMacEntry *pSTblEntry)
{
SMacEntry sTblEntryTmp;
UINT16 wTblPtr;
// Check if entry already exist
if (PIMACFLTEP_wSearchEntry(pSTblEntry->abyMacAddr, pSTblEntry->u16Fid) != UINT16_MAX)
return MACFLT_OP_GRP_EXIST;
// Search where in eeprom to insert the entry
for (wTblPtr = 0; wTblPtr < SWITCH_MAC_FLT_GRP_NUM; wTblPtr++) {
PIMACFLTEP_vGetEntry(wTblPtr, &sTblEntryTmp);
//If the static bit in entry is not TRUE, That's to say the group exist and is empty.
//So here is the position to insert a new group
if (!sTblEntryTmp.bStatic)
break;
}
// Check if table full
if (wTblPtr == SWITCH_MAC_FLT_GRP_NUM)
return MACFLT_OP_NO_EMPTY_GRP;
// Insert the target entry into EEPROM and update checksum
PIEEP_vSetCfgIntoEep( (PUINT8)pSTblEntry, PIMACFLTEP_dwEntryEepAddr(wTblPtr), EEP_SIZE_MACFLT_TBL_ENTRY);
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
return OP_OK;
}
void PIMACFLTEP_vDelEntry (UINT16 wTblPtr)
{
SMacEntry sTblEntry;
STR_pvMemset(&sTblEntry, 0, sizeof(SMacEntry));
PIEEP_vSetCfgIntoEep( (PUINT8)&sTblEntry, PIMACFLTEP_dwEntryEepAddr(wTblPtr), EEP_SIZE_MACFLT_TBL_ENTRY);
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
void PIMACFLTEP_vStatisTblInfo (SMacFltPageCfg *pSPageBuf)
{
SMacEntry sTblEntry;
PUINT8 pabyMacAddr;
UINT16 wTblPtr, si;
UINT8 abyValidGrpPhyIdList[SWITCH_MAC_FLT_GRP_NUM]; // Valid Port Phyid array
char astrGrpMacBuff[MAC_STRING_LEN+1];
pSPageBuf->wValidEntryNum = 0;
PIMACFLT_vGetSMacFltMode(&pSPageBuf->bySMACFltMode);
STR_pvMemset(&sTblEntry, 0, sizeof(SMacEntry));
pabyMacAddr = sTblEntry.abyMacAddr;
// Add entry into valid group list one by one
for (wTblPtr = 0; wTblPtr < SWITCH_MAC_FLT_GRP_NUM; wTblPtr++) {
PIMACFLTEP_vGetEntry(wTblPtr, &sTblEntry);
//valid entry if (static bit == 1) in eeprom
if (sTblEntry.bStatic) {
pSPageBuf->wValidEntryNum ++;
//Sort by Port PhyId
for (si = pSPageBuf->wValidEntryNum-1; si > 0; si--) {
if (sTblEntry.u8SrcId < abyValidGrpPhyIdList[si-1]) {
abyValidGrpPhyIdList[si] = abyValidGrpPhyIdList[si-1];
STR_pvMemcpy(pSPageBuf->astrGrpMacList + si*(MAC_STRING_LEN+1), pSPageBuf->astrGrpMacList + (si-1)*(MAC_STRING_LEN+1), MAC_STRING_LEN+1);
pSPageBuf->awValidGrpFidList[si] = pSPageBuf->awValidGrpFidList[si-1];
}
else
break;
}
abyValidGrpPhyIdList[si] = sTblEntry.u8SrcId;
//Note: In this function, using function STR_vCvtMacValtoStr(pSPageBuf->astrGrpMacList + si*(MAC_STRING_LEN+1), (char*)pabyMacAddr, MAC_STRING_LEN+1);
//to transfer mac value to mac string into astrGrpMacList will have bug
STR_vCvtMacValtoStr(astrGrpMacBuff, (char*)pabyMacAddr);
STR_pvMemcpy(pSPageBuf->astrGrpMacList + si*(MAC_STRING_LEN+1), astrGrpMacBuff, MAC_STRING_LEN+1);
pSPageBuf->awValidGrpFidList[si] = sTblEntry.u16Fid;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -