Source code of Windows XP (NT5)
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.

227 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. load.c
  5. Abstract:
  6. This module implements
  7. Author:
  8. K.S.Lokesh
  9. lokeshs@microsoft.com
  10. Revision History:
  11. Created 2-15-97
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. //------------------------------------------------------------------------------
  16. // DEFINE GLOBAL VARIABLES
  17. //------------------------------------------------------------------------------
  18. MIB_SERVER_HANDLE g_hMibServer = NULL;
  19. //
  20. // critical section to protect MibServerHandle
  21. //
  22. CRITICAL_SECTION g_CS;
  23. //
  24. // handle to subagent framework
  25. //
  26. SnmpTfxHandle g_tfxHandle = NULL;
  27. //
  28. // Extension Agent DLLs need access to elapsed time agent has been active.
  29. // This is implemented by initializing the Extension Agent with a time zero
  30. // reference, and allowing the agent to compute elapsed time by subtracting
  31. // the time zero reference from the current system time.
  32. //
  33. DWORD g_uptimeReference = 0;
  34. #if DBG
  35. DWORD g_dwTraceId = INVALID_TRACEID;
  36. #endif
  37. //--------------------------------------------------------------------------//
  38. // DllMain //
  39. //--------------------------------------------------------------------------//
  40. BOOL
  41. WINAPI
  42. DllMain (
  43. HINSTANCE hModule,
  44. DWORD dwReason,
  45. LPVOID lpvReserved
  46. )
  47. {
  48. switch (dwReason) {
  49. case DLL_PROCESS_ATTACH :
  50. {
  51. // no per thread initialization required for this dll
  52. DisableThreadLibraryCalls(hModule);
  53. // initialize MibServerHandle CS
  54. InitializeCriticalSection(&g_CS);
  55. break;
  56. }
  57. case DLL_PROCESS_DETACH :
  58. {
  59. // disconnect from router
  60. if (g_hMibServer)
  61. MprAdminMIBServerDisconnect(g_hMibServer);
  62. // delete global critical section
  63. DeleteCriticalSection(&g_CS);
  64. // deregister MibTrace
  65. #if DBG
  66. if (g_dwTraceId!=INVALID_TRACEID)
  67. TraceDeregister(g_dwTraceId);
  68. #endif
  69. break;
  70. }
  71. default :
  72. break;
  73. }
  74. return TRUE;
  75. }
  76. ///////////////////////////////////////////////////////////////////////////////
  77. // //
  78. // Subagent entry points //
  79. // //
  80. ///////////////////////////////////////////////////////////////////////////////
  81. BOOL
  82. SnmpExtensionInit(
  83. IN DWORD uptimeReference,
  84. OUT HANDLE * lpPollForTrapEvent,
  85. OUT AsnObjectIdentifier * lpFirstSupportedView
  86. )
  87. {
  88. DWORD dwErr;
  89. // register mib tracing
  90. #if DBG
  91. g_dwTraceId = TraceRegister("IGMPAgntMIB");
  92. #endif
  93. // save uptime reference
  94. g_uptimeReference = uptimeReference;
  95. // obtain handle to subagent framework
  96. g_tfxHandle = SnmpTfxOpen(1,&v_igmp);
  97. // validate handle
  98. if (g_tfxHandle == NULL) {
  99. return FALSE;
  100. }
  101. // pass back first view identifier to master
  102. *lpFirstSupportedView = v_igmp.viewOid;
  103. // traps not supported yet
  104. *lpPollForTrapEvent = NULL;
  105. //
  106. // verify router service is running. if not running then
  107. // just return.
  108. //
  109. if (!MprAdminIsServiceRunning(NULL)) {
  110. TRACE0("Router Service not running. "
  111. "IgmpAgent could not start");
  112. return TRUE;
  113. }
  114. //
  115. // connect to router. If failed, then connection can be
  116. // established later
  117. //
  118. dwErr = MprAdminMIBServerConnect(NULL, &g_hMibServer);
  119. if (dwErr!=NO_ERROR) {
  120. g_hMibServer = NULL;
  121. TRACE1("error:%d setting up IgmpAgent connection to MIB Server",
  122. dwErr);
  123. return FALSE;
  124. }
  125. return TRUE;
  126. }
  127. BOOL
  128. SnmpExtensionQuery(
  129. IN BYTE requestType,
  130. IN OUT RFC1157VarBindList *variableBindings,
  131. OUT AsnInteger *errorStatus,
  132. OUT AsnInteger *ErrorIndex
  133. )
  134. {
  135. // forward to framework
  136. return SnmpTfxQuery(g_tfxHandle,
  137. requestType,
  138. variableBindings,
  139. errorStatus,
  140. ErrorIndex);
  141. }
  142. BOOL
  143. SnmpExtensionTrap(
  144. OUT AsnObjectIdentifier *enterprise,
  145. OUT AsnInteger *genericTrap,
  146. OUT AsnInteger *specificTrap,
  147. OUT AsnTimeticks *timeStamp,
  148. OUT RFC1157VarBindList *variableBindings
  149. )
  150. {
  151. UNREFERENCED_PARAMETER(enterprise);
  152. UNREFERENCED_PARAMETER(genericTrap);
  153. UNREFERENCED_PARAMETER(specificTrap);
  154. UNREFERENCED_PARAMETER(timeStamp);
  155. UNREFERENCED_PARAMETER(variableBindings);
  156. // no traps
  157. return FALSE;
  158. }
  159. VOID
  160. SnmpExtensionClose(
  161. )
  162. {
  163. // release handle
  164. SnmpTfxClose(g_tfxHandle);
  165. // reinitialize
  166. g_tfxHandle = NULL;
  167. }