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 _##########################################################################*/
29 /*===================================================================
32 Hewlett-Packard Company
34 ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
35 Permission to use, copy, modify, distribute and/or sell this software
36 and/or its documentation is hereby granted without fee. User agrees
37 to display the above copyright notice and this license notice in all
38 copies of the software and any documentation of the software. User
39 agrees to assume all liability for the use of the software; Hewlett-Packard
40 makes no representations about the suitability of this software for any
41 purpose. It is provided "AS-IS without warranty of any kind,either express
42 or implied. User hereby grants a royalty-free license to any and all
43 derivatives based upon this software code base.
45 N O T I F Y Q U E U E. H
47 CNotifyEventQueue CLASS DEFINITION
49 COPYRIGHT HEWLETT PACKARD COMPANY 1999
51 INFORMATION NETWORKS DIVISION
53 NETWORK MANAGEMENT SECTION
55 DESIGN + AUTHOR: Tom Murray
58 Queue for holding sessions waiting for notifiactions
60 =====================================================================*/
61 // $Id: notifyqueue.h 1550 2009-06-26 19:59:30Z katz $
66 //----[ includes ]-----------------------------------------------------
67 #include <sys/types.h> // NOTE: due to 10.10 bug, order is important
68 // in that all routines must include types.h
69 // and time.h in same order otherwise you
70 // will get conflicting definitions of
71 // "fd_set" resulting in link time errors.
73 #if !(defined CPU && CPU == PPC603)
74 #include <sys/time.h> // time stuff and fd_set
78 //----[ snmp++ includes ]----------------------------------------------
80 #include "snmp_pp/config_snmp_pp.h"
81 #include "snmp_pp/oid.h"
82 #include "snmp_pp/target.h"
83 #include "snmp_pp/eventlist.h"
85 #ifdef SNMP_PP_NAMESPACE
89 class Snmp; // instead of snmp_pp.h
91 class EventListHolder;
93 //----[ defines ]------------------------------------------------------
95 //----[ CNotifyEvent class ]-------------------------------------------
97 /*----------------------------------------------------------------*/
99 /* a description of a sessions waiting for async notifiactions. */
100 /*----------------------------------------------------------------*/
101 class DLLOPT CNotifyEvent
105 CNotifyEvent(Snmp* snmp,
106 const OidCollection &trapids,
107 const TargetCollection &targets);
109 Snmp * GetId() { return m_snmp; };
110 int notify_filter(const Oid &trapid, SnmpTarget &target) const;
111 int Callback(SnmpTarget &target, Pdu &pdu, SnmpSocket fd, int status);
112 void get_filter(OidCollection &o, TargetCollection &t)
113 { o = *notify_ids; t = *notify_targets; };
117 TargetCollection *notify_targets;
118 OidCollection *notify_ids;
121 /*-----------------------------------------------------------*/
122 /* CNotifyEventQueue */
123 /* class describing a collection of outstanding SNMP msgs. */
124 /*-----------------------------------------------------------*/
125 class DLLOPT CNotifyEventQueue: public CEvents
128 CNotifyEventQueue(EventListHolder *holder, Snmp *session);
129 ~CNotifyEventQueue();
130 int AddEntry(Snmp * snmp,
131 const OidCollection &trapids,
132 const TargetCollection &targets);
133 CNotifyEvent * GetEntry(Snmp * snmp);
134 void DeleteEntry(Snmp * snmp);
136 // find the next timeout
137 int GetNextTimeout(msec &/*timeout*/) { return 1; }; // we have no timeouts
138 // set up parameters for select
139 #ifdef HAVE_POLL_SYSCALL
141 bool GetFdArray(struct pollfd *readfds, int &remaining);
142 int HandleEvents(const struct pollfd *readfds, const int fds);
144 void GetFdSets(int &maxfds, fd_set &readfds, fd_set &writefds,
146 int HandleEvents(const int maxfds,
147 const fd_set &readfds,
148 const fd_set &writefds,
149 const fd_set &exceptfds);
151 // return number of outstanding messages
152 int GetCount() { return m_msgCount; };
154 int DoRetries(const msec &/*sendtime*/) { return 0; }; // nothing to retry
156 int Done() { return 0; }; // we are never done
157 void set_listen_port(int port) { m_listen_port = port; };
158 int get_listen_port() { return m_listen_port; };
159 SnmpSocket get_notify_fd() const;
163 /*-----------------------------------------------------------*/
164 /* CNotifyEventQueueElt */
165 /* a container for a single item on a linked lists of */
167 /*-----------------------------------------------------------*/
168 class DLLOPT CNotifyEventQueueElt
171 CNotifyEventQueueElt(CNotifyEvent *notifyevent,
172 CNotifyEventQueueElt *next,
173 CNotifyEventQueueElt *previous);
175 ~CNotifyEventQueueElt();
176 CNotifyEventQueueElt *GetNext() { return m_Next; };
177 CNotifyEvent *GetNotifyEvent() { return m_notifyevent; };
178 CNotifyEvent *TestId(Snmp *snmp);
182 CNotifyEvent *m_notifyevent;
183 class CNotifyEventQueueElt *m_Next;
184 class CNotifyEventQueueElt *m_previous;
189 CNotifyEventQueueElt m_head;
191 SnmpSocket m_notify_fd;
193 EventListHolder *my_holder;
195 UdpAddress m_notify_addr;
198 #ifdef SNMP_PP_NAMESPACE
199 } // end of namespace Snmp_pp
202 #endif // NOTIFYQUEUE