00001 /*_############################################################################ 00002 _## 00003 _## mib_proxy.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_proxy_h_ 00092 #define mib_proxy_h_ 00093 00094 #include <agent_pp/agent++.h> 00095 #include <agent_pp/mib.h> 00096 #ifdef _SNMPv3 00097 #include <agent_pp/snmp_target_mib.h> 00098 #include <agent_pp/snmp_proxy_mib.h> 00099 #endif 00100 00101 #ifndef _PROXY_FORWARDER 00102 00103 #ifdef AGENTPP_NAMESPACE 00104 namespace Agentpp { 00105 #endif 00106 00107 /*--------------------------- class MibProxy -----------------------------*/ 00108 00126 class AGENTPP_DECL MibProxy: public MibEntry { 00127 00128 public: 00132 MibProxy(); 00133 00140 MibProxy(const MibProxy& other); 00141 00153 MibProxy(const Oidx&, mib_access, const UdpAddress&); 00154 00172 MibProxy(const Oidx&, mib_access, const Oidx&, const UdpAddress&); 00173 00177 virtual ~MibProxy() { } 00178 00185 virtual mib_type type() const { return AGENTPP_PROXY; } 00186 00193 virtual MibEntry* clone() { return new MibProxy(*this); } 00194 00203 virtual OidxPtr max_key(); 00204 00220 virtual Oidx find_succ(const Oidx&, Request* r = 0); 00221 00228 virtual boolean is_empty() 00229 { return ((find_succ(*key()).len() == 0) || 00230 (lastNext.get_oid() >= *max_key()));} 00231 00232 virtual void get_request(Request*, int); 00233 virtual int commit_set_request(Request*, int); 00234 virtual int prepare_set_request(Request*, int&); 00235 virtual void get_next_request(Request*, int); 00236 00247 void set_community(access_types a, 00248 const OctetStr& c) 00249 { community[a] = c; } 00250 00251 protected: 00252 virtual Oidx translate(const Oidx&); 00253 virtual Oidx backward_translate(const Oidx&); 00254 00255 void determineDefaultRange(const Oidx&); 00256 00257 UdpAddress source; 00258 Oidx translation; 00259 boolean translating; 00260 00261 OctetStr community[WRITING+1]; 00262 00263 Oidx range; 00264 00265 Vbx lastNext; 00266 int lastNextStatus; 00267 }; 00268 00269 #ifdef _SNMPv3 00270 00271 /*--------------------------- class MibProxyV3 -----------------------------*/ 00272 00290 class AGENTPP_DECL MibProxyV3: public MibEntry { 00291 00292 public: 00296 MibProxyV3(const Oidx&, mib_access); 00297 00304 MibProxyV3(const MibProxyV3& other); 00305 00317 MibProxyV3(snmpProxyEntry*, const Oidx&, mib_access); 00318 00326 MibProxyV3(const OctetStr&); 00327 00331 virtual ~MibProxyV3() { } 00332 00339 virtual mib_type type() const { return AGENTPP_PROXY; } 00340 00347 virtual MibEntry* clone() { return new MibProxyV3(*this); } 00348 00357 virtual OidxPtr max_key(); 00358 00374 virtual Oidx find_succ(const Oidx&, Request* r = 0); 00375 00376 virtual void get_request(Request*, int); 00377 virtual int commit_set_request(Request*, int); 00378 virtual int prepare_set_request(Request*, int&); 00379 virtual void get_next_request(Request*, int); 00380 00381 00382 protected: 00383 00384 OidList<MibTableRow>* get_matches(Request*); 00385 boolean match_target_params(Request*, const OctetStr&); 00386 int process_single(Pdux&, Request*); 00387 00388 void check_references(); 00389 void determineDefaultRange(const Oidx&); 00390 00391 snmpProxyEntry* myProxyInfo; 00392 00393 Oidx range; 00394 00395 Vbx lastNext; 00396 int lastNextStatus; 00397 }; 00398 00399 #ifdef AGENTPP_NAMESPACE 00400 } 00401 #endif 00402 00403 #endif 00404 00405 #endif 00406 #endif 00407 00408