swigmp.c

来自「VIA VT6524 8口网管交换机源码」· C语言 代码 · 共 117 行

C
117
字号
/*
 * 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:    swigmp.c
 *
 * Purpose: IGMP functions
 *
 * Author:  Tevin Chen
 *
 * Date:    Jan 08, 2002
 *
 * Functions:
 *
 * Revision History:
 *
 */


#if !defined(__SWREG_H__)
#include "swreg.h"
#endif
#if !defined(__SWITCH_H__)
#include "switch.h"
#endif
#if !defined(__SWIGMP_H__)
#include "swigmp.h"
#endif




/*---------------------  Static Definitions  ------------------------*/

/*---------------------  Static Types  ------------------------------*/

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

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

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

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

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




BOOL SWIGMP_bInit(void)
{
    UINT16 u16Tmp = 0;



    // Enable IGMP PDU Capture: TO CPU and Other Ports
    SWREG_vReadW(FWD_IP_CAPTURE_CFG, &u16Tmp);
    u16Tmp &= ~(PTN_FWD_IP_CAPTURE_IGMP|PTN_FWD_IP_CAPTURE_OSPF|PTN_FWD_IP_CAPTURE_PIM2);
    u16Tmp |= FWD_IP_CAPTURE_IGMP_FWD_CPU|FWD_IP_CAPTURE_OSPF_FWD_CPU|FWD_IP_CAPTURE_PIM2_FWD_CPU;
    SWREG_vWriteW(FWD_IP_CAPTURE_CFG, u16Tmp);

    // Enable ip multicast snooping
    SWIGMP_bSetIgmpEbl(1);

    // Clear igmp table
    //SWIGMP_bClearIgmpTbl();

    return TRUE;
}


BOOL SWIGMP_bSetIgmpEbl(BOOL bIgmpEbl)
{
    if (bIgmpEbl) {
        SWREG_vBitsOn(FWD_IP_MCAST_CFG, PTN_FWD_IP_MCAST_ENABLE);
        SWREG_vBitsOn(FWD_IP_CAPTURE_CFG, PTN_FWD_IP_CAPTURE_IGMP);
        // Disable ip mcst dpm
        SWREG_vWriteDW(FWD_IP_FLOOD_DPM, 0);

    }
    else {
        SWREG_vBitsOff(FWD_IP_MCAST_CFG, PTN_FWD_IP_MCAST_ENABLE);
        SWREG_vBitsOff(FWD_IP_CAPTURE_CFG, PTN_FWD_IP_CAPTURE_IGMP);
        // Disable ip mcst dpm
        SWREG_vWriteDW(FWD_IP_FLOOD_DPM, 0x03FFFFFFUL);
    }

    return TRUE;
}


BOOL SWIGMP_bGetIgmpEbl(BOOL * pbIgmpEbl)
{
    unsigned char byTmp = 0;


    SWREG_vReadB(FWD_IP_MCAST_CFG, &byTmp);
    *pbIgmpEbl = (byTmp & PTN_FWD_IP_MCAST_ENABLE) ? 1 : 0;

    return TRUE;
}

⌨️ 快捷键说明

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