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.

124 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. Revision history:
  6. --*/
  7. #include <snmp.h>
  8. #include <snmpexts.h>
  9. #include "mibentry.h"
  10. SnmpTfxHandle g_tfxHandle;
  11. PSNMP_MGMTVARS ge_pMgmtVars;
  12. CRITICAL_SECTION g_SnmpMibCriticalSection;
  13. BOOL g_fSnmpMibCritSecInited = FALSE;
  14. BOOL
  15. SnmpExtensionInit(
  16. IN DWORD uptimeReference,
  17. OUT HANDLE * lpPollForTrapEvent,
  18. OUT AsnObjectIdentifier * lpFirstSupportedView)
  19. {
  20. g_tfxHandle = SnmpTfxOpen(1,&view_snmp);
  21. if (g_tfxHandle == NULL)
  22. return FALSE;
  23. *lpFirstSupportedView = view_snmp.viewOid;
  24. *lpPollForTrapEvent = NULL;
  25. return TRUE;
  26. }
  27. // the SNMP master agent calls this function immediately after SnmpExtensionInit
  28. // in order to provide a pointer to the internal service management information.
  29. // No mutex protection is needed so far, as there is no concurrency in writing the
  30. // buffer pointed by this parameter.
  31. BOOL
  32. SnmpExtensionMonitor(
  33. IN LPVOID pAgentMgmtVars)
  34. {
  35. ge_pMgmtVars = (PSNMP_MGMTVARS)pAgentMgmtVars;
  36. return TRUE;
  37. }
  38. BOOL
  39. SnmpExtensionQuery(
  40. IN BYTE requestType,
  41. IN OUT RFC1157VarBindList * variableBindings,
  42. OUT AsnInteger * errorStatus,
  43. OUT AsnInteger * errorIndex)
  44. {
  45. // forward to framework
  46. return SnmpTfxQuery(
  47. g_tfxHandle,
  48. requestType,
  49. variableBindings,
  50. errorStatus,
  51. errorIndex);
  52. }
  53. BOOL
  54. SnmpExtensionTrap(
  55. OUT AsnObjectIdentifier *enterprise,
  56. OUT AsnInteger *genericTrap,
  57. OUT AsnInteger *specificTrap,
  58. OUT AsnTimeticks *timeStamp,
  59. OUT RFC1157VarBindList *variableBindings)
  60. {
  61. // no traps
  62. return FALSE;
  63. }
  64. BOOL WINAPI
  65. DllMain(
  66. HINSTANCE hInstDLL,
  67. DWORD fdwReason,
  68. LPVOID pReserved)
  69. {
  70. switch ( fdwReason )
  71. {
  72. case DLL_PROCESS_ATTACH :
  73. {
  74. DisableThreadLibraryCalls( hInstDLL );
  75. __try
  76. {
  77. InitializeCriticalSection(&g_SnmpMibCriticalSection);
  78. g_fSnmpMibCritSecInited = TRUE;
  79. }
  80. __except(EXCEPTION_EXECUTE_HANDLER)
  81. {
  82. SNMPDBG((
  83. SNMP_LOG_ERROR,
  84. "SNMP: SNMPMIB: DllMain: InitializeCriticalSection failed.\n"));
  85. return FALSE;
  86. }
  87. SNMPDBG((
  88. SNMP_LOG_TRACE,
  89. "SNMP: SNMPMIB: DllMain: InitializeCriticalSection done.\n"));
  90. break;
  91. }
  92. case DLL_PROCESS_DETACH :
  93. {
  94. if (g_fSnmpMibCritSecInited)
  95. {
  96. DeleteCriticalSection(&g_SnmpMibCriticalSection);
  97. SNMPDBG((
  98. SNMP_LOG_TRACE,
  99. "SNMP: SNMPMIB: DllMain: DeleteCriticalSection done.\n"));
  100. }
  101. break;
  102. }
  103. default :
  104. break;
  105. }
  106. return TRUE;
  107. }