SNMP++  3.3.11
eventlistholder.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## eventlistholder.h
4  _##
5  _## SNMP++ v3.3
6  _## -----------------------------------------------
7  _## Copyright (c) 2001-2013 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  _##########################################################################*/
27 
28 #ifndef _SNMP_EVENTLISTHOLDER_H_
29 #define _SNMP_EVENTLISTHOLDER_H_
30 
31 //----[ includes ]-----------------------------------------------------
32 #include <libsnmp.h>
33 #include "snmp_pp/config_snmp_pp.h"
34 #include "snmp_pp/snmperrs.h"
35 #include "snmp_pp/eventlist.h"
36 #include "snmp_pp/reentrant.h"
37 
38 #ifdef SNMP_PP_NAMESPACE
39 namespace Snmp_pp {
40 #endif
41 
42 class CSNMPMessageQueue;
43 class CNotifyEventQueue;
44 class Pdu;
45 class v3MP;
46 class Snmp;
47 
49 {
50  public:
51  EventListHolder(Snmp *snmp_session);
53 
54  CSNMPMessageQueue *&snmpEventList() { return m_snmpMessageQueue; };
55  CNotifyEventQueue *&notifyEventList() { return m_notifyEventQueue; };
56 
57  unsigned long SNMPGetNextTimeout();
58 
59 #ifdef HAVE_POLL_SYSCALL
60  int GetFdCount();
61  bool GetFdArray(struct pollfd *readfds, int &remaining);
62 #endif
63  void SNMPGetFdSets(int & maxfds,
64  fd_set & readfds,
65  fd_set & writefds,
66  fd_set & exceptfds);
67 
68  //---------[ Main Loop ]------------------------------------------
69  /**
70  * Infinite loop which blocks when there is nothing to do and handles
71  * any events.
72  *
73  * @note If no messages are outstanding, select() is called with the
74  * given timeout, so any async messages that are sent out later
75  * are not processed until this select call returns.
76  */
77  void SNMPMainLoop(const int max_block_milliseconds = 0 /* = infinite */);
78 
79  //---------[ Exit Main Loop ]---------------------------------------
80  // Force the SNMP Main Loop to terminate immediately
81  void SNMPExitMainLoop();
82 
83  /**
84  * Block until an event shows up - then handle the event(s).
85  *
86  * @note If no messages are outstanding, select() is called with the
87  * given timeout, so any async messages that are sent out later
88  * are not processed until this select call returns.
89  */
90  int SNMPProcessEvents(const int max_block_milliseconds = 0 /* = infinite */);
91 
92  //---------[ Process Pending Events ]-------------------------------
93  // Pull all available events out of their sockets - do not block
94  int SNMPProcessPendingEvents();
95 
96  //---------[ Block For Response ]-----------------------------------
97  // Wait for the completion of an outstanding SNMP event (msg).
98  // Handle any other events as they occur.
99  int SNMPBlockForResponse(const unsigned long req_id,
100  Pdu & pdu);
101 
102  private:
103 
104  CSNMPMessageQueue *m_snmpMessageQueue; // contains all outstanding messages
105  CNotifyEventQueue *m_notifyEventQueue; // contains all sessions waiting for notifications
106  CEventList m_eventList; // contains all expected events
107 
109 };
110 
111 #ifdef SNMP_PP_NAMESPACE
112 } // end of namespace Snmp_pp
113 #endif
114 
115 #endif // _SNMP_EVENTLISTHOLDER_H_
CSNMPMessageQueue *& snmpEventList()
SNMP class definition.
Definition: uxsnmp.h:107
#define DLLOPT
The SNMPv3 Message Processing Model (v3MP).
Definition: mp_v3.h:107
CNotifyEventQueue *& notifyEventList()
SnmpSynchronized pevents_mutex
CNotifyEventQueue * m_notifyEventQueue
CSNMPMessageQueue * m_snmpMessageQueue
CEventList m_eventList
Pdu class...
Definition: pdu.h:82