⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 piipmmod.c

📁 vt6528芯片交换机API函数和文档运行程序
💻 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:    piipmmod.c
 *
 * Purpose: IGMP mode setting UI callback functions
 *
 * Author:  Freeya Lin
 *
 * Date:    Dec 17, 2003
 *
 * Functions:
 *
 * Revision History:
 *
 */


#include "str.h"
#include "swproto.h"
#include "swipmtb.h"
#include "swsys.h"
#include "piportmp.h"
#include "picfgmp.h"
#include "pidef.h"

#include "piipmmod.h"
#include "piipmeep.h"
/*---------------------  Static Definitions -------------------------*/

/*---------------------  Static Classes  ----------------------------*/

/*---------------------  Static Variables  --------------------------*/

/*---------------------  Static Functions  --------------------------*/
static void s_vSetEepDefault (SIGMPPageCfg *pSPageBuf, BOOL bWriteDefault);

/*---------------------  Static Macros  -----------------------------*/

/*---------------------  Export Variables  --------------------------*/

/*---------------------  Export Functions  --------------------------*/

// Get config from EEPROM and set into page buf
void PIIGMP_vInitPage (SIGMPPageCfg *pSPageBuf)
{
    STR_pvMemset(pSPageBuf, 0, sizeof(SIGMPPageCfg));

    PIIGMP_vGetIGMPMode(&pSPageBuf->byMode);
    PIIPMEEP_vStatisTblInfo(pSPageBuf);
}


// Get config from EEPROM and set into hardware
void PIIGMP_vSetHwFromEep (SIGMPPageCfg *pSPageBuf)
{
    UINT16          si;
    SIpmEntry    sIpmTblEntry;  //TOCHECK
    
    // Initialize page and set igmp mode into hardware
    PIIGMP_vInitPage(pSPageBuf);
    SWPROTO_bIgmpSetEn(pSPageBuf->byMode);

    //if igmp disable, return
    if (!pSPageBuf->byMode)
        return;

    // If igmp enabled, add groups into hardware
    for (si = 0; si < pSPageBuf->wValidEntryNum; si++) {
        STR_pvMemset(&sIpmTblEntry, 0, sizeof(SIpmEntry)); //TOCHECK
        PIIPMEEP_vGetEntry(
                PIIPMEEP_wSearchEntry(STR_dwCvtIpStrtoVal(pSPageBuf->astrGrpIpList+si*(IP_STRING_LEN+1)), pSPageBuf->awValidGrpIdList[si])
                , &sIpmTblEntry);
        SWIPMTB_bInsEntry(&sIpmTblEntry, 0);     //0 means not "overwrite", new insert
    }
}

// Set default igmp mode into EEPROM
void PIIGMP_vSetEepDefault (SIGMPPageCfg *pSPageBuf, BOOL bWriteDefault)
{    
    pSPageBuf->byMode = DEFAULT_IPM_MODE; 
    s_vSetEepDefault(pSPageBuf, bWriteDefault);
}


void PIIGMP_vSetIGMPMode (SIGMPPageCfg *pSPageBuf)
{
    UINT8   byOldMode;
    UINT16  si;
        
    // Clear igmp table if (igmp mode is changed) && (new igmp mode is DISABLE)
    PIIGMP_vGetIGMPMode(&byOldMode);
    if (byOldMode != pSPageBuf->byMode) {
        if (!pSPageBuf->byMode) {    //disable : clean igmp table
            for (si = 0; si < pSPageBuf->wValidEntryNum; si++) 
                SWIPMTB_bDelEntry(STR_dwCvtIpStrtoVal(pSPageBuf->astrGrpIpList+si*(IP_STRING_LEN+1)), pSPageBuf->awValidGrpIdList[si]);
        }
        s_vSetEepDefault(pSPageBuf, FALSE);
    }
    
    // Get config from EEPROM and set into hardware
    PIIGMP_vSetHwFromEep(pSPageBuf);
}


// Set EEPROM default value of each igmp mode: set igmp mode and clear ipm entry in eeprom for ip = 0
static void s_vSetEepDefault (SIGMPPageCfg *pSPageBuf, BOOL bWriteDefault)
{
    // Set value to nvram software cache
    // Set igmp mode
    STR_pvMemcpy(g_pu8NVRSwCache + (EEP_ADDR_PROV_IGMP_CFG - NVR_ADDR_DATA_AREA_START), &pSPageBuf->byMode, EEP_SIZE_IGMP_MODE);              
    // Set default value of new igmp mode   
    STR_pvMemset(g_pu8NVRSwCache + (EEP_ADDR_IGMP_GROUP - NVR_ADDR_DATA_AREA_START), 0, EEP_SIZE_IGMP_TBL_ENTRY*SWITCH_IGMP_GRP_NUM);
    if (!bWriteDefault) {
        // Not write default operation     
        // Write cache data into flash
        NVRAM_bWriteBlock(EEP_ADDR_PROV_IGMP_CFG, g_pu8NVRSwCache + (EEP_ADDR_PROV_IGMP_CFG - NVR_ADDR_DATA_AREA_START), EEP_SIZE_PROV_IGMP_CFG, FALSE);        
        // Update checksum and return
        NVRAM_vUpdateChecksum(EEP_SIZE_DATA_AREA);
    }
}

void PIIGMP_vClrAllEepGrp (SIGMPPageCfg *pSPageBuf, BOOL bWriteDefault) 
{
    PIIGMP_vGetIGMPMode(&pSPageBuf->byMode);
    s_vSetEepDefault(pSPageBuf, bWriteDefault);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -