📄 pivlneep.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: pivlneep.c
*
* Purpose: VLAN related EEPROM accessing functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#include "piportmp.h"
#include "pieeprom.h"
#include "pivlneep.h"
#include "swmsg.h"
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Static Macros -----------------------------*/
#define s_vGetEntryId(wTblPtr, pwId) PIEEP_vGetCfgFromEep(PIVLNEEP_dwEntryEepAddr(wTblPtr), SIZE_OF_VID, (PUINT8)pwId)
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
// Search entry in table
// If search successed, return EEPROM table entry id; else return ENTRY_END_FLAG
UINT16 PIVLNEEP_wSearchEntry (UINT16 wEntryId)
{
UINT16 wId, si;
// Find where in EEPROM the current entry is
for (si = 0; si < SWITCH_VLAN_GRP_NUM; si++) {
// Get current entry id and compare with the target one
s_vGetEntryId(si, &wId);
// If HIT => return current location
if ((wId != 0) && (wId == wEntryId) )
return si;
}
// If entry not exist, return UINT16_MAX
return UINT16_MAX;
}
UINT8 PIVLNEEP_byInsEntry (SVlanGrp *pSEntry)
{
UINT16 wTblPtr, wId;
// Check if entry already exist
if (PIVLNEEP_wSearchEntry(pSEntry->u16Vid) != UINT16_MAX)
return VLAN_OP_GRP_EXIST;
// Search where in eeprom to insert the entry
for (wTblPtr = 0; wTblPtr < SWITCH_VLAN_GRP_NUM; wTblPtr++) {
s_vGetEntryId(wTblPtr, &wId);
if (wId == 0)
break;
}
// Check if table full
if (wTblPtr == SWITCH_VLAN_GRP_NUM)
return VLAN_OP_NO_EMPTY_GRP;
// Insert the target entry into EEPROM and update checksum
PIEEP_vSetCfgIntoEep( (PUINT8)pSEntry, PIVLNEEP_dwEntryEepAddr(wTblPtr), EEP_SIZE_VLAN_TBL_ENTRY );
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
return OP_OK;
}
void PIVLNEEP_vDelEntry (UINT16 wTblPtr)
{
UINT16 wBuf = 0;
PIEEP_vSetCfgIntoEep( (PUINT8)&wBuf, PIVLNEEP_dwEntryEepAddr(wTblPtr), SIZE_OF_VID );
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
void PIVLNEEP_vEditEntry (UINT16 wTblPtr, SVlanGrp *pSEntry)
{
PIEEP_vSetCfgIntoEep( (PUINT8)pSEntry, PIVLNEEP_dwEntryEepAddr(wTblPtr), EEP_SIZE_VLAN_TBL_ENTRY );
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
void PIVLNEEP_vStatisTblInfo (SVlanPageCfg *pSPageBuf)
{
UINT16 wTblPtr, u16Vid, si;
// Prepare for table info statistics
pSPageBuf->wValidEntryNum = 0;
// Add entry id into valid group list one by one
for (wTblPtr = 0; wTblPtr < SWITCH_VLAN_GRP_NUM; wTblPtr++) {
s_vGetEntryId(wTblPtr, &u16Vid);
if (u16Vid > 0) {
pSPageBuf->wValidEntryNum++;
for (si = pSPageBuf->wValidEntryNum-1; si > 0; si--) {
if (u16Vid < pSPageBuf->awValidGrpIdList[si-1])
pSPageBuf->awValidGrpIdList[si] = pSPageBuf->awValidGrpIdList[si-1];
else
break;
}
pSPageBuf->awValidGrpIdList[si] = u16Vid;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -