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