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

📄 rmapi.c

📁 xorp源码hg
💻 C
📖 第 1 页 / 共 2 页
字号:
    return dwErr;
}


/* XXX: Not sure if this is really needed */
DWORD
WINAPI
MibSet (
    ULONG 	InputDataSize,
    PVOID	InputData
    )
/*++

Routine Description
    This function sets XORPRTM's global or interface configuration.

Arguments
    InputData           Relevant input, struct XORPRTM_MIB_SET_INPUT_DATA
    InputDataSize       Size of the input
    
Return Value
    NO_ERROR            success
    Error Code          o/w
    
--*/    
{
    DWORD dwErr = NO_ERROR;

    TRACE2(ENTER, "Entering MibSet: %u 0x%08x",
           InputDataSize, InputData);

    do                          /* breakout loop */
    {
        /* validate parameters */
        if ((!InputData) ||
            (InputDataSize < sizeof(XORPRTM_MIB_SET_INPUT_DATA)))
        {
            dwErr = ERROR_INVALID_PARAMETER;
            break;
        }

        dwErr = MM_MibSet((PXORPRTM_MIB_SET_INPUT_DATA) InputData);

    } while(FALSE);
    
    TRACE1(LEAVE, "Leaving  MibSet: %u", dwErr);

    return dwErr;
}


/* XXX: Not sure if this is really needed */

DWORD
WINAPI
MibGet (
         ULONG	InputDataSize,
         PVOID	InputData,
     PULONG	OutputDataSize,
        PVOID	OutputData
    )
/*++

Routine Description
    This function retrieves one of...
    . global configuration
    . interface configuration
    . global stats
    . interface stats
    . interface binding

    Called by an admin (SNMP) utility.  It actually passes through the IP
    Router Manager, but all that does is demux the call to the desired
    routing protocol.

Arguments
    InputData           Relevant input, struct XORPRTM_MIB_GET_INPUT_DATA
    InputDataSize       Size of the input
    OutputData          Buffer for struct XORPRTM_MIB_GET_OUTPUT_DATA
    OutputDataSize       size of output buffer received
                        size of output buffer required
                        
Return Value
    NO_ERROR            success
    Error Code          o/w
    
--*/    
{
    DWORD dwErr = NO_ERROR;

    TRACE4(ENTER, "Entering MibGet: %u 0x%08x 0x%08x 0x%08x",
           InputDataSize, InputData, OutputDataSize, OutputData);

    do                          /* breakout loop */
    {
        /* validate parameters */
        if ((!InputData) ||
            (InputDataSize < sizeof(XORPRTM_MIB_GET_INPUT_DATA)) ||
            (!OutputDataSize))
        {
            dwErr = ERROR_INVALID_PARAMETER;
            break;
        }

        dwErr = MM_MibGet((PXORPRTM_MIB_GET_INPUT_DATA) InputData,
                          (PXORPRTM_MIB_GET_OUTPUT_DATA) OutputData,
                          OutputDataSize,
                          GET_EXACT);
        
    } while(FALSE);

    TRACE1(LEAVE, "Leaving  MibGet: %u", dwErr);

    return dwErr;
}


/* XXX: Not sure if this is really needed */

DWORD
WINAPI
MibGetFirst (
         ULONG	InputDataSize,
         PVOID	InputData,
     PULONG  OutputDataSize,
        PVOID   OutputData
    )
