📄 pigmrpmd.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: pigmrpmd.c
*
* Purpose: GMRP mode setting UI callback functions
*
* Author: Freeya Lin
*
* Date: Feb 26, 2004
*
* Functions:
*
* Revision History:
*
*/
#include "str.h"
#include "swgmrptb.h"
#include "swsys.h"
#include "piportmp.h"
#include "picfgmp.h"
#include "pidef.h"
#include "pigmrpmd.h"
#include "pigmrpep.h"
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
static void s_vSetEepDefault (SGMRPPageCfg *pSPageBuf, BOOL bWriteDefault);
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Export Variables --------------------------*/
/*--------------------- Export Functions --------------------------*/
// Get config from EEPROM and set into page buf
void PIGMRP_vInitPage (SGMRPPageCfg *pSPageBuf)
{
STR_pvMemset(pSPageBuf, 0, sizeof(SGMRPPageCfg));
PIGMRP_vGetGMRPMode(&pSPageBuf->byMode);
PIGMRPEP_vStatisTblInfo(pSPageBuf);
}
// Get config from EEPROM and set into hardware
void PIGMRP_vSetHwFromEep (SGMRPPageCfg *pSPageBuf)
{
UINT16 si;
SGMRPEntry sTblEntry; //TOCHECK
UINT8 abyMacBuff[MAC_ADDR_SIZE];
// Initialize page and set gmrp mode into hardware
PIGMRP_vInitPage(pSPageBuf);
SWGMRPTB_bGmrpSetEn(pSPageBuf->byMode);
//if gmrp disable, return
if (!pSPageBuf->byMode)
return;
// If gmrp enabled, add groups into hardware
for (si = 0; si < pSPageBuf->wValidEntryNum; si++) {
STR_pvMemset(&sTblEntry, 0, sizeof(SGMRPEntry)); //TOCHECK
abyMacBuff[0] = 0;
STR_vCvtMacStrtoVal(pSPageBuf->astrGrpMacList+si*(MAC_STRING_LEN+1), (char*)abyMacBuff);
PIGMRPEP_vGetEntry( PIGMRPEP_wSearchEntry(abyMacBuff, pSPageBuf->awValidGrpFidList[si]), &sTblEntry);
SWGMRPTB_bInsEntry(&sTblEntry, 0); //0 means not "overwrite", new insert
}
}
// Set default gmrp mode into EEPROM
void PIGMRP_vSetEepDefault (SGMRPPageCfg *pSPageBuf, BOOL bWriteDefault)
{
pSPageBuf->byMode = DEFAULT_GMRP_MODE;
s_vSetEepDefault(pSPageBuf, bWriteDefault);
}
void PIGMRP_vSetGMRPMode (SGMRPPageCfg *pSPageBuf)
{
UINT8 byOldMode;
UINT16 si;
UINT8 abyMacBuff[MAC_ADDR_SIZE];
// Clear gmrp table according to the original gmrp mode
PIGMRP_vGetGMRPMode(&byOldMode);
if (byOldMode != pSPageBuf->byMode) {
if (!pSPageBuf->byMode) { //disable : clean gmrp table
for (si = 0; si < pSPageBuf->wValidEntryNum; si++) {
abyMacBuff[0] = 0;
STR_vCvtMacStrtoVal(pSPageBuf->astrGrpMacList+si*(MAC_STRING_LEN+1), (char*)abyMacBuff);
SWGMRPTB_bDelEntry(abyMacBuff, pSPageBuf->awValidGrpFidList[si]);
}
}
s_vSetEepDefault(pSPageBuf, FALSE);
}
// Get config from EEPROM and set into hardware
PIGMRP_vSetHwFromEep(pSPageBuf);
}
// Set EEPROM default value of each gmrp mode: set gmrp mode and clear entry in eeprom for mac = 0
static void s_vSetEepDefault (SGMRPPageCfg *pSPageBuf, BOOL bWriteDefault)
{
// Set value to nvram software cache
// Set gmrp mode
STR_pvMemcpy(g_pu8NVRSwCache + (EEP_ADDR_PROV_GMRP_CFG - NVR_ADDR_DATA_AREA_START), &pSPageBuf->byMode, EEP_SIZE_GMRP_MODE);
// Set default value of new gmrp mode
STR_pvMemset(g_pu8NVRSwCache + (EEP_ADDR_GMRP_GROUP - NVR_ADDR_DATA_AREA_START), 0, EEP_SIZE_GMRP_TBL_ENTRY*SWITCH_GMRP_GRP_NUM);
if (!bWriteDefault) {
// Not write default operation
// Write cache data into flash
NVRAM_bWriteBlock(EEP_ADDR_PROV_GMRP_CFG, g_pu8NVRSwCache + (EEP_ADDR_PROV_GMRP_CFG - NVR_ADDR_DATA_AREA_START), EEP_SIZE_PROV_GMRP_CFG, FALSE);
// Update checksum and return
NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
}
}
void PIGMRP_vClrAllEepGrp (SGMRPPageCfg *pSPageBuf, BOOL bWriteDefault)
{
PIGMRP_vGetGMRPMode(&pSPageBuf->byMode);
s_vSetEepDefault(pSPageBuf, bWriteDefault);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -