00001 /*_############################################################################ 00002 _## 00003 _## mib_entry.h 00004 _## 00005 _## 00006 _## AGENT++ API Version 3.5.30 00007 _## ----------------------------------------------- 00008 _## Copyright (C) 2000-2009 Frank Fock, Jochen Katz 00009 _## 00010 _## LICENSE AGREEMENT 00011 _## 00012 _## WHEREAS, Frank Fock and Jochen Katz are the owners of valuable 00013 _## intellectual property rights relating to the AGENT++ API and wish to 00014 _## license AGENT++ subject to the terms and conditions set forth below; 00015 _## and 00016 _## 00017 _## WHEREAS, you ("Licensee") acknowledge that Frank Fock and Jochen Katz 00018 _## have the right to grant licenses to the intellectual property rights 00019 _## relating to AGENT++, and that you desire to obtain a license to use 00020 _## AGENT++ subject to the terms and conditions set forth below; 00021 _## 00022 _## Frank Fock and Jochen Katz grants Licensee a non-exclusive, 00023 _## non-transferable, royalty-free license to use AGENT++ and related 00024 _## materials without charge provided the Licensee adheres to all of the 00025 _## terms and conditions of this Agreement. 00026 _## 00027 _## By downloading, using, or copying AGENT++ or any portion thereof, 00028 _## Licensee agrees to abide by the intellectual property laws and all 00029 _## other applicable laws of Germany, and to all of the terms and 00030 _## conditions of this Agreement, and agrees to take all necessary steps 00031 _## to ensure that the terms and conditions of this Agreement are not 00032 _## violated by any person or entity under the Licensee's control or in 00033 _## the Licensee's service. 00034 _## 00035 _## Licensee shall maintain the copyright and trademark notices on the 00036 _## materials within or otherwise related to AGENT++, and not alter, 00037 _## erase, deface or overprint any such notice. 00038 _## 00039 _## Except as specifically provided in this Agreement, Licensee is 00040 _## expressly prohibited from copying, merging, selling, leasing, 00041 _## assigning, or transferring in any manner, AGENT++ or any portion 00042 _## thereof. 00043 _## 00044 _## Licensee may copy materials within or otherwise related to AGENT++ 00045 _## that bear the author's copyright only as required for backup purposes 00046 _## or for use solely by the Licensee. 00047 _## 00048 _## Licensee may not distribute in any form of electronic or printed 00049 _## communication the materials within or otherwise related to AGENT++ 00050 _## that bear the author's copyright, including but not limited to the 00051 _## source code, documentation, help files, examples, and benchmarks, 00052 _## without prior written consent from the authors. Send any requests for 00053 _## limited distribution rights to fock@agentpp.com. 00054 _## 00055 _## Licensee hereby grants a royalty-free license to any and all 00056 _## derivatives based upon this software code base, that may be used 00057 _## as a SNMP agent development environment or a SNMP agent development 00058 _## tool. 00059 _## 00060 _## Licensee may modify the sources of AGENT++ for the Licensee's own 00061 _## purposes. Thus, Licensee may not distribute modified sources of 00062 _## AGENT++ without prior written consent from the authors. 00063 _## 00064 _## The Licensee may distribute binaries derived from or contained within 00065 _## AGENT++ provided that: 00066 _## 00067 _## 1) The Binaries are not integrated, bundled, combined, or otherwise 00068 _## associated with a SNMP agent development environment or SNMP agent 00069 _## development tool; and 00070 _## 00071 _## 2) The Binaries are not a documented part of any distribution material. 00072 _## 00073 _## 00074 _## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00075 _## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00076 _## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00077 _## IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00078 _## INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00079 _## (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00080 _## SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00081 _## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00082 _## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00083 _## IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00084 _## POSSIBILITY OF SUCH DAMAGE. 00085 _## 00086 _## 00087 _## Stuttgart, Germany, Fri May 29 22:36:02 CEST 2009 00088 _## 00089 _##########################################################################*/ 00090 00091 #ifndef mib_entry_h_ 00092 #define mib_entry_h_ 00093 00094 00095 #include <agent_pp/agent++.h> 00096 00097 #include <agent_pp/snmp_pp_ext.h> 00098 #include <agent_pp/oidx_ptr.h> 00099 #include <agent_pp/threads.h> 00100 00101 #ifdef AGENTPP_NAMESPACE 00102 namespace Agentpp { 00103 #endif 00104 00105 typedef enum { NOACCESS, READONLY, READWRITE, READCREATE } mib_access; 00106 00107 typedef enum { AGENTPP_NONE, AGENTPP_PROXY, AGENTPP_LEAF, AGENTPP_TABLE, 00108 AGENTPP_GROUP, AGENTPP_COMPLEX, 00109 AGENTX_NODE, AGENTX_LEAF } mib_type; 00110 00111 #define REMOVE 0x01 00112 #define CREATE 0x02 00113 #define CHANGE 0x04 00114 #define UPDATE (REMOVE | CREATE | CHANGE) 00115 00116 00117 00118 typedef unsigned char mib_change; 00119 00120 /*--------------------------- class MibEntry --------------------------*/ 00121 00122 00123 class Mib; 00124 00134 #if !defined (AGENTPP_DECL_TEMPL_LIST_MIBENTRY) 00135 #define AGENTPP_DECL_TEMPL_LIST_MIBENTRY 00136 AGENTPP_DECL_TEMPL template class AGENTPP_DECL List<MibEntry>; 00137 #endif 00138 00139 class AGENTPP_DECL MibEntry: public ThreadManager { 00140 friend class Mib; 00141 public: 00145 MibEntry(); 00146 00154 MibEntry(const Oidx&, mib_access); 00155 00161 MibEntry(const MibEntry&); 00162 00166 virtual ~MibEntry(); 00167 00168 00177 virtual mib_type type() const; 00178 00184 virtual MibEntry* clone(); 00185 00199 virtual Oidx find_succ(const Oidx&, Request* req = 0) 00200 { return Oidx(); } 00201 00202 // interfaces dispatch table <-> management instrumentation 00203 00210 virtual void get_request(Request*, int) { } 00211 00223 virtual void get_next_request(Request*, int) { } 00224 00233 virtual int commit_set_request(Request*, int) 00234 { return SNMP_ERROR_COMITFAIL; } 00235 00245 virtual int prepare_set_request(Request*, int&) 00246 { return SNMP_ERROR_NO_SUCH_NAME; } 00247 00254 virtual int undo_set_request(Request*, int&) 00255 { return SNMP_ERROR_SUCCESS; } 00256 00264 virtual void cleanup_set_request(Request*, int&) { } 00265 00266 00267 // load/save mib objects from/to hard disk 00268 00274 virtual void load_from_file(const char*); 00275 00281 virtual void save_to_file(const char*); 00282 00290 virtual boolean serialize(char*&, int&); 00291 00303 virtual boolean deserialize(char*, int&); 00304 00311 virtual boolean is_empty() { return FALSE; } 00312 00313 00314 // communication between mib objects 00315 00324 virtual void notify_change(const Oidx&, mib_change); 00325 00332 virtual void register_for_notifications(MibEntry*); 00333 00338 virtual void add_change_notification(MibEntry* e) 00339 { register_for_notifications(e); } 00349 virtual void change_notification(const Oidx&, mib_change) {} 00350 00351 00357 OidxPtr key(); 00358 00367 virtual OidxPtr max_key(); 00368 00376 virtual mib_access get_access(); 00377 00384 virtual boolean is_volatile(); 00385 00391 virtual void reset() { } 00392 00393 00398 int operator<(const MibEntry&) const; 00399 int operator>(const MibEntry&) const; 00400 int operator==(const MibEntry&) const; 00401 00402 int operator<(const Oidx&) const; 00403 int operator>(const Oidx&) const; 00404 int operator<=(const Oidx&) const; 00405 int operator>=(const Oidx&) const; 00406 int operator==(const Oidx&) const; 00408 00409 protected: 00410 00416 void set_oid(const Oidx&); 00417 00418 // Oidx oid; 00419 Oidx oid; 00420 mib_access access; 00421 List<MibEntry> notifies; 00422 00423 }; 00424 00425 typedef MibEntry* MibEntryPtr; 00426 00427 #ifdef AGENTPP_NAMESPACE 00428 } 00429 #endif 00430 00431 00432 #endif 00433