/*++

Routine Description
    This function retrieves one of...
    . global configuration
    . interface configuration
    . global stats
    . interface stats
    . interface binding

    It differs from MibGet() in that it always returns the FIRST entry in
    whichever table is being queried.  There is only one entry in the
    global configuration and global stats tables, but the interface
    configuration, interface stats, and interface binding tables are sorted
    by IP address; this function returns the first entry from these.

Arguments
    InputData           Relevant input, struct XORPRTM_MIB_GET_INPUT_DATA
    InputDataSize       Size of the input
    OutputData          Buffer for struct XORPRTM_MIB_GET_OUTPUT_DATA
    OutputDataSize       size of output buffer received
                        size of output buffer required
                        
Return Value
    NO_ERROR            success
    Error Code          o/w
    
--*/    
{
    DWORD dwErr = NO_ERROR;

    TRACE4(ENTER, "Entering MibGetFirst: %u 0x%08x 0x%08x 0x%08x",
           InputDataSize, InputData, OutputDataSize, OutputData);

    do                          /* breakout loop */
    {
        /* validate parameters */
        if ((!InputData) ||
            (InputDataSize < sizeof(XORPRTM_MIB_GET_INPUT_DATA)) ||
            (!OutputDataSize))
        {
            dwErr = ERROR_INVALID_PARAMETER;
            break;
        }

        dwErr = MM_MibGet((PXORPRTM_MIB_GET_INPUT_DATA) InputData,
                          (PXORPRTM_MIB_GET_OUTPUT_DATA) OutputData,
                          OutputDataSize,
                          GET_FIRST);
        
    } while(FALSE);

    TRACE1(LEAVE, "Leaving  MibGetFirst: %u", dwErr);

    return dwErr;
}


/* XXX: Not sure if this is really needed */

DWORD
WINAPI
MibGetNext (
         ULONG   InputDataSize,
         PVOID	InputData,
     PULONG  OutputDataSize,
        PVOID	OutputData
    )
/*++

Routine Description
    This function retrieves one of...
    . global configuration
    . interface configuration
    . global stats
    . interface stats
    . interface binding

    It differs from both MibGet() and MibGetFirst() in that it returns the
    entry AFTER the one specified in the indicated table.  Thus, in the
    interface configuration, interface stats, and interface binding tables,
    this function supplies the entry after the one with the input address.

    If there are no more entries in the table being queried we return
    ERROR_NO_MORE_ITEMS.  Unlike SNMP we don't walk to the next table.
    This does not take away any functionality since the NT SNMP agent
    will try the next variable (having ID one greater than the ID passed
    in) automatically on getting this error.

Arguments
    InputData           Relevant input, struct XORPRTM_MIB_GET_INPUT_DATA
    InputDataSize       Size of the input
    OutputData          Buffer for struct XORPRTM_MIB_GET_OUTPUT_DATA
    OutputDataSize       size of output buffer received
                        size of output buffer required
                        
Return Value
    NO_ERROR            success
    Error Code          o/w
    
--*/    
{
    DWORD                           dwErr   = NO_ERROR;

    TRACE4(ENTER, "Entering MibGetFirst: %u 0x%08x 0x%08x 0x%08x",
           InputDataSize, InputData, OutputDataSize, OutputData);

    do                          /* breakout loop */
    {
        /* validate parameters */
        if ((!InputData) ||
            (InputDataSize < sizeof(XORPRTM_MIB_GET_INPUT_DATA)) ||
            (!OutputDataSize))
        {
            dwErr = ERROR_INVALID_PARAMETER;
            break;
        }

        dwErr = MM_MibGet((PXORPRTM_MIB_GET_INPUT_DATA) InputData,
                          (PXORPRTM_MIB_GET_OUTPUT_DATA) OutputData,
                          OutputDataSize,
                          GET_NEXT);

    } while(FALSE);

    TRACE1(LEAVE, "Leaving  MibGetNext: %u", dwErr);

    return dwErr;
}



DWORD
WINAPI
MibSetTrapInfo (
     HANDLE  Event,
     ULONG   InputDataSize,
     PVOID	InputData,
    PULONG	OutputDataSize,
    PVOID	OutputData
    )
{
    DWORD dwErr = ERROR_CAN_NOT_COMPLETE;

    TRACE0(ENTER, "Entering MibSetTrapInfo");
    TRACE1(LEAVE, "Leaving  MibSetTrapInfo: %u", dwErr);

    return dwErr;
}



