📄 piipmeep.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: piipmeep.c
*
* Purpose: IGMP related EEPROM accessing functions
*
* Author: Freeya Lin
*
* Date: Dec 18, 2003
*
* Functions:
*
* Revision History:
*
*/
#include "piportmp.h"
#include "piipmeep.h"
#include "swmsg.h"
#include "str.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 PIIPMEEP_wSearchEntry (UINT32 dwIpAddr, UINT16 u16Vid)
{
UINT32 dwIpAddrTmp = 0;
UINT16 u16VidTmp = 0, si;
// Find where in EEPROM the current entry is
for (si = 0; si < SWITCH_IGMP_GRP_NUM; si++) {
// Get current entry id and compare with the target one
PIEEP_vGetCfgFromEep(PIIPMEEP_dwEntryEepAddr(si), SIZE_OF_IP_ADDR, (PUINT8)&dwIpAddrTmp);
PIEEP_vGetCfgFromEep(PIIPMEEP_dwEntryEepAddr(si)+SIZE_OF_IP_ADDR, SIZE_OF_IGMP_VID, (PUINT8)&u16VidTmp);
// If HIT => return current location
if ((dwIpAddr == dwIpAddrTmp) && (u16Vid == u16VidTmp) )
return si;
}
// If entry not exist, return UINT16_MAX
return UINT16_MAX;
}
UINT8 PIIPMEEP_byInsEntry (SIpmEntry *pSIpmTblEntry) //TOCHECK
{
UINT32 dwIpAddr = 0;
UINT16 wTblPtr;
// Check if entry already exist
if (PIIPMEEP_wSearchEntry(pSIpmTblEntry->dwIpAddr, pSIpmTblEntry->u16Vid) != UINT16_MAX)
return IGMP_OP_GRP_EXIST;
// Search where in eeprom to insert the entry
for (wTblPtr = 0; wTblPtr < SWITCH_IGMP_GRP_NUM; wTblPtr++) {
PIEEP_vGetCfgFromEep(PIIPMEEP_dwEntryEepAddr(wTblPtr), SIZE_OF_IP_ADDR, (PUINT8)&dwIpAddr);
if (dwIpAddr == 0)
break;
}
// Check if table full
if (wTblPtr == SWITCH_IGMP_GRP_NUM)
return IGMP_OP_NO_EMPTY_GRP;
// Insert the target entry into EEPROM and update checksum
PIEEP_vSetCfgIntoEep( (PUINT8)pSIpmTblEntry, PIIPMEEP_dwEntryEepAddr(wTblPtr), EEP_SIZE_IGMP_TBL_ENTRY );
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
return OP_OK;
}
void PIIPMEEP_vDelEntry (UINT16 wTblPtr)
{
UINT32 dwBuf = 0;
PIEEP_vSetCfgIntoEep( (PUINT8)&dwBuf, PIIPMEEP_dwEntryEepAddr(wTblPtr), SIZE_OF_IP_ADDR );
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
void PIIPMEEP_vStatisTblInfo (SIGMPPageCfg *pSPageBuf)
{
UINT32 dwIpAddr = 0;
UINT16 u16Vid = 0, wTblPtr;
char acIpBuff[IP_STRING_LEN+1];
pSPageBuf->wValidEntryNum = 0;
// Add entry id into valid group list one by one
for (wTblPtr = 0; wTblPtr < SWITCH_IGMP_GRP_NUM; wTblPtr++) {
PIEEP_vGetCfgFromEep(PIIPMEEP_dwEntryEepAddr(wTblPtr), SIZE_OF_IP_ADDR, (PUINT8)&dwIpAddr);
if (dwIpAddr != 0) { //valid entry if (ip addr!=0) in eeprom
acIpBuff[0] = 0;
STR_vCvtIpValtoStr(acIpBuff, dwIpAddr);
STR_iStrcpy(pSPageBuf->astrGrpIpList+pSPageBuf->wValidEntryNum*(IP_STRING_LEN+1), acIpBuff);
PIEEP_vGetCfgFromEep(PIIPMEEP_dwEntryEepAddr(wTblPtr)+SIZE_OF_IP_ADDR, SIZE_OF_IGMP_VID, (PUINT8)&u16Vid);
pSPageBuf->awValidGrpIdList[pSPageBuf->wValidEntryNum] = u16Vid;
pSPageBuf->wValidEntryNum++;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -