SNMP++  3.3.4
notifyqueue.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## notifyqueue.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 
29  Copyright (c) 1999
30  Hewlett-Packard Company
31 
32  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
33  Permission to use, copy, modify, distribute and/or sell this software
34  and/or its documentation is hereby granted without fee. User agrees
35  to display the above copyright notice and this license notice in all
36  copies of the software and any documentation of the software. User
37  agrees to assume all liability for the use of the software; Hewlett-Packard
38  makes no representations about the suitability of this software for any
39  purpose. It is provided "AS-IS without warranty of any kind,either express
40  or implied. User hereby grants a royalty-free license to any and all
41  derivatives based upon this software code base.
42 
43  N O T I F Y Q U E U E. H
44 
45  CNotifyEventQueue CLASS DEFINITION
46 
47  COPYRIGHT HEWLETT PACKARD COMPANY 1999
48 
49  INFORMATION NETWORKS DIVISION
50 
51  NETWORK MANAGEMENT SECTION
52 
53  DESIGN + AUTHOR: Tom Murray
54 
55  DESCRIPTION:
56  Queue for holding sessions waiting for notifiactions
57 
58 =====================================================================*/
59 // $Id: notifyqueue.h 2359 2013-05-09 20:07:01Z fock $
60 
61 #ifndef _NOTIFYQUEUE
62 #define _NOTIFYQUEUE
63 
64 //----[ includes ]-----------------------------------------------------
65 #include <sys/types.h> // NOTE: due to 10.10 bug, order is important
66  // in that all routines must include types.h
67  // and time.h in same order otherwise you
68  // will get conflicting definitions of
69  // "fd_set" resulting in link time errors.
70 #ifndef WIN32
71 #if !(defined CPU && CPU == PPC603)
72 #include <sys/time.h> // time stuff and fd_set
73 #endif
74 #endif
75 
76 //----[ snmp++ includes ]----------------------------------------------
77 
78 #include "snmp_pp/config_snmp_pp.h"
79 #include "snmp_pp/oid.h"
80 #include "snmp_pp/target.h"
81 #include "snmp_pp/eventlist.h"
82 
83 #ifdef SNMP_PP_NAMESPACE
84 namespace Snmp_pp {
85 #endif
86 
87 class Snmp; // instead of snmp_pp.h
88 class msec;
89 class EventListHolder;
90 
91 //----[ defines ]------------------------------------------------------
92 
93 //----[ CNotifyEvent class ]-------------------------------------------
94 
95 /*----------------------------------------------------------------*/
96 /* CNotifyEvent */
97 /* a description of a sessions waiting for async notifiactions. */
98 /*----------------------------------------------------------------*/
100 {
101  public:
102 
103  CNotifyEvent(Snmp* snmp,
104  const OidCollection &trapids,
105  const TargetCollection &targets);
106  ~CNotifyEvent();
107  Snmp * GetId() { return m_snmp; };
108  int notify_filter(const Oid &trapid, SnmpTarget &target) const;
109  int Callback(SnmpTarget &target, Pdu &pdu, SnmpSocket fd, int status);
111  { o = *notify_ids; t = *notify_targets; };
112 
113  protected:
114  Snmp *m_snmp;
117 };
118 
119  /*-----------------------------------------------------------*/
120  /* CNotifyEventQueue */
121  /* class describing a collection of outstanding SNMP msgs. */
122  /*-----------------------------------------------------------*/
124 {
125  public:
126  CNotifyEventQueue(EventListHolder *holder, Snmp *session);
128  int AddEntry(Snmp * snmp,
129  const OidCollection &trapids,
130  const TargetCollection &targets);
131  CNotifyEvent * GetEntry(Snmp * snmp);
132  void DeleteEntry(Snmp * snmp);
133 
134  // find the next timeout
135  int GetNextTimeout(msec &/*timeout*/) { return 1; }; // we have no timeouts
136  // set up parameters for select
137 #ifdef HAVE_POLL_SYSCALL
138  int GetFdCount();
139  bool GetFdArray(struct pollfd *readfds, int &remaining);
140  int HandleEvents(const struct pollfd *readfds, const int fds);
141 #else
142  void GetFdSets(int &maxfds, fd_set &readfds, fd_set &writefds,
143  fd_set &exceptfds);
144  int HandleEvents(const int maxfds,
145  const fd_set &readfds,
146  const fd_set &writefds,
147  const fd_set &exceptfds);
148 #endif
149  // return number of outstanding messages
150  int GetCount() { return m_msgCount; };
151 
152  int DoRetries(const msec &/*sendtime*/) { return 0; }; // nothing to retry
153 
154  int Done() { return 0; }; // we are never done
155  void set_listen_port(int port) { m_listen_port = port; };
156  int get_listen_port() { return m_listen_port; };
157  SnmpSocket get_notify_fd() const;
158 
159  protected:
160 
161  /*-----------------------------------------------------------*/
162  /* CNotifyEventQueueElt */
163  /* a container for a single item on a linked lists of */
164  /* CNotifyEvents. */
165  /*-----------------------------------------------------------*/
167  {
168  public:
169  CNotifyEventQueueElt(CNotifyEvent *notifyevent,
170  CNotifyEventQueueElt *next,
171  CNotifyEventQueueElt *previous);
172 
174  CNotifyEventQueueElt *GetNext() { return m_Next; };
175  CNotifyEvent *GetNotifyEvent() { return m_notifyevent; };
176  CNotifyEvent *TestId(Snmp *snmp);
177 
178  private:
179 
183  };
184 
185  void cleanup();
186 
194 };
195 
196 #ifdef SNMP_PP_NAMESPACE
197 } // end of namespace Snmp_pp
198 #endif
199 
200 #endif // NOTIFYQUEUE
Snmp * GetId()
Definition: notifyqueue.h:107
SnmpSocket m_notify_fd
Definition: notifyqueue.h:189
EventListHolder * my_holder
Definition: notifyqueue.h:191
int DoRetries(const msec &)
Definition: notifyqueue.h:152
class CNotifyEventQueueElt * m_previous
Definition: notifyqueue.h:182
Time handling...
Definition: msec.h:79
SNMP class defintion.
Definition: uxsnmp.h:99
CNotifyEventQueueElt * GetNext()
Definition: notifyqueue.h:174
UdpAddress m_notify_addr
Definition: notifyqueue.h:193
void get_filter(OidCollection &o, TargetCollection &t)
Definition: notifyqueue.h:110
#define DLLOPT
The Object Identifier Class.
Definition: oid.h:94
TargetCollection * notify_targets
Definition: notifyqueue.h:115
class CNotifyEventQueueElt * m_Next
Definition: notifyqueue.h:181
int GetNextTimeout(msec &)
Definition: notifyqueue.h:135
CNotifyEventQueueElt m_head
Definition: notifyqueue.h:187
int SnmpSocket
OidCollection * notify_ids
Definition: notifyqueue.h:116
Pdu class...
Definition: pdu.h:81
void set_listen_port(int port)
Definition: notifyqueue.h:155
Abstract class used to provide a virtual interface into Targets.
Definition: target.h:92