snmp_pp_ext.h

Go to the documentation of this file.
00001 /*_############################################################################
00002   _## 
00003   _##  snmp_pp_ext.h  
00004   _## 
00005   _##
00006   _##  AGENT++ API Version 3.5.28
00007   _##  -----------------------------------------------
00008   _##  Copyright (C) 2000-2007 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, Wed May  2 22:12:11 CEST 2007 
00088   _##  
00089   _##########################################################################*/
00090 
00091 #ifndef _SNMP_PP_EXT_H_
00092 #define _SNMP_PP_EXT_H_
00093 
00094 #include <agent_pp/agent++.h>
00095 #include <snmp_pp/oid.h>
00096 #include <snmp_pp/pdu.h>
00097 #include <snmp_pp/vb.h>
00098 #include <snmp_pp/octet.h>
00099 #include <snmp_pp/oid.h>
00100 #include <snmp_pp/snmpmsg.h>
00101 
00102 
00103 #define LENGTH_OF_IPADDRESS     4
00104 
00105 #ifndef WIN32
00106 #include <sys/types.h>
00107 #include <sys/time.h>
00108 #include <unistd.h>
00109 #endif
00110 
00111 #ifdef SNMP_PP_NAMESPACE
00112 #define NS_SNMP Snmp_pp::
00113 #else
00114 #define NS_SNMP
00115 #endif
00116 
00117 #ifdef AGENTPP_NAMESPACE
00118 namespace Agentpp {
00119 #endif
00120 
00121 
00122 /*--------------------------- class Oidx -----------------------------*/
00123 
00133 class AGENTPP_DECL Oidx: public NS_SNMP Oid {
00134 public:
00138         Oidx() : Oid() { };
00139 
00145         Oidx(const char* s) : Oid(s) { };
00146 
00153         Oidx(const unsigned long *data, int length) : Oid(data, length) { };
00154 
00160         Oidx(const Oid& oid) : Oid(oid) { };
00161 
00165         virtual ~Oidx() { };
00166 
00174         Oidx            cut_left(const unsigned int) const;
00175 
00183         Oidx            cut_right(const unsigned int) const;
00184 
00185 
00199         Oidx&           mask(const NS_SNMP OctetStr&);
00200 
00201 
00210         static Oidx     cut_left(const Oidx&, const unsigned int);
00211 
00220         static Oidx     cut_right(const Oidx&, const unsigned int);
00221 
00227         unsigned long   last() const;
00228 
00229         virtual Oidx&   operator=(unsigned long l);
00230 
00231         Oidx            &operator+=(NS_SNMP IpAddress&); 
00232         Oidx            &operator+=(const char *); 
00233         Oidx            &operator+=(const unsigned long i);
00234         Oidx            &operator+=(const Oid &);
00235 
00243         int             in_subtree_of(const Oidx& o) const;
00244 
00252         int             is_root_of(const Oidx& o) const;
00253 
00268         int             compare(const Oidx&, const NS_SNMP OctetStr&) const; 
00269 
00282         int             compare(const Oidx&, u_int) const; 
00283 
00291         NS_SNMP OctetStr        as_string() const;
00292 
00303         static Oidx     from_string(const NS_SNMP OctetStr&, boolean withLength=TRUE);
00304 
00311         Oidx            successor() const;
00312 
00319         Oidx            predecessor() const;
00320 
00330         Oidx            next_peer() const;
00331 };
00332 
00333 
00334 /*--------------------------- class Vbx -----------------------------*/
00335 
00347 class AGENTPP_DECL Vbx: public NS_SNMP Vb {
00348 public:
00349         Vbx(): Vb() { }
00350         Vbx(const NS_SNMP Vb& vb): Vb(vb) { }
00351         Vbx(const NS_SNMP Oid& oid): Vb(oid) { }
00352 
00361         Vbx(const NS_SNMP Oid& oid, const NS_SNMP SnmpSyntax &val): Vb(oid) {
00362           set_value(val); 
00363         }
00364 
00371         Oidx            get_oid() const { return iv_vb_oid; };
00372 
00373         void            get_oid(Oidx& oid) const { oid = iv_vb_oid; };
00374 
00379         void            clear();
00380 
00381         Vbx*            clone() const { return new Vbx(*this); }
00382 
00383         friend int      operator==(const Vbx&, const Vbx&);
00384 
00398         static boolean  equal(Vbx*, Vbx*, int); 
00399 
00418         static int      to_asn1(Vbx*, int, unsigned char*&, int&);
00419 
00438         static int      from_asn1(Vbx*&, int&, unsigned char*&, int&);
00439 
00440  private:
00441         static unsigned char* asn_build_long_len_sequence(unsigned char *,
00442                                                           int*,
00443                                                           unsigned char,
00444                                                           int, int);
00445         static unsigned char* asn_build_long_length(unsigned char*,
00446                                                     int*,
00447                                                     int,
00448                                                     int);
00449 };
00450  
00451 
00452 /*------------------------- class OidxRange ---------------------------*/
00453 
00462 class AGENTPP_DECL OidxRange {
00463 
00464 public:
00468         OidxRange();
00469 
00479         OidxRange(const Oidx&, const Oidx&);
00480 
00484         OidxRange(const OidxRange&);
00485 
00489         virtual ~OidxRange();
00490 
00497         virtual OidxRange* clone() const;
00498 
00507         virtual int     operator==(const OidxRange&) const;
00517         virtual int     operator<(const OidxRange&) const;
00527         virtual int     operator>(const OidxRange&) const;
00528 
00538         virtual int     includes(const Oidx&) const;
00539 
00549         virtual int     includes_excl(const Oidx&) const;
00550 
00561         virtual boolean covers(const OidxRange&) const;
00562 
00571         virtual boolean overlaps(const OidxRange&) const;
00572 
00579         virtual Oidx    get_lower() const;
00580 
00587         virtual Oidx    get_upper() const;
00588 
00589         Oidx lower, upper;
00590 };
00591 
00592 
00593 /*--------------------------- class Pdux -----------------------------*/
00594 
00606 class AGENTPP_DECL Pdux: public NS_SNMP Pdu {
00607 public:
00608         Pdux(): Pdu() { }
00609         Pdux(NS_SNMP Vb* pvbs, const int pvb_count): Pdu(pvbs, pvb_count) { }
00610         Pdux(const Pdu& pdu): Pdu(pdu) { }
00611         Pdux(const Pdux& pdu): Pdu(pdu) { }
00612 
00613         virtual ~Pdux() { }
00614 
00618         void    clear();
00619 
00620         // const redefinitions of originals: 
00621         Pdux&   operator+=(const NS_SNMP Vb&);
00622 
00629         virtual Pdux*   clone() const { return new Pdux(*this); }
00630 };
00631 
00632 
00633 /*--------------------------- class Snmpx -----------------------------*/
00634 
00646 class AGENTPP_DECL Snmpx: public NS_SNMP Snmp {
00647 public:
00657         Snmpx (int &status , u_short port): Snmp(status, port) {};
00658 
00659 #ifdef SNMP_PP_WITH_UDPADDR
00660 
00670         Snmpx(int& status, const NS_SNMP UdpAddress& addr): Snmp(status, addr) { }
00671 #endif
00672 
00673 #ifdef _SNMPv3          
00674 
00691         int receive(struct timeval*, Pdux&, NS_SNMP UTarget&);
00692 #else
00693 
00711         int receive(struct timeval*, Pdux&, NS_SNMP UdpAddress&, 
00712                     NS_SNMP snmp_version&, NS_SNMP OctetStr&);
00713 #endif
00714 #ifdef _SNMPv3
00715 
00731         int send (Pdux, NS_SNMP SnmpTarget*);
00732 #else
00733 
00748         int send (Pdux, NS_SNMP UdpAddress, NS_SNMP snmp_version, NS_SNMP OctetStr);
00749 #endif
00750 
00756         u_short get_port();
00757 
00768         SnmpSocket      get_session_fds() { return iv_snmp_session; }
00769 
00770 
00771 protected:
00772         unsigned long ProcessizedReqId(unsigned short);
00773         unsigned long MyMakeReqId();
00774         
00775         int snmp_engine( NS_SNMP Pdu &,          // pdu to use
00776                          long int,       // # of non repititions
00777                          long int,       // # of max repititions
00778                          NS_SNMP SnmpTarget&,    // from this target
00779                          const NS_SNMP snmp_callback cb, 
00780                          const void * cbd);
00781 };    
00782 
00783 #ifdef AGENTPP_NAMESPACE
00784 }
00785 #endif
00786 
00787 #endif
00788 
00789 
00790 
00791 
00792 
00793 
00794 

Generated on Wed May 2 22:24:05 2007 for AGENT++ by  doxygen 1.5.0