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.

239 lines
4.5 KiB

  1. //***************************************************************************
  2. //
  3. // File:
  4. //
  5. // Module: MS SNMP Provider
  6. //
  7. // Purpose:
  8. //
  9. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #ifndef _SNMP_EVT_PROV_EVTTHRD_H
  13. #define _SNMP_EVT_PROV_EVTTHRD_H
  14. #include <windows.h>
  15. #include <provexpt.h>
  16. class CTrapEventProvider;
  17. class CEventProviderThread;
  18. class CMapToEvent;
  19. struct SCacheEntry
  20. {
  21. public:
  22. IWbemClassObject* m_Class;
  23. DWORD m_Marker;
  24. SCacheEntry(IWbemClassObject *a_Class)
  25. {
  26. m_Class = a_Class;
  27. m_Marker = 0;
  28. }
  29. };
  30. template <> inline void AFXAPI DestructElements<SCacheEntry*> (SCacheEntry** ptr_e, int x)
  31. {
  32. //x is always one for a CMap!
  33. if ( (ptr_e != NULL) && (*ptr_e != NULL) )
  34. {
  35. if ((*ptr_e)->m_Class != NULL)
  36. {
  37. (*ptr_e)->m_Class->Release();
  38. }
  39. delete *ptr_e;
  40. }
  41. }
  42. class MySnmpV1Security : public SnmpV1Security
  43. {
  44. public:
  45. MySnmpV1Security(const SnmpV1Security& sec) : SnmpV1Security(sec){}
  46. const char* GetName()const {return GetCommunityName();}
  47. };
  48. class CControlObjectMap : public CMap< UINT, UINT, CTrapEventProvider*, CTrapEventProvider* >
  49. {
  50. private:
  51. UINT HashKey(UINT key) { return key; }
  52. CCriticalSection m_Lock;
  53. public:
  54. BOOL Lock() { return m_Lock.Lock(); }
  55. BOOL Unlock() { return m_Lock.Unlock(); }
  56. };
  57. class CTrapListener : public SnmpTrapReceiver
  58. {
  59. private:
  60. CEventProviderThread* m_pParent;
  61. LONG m_Ref;
  62. public:
  63. CTrapListener(CEventProviderThread* parentptr);
  64. void Receive(SnmpTransportAddress &sender_addr,
  65. SnmpSecurity &security_context,
  66. SnmpVarBindList &vbList);
  67. void Destroy();
  68. ~CTrapListener() {}
  69. };
  70. class CTrapData
  71. {
  72. private:
  73. LONG m_Ref;
  74. public:
  75. char m_static_sender_addr [ 32 ] ;
  76. char *m_sender_addr;
  77. char *m_security_context;
  78. char m_static_security_context [ 32 ] ;
  79. char *m_trap_oid;
  80. char m_static_trap_oid [ 32 ] ;
  81. char *m_transport;
  82. char m_static_transport [ 32 ] ;
  83. SnmpVarBindList m_variable_bindings;
  84. CTrapData (const char* sender_addr,
  85. const char* security_Context,
  86. const char* snmpTrapOid,
  87. const char* trnsp,
  88. SnmpVarBindList& vbList);
  89. LONG AddRef();
  90. LONG Release();
  91. ~CTrapData();
  92. };
  93. class CTrapProcessTaskObject : public SnmpTaskObject
  94. {
  95. private:
  96. CTrapData *m_trap_data;
  97. CTrapEventProvider *m_Cntrl;
  98. protected:
  99. public:
  100. CTrapProcessTaskObject (CTrapData *pTData, CTrapEventProvider* pCntrl) ;
  101. ~CTrapProcessTaskObject();
  102. void Process () ;
  103. void ProcessEncapsulated () ;
  104. void ProcessReferent () ;
  105. } ;
  106. class CEventProviderWorkerThread;
  107. class TimerRegistryTaskObject : public SnmpTaskObject
  108. {
  109. private:
  110. HKEY m_LogKey ;
  111. CEventProviderWorkerThread *m_parent;
  112. protected:
  113. public:
  114. TimerRegistryTaskObject (CEventProviderWorkerThread *parent) ;
  115. ~TimerRegistryTaskObject () ;
  116. void Process () ;
  117. void ReadRegistry();
  118. void SetRegistryNotification () ;
  119. } ;
  120. class CWbemServerWrap ;
  121. class CEventProviderWorkerThread : public SnmpThreadObject
  122. {
  123. private:
  124. void Initialise();
  125. void Uninitialise();
  126. void TimedOut();
  127. DWORD m_TimeOut;
  128. DWORD m_MaxMarks;
  129. TimerRegistryTaskObject *m_RegTaskObject;
  130. ISmirDatabase *m_pNotifyInt;
  131. CEventCacheNotify *m_notify;
  132. CMap<DWORD, DWORD,
  133. CMap<CString, LPCWSTR, SCacheEntry*, SCacheEntry*>*,
  134. CMap<CString, LPCWSTR, SCacheEntry*, SCacheEntry*>*> m_Classes;
  135. CWbemServerWrap *m_pSmirNamespace ;
  136. public:
  137. CEventProviderWorkerThread();
  138. void AddClassesToCache(DWORD_PTR key, CMap<CString, LPCWSTR, SCacheEntry*, SCacheEntry*>* item);
  139. void RemoveClassesFromCache(DWORD_PTR key);
  140. void SetMaxMarks(DWORD dwM);
  141. void Clear();
  142. CWbemServerWrap *GetServerWrap () { return m_pSmirNamespace ; } ;
  143. void CreateServerWrap () ;
  144. void GetDeleteNotifyParams(ISmirDatabase** a_ppNotifyInt, CEventCacheNotify** a_ppNotify);
  145. ~CEventProviderWorkerThread();
  146. };
  147. class CEventProviderThread
  148. {
  149. private:
  150. CTrapListener* m_Ear;
  151. CControlObjectMap m_ControlObjects;
  152. public:
  153. CEventProviderThread() : m_Ear(NULL) {}
  154. BOOL Register(CTrapEventProvider* prov);
  155. void UnRegister(CTrapEventProvider* prov);
  156. virtual void ProcessTrap(const char* sender_addr,
  157. const char* security_Context,
  158. const char* snmpTrapOid,
  159. const char* trnsp,
  160. SnmpVarBindList& vbList);
  161. };
  162. #endif //_SNMP_EVT_PROV_EVTTHRD_H