📄 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(byTblPtr, pwId) PIEEP_vGetCfgFromEep(PIVLNEEP_byEntryEepAddr(byTblPtr), SIZE_OF_VID, (PBYTE)pwId)
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
// Search entry in table
// If search successed, return EEPROM table entry id; else return ENTRY_END_FLAG
BYTE PIVLNEEP_bySearchEntry (UINT16 wEntryId) DIRECT_FUNTYPE_REENT
{
UINT8 si;
UINT16 wId;
// 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 ENTRY_END_FLAG
return ENTRY_END_FLAG;
}
BYTE PIVLNEEP_byInsEntry (SVlanGrp *pSEntry) DIRECT_FUNTYPE_REENT
{
UINT16 wId;
UINT8 byTblPtr;
// Check if entry already exist
if (PIVLNEEP_bySearchEntry(pSEntry->wVid) != ENTRY_END_FLAG)
return VLAN_OP_GRP_EXIST;
// Search where in eeprom to insert the entry
for (byTblPtr = 0; byTblPtr < SWITCH_VLAN_GRP_NUM; byTblPtr++) {
s_vGetEntryId(byTblPtr, &wId);
if (wId == 0)
break;
}
// Check if table full
if (byTblPtr == SWITCH_VLAN_GRP_NUM)
return VLAN_OP_NO_EMPTY_GRP;
// Insert the target entry into EEPROM and update checksum
PIEEP_vSetCfgIntoEep( (PBYTE)pSEntry, PIVLNEEP_byEntryEepAddr(byTblPtr), EEP_SIZE_VLAN_TBL_ENTRY );
PIEEP_vUpdateChecksum();
return OP_OK;
}
void PIVLNEEP_vDelEntry (UINT8 byTblPtr) DIRECT_FUNTYPE_REENT
{
UINT16 wBuf = 0;
PIEEP_vSetCfgIntoEep( (PBYTE)&wBuf, PIVLNEEP_byEntryEepAddr(byTblPtr), SIZE_OF_VID );
PIEEP_vUpdateChecksum();
}
void PIVLNEEP_vEditEntry (UINT8 byTblPtr, SVlanGrp *pSEntry) DIRECT_FUNTYPE_REENT
{
PIEEP_vSetCfgIntoEep( (PBYTE)pSEntry, PIVLNEEP_byEntryEepAddr(byTblPtr), EEP_SIZE_VLAN_TBL_ENTRY );
PIEEP_vUpdateChecksum();
}
void PIVLNEEP_vStatisTblInfo (SVlanPageCfg *pSPageBuf) DIRECT_FUNTYPE_REENT
{
UINT8 byTblPtr, si;
UINT16 wVid;
// Prepare for table info statistics
pSPageBuf->byValidEntryNum = 0;
// Add entry id into valid group list one by one
for (byTblPtr = 0; byTblPtr < SWITCH_VLAN_GRP_NUM; byTblPtr++) {
s_vGetEntryId(byTblPtr, &wVid);
if (wVid > 0) {
pSPageBuf->byValidEntryNum++;
for (si = pSPageBuf->byValidEntryNum-1; si > 0; si--) {
if (wVid < pSPageBuf->awValidGrpIdList[si-1])
pSPageBuf->awValidGrpIdList[si] = pSPageBuf->awValidGrpIdList[si-1];
else
break;
}
pSPageBuf->awValidGrpIdList[si] = wVid;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -