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

📄 piipmgrp.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:    piipmgrp.c
 *
 * Purpose: IGMP group setting UI callback functions
 *
 * Author:  Freeya Lin
 *
 * Date:    Dec 18, 2003
 *
 * Functions:
 *
 * Revision History:
 *
 */


#include "swreg.h"
#if !defined(__SWCFG_H__)
#include "swcfg.h"
#endif
#include "str.h"
#include "piportmp.h"
#include "picfgmp.h"
#include "swmsg.h"
#include "swsys.h"

#include "pivlan.h"
#include "piipmeep.h"
#include "piipmgrp.h"

/*---------------------  EEPROM Content Statement  ------------------*/
/*---------------------  Static Definitions -------------------------*/

// Definitions to reduce statement length
#define pSCurGrp            (&pSPageBuf->SCurGrp)

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

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

/*---------------------  Static Functions  --------------------------*/

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

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

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

// Get a igmp group
UINT8 PIIGMP_byGetGrp (SIGMPPageCfg *pSPageBuf)
{
    UINT16          wTblPtr;
    SIpmEntry    sIpmTblEntry;     //TOCHECK

    STR_pvMemset(&sIpmTblEntry, 0, sizeof(SIpmEntry)); //TOCHECK

    // If group id not exist, return error code
    wTblPtr = PIIPMEEP_wSearchEntry(STR_dwCvtIpStrtoVal(pSCurGrp->szIp), pSCurGrp->u16Vid);
    if (wTblPtr == UINT16_MAX)
        return IGMP_OP_GRP_NOT_EXIST;

    // Get entry from EEPROM and transfer into config buffer format
    PIIPMEEP_vGetEntry(wTblPtr, &sIpmTblEntry);
    PIIGMP_vTrfrEepOrHWtoUI(pSPageBuf, &sIpmTblEntry);
    
    return OP_OK;
}


// Insert a igmp group
UINT8 PIIGMP_byInsGrp (SIGMPPageCfg *pSPageBuf)
{
    SIpmEntry sIpmTblEntry;    //TOCHECK

    STR_pvMemset(&sIpmTblEntry, 0, sizeof(SIpmEntry)); //TOCHECK

    // If no empty group, return error code
    if (pSPageBuf->wValidEntryNum == SWITCH_IGMP_GRP_NUM )
        return IGMP_OP_NO_EMPTY_GRP;

    // If VID invalid, return error code
    if (pSCurGrp->u16Vid > VLAN_MAX_VALID_VID_3077)
        return VLAN_OP_VID_INVALID;

    // If group already exist, return error code
    if (PIIPMEEP_wSearchEntry(STR_dwCvtIpStrtoVal(pSCurGrp->szIp), pSCurGrp->u16Vid) != UINT16_MAX )
        return IGMP_OP_GRP_EXIST;


    //need to trsfer logic portmsk to physical portmsk
    PIIGMP_vTrfrUItoEepOrHW(pSPageBuf, &sIpmTblEntry);
    //set into HW
    SWIPMTB_bInsEntry(&sIpmTblEntry, 0);   //0 means not "overwrite", new insert
    //set into Eep
    PIIPMEEP_byInsEntry(&sIpmTblEntry);


    return OP_OK;
}


// Edit a igmp group
UINT8 PIIGMP_byEditGrp (SIGMPPageCfg *pSPageBuf)
{
    UINT32          dwIpAddr = 0;
    UINT16          wTblPtr;
    SIpmEntry    sIpmTblEntry; //TOCHECK
    
    STR_pvMemset(&sIpmTblEntry, 0, sizeof(SIpmEntry)); //TOCHECK
    
    // If group id not exist, return error code
    dwIpAddr = STR_dwCvtIpStrtoVal(pSCurGrp->szIp);
    wTblPtr = PIIPMEEP_wSearchEntry(dwIpAddr, pSCurGrp->u16Vid);
    if (wTblPtr == UINT16_MAX)
        return IGMP_OP_GRP_NOT_EXIST;

    SWIPMTB_bDelEntry(dwIpAddr, pSCurGrp->u16Vid);    
    PIIPMEEP_vDelEntry(wTblPtr);

    PIIGMP_vTrfrUItoEepOrHW(pSPageBuf, &sIpmTblEntry);
    //set into HW
    SWIPMTB_bInsEntry(&sIpmTblEntry, 0); //0 means not "overwrite", new insert
    //set into Eep
    PIIPMEEP_byInsEntry(&sIpmTblEntry);
    
    return OP_OK;
}

//transfer ui(logic portmsk, Ip string) to HW/Eeprom(physical portmsk, dwIpAddr)
void PIIGMP_vTrfrUItoEepOrHW(SIGMPPageCfg *pSPageBuf, SIpmEntry *pSIpmTblEntry) //TOCHECK
{
    pSIpmTblEntry->dwIpAddr = STR_dwCvtIpStrtoVal(pSCurGrp->szIp);
    pSIpmTblEntry->u16Vid = pSCurGrp->u16Vid;
    pSIpmTblEntry->bStatic = pSCurGrp->bStatic;
    //pSIpmTblEntry->bCpu = pSCurGrp->bCpu; //TOCHECK
    //pSIpmTblEntry->bDp = pSCurGrp->bDp;   //TOCHECK
    //from logic portmsk to physical portmsk
    PICFGMP_v1bLogPtrMskTo4BPhyMsk(pSCurGrp->abyMbrMsk);    

    STR_pvMemcpy( (PUINT8)(&pSIpmTblEntry->u32MbrPortMsk)+BYTE_OFFSET_IN_DWORD_OF_CFGMASK,
                pSCurGrp->abyMbrMsk, BYTE_NUM_OF_CFGBUF_BIT_MASK );
}

//transfer HW/Eeprom(physical portmsk, dwIpAddr) to ui(logic portmsk, Ip string)
void PIIGMP_vTrfrEepOrHWtoUI(SIGMPPageCfg *pSPageBuf, SIpmEntry *pSIpmTblEntry) //TOCHECK
{
    STR_vCvtIpValtoStr(pSCurGrp->szIp, pSIpmTblEntry->dwIpAddr);
    pSCurGrp->u16Vid = pSIpmTblEntry->u16Vid;
    pSCurGrp->bStatic = pSIpmTblEntry->bStatic;
    //pSCurGrp->bCpu = pSIpmTblEntry->bCpu; //TOCHECK
    //pSCurGrp->bDp = pSIpmTblEntry->bDp; //TOCHECK
    //from physical portmsk to logic portmsk
    STR_pvMemcpy( pSCurGrp->abyMbrMsk, 
                (PUINT8)(&pSIpmTblEntry->u32MbrPortMsk)+BYTE_OFFSET_IN_DWORD_OF_CFGMASK, BYTE_NUM_OF_CFGBUF_BIT_MASK );

    PICFGMP_v4BPhyMskTo1bLogPtrMsk(pSCurGrp->abyMbrMsk);
}


// Delete a igmp group
UINT8 PIIGMP_byDelGrp (SIGMPPageCfg *pSPageBuf)
{
    UINT16          wTblPtr;
    UINT32          dwIpAddr = 0;
        
    // If group id not exist, return error code
    dwIpAddr = STR_dwCvtIpStrtoVal(pSCurGrp->szIp);
    wTblPtr = PIIPMEEP_wSearchEntry(dwIpAddr, pSCurGrp->u16Vid);
    if (wTblPtr == UINT16_MAX)
        return IGMP_OP_GRP_NOT_EXIST;

    //clear entry in hw table
    if (!SWIPMTB_bDelEntry(dwIpAddr, pSCurGrp->u16Vid))
        return IGMP_OP_GRP_NOT_EXIST;
    
    // Delete group from EEPROM and return
    PIIPMEEP_vDelEntry(wTblPtr);
    PIIPMEEP_vStatisTblInfo(pSPageBuf);
    
    return OP_OK;
}

⌨️ 快捷键说明

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