]> git.stg.codes - ssmd.git/blob - 3rdparty/snmp++/include/snmp_pp/eventlistholder.h
Initial adding
[ssmd.git] / 3rdparty / snmp++ / include / snmp_pp / eventlistholder.h
1 /*_############################################################################
2   _## 
3   _##  eventlistholder.h  
4   _##
5   _##  SNMP++v3.2.25
6   _##  -----------------------------------------------
7   _##  Copyright (c) 2001-2010 Jochen Katz, Frank Fock
8   _##
9   _##  This software is based on SNMP++2.6 from Hewlett Packard:
10   _##  
11   _##    Copyright (c) 1996
12   _##    Hewlett-Packard Company
13   _##  
14   _##  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
15   _##  Permission to use, copy, modify, distribute and/or sell this software 
16   _##  and/or its documentation is hereby granted without fee. User agrees 
17   _##  to display the above copyright notice and this license notice in all 
18   _##  copies of the software and any documentation of the software. User 
19   _##  agrees to assume all liability for the use of the software; 
20   _##  Hewlett-Packard and Jochen Katz make no representations about the 
21   _##  suitability of this software for any purpose. It is provided 
22   _##  "AS-IS" without warranty of any kind, either express or implied. User 
23   _##  hereby grants a royalty-free license to any and all derivatives based
24   _##  upon this software code base. 
25   _##  
26   _##  Stuttgart, Germany, Thu Sep  2 00:07:47 CEST 2010 
27   _##  
28   _##########################################################################*/
29
30 #ifndef _EVENTLISTHOLDER_H_
31 #define _EVENTLISTHOLDER_H_
32
33 //----[ includes ]-----------------------------------------------------
34 #include "snmp_pp/config_snmp_pp.h"
35 #include "snmp_pp/snmperrs.h"
36 #include "snmp_pp/eventlist.h"
37 #include "snmp_pp/reentrant.h"
38
39 #ifdef SNMP_PP_NAMESPACE
40 namespace Snmp_pp {
41 #endif
42
43 class CSNMPMessageQueue;
44 class CNotifyEventQueue;
45 class Pdu;
46 class v3MP;
47 class Snmp;
48
49 typedef unsigned long Uint32;
50
51 class DLLOPT EventListHolder
52 {
53  public:
54   EventListHolder(Snmp *snmp_session);
55   ~EventListHolder() {};
56
57   CSNMPMessageQueue *&snmpEventList()   { return m_snmpMessageQueue; };
58   CNotifyEventQueue *&notifyEventList() { return m_notifyEventQueue; };
59
60   Uint32 SNMPGetNextTimeout();
61
62 #ifdef HAVE_POLL_SYSCALL
63   int GetFdCount();
64   bool GetFdArray(struct pollfd *readfds, int &remaining);
65 #endif
66   void SNMPGetFdSets(int &  maxfds,
67                      fd_set & readfds,
68                      fd_set & writefds,
69                      fd_set & exceptfds);
70
71   //---------[ Main Loop ]------------------------------------------
72   /**
73    * Infinite loop which blocks when there is nothing to do and handles
74    * any events.
75    *
76    * @note If no messages are outstanding, select() is called with the
77    *       given timeout, so any async messages that are sent out later
78    *       are not processed until this select call returns.
79    */
80   void SNMPMainLoop(const int max_block_milliseconds = 0 /* = infinite */);
81
82   //---------[ Exit Main Loop ]---------------------------------------
83   // Force the SNMP Main Loop to terminate immediately
84   void SNMPExitMainLoop();
85
86   /**
87    * Block until an event shows up - then handle the event(s).
88    *
89    * @note If no messages are outstanding, select() is called with the
90    *       given timeout, so any async messages that are sent out later
91    *       are not processed until this select call returns.
92    */
93   int SNMPProcessEvents(const int max_block_milliseconds = 0 /* = infinite */);
94
95   //---------[ Process Pending Events ]-------------------------------
96   // Pull all available events out of their sockets - do not block
97   int SNMPProcessPendingEvents();
98
99   //---------[ Block For Response ]-----------------------------------
100   // Wait for the completion of an outstanding SNMP event (msg).
101   // Handle any other events as they occur.
102   int SNMPBlockForResponse(const unsigned long req_id,
103                            Pdu &    pdu);
104
105  private:
106
107   CSNMPMessageQueue *m_snmpMessageQueue;  // contains all outstanding messages
108   CNotifyEventQueue *m_notifyEventQueue; // contains all sessions waiting for notifications
109   CEventList   m_eventList;  // contains all expected events
110
111   SnmpSynchronized      pevents_mutex;
112 };
113
114 #ifdef SNMP_PP_NAMESPACE
115 } // end of namespace Snmp_pp
116 #endif 
117
118 #endif // _EVENTLISTHOLDER_H_