' ########################################################################################
' Microsoft Windows
' File: Mgm.inc
' Contents: Data structures and entry points into MGM
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_Mgm_PBI)
#DEFINE PBX_Mgm_PBI
%EQUATE `MGM_INC = 1
#INCLUDE ONCE "Legacy/System/ipmib.inc"
'//----------------------------------------------------------------------------
'//
'// typedefs for callback interface
'//
'//----------------------------------------------------------------------------
'//
'// MGM_IF_ENTRY
'//
'// structure used in MGM_CREATION_ALERT_CALLBACK. In the process of
'// creating an MFE the routing protocol needs to enable/disable
'// multicast forwarding on each interface
'//
' // Size = 16 bytes
TYPE MGM_IF_ENTRY DWORD
 dwIfIndex AS DWORD
 dwIfNextHopAddr AS DWORD
 bIGMP AS LONG
 bIsEnabled AS LONG
END TYPE
'//----------------------------------------------------------------------------
'//
'// Callbacks into routing protocols
'//
'//----------------------------------------------------------------------------
'//
'// call into a routing protocol to perform RPF check.
'//
'// Invoked in the context of MgmNewPacketReceived into protocol component
'// owning the incoming interface.
'//
'typedef DWORD
'(*PMGM_RPF_CALLBACK)(
' IN DWORD dwSourceAddr,
' IN DWORD dwSourceMask,
' IN DWORD dwGroupAddr,
' IN DWORD dwGroupMask,
' IN OUT PDWORD pdwInIfIndex,
' IN OUT PDWORD pdwInIfNextHopAddr,
' IN OUT PDWORD pdwUpStreamNbr,
' IN DWORD dwHdrSize,
' IN PBYTE pbPacketHdr,
' IN OUT PBYTE pbRoute
');
'FUNCTION MGM_RPF_CALLBACK ( ' BYVAL dwSourceAddr AS DWORD
' , BYVAL dwSourceMask AS DWORD
' , BYVAL dwGroupAddr AS DWORD
' , BYVAL dwGroupMask AS DWORD
' , BYREF pdwInIfIndex AS DWORD
' , BYREF pdwInIfNextHopAddr AS DWORD
' , BYREF pdwUpStreamNbr AS DWORD
' , BYVAL dwHdrSize AS DWORD
' , BYVAL pbPacketHdr AS BYTE PTR
' , BYVAL pbRoute AS BYTE PTR
' ) AS DWORD
'END FUNCTION
'//
'// call into a routing protocol to determine the subset of interfaces
'// (owned by the routing protocol) on which a multicast packet from a
'// "new" source should be forwarded.
'//
'// Invoked in the context of MgmNewPacketReceived into all
'// routing protocols that have outgoing interfaces for this source.
'//
'typedef
'DWORD (*PMGM_CREATION_ALERT_CALLBACK)(
' IN DWORD dwSourceAddr,
' IN DWORD dwSourceMask,
' IN DWORD dwGroupAddr,
' IN DWORD dwGroupMask,
' IN DWORD dwInIfIndex,
' IN DWORD dwInIfNextHopAddr,
' IN DWORD dwIfCount,
' IN OUT PMGM_IF_ENTRY pmieOutIfList
');
'FUNCTION MGM_CREATION_ALERT_CALLBACK ( ' BYVAL dwSourceAddr AS DWORD
' , BYVAL dwSourceMask AS DWORD
' , BYVAL dwGroupAddr AS DWORD
' , BYVAL dwGroupMask AS DWORD
' , BYVAL dwInIfIndex AS DWORD
' , BYVAL dwInIfNextHopAddr AS DWORD
' , BYVAL dwIfCount AS DWORD
' , BYREF pmieOutIfList AS MGM_IF_ENTRY
' ) AS DWORD
'END FUNCTION
'//
'// call into routing protocol to notify protocol that an interface has
'// been deleted from the outgoing interface list of a group entry / MFE
'//
'// invoked in the context of MgmDeleteMembershipEntry()
'//
'typedef
'DWORD (*PMGM_PRUNE_ALERT_CALLBACK)(
' IN DWORD dwSourceAddr,
' IN DWORD dwSourceMask,
' IN DWORD dwGroupAddr,
' IN DWORD dwGroupMask,
' IN DWORD dwIfIndex,
' IN DWORD dwIfNextHopAddr,
' IN BOOL bMemberDelete,
' IN OUT PDWORD pdwTimeout
');
'FUNCTION MGM_PRUNE_ALERT_CALLBACK ( ' BYVAL dwSourceAddr AS DWORD
' , BYVAL dwSourceMask AS DWORD
' , BYVAL dwGroupAddr AS DWORD
' , BYVAL dwGroupMask AS DWORD
' , BYVAL dwIfIndex AS DWORD
' , BYVAL dwIfNextHopAddr AS DWORD
' , BYVAL bMemberDelete AS LONG
' , BYREF pdwTimeout AS DWORD
' ) AS DWORD
'END FUNCTION
'//
'// call into routing protocol to notify protocol that an interface has
'// been added to the outgoing interface list of a group entry / MFE
'//
'// invoked in the context of MgmAddMembershipEntry()
'//
'typedef
'DWORD (*PMGM_JOIN_ALERT_CALLBACK)(
' IN DWORD dwSourceAddr,
' IN DWORD dwSourceMask,
' IN DWORD dwGroupAddr,
' IN DWORD dwGroupMask,
' IN BOOL bMemberUpdate
');
'FUNCTION MGM_JOIN_ALERT_CALLBACK ( ' BYVAL dwSourceAddr AS DWORD
' , BYVAL dwSourceMask AS DWORD
' , BYVAL dwGroupAddr AS DWORD
' , BYVAL dwGroupMask AS DWORD
' , BYVAL bMemberUpdate AS LONG
' ) AS DWORD
'END FUNCTION
'//
'// call into routing protocol to notify protocol that a packet
'// has been received from a (source, group) on a wrong interface
'//
'typedef
'DWORD (*PMGM_WRONG_IF_CALLBACK)(
' IN DWORD dwSourceAddr,
' IN DWORD dwGroupAddr,
' IN DWORD dwIfIndex,
' IN DWORD dwIfNextHopAddr,
' IN DWORD dwHdrSize,
' IN PBYTE pbPacketHdr
');
'FUNCTION MGM_WRONG_IF_CALLBACK ( ' BYVAL dwSourceAddr AS DWORD
' , BYVAL dwGroupAddr AS DWORD
' , BYVAL dwIfIndex AS DWORD
' , BYVAL dwIfNextHopAddr AS DWORD
' , BYVAL dwHdrSize AS DWORD
' , BYVAL pbPacketHdr AS BYTE PTR
' ) AS DWORD
'END FUNCTION
'//
'// call into routing protocol to notify protocol that IGMP needs to add
'// an interface to the outgoing interface list of a group entry / MFE
'//
'// invoked in the context of MgmLocalGroupJoin()
'//
'typedef DWORD
'(*PMGM_LOCAL_JOIN_CALLBACK) (
' IN DWORD dwSourceAddr,
' IN DWORD dwSourceMask,
' IN DWORD dwGroupAddr,
' IN DWORD dwGroupMask,
' IN DWORD dwIfIndex,
' IN DWORD dwIfNextHopAddr
');
'FUNCTION MGM_LOCAL_JOIN_CALLBACK ( ' BYVAL dwSourceAddr AS DWORD
' , BYVAL dwSourceMask AS DWORD
' , BYVAL dwGroupAddr AS DWORD
' , BYVAL dwGroupMask AS DWORD
' , BYVAL dwIfIndex AS DWORD
' , BYVAL dwIfNextHopAddr AS DWORD
' ) AS DWORD
'END FUNCTION
'//
'// call into routing protocol to notify protocol that IGMP needs to
'// delete an interface to the outgoing interface list of a group
'// entry / MFE
'//
'// invoked in the context of MgmLocalGroupJoin()
'//
'typedef DWORD
'(*PMGM_LOCAL_LEAVE_CALLBACK) (
' IN DWORD dwSourceAddr,
' IN DWORD dwSourceMask,
' IN DWORD dwGroupAddr,
' IN DWORD dwGroupMask,
' IN DWORD dwIfIndex,
' IN DWORD dwIfNextHopAddr
');
'FUNCTION MGM_LOCAL_LEAVE_CALLBACK ( ' BYVAL dwSourceAddr AS DWORD
' , BYVAL dwSourceMask AS DWORD
' , BYVAL dwGroupAddr AS DWORD
' , BYVAL dwGroupMask AS DWORD
' , BYVAL dwIfIndex AS DWORD
' , BYVAL dwIfNextHopAddr AS DWORD
' ) AS DWORD
'END FUNCTION
'//
'// call into IGMP to notify it that a protocol is taking or
'// releasing ownership of an interface that has IGMP enabled on it.
'//
'// When this callback is invoked IGMP should stop adding/deleting
'// group memberships on the specified interface.
'//
'typedef DWORD
'(*PMGM_DISABLE_IGMP_CALLBACK) (
' IN DWORD dwIfIndex,
' IN DWORD dwIfNextHopAddr
');
'FUNCTION MGM_DISABLE_IGMP_CALLBACK ( ' BYVAL dwIfIndex AS DWORD
' , BYVAL dwIfNextHopAddr AS DWORD
' ) AS DWORD
'END FUNCTION
'//
'// call into IGMP to notify it that a protocol has finished taking
'// or releasing ownership of an interface.
'//
'// When this callback is invoked IGMP should add all its group memberships
'// on the interface.
'//
'typedef DWORD
'(*PMGM_ENABLE_IGMP_CALLBACK) (
' IN DWORD dwIfIndex,
' IN DWORD dwIfNextHopAddr
');
'FUNCTION MGM_ENABLE_IGMP_CALLBACK ( ' BYVAL dwIfIndex AS DWORD
' , BYVAL dwIfNextHopAddr AS DWORD
' ) AS DWORD
'END FUNCTION
'//----------------------------------------------------------------------------
'//
'// typedefs for MGM API interface
'//
'//----------------------------------------------------------------------------
'//
'// ROUTING_PROTOCOL_CONFIG
'//
'// routing protocol configuration that is passed to MGM at registration.
'//
'//
'// Callbacks into routing protocols
'//
' // Size = 40 bytes
TYPE ROUTING_PROTOCOL_CONFIG DWORD
 dwCallbackFlags AS DWORD
 pfnRpfCallback AS DWORD ' PMGM_RPF_CALLBACK
 pfnCreationAlertCallback AS DWORD ' PMGM_CREATION_ALERT_CALLBACK
 pfnPruneAlertCallback AS DWORD ' PMGM_PRUNE_ALERT_CALLBACK
 pfnJoinAlertCallback AS DWORD ' PMGM_JOIN_ALERT_CALLBACK
 pfnWrongIfCallback AS DWORD ' PMGM_WRONG_IF_CALLBACK
 ' // callbacks into Routing protocols
 pfnLocalJoinCallback AS DWORD ' PMGM_LOCAL_JOIN_CALLBACK
 pfnLocalLeaveCallback AS DWORD ' PMGM_LOCAL_LEAVE_CALLBACK
 ' // callbacks into IGMP
 pfnDisableIgmpCallback AS DWORD ' PMGM_DISABLE_IGMP_CALLBACK
 pfnEnableIgmpCallback AS DWORD ' PMGM_ENABLE_IGMP_CALLBACK
END TYPE
'//
'// MGM_ENUM_TYPES
'//
'// Enumeration types to be specified when the
'//
' enum MGM_ENUM_TYPES
%EQUATE `ANY_SOURCE = 0 ' // enumerate group entries with
 ' // atleast one source
