00001 /*_############################################################################ 00002 _## 00003 _## notifyqueue.h 00004 _## 00005 _## SNMP++v3.2.15 00006 _## ----------------------------------------------- 00007 _## Copyright (c) 2001-2004 Jochen Katz, Frank Fock 00008 _## 00009 _## This software is based on SNMP++2.6 from Hewlett Packard: 00010 _## 00011 _## Copyright (c) 1996 00012 _## Hewlett-Packard Company 00013 _## 00014 _## ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. 00015 _## Permission to use, copy, modify, distribute and/or sell this software 00016 _## and/or its documentation is hereby granted without fee. User agrees 00017 _## to display the above copyright notice and this license notice in all 00018 _## copies of the software and any documentation of the software. User 00019 _## agrees to assume all liability for the use of the software; 00020 _## Hewlett-Packard and Jochen Katz make no representations about the 00021 _## suitability of this software for any purpose. It is provided 00022 _## "AS-IS" without warranty of any kind, either express or implied. User 00023 _## hereby grants a royalty-free license to any and all derivatives based 00024 _## upon this software code base. 00025 _## 00026 _## Stuttgart, Germany, Tue Jan 4 21:42:42 CET 2005 00027 _## 00028 _##########################################################################*/ 00029 /*=================================================================== 00030 00031 Copyright (c) 1999 00032 Hewlett-Packard Company 00033 00034 ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. 00035 Permission to use, copy, modify, distribute and/or sell this software 00036 and/or its documentation is hereby granted without fee. User agrees 00037 to display the above copyright notice and this license notice in all 00038 copies of the software and any documentation of the software. User 00039 agrees to assume all liability for the use of the software; Hewlett-Packard 00040 makes no representations about the suitability of this software for any 00041 purpose. It is provided "AS-IS without warranty of any kind,either express 00042 or implied. User hereby grants a royalty-free license to any and all 00043 derivatives based upon this software code base. 00044 00045 N O T I F Y Q U E U E. H 00046 00047 CNotifyEventQueue CLASS DEFINITION 00048 00049 COPYRIGHT HEWLETT PACKARD COMPANY 1999 00050 00051 INFORMATION NETWORKS DIVISION 00052 00053 NETWORK MANAGEMENT SECTION 00054 00055 00056 DESIGN + AUTHOR: 00057 Tom Murray 00058 00059 LANGUAGE: 00060 ANSI C++ 00061 00062 OPERATING SYSTEMS: 00063 DOS/WINDOWS 3.1 00064 BSD UNIX 00065 00066 DESCRIPTION: 00067 Queue for holding sessions waiting for notifiactions 00068 00069 COMPILER DIRECTIVES: 00070 UNIX - For UNIX build 00071 00072 =====================================================================*/ 00073 // $Id: notifyqueue.h,v 1.6 2004/03/03 23:11:21 katz Exp $ 00074 00075 #ifndef _NOTIFYQUEUE 00076 #define _NOTIFYQUEUE 00077 00078 //----[ includes ]----------------------------------------------------- 00079 #include <sys/types.h> // NOTE: due to 10.10 bug, order is important 00080 // in that all routines must include types.h 00081 // and time.h in same order otherwise you 00082 // will get conflicting definitions of 00083 // "fd_set" resulting in link time errors. 00084 #ifndef WIN32 00085 #include <sys/time.h> // time stuff and fd_set 00086 #else 00087 #include <winsock.h> 00088 #endif 00089 #ifdef SNMPX11 00090 #include <X11/Intrinsic.h> 00091 #endif 00092 00093 //----[ snmp++ includes ]---------------------------------------------- 00094 00095 #include "snmp_pp/oid.h" 00096 #include "snmp_pp/target.h" 00097 #include "snmp_pp/eventlist.h" 00098 00099 #ifdef SNMP_PP_NAMESPACE 00100 namespace Snmp_pp { 00101 #endif 00102 00103 class Snmp; // instead of snmp_pp.h 00104 class msec; 00105 class EventListHolder; 00106 00107 //----[ defines ]------------------------------------------------------ 00108 00109 //----[ CNotifyEvent class ]------------------------------------------- 00110 00111 /*----------------------------------------------------------------*/ 00112 /* CNotifyEvent */ 00113 /* a description of a sessions waiting for async notifiactions. */ 00114 /*----------------------------------------------------------------*/ 00115 class DLLOPT CNotifyEvent 00116 { 00117 public: 00118 00119 CNotifyEvent(Snmp* snmp, 00120 const OidCollection &trapids, 00121 const TargetCollection &targets, 00122 const AddressCollection &addresses); 00123 ~CNotifyEvent(); 00124 Snmp * GetId() { return m_snmp; }; 00125 int notify_filter(const Oid &trapid, SnmpTarget &target) const; 00126 int Callback(SnmpTarget & target, Pdu & pdu, int status); 00127 void get_filter(OidCollection &o, TargetCollection &t, 00128 AddressCollection &a) 00129 { o = *notify_ids; t = *notify_targets; a = *notify_addresses; }; 00130 00131 protected: 00132 Snmp *m_snmp; 00133 TargetCollection *notify_targets; 00134 OidCollection *notify_ids; 00135 AddressCollection *notify_addresses; 00136 }; 00137 00138 /*-----------------------------------------------------------*/ 00139 /* CNotifyEventQueue */ 00140 /* class describing a collection of outstanding SNMP msgs. */ 00141 /*-----------------------------------------------------------*/ 00142 class DLLOPT CNotifyEventQueue: public CEvents 00143 { 00144 public: 00145 CNotifyEventQueue(EventListHolder *holder, Snmp *session); 00146 ~CNotifyEventQueue(); 00147 int AddEntry(Snmp * snmp, 00148 const OidCollection &trapids, 00149 const TargetCollection &targets, 00150 const AddressCollection &addresses); 00151 CNotifyEvent * GetEntry(Snmp * snmp); 00152 void DeleteEntry(Snmp * snmp); 00153 00154 // find the next timeout 00155 int GetNextTimeout(msec &/*timeout*/) { return 1; }; // we have no timeouts 00156 // set up parameters for select 00157 void GetFdSets(int &maxfds, fd_set &readfds, fd_set &writefds, 00158 fd_set &exceptfds); 00159 // return number of outstanding messages 00160 int GetCount() { return m_msgCount; }; 00161 00162 int HandleEvents(const int maxfds, 00163 const fd_set &readfds, 00164 const fd_set &writefds, 00165 const fd_set &exceptfds); 00166 int DoRetries(const msec &/*sendtime*/) { return 0; }; // nothing to retry 00167 00168 int Done() { return 0; }; // we are never done 00169 static void set_listen_port(int port) { m_listen_port = port; }; 00170 static int get_listen_port() { return m_listen_port; }; 00171 int get_notify_fd() const { return m_notify_fd; }; 00172 00173 protected: 00174 00175 /*-----------------------------------------------------------*/ 00176 /* CNotifyEventQueueElt */ 00177 /* a container for a single item on a linked lists of */ 00178 /* CNotifyEvents. */ 00179 /*-----------------------------------------------------------*/ 00180 class DLLOPT CNotifyEventQueueElt 00181 { 00182 public: 00183 CNotifyEventQueueElt(CNotifyEvent *notifyevent, 00184 CNotifyEventQueueElt *next, 00185 CNotifyEventQueueElt *previous); 00186 00187 ~CNotifyEventQueueElt(); 00188 CNotifyEventQueueElt *GetNext() { return m_next; }; 00189 CNotifyEvent *GetNotifyEvent() { return m_notifyevent; }; 00190 CNotifyEvent *TestId(Snmp * snmp); 00191 00192 private: 00193 00194 CNotifyEvent *m_notifyevent; 00195 class CNotifyEventQueueElt *m_next; 00196 class CNotifyEventQueueElt *m_previous; 00197 }; 00198 00199 CNotifyEventQueueElt m_head; 00200 int m_msgCount; 00201 int m_notify_fd; 00202 static int m_listen_port; 00203 #ifdef SNMPX11 00204 XtInputId m_inputId; 00205 #endif // SNMPX11 00206 EventListHolder *my_holder; 00207 Snmp *m_snmpSession; 00208 }; 00209 00210 #ifdef SNMP_PP_NAMESPACE 00211 }; // end of namespace Snmp_pp 00212 #endif 00213 00214 #endif // NOTIFYQUEUE
1.3.2