1 /*_############################################################################
6 _## -----------------------------------------------
7 _## Copyright (c) 2001-2010 Jochen Katz, Frank Fock
9 _## This software is based on SNMP++2.6 from Hewlett Packard:
11 _## Copyright (c) 1996
12 _## Hewlett-Packard Company
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.
26 _## Stuttgart, Germany, Thu Sep 2 00:07:47 CEST 2010
28 _##########################################################################*/
30 #ifndef _EVENTLISTHOLDER_H_
31 #define _EVENTLISTHOLDER_H_
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"
39 #ifdef SNMP_PP_NAMESPACE
43 class CSNMPMessageQueue;
44 class CNotifyEventQueue;
49 typedef unsigned long Uint32;
51 class DLLOPT EventListHolder
54 EventListHolder(Snmp *snmp_session);
55 ~EventListHolder() {};
57 CSNMPMessageQueue *&snmpEventList() { return m_snmpMessageQueue; };
58 CNotifyEventQueue *¬ifyEventList() { return m_notifyEventQueue; };
60 Uint32 SNMPGetNextTimeout();
62 #ifdef HAVE_POLL_SYSCALL
64 bool GetFdArray(struct pollfd *readfds, int &remaining);
66 void SNMPGetFdSets(int & maxfds,
71 //---------[ Main Loop ]------------------------------------------
73 * Infinite loop which blocks when there is nothing to do and handles
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.
80 void SNMPMainLoop(const int max_block_milliseconds = 0 /* = infinite */);
82 //---------[ Exit Main Loop ]---------------------------------------
83 // Force the SNMP Main Loop to terminate immediately
84 void SNMPExitMainLoop();
87 * Block until an event shows up - then handle the event(s).
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.
93 int SNMPProcessEvents(const int max_block_milliseconds = 0 /* = infinite */);
95 //---------[ Process Pending Events ]-------------------------------
96 // Pull all available events out of their sockets - do not block
97 int SNMPProcessPendingEvents();
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,
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
111 SnmpSynchronized pevents_mutex;
114 #ifdef SNMP_PP_NAMESPACE
115 } // end of namespace Snmp_pp
118 #endif // _EVENTLISTHOLDER_H_