Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
5.4 KiB

  1. //=============================================================================
  2. // Copyright (c) 1998 Microsoft Corporation
  3. // File Name: work.c
  4. // Abstract:
  5. //
  6. // Author: K.S.Lokesh (lokeshs@) 1-1-98
  7. //=============================================================================
  8. #include "pchdvmrp.h"
  9. #pragma hdrstop
  10. DWORD
  11. DvmrpRpfCallback (
  12. DWORD dwSourceAddr,
  13. DWORD dwSourceMask,
  14. DWORD dwGroupAddr,
  15. DWORD dwGroupMask,
  16. DWORD *dwInIfIndex,
  17. DWORD *dwInIfNextHopAddr,
  18. DWORD *dwUpstreamNeighbor,
  19. DWORD dwHdrSize,
  20. PBYTE pbPacketHdr,
  21. PBYTE pbBuffer
  22. );
  23. DWORD
  24. ProxyCreationAlertCallback(
  25. IN DWORD dwSourceAddr,
  26. IN DWORD dwSourceMask,
  27. IN DWORD dwGroupAddr,
  28. IN DWORD dwGroupMask,
  29. IN DWORD dwInIfIndex,
  30. IN DWORD dwInIfNextHopAddr,
  31. IN DWORD dwIfCount,
  32. IN OUT PMGM_IF_ENTRY pmieOutIfList
  33. )
  34. {
  35. return ERROR_CAN_NOT_COMPLETE;
  36. }
  37. DWORD
  38. ProxyDeletionAlertCallback(
  39. IN DWORD dwSourceAddr,
  40. IN DWORD dwSourceMask,
  41. IN DWORD dwGroupAddr,
  42. IN DWORD dwGroupMask,
  43. IN DWORD dwIfIndex,
  44. IN DWORD dwIfNextHopAddr,
  45. IN BOOL bMemberDelete,
  46. IN OUT PDWORD pdwTimeout
  47. )
  48. {
  49. return ERROR_CAN_NOT_COMPLETE;
  50. }
  51. DWORD
  52. ProxyNewMemberCallback(
  53. IN DWORD dwSourceAddr,
  54. IN DWORD dwSourceMask,
  55. IN DWORD dwGroupAddr,
  56. IN DWORD dwGroupMask
  57. )
  58. {
  59. return ERROR_CAN_NOT_COMPLETE;
  60. }
  61. //-----------------------------------------------------------------------------
  62. // _GetCurrentDvmrpTimer
  63. // uses GetTickCount(). converts it into 64 bit absolute timer.
  64. //-----------------------------------------------------------------------------
  65. LONGLONG
  66. GetCurrentDvmrpTime(
  67. )
  68. {
  69. ULONG ulCurTimeLow = GetTickCount();
  70. //
  71. // see if timer has wrapped
  72. //
  73. // since multi-threaded, it might get preempted and CurrentTime
  74. // might get lower than the global variable g_TimerStruct.CurrentTime.LowPart
  75. // which might be set by another thread. So we also explicitly verify the
  76. // switch from a very large DWORD to a small one.
  77. // (code thanks to murlik&jamesg)
  78. //
  79. if ( (ulCurTimeLow < Globals.CurrentTime.LowPart)
  80. && ((LONG)Globals.CurrentTime.LowPart < 0)
  81. && ((LONG)ulCurTimeLow > 0) )
  82. {
  83. // use global CS instead of creating a new CS
  84. ACQUIRE_WORKITEM_LOCK("_GetCurrentDvmrpTime");
  85. // make sure that the global timer has not been updated meanwhile
  86. if ( (LONG)Globals.CurrentTime.LowPart < 0)
  87. {
  88. Globals.CurrentTime.HighPart++;
  89. Globals.CurrentTime.LowPart = ulCurTimeLow;
  90. }
  91. RELEASE_WORKITEM_LOCK("_GetCurrentDvmrpTime");
  92. }
  93. Globals.CurrentTime.LowPart = ulCurTimeLow;
  94. return Globals.CurrentTime.QuadPart;
  95. }
  96. //-----------------------------------------------------------------------------
  97. // RegisterDvmrpWithMgm
  98. //-----------------------------------------------------------------------------
  99. DWORD
  100. RegisterDvmrpWithMgm(
  101. )
  102. {
  103. DWORD Error = NO_ERROR;
  104. ROUTING_PROTOCOL_CONFIG rpiInfo;
  105. HANDLE g_MgmProxyHandle;
  106. rpiInfo.dwCallbackFlags = 0;
  107. rpiInfo.pfnRpfCallback
  108. = (PMGM_RPF_CALLBACK)DvmrpRpfCallback;
  109. rpiInfo.pfnCreationAlertCallback
  110. = (PMGM_CREATION_ALERT_CALLBACK)ProxyCreationAlertCallback;
  111. rpiInfo.pfnDeletionAlertCallback
  112. = (PMGM_DELETION_ALERT_CALLBACK)ProxyDeletionAlertCallback;
  113. rpiInfo.pfnNewMemberCallback
  114. = (PMGM_NEW_MEMBER_CALLBACK)ProxyNewMemberCallback;
  115. rpiInfo.pfnWrongIfCallback
  116. = NULL;
  117. rpiInfo.pfnIgmpJoinCallback
  118. = NULL;
  119. rpiInfo.pfnIgmpLeaveCallback
  120. = NULL;
  121. Error = MgmRegisterMProtocol(
  122. &rpiInfo, PROTO_IP_IGMP, // must be PROTO_IP_IGMP_PROXY
  123. IGMP_PROXY,
  124. &g_MgmProxyHandle);
  125. if (Error!=NO_ERROR) {
  126. Trace1(ERR, "Error:%d registering Igmp Proxy with Mgm", Error);
  127. Logerr0(MGM_PROXY_REGISTER_FAILED, Error);
  128. return Error;
  129. }
  130. return Error;
  131. }
  132. //-----------------------------------------------------------------------------
  133. // ProxyRpfCallback
  134. //-----------------------------------------------------------------------------
  135. DWORD
  136. DvmrpRpfCallback (
  137. DWORD dwSourceAddr,
  138. DWORD dwSourceMask,
  139. DWORD dwGroupAddr,
  140. DWORD dwGroupMask,
  141. DWORD *dwInIfIndex,
  142. DWORD *dwInIfNextHopAddr,
  143. DWORD *dwUpstreamNeighbor,
  144. DWORD dwHdrSize,
  145. PBYTE pbPacketHdr,
  146. PBYTE pbBuffer
  147. )
  148. {
  149. DWORD Error = NO_ERROR;
  150. #if 0
  151. PRTM_DEST_INFO
  152. RtmGetMostSpecificDest(RtmHandle, dwSourceAddr, IP_PROTO_IGMP,
  153. RTM_VIEW_ID_MCAST
  154. );
  155. #endif
  156. return ERROR_CAN_NOT_COMPLETE;
  157. }