DWORD
WINAPI
MibGetTrapInfo (
     ULONG	InputDataSize,
     PVOID	InputData,
    PULONG  OutputDataSize,
    PVOID	OutputData
    )
{
    DWORD dwErr = ERROR_CAN_NOT_COMPLETE;

    TRACE0(ENTER, "Entering MibGetTrapInfo");
    TRACE1(LEAVE, "Leaving  MibGetTrapInfo: %u", dwErr);

    return dwErr;
}



/*------------------------------------------------------------------------ */

/* This is where the action is. First function called after dll load. */

#define RF_FUNC_FLAGS (RF_ROUTING | RF_ADD_ALL_INTERFACES)

DWORD
APIENTRY
RegisterProtocol(
    PMPR_ROUTING_CHARACTERISTICS pRoutingChar,
    PMPR_SERVICE_CHARACTERISTICS pServiceChar
    )
{
    DWORD   dwErr = NO_ERROR;
    
    TRACE0(ENTER, "Entering RegisterProtocol");

    do {
        if (pRoutingChar->dwProtocolId != XORPRTM_PROTOCOL_ID) {
            dwErr = ERROR_NOT_SUPPORTED;
            break;
        }


	TRACE1(CONFIGURATION, "fSupportedFunctionality is: %08lx", 
		pRoutingChar->fSupportedFunctionality);

        if  ((pRoutingChar->fSupportedFunctionality & RF_FUNC_FLAGS) !=
	     RF_FUNC_FLAGS) {
            dwErr = ERROR_NOT_SUPPORTED;
            break;
        }
    
        pRoutingChar->fSupportedFunctionality = RF_FUNC_FLAGS;
        pServiceChar->fSupportedFunctionality = 0;

        pRoutingChar->pfnStartProtocol      = StartProtocol;
        pRoutingChar->pfnStartComplete      = StartComplete;
        pRoutingChar->pfnStopProtocol       = StopProtocol;
        pRoutingChar->pfnGetGlobalInfo      = GetGlobalInfo;
        pRoutingChar->pfnSetGlobalInfo      = SetGlobalInfo;
        pRoutingChar->pfnQueryPower         = NULL;
        pRoutingChar->pfnSetPower           = NULL;

        pRoutingChar->pfnAddInterface       = AddInterface;
        pRoutingChar->pfnDeleteInterface    = DeleteInterface;
        pRoutingChar->pfnInterfaceStatus    = InterfaceStatus;
        pRoutingChar->pfnGetInterfaceInfo   = GetInterfaceConfigInfo;
        pRoutingChar->pfnSetInterfaceInfo   = SetInterfaceConfigInfo;

        pRoutingChar->pfnGetEventMessage    = GetEventMessage;

        pRoutingChar->pfnUpdateRoutes       = DoUpdateRoutes;

        pRoutingChar->pfnConnectClient      = NULL;
        pRoutingChar->pfnDisconnectClient   = NULL;

        pRoutingChar->pfnGetNeighbors       = NULL;
        pRoutingChar->pfnGetMfeStatus       = NULL; /* XXX multicast */

        pRoutingChar->pfnMibCreateEntry     = MibCreate;
        pRoutingChar->pfnMibDeleteEntry     = MibDelete;
        pRoutingChar->pfnMibGetEntry        = MibGet;
        pRoutingChar->pfnMibSetEntry        = MibSet;
        pRoutingChar->pfnMibGetFirstEntry   = MibGetFirst;
        pRoutingChar->pfnMibGetNextEntry    = MibGetNext;
        pRoutingChar->pfnMibSetTrapInfo     = MibSetTrapInfo;
        pRoutingChar->pfnMibGetTrapInfo     = MibGetTrapInfo;
    } while (FALSE);

    TRACE1(LEAVE, "Leaving RegisterProtocol: %u", dwErr);

    return dwErr;
}

⌨️ 快捷键说明

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