%EQUATE `ALL_SOURCES = 1 ' // enumerate all source entries
 ' // for a group entry
'//
'// SOURCE_GROUP_ENTRY
'//
'// (S, G) entry that is returned by the group entry enumeration API.
'//
' // Size = 16 bytes
TYPE SOURCE_GROUP_ENTRY DWORD
 dwSourceAddr AS DWORD
 dwSourceMask AS DWORD
 dwGroupAddr AS DWORD
 dwGroupMask AS DWORD
END TYPE
'//----------------------------------------------------------------------------
'//
'// Entry points into MGM.
'//
'//----------------------------------------------------------------------------
'//============================================================================
'// Routing protocol registration / de-registration API
'//============================================================================
DECLARE FUNCTION MgmRegisterMProtocol LIB "rtm.dll" ALIAS "MgmRegisterMProtocol" ( BYREF prpiInfo AS ROUTING_PROTOCOL_CONFIG , BYVAL dwProtocolId AS QUAD , BYVAL dwComponentId AS QUAD , BYREF phProtocol AS QUAD ) AS QUAD
DECLARE FUNCTION MgmDeRegisterMProtocol LIB "rtm.dll" ALIAS "MgmDeRegisterMProtocol" ( BYVAL hProtocol AS QUAD
 ) AS DWORD
'//============================================================================
'// Interface ownership API
'//============================================================================
DECLARE FUNCTION MgmTakeInterfaceOwnership LIB "rtm.dll" ALIAS "MgmTakeInterfaceOwnership" ( BYVAL hProtocol AS QUAD , BYVAL dwIfIndex AS QUAD , BYVAL dwIfNextHopAddr AS QUAD ) AS QUAD
DECLARE FUNCTION MgmReleaseInterfaceOwnership LIB "rtm.dll" ALIAS "MgmReleaseInterfaceOwnership" ( BYVAL hProtocol AS QUAD
 , BYVAL dwIfIndex AS DWORD
 , BYVAL dwIfNextHopAddr AS DWORD
 ) AS DWORD
DECLARE FUNCTION MgmGetProtocolOnInterface LIB "rtm.dll" ALIAS "MgmGetProtocolOnInterface" ( BYVAL dwIfIndex AS DWORD
 , BYVAL dwIfNextHopAddr AS DWORD
 , BYREF pdwIfProtocolId AS DWORD
 , BYREF pdwIfComponentId AS DWORD
 ) AS DWORD
'//============================================================================
'// Group membership manipulation API. (addition / deletion )
'//============================================================================
%EQUATE `MGM_JOIN_STATE_FLAG = &H00000001
%EQUATE `MGM_FORWARD_STATE_FLAG = &H00000002
DECLARE FUNCTION MgmAddGroupMembershipEntry LIB "rtm.dll" ALIAS "MgmAddGroupMembershipEntry" ( BYVAL hProtocol AS QUAD , BYVAL dwSourceAddr AS QUAD , BYVAL dwSourceMask AS QUAD , BYVAL dwGroupAddr AS QUAD , BYVAL dwGroupMask AS QUAD , BYVAL dwIfIndex AS QUAD , BYVAL dwIfNextHopIPAddr AS QUAD , BYVAL dwFlags AS QUAD ) AS QUAD
DECLARE FUNCTION MgmDeleteGroupMembershipEntry LIB "rtm.dll" ALIAS "MgmDeleteGroupMembershipEntry" ( BYVAL hProtocol AS QUAD
 , BYVAL dwSourceAddr AS DWORD
 , BYVAL dwSourceMask AS DWORD
 , BYVAL dwGroupAddr AS DWORD
 , BYVAL dwGroupMask AS DWORD
 , BYVAL dwIfIndex AS DWORD
 , BYVAL dwIfNextHopIPAddr AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS DWORD
'//============================================================================
'//
'// Enumeration API
'//
'//============================================================================
'//----------------------------------------------------------------------------
'// MFE enumeration API
'//----------------------------------------------------------------------------
DECLARE FUNCTION MgmGetMfe LIB "rtm.dll" ALIAS "MgmGetMfe" ( BYREF pimm AS MIB_IPMCAST_MFE , BYREF pdwBufferSize AS QUAD , BYVAL pbBuffer AS BYTE PTR ) AS QUAD
DECLARE FUNCTION MgmGetFirstMfe LIB "rtm.dll" ALIAS "MgmGetFirstMfe" ( BYREF pdwBufferSize AS QUAD
 , BYVAL pbBuffer AS BYTE PTR
 , BYVAL pdwNumEntries AS BYTE PTR
 ) AS DWORD
DECLARE FUNCTION MgmGetNextMfe LIB "rtm.dll" ALIAS "MgmGetNextMfe" ( BYREF pimmStart AS MIB_IPMCAST_MFE
 , BYREF pdwBufferSize AS DWORD
 , BYVAL pbBuffer AS BYTE PTR
 , BYREF pdwNumEntries AS DWORD
 ) AS DWORD
'//
'// Include statistics corresponding to MIB_IPMCAST_MFE_STATS
'//
%EQUATE `MGM_MFE_STATS_0 = &H00000001
'//
'// Include statistics corresponding to MIB_IPMCAST_MFE_STATS_EX
'//
%EQUATE `MGM_MFE_STATS_1 = &H00000002
DECLARE FUNCTION MgmGetMfeStats LIB "rtm.dll" ALIAS "MgmGetMfeStats" ( BYREF pimm AS MIB_IPMCAST_MFE , BYREF pdwBufferSize AS QUAD , BYVAL pbBuffer AS BYTE PTR , BYVAL dwFlags AS QUAD ) AS QUAD
DECLARE FUNCTION MgmGetFirstMfeStats LIB "rtm.dll" ALIAS "MgmGetFirstMfeStats" ( BYREF pdwBufferSize AS QUAD
 , BYVAL pbBuffer AS BYTE PTR
 , BYREF pdwNumEntries AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS DWORD
DECLARE FUNCTION MgmGetNextMfeStats LIB "rtm.dll" ALIAS "MgmGetNextMfeStats" ( BYREF pimmStart AS MIB_IPMCAST_MFE
 , BYREF pdwBufferSize AS DWORD
 , BYVAL pbBuffer AS BYTE PTR
 , BYREF pdwNumEntries AS DWORD
 , BYVAL dwFlags AS DWORD
 ) AS DWORD
'//----------------------------------------------------------------------------
'// Group menbership entry enumeration API
'//----------------------------------------------------------------------------
DECLARE FUNCTION MgmGroupEnumerationStart LIB "rtm.dll" ALIAS "MgmGroupEnumerationStart" ( BYVAL hProtocol AS QUAD , BYVAL metEnumType AS LONG , BYREF phEnumHandle AS QUAD ) AS QUAD
DECLARE FUNCTION MgmGroupEnumerationGetNext LIB "rtm.dll" ALIAS "MgmGroupEnumerationGetNext" ( BYVAL hEnum AS QUAD
 , BYREF pdwBufferSize AS DWORD
 , BYVAL pbBuffer AS BYTE PTR
 , BYREF pdwNumEntries AS DWORD
 ) AS DWORD
DECLARE FUNCTION MgmGroupEnumerationEnd LIB "rtm.dll" ALIAS "MgmGroupEnumerationEnd" ( BYVAL hEnum AS DWORD
 ) AS DWORD
'//-----------------------------------------------------------------
'// Mgm MFE Update API.
'//
'//-----------------------------------------------------------------
DECLARE FUNCTION MgmSetMfe LIB "rtm.dll" ALIAS "MgmSetMfe" ( BYVAL hProtocol AS QUAD , BYREF pmimm AS MIB_IPMCAST_MFE ) AS QUAD
#ENDIF
