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.

88 lines
1.6 KiB

  1. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  2. #ifndef __TRAP_MANAGEMENT__
  3. #define __TRAP_MANAGEMENT__
  4. //#include <snmpevt.h>
  5. //#include <snmpthrd.h>
  6. class SnmpClTrapThreadObject;
  7. class DllImportExport SnmpTrapReceiver
  8. {
  9. friend SnmpWinSnmpTrapSession; //needs access to m_cRef.
  10. private:
  11. BOOL m_bregistered;
  12. LONG m_cRef;
  13. protected:
  14. SnmpTrapReceiver ();
  15. public:
  16. virtual void Receive(SnmpTransportAddress &sender_addr,
  17. SnmpSecurity &security_context,
  18. SnmpVarBindList &vbList) = 0;
  19. BOOL IsRegistered() { return m_bregistered; }
  20. BOOL DestroyReceiver();
  21. ~SnmpTrapReceiver ();
  22. };
  23. class SnmpTrapReceiverStore
  24. {
  25. private:
  26. CRITICAL_SECTION m_Lock;
  27. void* m_HandledRxStack;
  28. void* m_UnHandledRxStack;
  29. void Lock();
  30. void Unlock();
  31. public:
  32. SnmpTrapReceiverStore();
  33. BOOL Add(SnmpTrapReceiver* receiver);
  34. BOOL Delete(SnmpTrapReceiver* receiver);
  35. BOOL IsEmpty();
  36. SnmpTrapReceiver* GetNext();
  37. ~SnmpTrapReceiverStore();
  38. };
  39. class SnmpTrapManager
  40. {
  41. friend SnmpWinSnmpTrapSession; //needs access to m_receivers.
  42. private:
  43. BOOL m_bListening;
  44. SnmpWinSnmpTrapSession* m_trapSession;
  45. SnmpTrapReceiverStore m_receivers;
  46. SnmpClTrapThreadObject* m_trapThread;
  47. public:
  48. SnmpTrapManager ();
  49. BOOL RegisterReceiver (SnmpTrapReceiver *trapRx);
  50. BOOL UnRegisterReceiver (SnmpTrapReceiver *trapRx);
  51. BOOL IsListening() const { return m_bListening; }
  52. ~SnmpTrapManager ();
  53. static SnmpTrapManager *s_TrapMngrPtr;
  54. };
  55. #endif //__TRAP_MANAGEMENT__