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.

242 lines
5.4 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. routing\ip\mcastmib\load.c
  5. Abstract:
  6. IP Multicast MIB subagent
  7. Revision history:
  8. Dave Thaler 4/17/98 Created
  9. --*/
  10. #include "precomp.h"
  11. #pragma hdrstop
  12. #if defined( MIB_DEBUG )
  13. DWORD g_dwTraceId = INVALID_TRACEID;
  14. #endif
  15. MIB_SERVER_HANDLE g_hMIBServer = ( MIB_SERVER_HANDLE) NULL;
  16. //
  17. // Critical section to protect MIB server handle
  18. //
  19. CRITICAL_SECTION g_CS;
  20. //
  21. // Extension Agent DLLs need access to elapsed time agent has been active.
  22. // This is implemented by initializing the Extension Agent with a time zero
  23. // reference, and allowing the agent to compute elapsed time by subtracting
  24. // the time zero reference from the current system time.
  25. //
  26. DWORD g_uptimeReference = 0;
  27. //
  28. // Handle to Subagent Framework
  29. //
  30. SnmpTfxHandle g_tfxHandle;
  31. ///////////////////////////////////////////////////////////////////////////////
  32. // //
  33. // Subagent entry points //
  34. // //
  35. ///////////////////////////////////////////////////////////////////////////////
  36. BOOL
  37. SnmpExtensionInit(
  38. IN DWORD uptimeReference,
  39. OUT HANDLE * lpPollForTrapEvent,
  40. OUT AsnObjectIdentifier * lpFirstSupportedView
  41. )
  42. {
  43. DWORD dwRes = (DWORD) -1;
  44. #if defined( MIB_DEBUG )
  45. //
  46. // tracing for DEBUG
  47. //
  48. g_dwTraceId = TraceRegister( "IPMULTICASTMIB" );
  49. #endif
  50. TraceEnter("SnmpExtensionInit");
  51. //
  52. // Verify router service is running
  53. //
  54. if ( !MprAdminIsServiceRunning( NULL ) )
  55. {
  56. TRACE0( "Router Service not running" );
  57. }
  58. else {
  59. //
  60. // Connect to router. In case of error, set
  61. // connection handle to NULL. Connection can
  62. // be established later.
  63. //
  64. dwRes = MprAdminMIBServerConnect(
  65. NULL,
  66. &g_hMIBServer
  67. );
  68. if ( dwRes != NO_ERROR )
  69. {
  70. g_hMIBServer = (MIB_SERVER_HANDLE) NULL;
  71. TRACE1(
  72. "Error %d setting up DIM connection to MIB Server\n", dwRes
  73. );
  74. return FALSE;
  75. }
  76. }
  77. // save uptime reference
  78. g_uptimeReference = uptimeReference;
  79. // obtain handle to subagent framework
  80. g_tfxHandle = SnmpTfxOpen(1,&v_multicast);
  81. // validate handle
  82. if (g_tfxHandle == NULL) {
  83. return FALSE;
  84. }
  85. // pass back first view identifier to master
  86. *lpFirstSupportedView = v_multicast.viewOid;
  87. // traps not supported yet
  88. *lpPollForTrapEvent = NULL;
  89. TraceLeave("SnmpExtensionInit");
  90. return TRUE;
  91. }
  92. #ifdef THREE_PHASE
  93. BOOL SnmpExtensionQueryEx(
  94. DWORD dwRequestType, // extension agent request type
  95. DWORD dwTransactionId, // identifier of the incoming PDU
  96. SnmpVarBindList *pVarBindList, // pointer to variable binding list
  97. AsnOctetString *pContextInfo, // pointer to context information
  98. AsnInteger32 *pErrorStatus, // pointer to SNMPv2 error status
  99. AsnInteger32 *pErrorIndex // pointer to the error index);
  100. {
  101. // forward to framework
  102. return SnmpTfxQueryEx(
  103. g_tfxHandle,
  104. dwRequestType,
  105. pVarBindlist,
  106. pErrorStatus,
  107. pErrorIndex
  108. );
  109. }
  110. #endif
  111. BOOL
  112. SnmpExtensionQuery(
  113. IN BYTE requestType,
  114. IN OUT RFC1157VarBindList * variableBindings,
  115. OUT AsnInteger * errorStatus,
  116. OUT AsnInteger * errorIndex
  117. )
  118. {
  119. // forward to framework
  120. return SnmpTfxQuery(
  121. g_tfxHandle,
  122. requestType,
  123. variableBindings,
  124. errorStatus,
  125. errorIndex
  126. );
  127. }
  128. BOOL
  129. SnmpExtensionTrap(
  130. OUT AsnObjectIdentifier *enterprise,
  131. OUT AsnInteger *genericTrap,
  132. OUT AsnInteger *specificTrap,
  133. OUT AsnTimeticks *timeStamp,
  134. OUT RFC1157VarBindList *variableBindings
  135. )
  136. {
  137. // no traps
  138. return FALSE;
  139. }
  140. BOOL WINAPI
  141. DllMain(
  142. HINSTANCE hInstDLL,
  143. DWORD fdwReason,
  144. LPVOID pReserved
  145. )
  146. {
  147. switch ( fdwReason )
  148. {
  149. case DLL_PROCESS_ATTACH :
  150. {
  151. DisableThreadLibraryCalls( hInstDLL );
  152. InitializeCriticalSection( &g_CS );
  153. g_hMIBServer = (MIB_SERVER_HANDLE) NULL;
  154. break;
  155. }
  156. case DLL_PROCESS_DETACH :
  157. {
  158. //
  159. // Disconnect from router
  160. //
  161. if ( g_hMIBServer )
  162. {
  163. MprAdminMIBServerDisconnect( g_hMIBServer );
  164. }
  165. DeleteCriticalSection( &g_CS );
  166. #if defined( MIB_DEBUG )
  167. if ( g_dwTraceId != INVALID_TRACEID )
  168. {
  169. TraceDeregister( g_dwTraceId );
  170. }
  171. #endif
  172. break;
  173. }
  174. default :
  175. {
  176. break;
  177. }
  178. }
  179. return TRUE;
  180. }