RegisterProtocol Sample

[This is preliminary documentation and subject to change.]

DWORD
APIENTRY
RegisterProtocol(
    IN OUT PMPR_ROUTING_CHARACTERISTICS pRoutingChar,
    IN OUT PMPR_SERVICE_CHARACTERISTICS pServiceChar
    )
/*++
Routine Description
    This is the first function called by the IP Router Manager.  
    The Router Manager tells the routing protocol it version and 
    capabilities. It also tells the our DLL, the ID of the protocol
    it expects us to register.  This allows one DLL to support
    multiple routing protocols.
    We return the functionality we support and a pointer to
    our functions.
    
Arguments
  

Return Value
    NO_ERROR

--*/
{
    //
    // The Router Manager should be calling us to register
    // our protocol.
    // The Router Manager must be atleast the version we are
    // compiled with.
    // The Router Manager must support routing and demand update.
    //

    if(pRoutingChar->dwProtocolId != SAMPLE_PROTOCOL_ROUTE_ID)
    {
        return ERROR_NOT_SUPPORTED;
    }

    if(pRoutingChar->dwVersion < MS_ROUTER_VERSION)
    {
        return ERROR_NOT_SUPPORTED;
    }

    if(pRoutingChar->fSupportedFunctionality != (ROUTING |
                                             DEMAND_UPDATE_ROUTES))
    {
        return ERROR_NOT_SUPPORTED;
    }

    //
    // Since we are not a service advertiser (an IPX thing)
    //

    //
    // We setup our characteristics and function pointers
    //

    pServiceChar->fSupportedFunctionality = 0;

    pRoutingChar->fSupportedFunctionality = (ROUTING |
                                             DEMAND_UPDATE_ROUTES);

    pRoutingChar->pfnStartProtocol    = StartProtocol;
    pRoutingChar->pfnStopProtocol     = StopProtocol;
    pRoutingChar->pfnAddInterface     = AddInterface;
    pRoutingChar->pfnDeleteInterface  = DeleteInterface;
    pRoutingChar->pfnGetEventMessage  = GetEventMessage;
    pRoutingChar->pfnGetInterfaceInfo = GetInterfaceConfigInfo;
    pRoutingChar->pfnSetInterfaceInfo = SetInterfaceConfigInfo;
    pRoutingChar->pfnBindInterface    = BindInterface;
    pRoutingChar->pfnUnbindInterface  = UnBindInterface;
    pRoutingChar->pfnEnableInterface  = EnableInterface;
    pRoutingChar->pfnDisableInterface = DisableInterface;
    pRoutingChar->pfnGetGlobalInfo    = GetGlobalInfo;
    pRoutingChar->pfnSetGlobalInfo    = SetGlobalInfo;
    pRoutingChar->pfnMibCreateEntry   = MibCreate;
    pRoutingChar->pfnMibDeleteEntry   = MibDelete;
    pRoutingChar->pfnMibGetEntry      = MibGet;
    pRoutingChar->pfnMibSetEntry      = MibSet;
    pRoutingChar->pfnMibGetFirstEntry = MibGetFirst;
    pRoutingChar->pfnMibGetNextEntry  = MibGetNext;
    pRoutingChar->pfnUpdateRoutes     = DoUpdateRoutes;

    return NO_ERROR;
}