📄 pigmrpep.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: pigmrpep.c
*
* Purpose: GMRP related EEPROM accessing functions
*
* Author: Freeya Lin
*
* Date: Feb 25, 2004
*
* Functions:
*
* Revision History:
*
*/
#include "piportmp.h"
#include "pigmrpep.h"
#include "swmsg.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
UINT16 PIGMRPEP_wSearchEntry (UINT8 *abyMacAddr, UINT16 u16Fid)
{
UINT8 abyMacAddrTmp[MAC_ADDR_SIZE];
UINT16 u16FidTmp = 0, si;
// Find where in EEPROM the current entry is
for (si = 0; si < SWITCH_GMRP_GRP_NUM; si++) {
// Get current entry id and compare with the target one
PIEEP_vGetCfgFromEep(PIGMRPEP_dwEntryEepAddr(si), MAC_ADDR_SIZE, (PUINT8)abyMacAddrTmp);
PIEEP_vGetCfgFromEep(PIGMRPEP_dwEntryEepAddr(si)+MAC_ADDR_SIZE, SIZE_OF_GMRP_FID, (PUINT8)&u16FidTmp);
// If HIT => return current location
if ((abyMacAddr[0] == abyMacAddrTmp[0]) && (abyMacAddr[1] == abyMacAddrTmp[1]) && (abyMacAddr[2] == abyMacAddrTmp[2])
&& (abyMacAddr[3] == abyMacAddrTmp[3]) && (abyMacAddr[4] == abyMacAddrTmp[4]) && (abyMacAddr[5] == abyMacAddrTmp[5])
&& (u16Fid == u16FidTmp) )
return si;
}
// If entry not exist, return UINT16_MAX
return UINT16_MAX;
}
UINT8 PIGMRPEP_byInsEntry (SGMRPEntry *pSTblEntry) //TOCHECK
{
UINT16 wTblPtr;
UINT8 abyMacAddrTmp[MAC_ADDR_SIZE];
// Check if entry already exist
if (PIGMRPEP_wSearchEntry(pSTblEntry->sMacEntry.abyMacAddr, pSTblEntry->sMacEntry.u16Fid) != UINT16_MAX) //TOCHECK
return GMRP_OP_GRP_EXIST;
// Search where in eeprom to insert the entry
for (wTblPtr = 0; wTblPtr < SWITCH_GMRP_GRP_NUM; wTblPtr++) {
PIEEP_vGetCfgFromEep(PIGMRPEP_dwEntryEepAddr(wTblPtr), MAC_ADDR_SIZE, (PUINT8)abyMacAddrTmp);
if (!abyMacAddrTmp[0] && !abyMacAddrTmp[1] && !abyMacAddrTmp[2]
&& !abyMacAddrTmp[3] && !abyMacAddrTmp[4] && !abyMacAddrTmp[5] )
break;
}
// Check if table full
if (wTblPtr == SWITCH_GMRP_GRP_NUM)
return GMRP_OP_NO_EMPTY_GRP;
// Insert the target entry into EEPROM and update checksum
PIEEP_vSetCfgIntoEep( (PUINT8)pSTblEntry, PIGMRPEP_dwEntryEepAddr(wTblPtr), EEP_SIZE_GMRP_TBL_ENTRY );
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
return OP_OK;
}
void PIGMRPEP_vDelEntry (UINT16 wTblPtr)
{
UINT8 abyMacAddrTmp[MAC_ADDR_SIZE];
UINT8 si;
for (si = 0; si < MAC_ADDR_SIZE; si++)
abyMacAddrTmp[si] = 0;
PIEEP_vSetCfgIntoEep( (PUINT8)abyMacAddrTmp, PIGMRPEP_dwEntryEepAddr(wTblPtr), MAC_ADDR_SIZE);
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
void PIGMRPEP_vStatisTblInfo (SGMRPPageCfg *pSPageBuf)
{
UINT8 abyMacAddr[MAC_ADDR_SIZE];
UINT16 u16Fid = 0, wTblPtr;
pSPageBuf->wValidEntryNum = 0;
// Add entry id into valid group list one by one
for (wTblPtr = 0; wTblPtr < SWITCH_GMRP_GRP_NUM; wTblPtr++) {
PIEEP_vGetCfgFromEep(PIGMRPEP_dwEntryEepAddr(wTblPtr), MAC_ADDR_SIZE, (PUINT8)abyMacAddr);
//valid entry if (mac addr!=0) in eeprom
if (!abyMacAddr[0] && !abyMacAddr[1] && !abyMacAddr[2] && !abyMacAddr[3] && !abyMacAddr[4] && !abyMacAddr[5] ){
}
else{
STR_vCvtMacValtoStr(pSPageBuf->astrGrpMacList+pSPageBuf->wValidEntryNum*(MAC_STRING_LEN+1), (char*)abyMacAddr);
PIEEP_vGetCfgFromEep(PIGMRPEP_dwEntryEepAddr(wTblPtr)+MAC_ADDR_SIZE, SIZE_OF_GMRP_FID, (PUINT8)&u16Fid);
pSPageBuf->awValidGrpFidList[pSPageBuf->wValidEntryNum] = u16Fid;
pSPageBuf->wValidEntryNum++;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -