SNMP++  3.3.11
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$
60 
61 #ifndef _SNMP_NOTIFYQUEUE_H_
62 #define _SNMP_NOTIFYQUEUE_H_
63 
64 //----[ includes ]-----------------------------------------------------
65 #include <libsnmp.h>
66 #include <sys/types.h>
67 #ifndef WIN32
68 #if !(defined CPU && CPU == PPC603)
69 #include <sys/time.h> // time stuff and fd_set
70 #endif
71 #endif
72 
73 //----[ snmp++ includes ]----------------------------------------------
74 
75 #include "snmp_pp/config_snmp_pp.h"
76 #include "snmp_pp/oid.h"
77 #include "snmp_pp/target.h"
78 #include "snmp_pp/eventlist.h"
79 
80 #ifdef SNMP_PP_NAMESPACE
81 namespace Snmp_pp {
82 #endif
83 
84 class Snmp; // instead of snmp_pp.h
85 class msec;
86 class EventListHolder;
87 
88 //----[ defines ]------------------------------------------------------
89 
90 //----[ CNotifyEvent class ]-------------------------------------------
91 
92 /*----------------------------------------------------------------*/
93 /* CNotifyEvent */
94 /* a description of a sessions waiting for async notifiactions. */
95 /*----------------------------------------------------------------*/
97 {
98  public:
99 
100  CNotifyEvent(Snmp* snmp,
101  const OidCollection &trapids,
102  const TargetCollection &targets);
103  ~CNotifyEvent();
104  Snmp * GetId() { return m_snmp; };
105  int notify_filter(const Oid &trapid, SnmpTarget &target) const;
106  int Callback(SnmpTarget &target, Pdu &pdu, SnmpSocket fd, int status);
108  { o = *notify_ids; t = *notify_targets; };
109 
110  protected:
111  Snmp *m_snmp;
114 };
115 
116  /*-----------------------------------------------------------*/
117  /* CNotifyEventQueue */
118  /* class describing a collection of outstanding SNMP msgs. */
119  /*-----------------------------------------------------------*/
121 {
122  public:
123  CNotifyEventQueue(EventListHolder *holder, Snmp *session);
125  int AddEntry(Snmp * snmp,
126  const OidCollection &trapids,
127  const TargetCollection &targets);
128  CNotifyEvent * GetEntry(Snmp * snmp);
129  void DeleteEntry(Snmp * snmp);
130 
131  // find the next timeout
132  int GetNextTimeout(msec &/*timeout*/) { return 1; }; // we have no timeouts
133  // set up parameters for select
134 #ifdef HAVE_POLL_SYSCALL
135  int GetFdCount();
136  bool GetFdArray(struct pollfd *readfds, int &remaining);
137  int HandleEvents(const struct pollfd *readfds, const int fds);
138 #else
139  void GetFdSets(int &maxfds, fd_set &readfds, fd_set &writefds,
140  fd_set &exceptfds);
141  int HandleEvents(const int maxfds,
142  const fd_set &readfds,
143  const fd_set &writefds,
144  const fd_set &exceptfds);
145 #endif
146  // return number of outstanding messages
147  int GetCount() { return m_msgCount; };
148 
149  int DoRetries(const msec &/*sendtime*/) { return 0; }; // nothing to retry
150 
151  int Done() { return 0; }; // we are never done
152  void set_listen_port(int port) { m_listen_port = port; };
153  int get_listen_port() { return m_listen_port; };
154  SnmpSocket get_notify_fd() const;
155 
156  protected:
157 
158  /*-----------------------------------------------------------*/
159  /* CNotifyEventQueueElt */
160  /* a container for a single item on a linked lists of */
161  /* CNotifyEvents. */
162  /*-----------------------------------------------------------*/
164  {
165  public:
166  CNotifyEventQueueElt(CNotifyEvent *notifyevent,
167  CNotifyEventQueueElt *next,
168  CNotifyEventQueueElt *previous);
169 
171  CNotifyEventQueueElt *GetNext() { return m_Next; };
172  CNotifyEvent *GetNotifyEvent() { return m_notifyevent; };
173  CNotifyEvent *TestId(Snmp *snmp);
174 
175  private:
176 
180  };
181 
182  void cleanup();
183 
191 };
192 
193 #ifdef SNMP_PP_NAMESPACE
194 } // end of namespace Snmp_pp
195 #endif
196 
197 #endif // _SNMP_NOTIFYQUEUE_H_
Snmp * GetId()
Definition: notifyqueue.h:104
SnmpSocket m_notify_fd
Definition: notifyqueue.h:186
EventListHolder * my_holder
Definition: notifyqueue.h:188
int DoRetries(const msec &)
Definition: notifyqueue.h:149
class CNotifyEventQueueElt * m_previous
Definition: notifyqueue.h:179
Time handling...
Definition: msec.h:70
SNMP class definition.
Definition: uxsnmp.h:107
CNotifyEventQueueElt * GetNext()
Definition: notifyqueue.h:171
UdpAddress m_notify_addr
Definition: notifyqueue.h:190
void get_filter(OidCollection &o, TargetCollection &t)
Definition: notifyqueue.h:107
#define DLLOPT
The Object Identifier Class.
Definition: oid.h:90
TargetCollection * notify_targets
Definition: notifyqueue.h:112
class CNotifyEventQueueElt * m_Next
Definition: notifyqueue.h:178
int GetNextTimeout(msec &)
Definition: notifyqueue.h:132
CNotifyEventQueueElt m_head
Definition: notifyqueue.h:184
int SnmpSocket
OidCollection * notify_ids
Definition: notifyqueue.h:113
Pdu class...
Definition: pdu.h:82
void set_listen_port(int port)
Definition: notifyqueue.h:152
Abstract class used to provide a virtual interface into Targets.
Definition: target.h:93