diff options
Diffstat (limited to 'ASNMP')
-rw-r--r-- | ASNMP/agent/agent_impl.h | 16 | ||||
-rw-r--r-- | ASNMP/agent/snmp_agent.h | 4 | ||||
-rw-r--r-- | ASNMP/asnmp/address.h | 197 | ||||
-rw-r--r-- | ASNMP/asnmp/asn1.h | 363 | ||||
-rw-r--r-- | ASNMP/asnmp/counter.h | 26 | ||||
-rw-r--r-- | ASNMP/asnmp/ctr64.h | 64 | ||||
-rw-r--r-- | ASNMP/asnmp/enttraps.h | 66 | ||||
-rw-r--r-- | ASNMP/asnmp/gauge.h | 22 | ||||
-rw-r--r-- | ASNMP/asnmp/integer.h | 70 | ||||
-rw-r--r-- | ASNMP/asnmp/octet.h | 30 | ||||
-rw-r--r-- | ASNMP/asnmp/oid.h | 59 | ||||
-rw-r--r-- | ASNMP/asnmp/oid_def.h | 26 | ||||
-rw-r--r-- | ASNMP/asnmp/pdu.h | 62 | ||||
-rw-r--r-- | ASNMP/asnmp/sagent.h | 33 | ||||
-rw-r--r-- | ASNMP/asnmp/smi.h | 90 | ||||
-rw-r--r-- | ASNMP/asnmp/smival.h | 38 | ||||
-rw-r--r-- | ASNMP/asnmp/snmp.h | 59 | ||||
-rw-r--r-- | ASNMP/asnmp/snmperrs.h | 82 | ||||
-rw-r--r-- | ASNMP/asnmp/target.h | 149 | ||||
-rw-r--r-- | ASNMP/asnmp/timetick.h | 42 | ||||
-rw-r--r-- | ASNMP/asnmp/transaction.h | 31 | ||||
-rw-r--r-- | ASNMP/asnmp/transaction_result.h | 4 | ||||
-rw-r--r-- | ASNMP/asnmp/vb.h | 108 | ||||
-rw-r--r-- | ASNMP/asnmp/wpdu.h | 27 | ||||
-rw-r--r-- | ASNMP/tests/test_config.h | 56 |
25 files changed, 886 insertions, 838 deletions
diff --git a/ASNMP/agent/agent_impl.h b/ASNMP/agent/agent_impl.h index ee107a88a99..60ee90034a2 100644 --- a/ASNMP/agent/agent_impl.h +++ b/ASNMP/agent/agent_impl.h @@ -5,16 +5,16 @@ // // = LIBRARY // ASNMP -// +// // = FILENAME -// agent_impl.h +// agent_impl.h // // = AUTHOR -// Michael R. MacFaden -// +// Michael R. MacFaden +// // ============================================================================ -#if !defined (AGENT_IMPL_H) +#ifndef AGENT_IMPL_H #define AGENT_IMPL_H #include <ace/Event_Handler.h> @@ -24,7 +24,7 @@ #include <asnmp/sagent.h> #include <asnmp/vb.h> -class agent_impl : public sagent +class agent_impl : public sagent { public: agent_impl(unsigned short port, const char *rd, const char *wr); @@ -35,7 +35,7 @@ public: virtual int handle_get_next( Pdu &pdu, UdpTarget &target); // retrieve data lexically adjacent to the oids specified in the pdu - // from the peer agent + // from the peer agent virtual int handle_set( Pdu &pdu, UdpTarget &target); // set data in the agent from the list of oids in the pdu @@ -45,7 +45,7 @@ public: private: UdpTarget tgt_; // this agent's read, write community strings - int get_response(Vb& vb); // set values for a "get" cmd + int get_response(Vb& vb); // set values for a "get" cmd ACE_High_Res_Timer agent_clock_; // agent "uptime" ticks reported in 1/100 second }; diff --git a/ASNMP/agent/snmp_agent.h b/ASNMP/agent/snmp_agent.h index 72184ddb14a..a7fc4c42de8 100644 --- a/ASNMP/agent/snmp_agent.h +++ b/ASNMP/agent/snmp_agent.h @@ -13,7 +13,7 @@ // snmp_agent.h // // = AUTHOR -// Michael R. MacFaden (mrm@cisco.com) +// Michael R. MacFaden (mrm@cisco.com) // // ============================================================================ @@ -24,7 +24,7 @@ class snmp_agent { // An SNMP v1 agent class // // = DESCRIPTION - // Contructs agents that are capable of processing SNMPv1 requests + // Contructs agents that are capable of processing SNMPv1 requests // over the MIB II System group public: diff --git a/ASNMP/asnmp/address.h b/ASNMP/asnmp/address.h index 5640a607f98..a9250b8244d 100644 --- a/ASNMP/asnmp/address.h +++ b/ASNMP/asnmp/address.h @@ -15,7 +15,7 @@ // addresses into easy to use, safe and portable classes. // // = AUTHOR -// Peter E Mellquist +// Peter E Mellquist // // ============================================================================ @@ -24,37 +24,42 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. =====================================================================*/ //----[ includes ]----------------------------------------------------- // ACE OS Adaption layer #include "ace/OS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + #include "asnmp/smival.h" #include "asnmp/octet.h" -//----[ enumerated types ] -------------------------------- +//----[ enumerated types ] -------------------------------- enum address_lengths { IPV4LEN=4, UDPIPV4LEN=6, IPV6LEN=16, UDPIPV6LEN=18, IPXLEN=10, - IPXSOCKLEN=12, + IPXSOCKLEN=12, NETBIOSLEN=16, APPLETKLEN=3, DECNETLEN=2, MACLEN=6, HASH0=19, - HASH1=13, + HASH1=13, HASH2=7, MAX_ADDR_SZ=20, MAX_DISPLAY_SZ=MAXHOSTNAMELEN+1 @@ -74,28 +79,28 @@ enum addr_type { type_invalid }; -// TODO: get rest of nb service types added here +// TODO: get rest of nb service types added here enum nb_service { nb_workstation = 0x0, nb_server = 0x20 }; //---[ forward declarations ]----------------------------------------- -class GenAddress; +class GenAddress; class UdpAddress; class IpxSockAddress; class NetbiosAddress; class SIPAddress; // aka ipv6 -// TODO: +// TODO: // class AtmE164Address; //-------------------------------------------------------------------- //----[ Address class ]----------------------------------------------- //-------------------------------------------------------------------- -class ACE_Export Address: public SnmpSyntax +class ACE_Export Address: public SnmpSyntax // = TITLE - // Defines the member functions for the abstract base class + // Defines the member functions for the abstract base class // Address. An Address is a unique network endpoint. { @@ -140,13 +145,13 @@ public: // overloaded <=, is an address less than or equal to a string? virtual operator const char *() const = 0; - // overloaded const char * cast + // overloaded const char * cast - virtual int valid() const; + virtual int valid() const; // verify the is the address object constructed ok - virtual void to_octet(OctetStr& octet) const = 0; - // return a suitable buffer to contain the address + virtual void to_octet(OctetStr& octet) const = 0; + // return a suitable buffer to contain the address virtual SmiUINT32 get_syntax() = 0; // (pure virtual) syntax type @@ -160,7 +165,7 @@ public: virtual SnmpSyntax *clone() const = 0; // create a new instance of this Value - virtual addr_type get_type() const = 0; + virtual addr_type get_type() const = 0; // return the type of address virtual SnmpSyntax& operator=( SnmpSyntax &val) = 0; @@ -173,7 +178,7 @@ public: protected: int valid_flag; // state of constructed object (TRUE/FALSE) - unsigned char address_buffer[MAX_ADDR_SZ]; + unsigned char address_buffer[MAX_ADDR_SZ]; // addr internal representation virtual int parse_address( const char * inaddr) =0; @@ -192,11 +197,11 @@ protected: //----------------------------------------------------------------------- //---------[ IPv4 Address Class ]---------------------------------------- //----------------------------------------------------------------------- -class ACE_Export IpAddress : public Address +class ACE_Export IpAddress : public Address // = TITLE // Defines the member functions for the concrete class IpAddress // An IP Version 4 Address is 4 bytes long and consists of a - // Network, Sub Network, and host component. + // Network, Sub Network, and host component. { public: IpAddress( const char *inaddr = ""); @@ -246,13 +251,13 @@ public: // is this the loopback address? 127.0.0.1/loopback/1.0.0.127.in-addr.arpa int is_multicast() const; - // determine if this is a multicast address + // determine if this is a multicast address int is_broadcast() const; - // determine if this a broadcast address + // determine if this a broadcast address int is_private() const; - // per RFC 1597, private addresses are:: 10, 172.16, and 192.168.0 + // per RFC 1597, private addresses are:: 10, 172.16, and 192.168.0 virtual void to_octet(OctetStr& octet) const; // convert address into octet string format in network byte order @@ -264,12 +269,12 @@ protected: // friendly name storage int iv_friendly_name_status_; - // did resolver call work? some addrs won't resolve + // did resolver call work? some addrs won't resolve virtual int parse_address( const char *inaddr); // redefined parse address // specific to IP addresses - + virtual void format_output(); // redefined format output // specific to IP addresses @@ -295,7 +300,7 @@ protected: //--------------[ DNS Iterator Class ]------------------------------------ //------------------------------------------------------------------------ -class ACE_Export Address_Iter +class ACE_Export Address_Iter // = TITLE // Defines routines to obtain information on a hostname/FQDN // such as multiple addresses @@ -314,9 +319,9 @@ public: private: Address_Iter(const Address_Iter&); - int valid_; // ctor status - int count_; // number of addresses - char **entry_; // ptr to current address + int valid_; // ctor status + int count_; // number of addresses + char **entry_; // ptr to current address struct hostent lookupResult_; ACE_HOSTENT_DATA buffer_; int query_dns(const char *hostname); @@ -325,7 +330,7 @@ private: //------------------------------------------------------------------------ //---------[ UDP/IPv4 Address Class ]------------------------------------- //------------------------------------------------------------------------ -class ACE_Export UdpAddress : public IpAddress +class ACE_Export UdpAddress : public IpAddress // = TITLE // Defines the member functions for the concrete class UdpAddress // A Udp Address consists of an IP Version 4 Address (IpAddress) @@ -370,14 +375,14 @@ public: void set_port( const unsigned short p); // set the port number - unsigned short get_port() const; + unsigned short get_port() const; // get the port number virtual addr_type get_type() const; // return the type protected: - char output_buffer[MAX_DISPLAY_SZ]; + char output_buffer[MAX_DISPLAY_SZ]; // output buffer virtual int parse_address( const char *inaddr); @@ -393,10 +398,10 @@ protected: //------------------------------------------------------------------------- //---------[ 802.3 MAC Address Class ]------------------------------------- //------------------------------------------------------------------------- -class ACE_Export MacAddress : public Address +class ACE_Export MacAddress : public Address // = TITLE // Defines the member functions for the concrete class MacAddress. - // A Media Access Control Address consists of 48 bits as defined + // A Media Access Control Address consists of 48 bits as defined // in IEEE 802.3 specifications. { public: @@ -410,7 +415,7 @@ public: // construct a MacAddress with a GenAddress ~MacAddress(); - // destructor + // destructor SmiUINT32 get_syntax(); // syntax type @@ -421,7 +426,7 @@ public: MacAddress& operator=( const MacAddress &macaddress); // assignment to another IpAddress object overloaded - SnmpSyntax *clone() const; + SnmpSyntax *clone() const; // create a new instance of this Value virtual char *to_string(); @@ -437,10 +442,10 @@ public: // return a hash key virtual void to_octet(OctetStr& octet) const; - // return byte array of the mac address + // return byte array of the mac address protected: - char output_buffer[MAX_DISPLAY_SZ]; + char output_buffer[MAX_DISPLAY_SZ]; // output buffer containing string representation of object virtual int parse_address( const char *inaddr); @@ -453,10 +458,10 @@ protected: //------------------------------------------------------------------------ //---------[ Netbios Address Class ]-------------------------------------- //------------------------------------------------------------------------ -class ACE_Export NetbiosAddress : public Address +class ACE_Export NetbiosAddress : public Address // = TITLE // Defines the member functions for the concrete class NetbiosAddress. - // The IBM/Microsoft address for NETBIOS, NETBEUI protocol transport. + // The IBM/Microsoft address for NETBIOS, NETBEUI protocol transport. { public: @@ -464,15 +469,15 @@ public: // default constructor with string arg NetbiosAddress( const char *inaddr, nb_service svc); - // set name and service type + // set name and service type - NetbiosAddress( const NetbiosAddress& nbaddr); + NetbiosAddress( const NetbiosAddress& nbaddr); // copy constructor - NetbiosAddress( const GenAddress& genaddr); + NetbiosAddress( const GenAddress& genaddr); // construct with a GenAddress - - ~NetbiosAddress(); + + ~NetbiosAddress(); virtual char *to_string(); @@ -490,20 +495,20 @@ public: virtual SmiUINT32 get_syntax(); // syntax type - SnmpSyntax& operator=( SnmpSyntax &val); + SnmpSyntax& operator=( SnmpSyntax &val); // copy an instance of this Value - SnmpSyntax *clone() const; + SnmpSyntax *clone() const; // create a new instance of this Value virtual void to_octet(OctetStr& octet) const; - // output byte buffer containing netbios name + // output byte buffer containing netbios name protected: void InitNBAddr(const char *inaddr); - char output_buffer[MAX_DISPLAY_SZ]; + char output_buffer[MAX_DISPLAY_SZ]; - virtual void format_output(); + virtual void format_output(); // output buffer to hold string representation virtual int parse_address( const char *inaddr); virtual addr_type get_type() const; @@ -512,7 +517,7 @@ protected: //------------------------------------------------------------------------ //---------[ DecNet Address Class ]--------------------------------------- //------------------------------------------------------------------------ -class ACE_Export DecNetAddress : public Address +class ACE_Export DecNetAddress : public Address // = TITLE // Defines the member functions for the concrete class DecNetAddress. // DecNet Phase ? address consists of two octets (CISCO-TC.my) @@ -520,45 +525,45 @@ class ACE_Export DecNetAddress : public Address public: DecNetAddress( const char *inaddr = ""); // default constructor with string arg - + DecNetAddress( const DecNetAddress& decaddr); // copy constructor - + DecNetAddress( const GenAddress& genaddr); // construct with a GenAddress - + ~DecNetAddress(); - + virtual char *to_string(); - + DecNetAddress& operator=( const DecNetAddress &decaddr); virtual void to_octet(OctetStr& octet) const; - // convert address into octet string format 2 bytes of decnet address - + // convert address into octet string format 2 bytes of decnet address + virtual operator const char *() const; // const char * operator overloaded for streaming output - + virtual SmiUINT32 get_syntax(); // syntax type - + SnmpSyntax& operator=( SnmpSyntax &val); // copy an instance of this Value - + SnmpSyntax *clone() const; // create a new instance of this Value - protected: + protected: virtual int parse_address( const char *inaddr); virtual addr_type get_type() const; virtual void format_output(); - char output_buffer[MAX_DISPLAY_SZ]; + char output_buffer[MAX_DISPLAY_SZ]; }; //------------------------------------------------------------------------ //---------[ AppleTalk Address Class ]------------------------------------ //------------------------------------------------------------------------ -class ACE_Export AppleTalkAddress : public Address +class ACE_Export AppleTalkAddress : public Address // = TITLE // Defines the member functions for the concrete class DecNetAddress. // DecNet Phase ? address consists of two octets (CISCO-TC.my) @@ -566,21 +571,21 @@ class ACE_Export AppleTalkAddress : public Address public: AppleTalkAddress( const char *inaddr = ""); // default constructor with string arg - + AppleTalkAddress( const AppleTalkAddress& atkaddr); // copy constructor - + AppleTalkAddress( const GenAddress& genaddr); // construct with a GenAddress - + ~AppleTalkAddress(); - + virtual char *to_string(); - + AppleTalkAddress& operator=( const AppleTalkAddress &atkaddr); - + virtual void to_octet(OctetStr& octet) const; - // convert address into octet string format 3 bytes of atk address + // convert address into octet string format 3 bytes of atk address char get_host_address() const; // get the host part of the address @@ -593,30 +598,30 @@ class ACE_Export AppleTalkAddress : public Address void set_net_address(const short atknet); // set the host 2 byte atk network address - + virtual operator const char *() const; // const char * operator overloaded for streaming output - + virtual SmiUINT32 get_syntax(); // syntax type - + SnmpSyntax& operator=( SnmpSyntax &val); // copy an instance of this Value - + SnmpSyntax *clone() const; // create a new instance of this Value - + private: virtual int parse_address( const char *inaddr); virtual addr_type get_type() const; virtual void format_output(); - char output_buffer[MAX_DISPLAY_SZ]; + char output_buffer[MAX_DISPLAY_SZ]; }; //------------------------------------------------------------------------ //---------[ IPX Address Class ]------------------------------------------ //------------------------------------------------------------------------ -class ACE_Export IpxAddress : public Address +class ACE_Export IpxAddress : public Address // = TITLE // Defines the member functions for the concrete class IpxAddress. // Novell's IPX (version ?) network protocol endpoint @@ -632,12 +637,12 @@ public: // construct with a GenAddress ~IpxAddress(); - // destructor + // destructor virtual SmiUINT32 get_syntax(); // syntax type - SnmpSyntax& operator=( SnmpSyntax &val); + SnmpSyntax& operator=( SnmpSyntax &val); // copy an instance of this Value IpxAddress& operator=( const IpxAddress &ipxaddress); @@ -646,7 +651,7 @@ public: int get_hostid( MacAddress& mac); // get the host id portion of an ipx address - SnmpSyntax *clone() const; + SnmpSyntax *clone() const; // create a new instance of this Value virtual char *to_string(); @@ -659,13 +664,13 @@ public: // return the type virtual void to_octet(OctetStr& octet) const; - // return byte sequence containing ipx address + // return byte sequence containing ipx address protected: char separator; // ipx format separator {:,/} - char output_buffer[MAX_DISPLAY_SZ]; + char output_buffer[MAX_DISPLAY_SZ]; // output buffer to hold string representation virtual int parse_address( const char *inaddr); @@ -681,10 +686,10 @@ protected: //------------------------------------------------------------------------ //---------[ IpxSock Address Class ]-------------------------------------- //------------------------------------------------------------------------ -class ACE_Export IpxSockAddress : public IpxAddress +class ACE_Export IpxSockAddress : public IpxAddress // = TITLE // Defines the member functions for the concrete class IpxAddress. - // Novell's IPX (version ?) network protocol endpoint + // Novell's IPX (version ?) network protocol endpoint { public: IpxSockAddress( const char *inaddr = ""); @@ -706,7 +711,7 @@ public: virtual SmiUINT32 get_syntax(); // syntax type - SnmpSyntax& operator=( SnmpSyntax &val); + SnmpSyntax& operator=( SnmpSyntax &val); // copy an instance of this Value IpxSockAddress& operator=( const IpxSockAddress &ipxaddr); @@ -731,7 +736,7 @@ public: // return the type protected: - char output_buffer[MAX_DISPLAY_SZ]; + char output_buffer[MAX_DISPLAY_SZ]; // output buffer to hold string representation of object virtual int parse_address( const char *inaddr); @@ -745,7 +750,7 @@ protected: //------------------------------------------------------------------------- //--------[ Generic Address ]---------------------------------------------- //------------------------------------------------------------------------- -class ACE_Export GenAddress : public Address +class ACE_Export GenAddress : public Address // = TITLE // Defines the member functions for the concrete class GenAddress. // This class attempts to determine an address type given a char string. @@ -786,12 +791,12 @@ public: virtual void to_octet(OctetStr& octet) const; // return the address as a octet sequence - + protected: Address *address; // pointer to a a concrete address - char output_buffer[MAX_DISPLAY_SZ]; + char output_buffer[MAX_DISPLAY_SZ]; // output buffer of objects value virtual int parse_address( const char *addr); diff --git a/ASNMP/asnmp/asn1.h b/ASNMP/asnmp/asn1.h index ce0256c43df..dd84e8f5b00 100644 --- a/ASNMP/asnmp/asn1.h +++ b/ASNMP/asnmp/asn1.h @@ -15,24 +15,24 @@ // As defined in ISO/IS 8824 and ISO/IS 8825 // This implements a subset of the above International Standards that // is sufficient to implement SNMP. -// +// // = AUTHOR // Steve Waldbusser/CMU ? // // ============================================================================ /********************************************************************** - Copyright 1988, 1989, 1991, 1992 by Carnegie Mellon University + Copyright 1988, 1989, 1991, 1992 by Carnegie Mellon University All Rights Reserved -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in +both that copyright notice and this permission notice appear in supporting documentation, and that the name of CMU not be used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. +software without specific, written prior permission. CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL @@ -44,68 +44,73 @@ SOFTWARE. ******************************************************************/ #include "ace/OS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + #include "asnmp/snmp.h" // CMU code to define "oid" typedef (old C style) #ifndef EIGHTBIT_SUBIDS -typedef unsigned long oid; +typedef unsigned long oid; #define MAX_SUBID 0xFFFFFFFF #else -typedef unsigned char oid; +typedef unsigned char oid; #define MAX_SUBID 0xFF #endif -#define MAX_OID_LEN 64 /* max subid's in an oid */ +#define MAX_OID_LEN 64 /* max subid's in an oid */ // asn.1 values -#define ASN_BOOLEAN (0x01) -#define ASN_INTEGER (0x02) -#define ASN_BIT_STR (0x03) -#define ASN_OCTET_STR (0x04) -#define ASN_NULL (0x05) -#define ASN_OBJECT_ID (0x06) -#define ASN_SEQUENCE (0x10) -#define ASN_SET (0x11) -#define ASN_UNIVERSAL (0x00) +#define ASN_BOOLEAN (0x01) +#define ASN_INTEGER (0x02) +#define ASN_BIT_STR (0x03) +#define ASN_OCTET_STR (0x04) +#define ASN_NULL (0x05) +#define ASN_OBJECT_ID (0x06) +#define ASN_SEQUENCE (0x10) +#define ASN_SET (0x11) +#define ASN_UNIVERSAL (0x00) #define ASN_APPLICATION (0x40) -#define ASN_CONTEXT (0x80) -#define ASN_PRIVATE (0xC0) -#define ASN_PRIMITIVE (0x00) -#define ASN_CONSTRUCTOR (0x20) -#define ASN_LONG_LEN (0x80) +#define ASN_CONTEXT (0x80) +#define ASN_PRIVATE (0xC0) +#define ASN_PRIMITIVE (0x00) +#define ASN_CONSTRUCTOR (0x20) +#define ASN_LONG_LEN (0x80) #define ASN_EXTENSION_ID (0x1F) -#define ASN_BIT8 (0x80) +#define ASN_BIT8 (0x80) -#define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR) -#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID) +#define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR) +#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID) #define ASNERROR( string) -#define MAX_NAME_LEN 64 +#define MAX_NAME_LEN 64 #define SNMP_VERSION_1 0 #define SNMP_VERSION_2C 1 -// defined types (from the SMI, RFC 1065) +// defined types (from the SMI, RFC 1065) #define SMI_IPADDRESS (ASN_APPLICATION | 0) -#define SMI_COUNTER (ASN_APPLICATION | 1) -#define SMI_GAUGE (ASN_APPLICATION | 2) +#define SMI_COUNTER (ASN_APPLICATION | 1) +#define SMI_GAUGE (ASN_APPLICATION | 2) #define SMI_TIMETICKS (ASN_APPLICATION | 3) -#define SMI_OPAQUE (ASN_APPLICATION | 4) +#define SMI_OPAQUE (ASN_APPLICATION | 4) #define SMI_NSAP (ASN_APPLICATION | 5) #define SMI_COUNTER64 (ASN_APPLICATION | 6) #define SMI_UINTEGER (ASN_APPLICATION | 7) -#define GET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) -#define GETNEXT_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) -#define GET_RSP_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) -#define SET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) -#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) +#define GET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0) +#define GETNEXT_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1) +#define GET_RSP_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2) +#define SET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3) +#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4) -#define GETBULK_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) -#define INFORM_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) -#define TRP2_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) -#define REPORT_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) +#define GETBULK_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5) +#define INFORM_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6) +#define TRP2_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7) +#define REPORT_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8) #define SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0) #define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1) @@ -117,37 +122,37 @@ typedef struct sockaddr_in ipaddr; // pdu struct snmp_pdu { - int command; // pdu type - unsigned long reqid; // Request id - unsigned long errstat; // Error status - unsigned long errindex; // Error index - - // Trap information - oid *enterprise; // System OID - int enterprise_length; - ipaddr agent_addr; // address of object generating trap - int trap_type; // trap type - int specific_type; // specific type - unsigned long time; // Uptime - - // vb list + int command; // pdu type + unsigned long reqid; // Request id + unsigned long errstat; // Error status + unsigned long errindex; // Error index + + // Trap information + oid *enterprise; // System OID + int enterprise_length; + ipaddr agent_addr; // address of object generating trap + int trap_type; // trap type + int specific_type; // specific type + unsigned long time; // Uptime + + // vb list struct variable_list *variables; }; // vb list struct variable_list { - struct variable_list *next_variable; // NULL for last variable - oid *name; // Object identifier of variable - int name_length; // number of subid's in name - unsigned char type; // ASN type of variable - union { // value of variable - long *integer; - unsigned char *string; - oid *objid; - unsigned char *bitstring; - struct counter64 *counter64; + struct variable_list *next_variable; // NULL for last variable + oid *name; // Object identifier of variable + int name_length; // number of subid's in name + unsigned char type; // ASN type of variable + union { // value of variable + long *integer; + unsigned char *string; + oid *objid; + unsigned char *bitstring; + struct counter64 *counter64; } val; - int val_len; + int val_len; }; struct counter64 { @@ -156,180 +161,180 @@ struct counter64 { }; // CMU Interface class for ASN.1 routines -class ACE_Export asn1 +class ACE_Export asn1 // = TITLE - // Defines the member functions for the asn1 concrete interface class + // Defines the member functions for the asn1 concrete interface class // CMU routines for performing ASN.1 data marshalling / representation { public: -static unsigned char *parse_int( unsigned char *data, - int *datalength, - unsigned char *type, - long int *intp, - int intsize); -static unsigned char *parse_unsigned_int( unsigned char *data, - int *datalength, - unsigned char *type, - unsigned long *intp, - int intsize); +static unsigned char *parse_int( unsigned char *data, + int *datalength, + unsigned char *type, + long int *intp, + int intsize); +static unsigned char *parse_unsigned_int( unsigned char *data, + int *datalength, + unsigned char *type, + unsigned long *intp, + int intsize); static unsigned char *build_int( unsigned char *data, - int *datalength, - unsigned char type, - long *intp, - int intsize); + int *datalength, + unsigned char type, + long *intp, + int intsize); static unsigned char *build_unsigned_int( unsigned char *data, - int *datalength, - unsigned char type, - unsigned long *intp, - int intsize); + int *datalength, + unsigned char type, + unsigned long *intp, + int intsize); -static unsigned char *parse_string( unsigned char *data, - int *datalength, - unsigned char *type, - unsigned char *string, - int *strlength); +static unsigned char *parse_string( unsigned char *data, + int *datalength, + unsigned char *type, + unsigned char *string, + int *strlength); static unsigned char *build_string( unsigned char *data, - int *datalength, - unsigned char type, - unsigned char *string, - int strlength); + int *datalength, + unsigned char type, + unsigned char *string, + int strlength); static unsigned char *parse_header( unsigned char *data, - int *datalength, - unsigned char *type); + int *datalength, + unsigned char *type); static unsigned char * build_header( unsigned char *data, - int *datalength, - unsigned char type, - int length); + int *datalength, + unsigned char type, + int length); static unsigned char * build_sequence( unsigned char *data, - int *datalength, - unsigned char type, - int length); + int *datalength, + unsigned char type, + int length); static unsigned char * parse_length( unsigned char *data, - unsigned long *length); + unsigned long *length); static unsigned char *build_length( unsigned char *data, - int *datalength, - int length); + int *datalength, + int length); static unsigned char *build_objid( unsigned char *data, - int *datalength, - unsigned char type, - oid *objid, - int objidlength); + int *datalength, + unsigned char type, + oid *objid, + int objidlength); static unsigned char *parse_objid( unsigned char *data, - int *datalength, - unsigned char *type, - oid *objid, - int *objidlength); + int *datalength, + unsigned char *type, + oid *objid, + int *objidlength); -static unsigned char *parse_null(unsigned char *data, - int *datalength, unsigned - char *type); +static unsigned char *parse_null(unsigned char *data, + int *datalength, unsigned + char *type); static unsigned char *build_null( unsigned char *data, - int *datalength, - unsigned char type); + int *datalength, + unsigned char type); static unsigned char *parse_bitstring( unsigned char *data, - int *datalength, - unsigned char *type, - unsigned char *string, - int *strlength); + int *datalength, + unsigned char *type, + unsigned char *string, + int *strlength); static unsigned char *build_bitstring( unsigned char *data, - int *datalength, - unsigned char type, - unsigned char *string, - int strlength); + int *datalength, + unsigned char type, + unsigned char *string, + int strlength); static unsigned char * parse_unsigned_int64(unsigned char *data, - int *datalength, - unsigned char *type, - struct counter64 *cp, - int countersize); + int *datalength, + unsigned char *type, + struct counter64 *cp, + int countersize); static unsigned char * build_unsigned_int64( unsigned char *data, - int *datalength, - unsigned char type, - struct counter64 *cp, - int countersize); + int *datalength, + unsigned char type, + struct counter64 *cp, + int countersize); }; // CMU Interface class for SNMPv1, SNMPv2c routines -class ACE_Export cmu_snmp +class ACE_Export cmu_snmp // = TITLE - // Defines the static functions for the cmu_snmp concrete class. - // These routine create cmu pdu's that can be sent/received on/from agents + // Defines the static functions for the cmu_snmp concrete class. + // These routine create cmu pdu's that can be sent/received on/from agents { public: static struct snmp_pdu *pdu_create( int command); static void free_pdu( struct snmp_pdu *pdu); - static int build( struct snmp_pdu *pdu, - unsigned char *packet, - int *out_length, - long version, - unsigned char* community, - int community_len); - - static void add_var(struct snmp_pdu *pdu, - oid *name, - int name_length, - SmiVALUE *smival); + static int build( struct snmp_pdu *pdu, + unsigned char *packet, + int *out_length, + long version, + unsigned char* community, + int community_len); + + static void add_var(struct snmp_pdu *pdu, + oid *name, + int name_length, + SmiVALUE *smival); static int parse( struct snmp_pdu *pdu, - unsigned char *data, - unsigned char *community_name, - unsigned long &community_len, - snmp_version &version, - int length); + unsigned char *data, + unsigned char *community_name, + unsigned long &community_len, + snmp_version &version, + int length); static unsigned char *auth_build( unsigned char *data, - int *length, - long int version, - unsigned char *community, - int community_len, - int messagelen); + int *length, + long int version, + unsigned char *community, + int community_len, + int messagelen); - static unsigned char *build_var_op(unsigned char *data, - oid * var_name, - int *var_name_len, - unsigned char var_val_type, - int var_val_len, - unsigned char *var_val, - int *listlength); + static unsigned char *build_var_op(unsigned char *data, + oid * var_name, + int *var_name_len, + unsigned char var_val_type, + int var_val_len, + unsigned char *var_val, + int *listlength); static unsigned char *auth_parse(unsigned char *data, int *length, unsigned char *sid, - int *slen, - long *version); + int *slen, + long *version); /* - @params data, IN - pointer to the start of object - var_name OUT - object id of variable - var_name_len IN/OUT - length of variable name - var_val_type OUT - type of variable (int or octet string) (one byte) + @params data, IN - pointer to the start of object + var_name OUT - object id of variable + var_name_len IN/OUT - length of variable name + var_val_type OUT - type of variable (int or octet string) (one byte) var_val_len OUT - length of variable - var_val, OUT - pointer to ASN1 encoded value of variable + var_val, OUT - pointer to ASN1 encoded value of variable listlength IN/OUT - number of valid bytes left in var_op_list */ -static unsigned char *parse_var_op( unsigned char *data, - oid *var_name, - int *var_name_len, - unsigned char *var_val_type, - int *var_val_len, - unsigned char **var_val, - int *listlength); +static unsigned char *parse_var_op( unsigned char *data, + oid *var_name, + int *var_name_len, + unsigned char *var_val_type, + int *var_val_len, + unsigned char **var_val, + int *listlength); }; diff --git a/ASNMP/asnmp/counter.h b/ASNMP/asnmp/counter.h index a4cac10eec7..2b0f79807f3 100644 --- a/ASNMP/asnmp/counter.h +++ b/ASNMP/asnmp/counter.h @@ -14,23 +14,23 @@ // Class definition for SMI Counter32 class. // // = AUTHOR -// Peter E Mellquist +// Peter E Mellquist // // ============================================================================ /*=================================================================== Copyright (c) 1996 Hewlett-Packard Company - + ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. =====================================================================*/ #include "asnmp/smival.h" @@ -46,9 +46,9 @@ class ACE_Export Counter32: public SnmpUInt32 // = TITLE - // Defines the member functions for the Counter32 concrete class + // Defines the member functions for the Counter32 concrete class // This class implements RFC 1155 Counter Object and is named - // Counter32 after the RFC1902 redefinition of V1 SMI datatypes + // Counter32 after the RFC1902 redefinition of V1 SMI datatypes { public: Counter32( const unsigned long i = 0); diff --git a/ASNMP/asnmp/ctr64.h b/ASNMP/asnmp/ctr64.h index fc2d00149c6..f9dc641a94a 100644 --- a/ASNMP/asnmp/ctr64.h +++ b/ASNMP/asnmp/ctr64.h @@ -14,7 +14,7 @@ // SNMP Counter64 class definition. // // = AUTHOR -// Peter E Mellquist +// Peter E Mellquist // // ============================================================================ /*=================================================================== @@ -22,22 +22,22 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. -=====================================================================*/ + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. +=====================================================================*/ #include "asnmp/smival.h" #define CTR64OUTBUF 30 // maximum ascii string for a 64-bit ctr - + //---------[ 64 bit Counter Class ]-------------------------------- // Counter64 Class encapsulates two unsigned integers into a // a single entity. This type has is available in SNMPv2 but @@ -46,18 +46,18 @@ class ACE_Export Counter64: public SnmpSyntax // = TITLE // Defines the member functions for the Counter64 concrete class - // This class implements RFC 1902 64 bit Counter Object. -{ + // This class implements RFC 1902 64 bit Counter Object. +{ public: Counter64( unsigned long long llw = 0); - // default constructor + // default constructor Counter64( unsigned long hiparm, unsigned long loparm); - // constructor with values - + // constructor with values + Counter64( const Counter64 &ctr64); // copy constructor - + ~Counter64(); // destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden) @@ -70,41 +70,41 @@ public: Counter64& assign( long double ld); // assign a long double to a counter64 - unsigned long high() const; - // return the high part - + unsigned long high() const; + // return the high part + unsigned long low() const; - // return the low part - + // return the low part + void set_high( const unsigned long h); - // set the high part - + // set the high part + void set_low( const unsigned long l); - // set the low part + // set the low part Counter64& operator=( const unsigned long long rhs); // overloaded assignment - + Counter64& operator=( const Counter64 &rhs); // overloaded assignment - + char *to_string(); // get a printable ASCII representation - SnmpSyntax *clone() const; + SnmpSyntax *clone() const; // create a new instance of this Value SnmpSyntax& operator=( SnmpSyntax &val); // copy an instance of this Value int valid() const; - // general validity test, always true + // general validity test, always true operator unsigned long long(); // otherwise, behave like an unsigned long long protected: char output_buffer[CTR64OUTBUF]; -}; +}; -#endif // CTR64_ +#endif // CTR64_ diff --git a/ASNMP/asnmp/enttraps.h b/ASNMP/asnmp/enttraps.h index 130f7bdfffe..d90a593a4e4 100644 --- a/ASNMP/asnmp/enttraps.h +++ b/ASNMP/asnmp/enttraps.h @@ -11,7 +11,7 @@ // enttraps.cpp // // = DESCRIPTION -// constants for Enterprise Traps +// constants for Enterprise Traps // // = AUTHOR // Peter E Mellquist @@ -22,84 +22,84 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. -=====================================================================*/ + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. +=====================================================================*/ #include "asnmp/asn1.h" // ASN.1 header file //--------------[ well known trap ids ]----------------------------------- -class ACE_Export snmpTrapsOid: public Oid +class ACE_Export snmpTrapsOid: public Oid // = TITLE - // Defines the member functions for the snmpTrapsOid base class - // to implement the traps defined in RFC 1215 + // Defines the member functions for the snmpTrapsOid base class + // to implement the traps defined in RFC 1215 { - public: + public: snmpTrapsOid (void):Oid("1.3.6.1.6.3.1.1.5"){} }; -class ACE_Export snmpTrapEnterpriseOid: public Oid +class ACE_Export snmpTrapEnterpriseOid: public Oid // = TITLE // Defines the default Enterprise Oid for this software package { - public: + public: snmpTrapEnterpriseOid(void): Oid("1.3.6.1.6.3.1.1.4.3.0") { } }; -class ACE_Export coldStartOid: public snmpTrapsOid +class ACE_Export coldStartOid: public snmpTrapsOid // = TITLE // Defines the RFC 1215 agent cold start generic trap (system reboot) { - public: + public: coldStartOid( void){*this+=".1";} }; -class ACE_Export warmStartOid: public snmpTrapsOid +class ACE_Export warmStartOid: public snmpTrapsOid // = TITLE // Defines the RFC 1215 agent warm start generic trap (agent reboot) { - public: + public: warmStartOid( void){*this+=".2";} }; -class ACE_Export linkDownOid: public snmpTrapsOid +class ACE_Export linkDownOid: public snmpTrapsOid // = TITLE - // Defines the RFC 1215 interface (link) down trap + // Defines the RFC 1215 interface (link) down trap { - public: + public: linkDownOid( void){*this+=".3";} }; // SMI LinkUp Oid -class ACE_Export linkUpOid: public snmpTrapsOid +class ACE_Export linkUpOid: public snmpTrapsOid // = TITLE - // Defines the RFC 1215 interface (link) up trap + // Defines the RFC 1215 interface (link) up trap { - public: + public: linkUpOid( void){*this+=".4";} }; -class ACE_Export authenticationFailureOid: public snmpTrapsOid +class ACE_Export authenticationFailureOid: public snmpTrapsOid // = TITLE // Defines the RFC 1215 device/agent invalid access trap { - public: + public: authenticationFailureOid( void){*this+=".5";} }; -class ACE_Export egpNeighborLossOid: public snmpTrapsOid +class ACE_Export egpNeighborLossOid: public snmpTrapsOid // = TITLE - // Defines the RFC 1215 Exterior Gateway Protocol neighbor loss trap + // Defines the RFC 1215 Exterior Gateway Protocol neighbor loss trap { - public: + public: egpNeighborLossOid( void){*this+=".6";} }; @@ -113,6 +113,6 @@ const authenticationFailureOid authenticationFailure; const egpNeighborLossOid egpNeighborLoss; const snmpTrapEnterpriseOid snmpTrapEnterprise; -#endif +#endif #endif // ENTTRAPS_ diff --git a/ASNMP/asnmp/gauge.h b/ASNMP/asnmp/gauge.h index 612f4b1c3c5..765a713736c 100644 --- a/ASNMP/asnmp/gauge.h +++ b/ASNMP/asnmp/gauge.h @@ -16,7 +16,7 @@ // in RFC 1155 section 3.2.3.4 (ie the value doesn't latch on the max value) // // = AUTHOR -// Peter E Mellquist +// Peter E Mellquist // // ============================================================================ /*=================================================================== @@ -24,15 +24,15 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. =====================================================================*/ #include "asnmp/integer.h" @@ -45,7 +45,7 @@ class ACE_Export Gauge32: public SnmpUInt32 // = TITLE - // Define RFC1902 Gauge datatype from RFC 1155 section 3.2.3.4 + // Define RFC1902 Gauge datatype from RFC 1155 section 3.2.3.4 // Note that this datatype does not behave exactly (acts like a long) { public: diff --git a/ASNMP/asnmp/integer.h b/ASNMP/asnmp/integer.h index 38d94bf7d68..d0dc2972742 100644 --- a/ASNMP/asnmp/integer.h +++ b/ASNMP/asnmp/integer.h @@ -22,16 +22,16 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. -=====================================================================*/ + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. +=====================================================================*/ #include "asnmp/smival.h" @@ -43,35 +43,35 @@ // integers but is contained in a Value object for consistency // among the various types. // class objects may be set or get into Vb objects. -// +// // 32 bit unsigned integer class class ACE_Export SnmpUInt32: public SnmpSyntax // = TITLE - // Implement RFC 1920 Unsigned Integer SMI datatype + // Implement RFC 1920 Unsigned Integer SMI datatype { - - public: + + public: SnmpUInt32 (const unsigned long i = 0); - // default constructor + // default constructor SnmpUInt32( const SnmpUInt32 &c); // copy constructor - + virtual ~SnmpUInt32(); // destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden) virtual SmiUINT32 get_syntax(); // syntax type - SnmpUInt32& operator=( const unsigned long i); - // overloaded assignment - - SnmpUInt32& operator=( const SnmpUInt32 &uli); - // overloaded assignment - + SnmpUInt32& operator=( const unsigned long i); + // overloaded assignment + + SnmpUInt32& operator=( const SnmpUInt32 &uli); + // overloaded assignment + operator unsigned long(); - // otherwise, behave like an unsigned long int + // otherwise, behave like an unsigned long int virtual char *to_string(); // get a printable ASCII value @@ -89,14 +89,14 @@ class ACE_Export SnmpUInt32: public SnmpSyntax int valid_flag; char output_buffer[INTOUTBUF]; // contain string representation of object -}; +}; // 32 bit signed integer class class ACE_Export SnmpInt32: public SnmpSyntax { // = TITLE - // Implement RFC 1902 32 bit Integer SMI data object + // Implement RFC 1902 32 bit Integer SMI data object public: SnmpInt32 (const long i = 0); // constructor with value @@ -110,14 +110,14 @@ class ACE_Export SnmpInt32: public SnmpSyntax virtual SmiUINT32 get_syntax(); // syntax type - SnmpInt32& operator=( const long i); - // overloaded assignment - - SnmpInt32& operator=( const SnmpInt32 &li); - // overloaded assignment - + SnmpInt32& operator=( const long i); + // overloaded assignment + + SnmpInt32& operator=( const SnmpInt32 &li); + // overloaded assignment + operator long(); - // otherwise, behave like a long int + // otherwise, behave like a long int SnmpSyntax *clone() const; // create a new instance of this Value @@ -129,12 +129,12 @@ class ACE_Export SnmpInt32: public SnmpSyntax // get a printable ASCII value int valid() const; - // logical state of object + // logical state of object protected: int valid_flag; char output_buffer[INTOUTBUF]; - // contain string representation of object + // contain string representation of object }; -#endif +#endif diff --git a/ASNMP/asnmp/octet.h b/ASNMP/asnmp/octet.h index d17290dc646..28b3d9fda21 100644 --- a/ASNMP/asnmp/octet.h +++ b/ASNMP/asnmp/octet.h @@ -25,15 +25,15 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. =====================================================================*/ //------------------------------------------------------------------------ @@ -41,12 +41,12 @@ class ACE_Export OctetStr: public SnmpSyntax // = TITLE - // Implement RFC1155 Octet SMI data object + // Implement RFC1155 Octet SMI data object { public: OctetStr( const char *string = "", long size = -1); - // construct octet from byte buffer, assume c style string if size == -1 + // construct octet from byte buffer, assume c style string if size == -1 OctetStr ( const OctetStr &octet); // constructor using another octet object @@ -58,7 +58,7 @@ public: // syntax type void set_data( const SmiBYTE* string, long int size = -1); - // set octet from byte buffer, assume c style string if size == -1 + // set octet from byte buffer, assume c style string if size == -1 OctetStr& operator=( const char *string); // assignment to a string operator overloaded @@ -135,7 +135,7 @@ public: char *to_string_hex(); // get an ASCII formattted hex dump of the contents - SnmpSyntax *clone() const; + SnmpSyntax *clone() const; // create a new instance of this Value SnmpSyntax& operator=( SnmpSyntax &val); @@ -143,8 +143,8 @@ public: protected: //----[ instance variables ] - char *output_buffer; // formatted Octet value - int validity; // validity boolean + char *output_buffer; // formatted Octet value + int validity; // validity boolean }; #endif // OCTET_CLS_ diff --git a/ASNMP/asnmp/oid.h b/ASNMP/asnmp/oid.h index c1a3af2131b..16020e374c0 100644 --- a/ASNMP/asnmp/oid.h +++ b/ASNMP/asnmp/oid.h @@ -8,18 +8,18 @@ // asnmp // // = FILENAME -// oid.h +// oid.h // // = DESCRIPTION // This class is fully contained and does not rely on or any other // SNMP libraries. This class is portable across any platform -// which supports C++. Ported to ACE by Mike MacFaden mrm@cisco.com +// which supports C++. Ported to ACE by Mike MacFaden mrm@cisco.com // and modified for MT. Some API cleanup: collapse constructors, -// add suboid() method remove unnecessary overload, and update a few -// names and types to improve clarity. +// add suboid() method remove unnecessary overload, and update a few +// names and types to improve clarity. // // = AUTHOR -// Peter E Mellquist +// Peter E Mellquist // // ============================================================================ /*=================================================================== @@ -27,24 +27,29 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. =====================================================================*/ //----------[ extern C libraries Needed ]--------------------------------- #include "ace/OS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + #include "asnmp/smival.h" // derived class for all values -class ACE_Export Oid: public SnmpSyntax +class ACE_Export Oid: public SnmpSyntax // = TITLE - // Implement RFC 1155 Object Identifier (OID) datatype + // Implement RFC 1155 Object Identifier (OID) datatype { public: Oid( const char * dotted_oid_string = "", size_t size = unsigned(-1) ); @@ -94,7 +99,7 @@ public: unsigned long & operator[]( size_t position); // allows element access - + SmiLPOID oidval(); // return the WinSnmp oid part @@ -103,7 +108,7 @@ public: void set_data( const unsigned long *raw_oid, const size_t oid_len); // reset the data from raw 4byte integer format - + size_t length() const; // return the len of the oid @@ -111,16 +116,16 @@ public: // trim off the n rightmost values of an oid int suboid(Oid& oid, size_t start = 0, size_t how_many = -1); - // the equivalent of a substr(new_str, 0, 1) + // the equivalent of a substr(new_str, 0, 1) - int left_comparison( const unsigned long n, const Oid &o) const; + int left_comparison( const unsigned long n, const Oid &o) const; // compare the n leftmost bytes (left-to-right) // returns 0, equal // returns -1, < // returns 1 , > - - int right_comparison( const unsigned long n, const Oid &o) const; + + int right_comparison( const unsigned long n, const Oid &o) const; // compare the n rightmost bytes (right-to-left) // returns 0, equal // returns -1, < @@ -129,7 +134,7 @@ public: int valid() const; // is the Oid object valid - char *to_string(); + char *to_string(); // return dotted string value from the right // where the user specifies how many positions to print @@ -140,7 +145,7 @@ public: // copy an instance of this Value protected: - char *iv_str; + char *iv_str; // used for returning oid string int StrToOid( const char *string, SmiLPOID dstOid, size_t& how_many_bytes); @@ -153,10 +158,10 @@ protected: // convert an smi oid to its string representation private: - void set_invalid(); - // release memory, re-init data members + void set_invalid(); + // release memory, re-init data members - void set_null(); + void set_null(); // initialize object data members void init_value( const SmiLPOID srcOid, size_t len); void init_value(const unsigned long *raw_oid, size_t oid_len); diff --git a/ASNMP/asnmp/oid_def.h b/ASNMP/asnmp/oid_def.h index c32c4d0e1f8..bdf46ec4f88 100644 --- a/ASNMP/asnmp/oid_def.h +++ b/ASNMP/asnmp/oid_def.h @@ -14,7 +14,7 @@ // Well known Oids defined in RFC 1215 // // = AUTHOR -// Peter E Mellquist +// Peter E Mellquist // // ============================================================================ /*=================================================================== @@ -36,50 +36,50 @@ // SMI trap oid def class snmpTrapsOid: public Oid { - public: + public: snmpTrapsOid (void):Oid("1.3.6.1.6.3.1.1.5"){}; -}; +}; // SMI Enterprose Oid class snmpTrapEnterpriseOid: public Oid { - public: + public: snmpTrapEnterpriseOid(void):Oid("1.3.6.1.6.3.1.1.4.3.0"){}; -}; +}; // SMI Cold Start Oid class coldStartOid: public snmpTrapsOid { - public: + public: coldStartOid( void){*this+=".1";}; }; // SMI WarmStart Oid class warmStartOid: public snmpTrapsOid { - public: + public: warmStartOid( void){*this+=".2";}; }; // SMI LinkDown Oid class linkDownOid: public snmpTrapsOid { - public: + public: linkDownOid( void){*this+=".3";}; -}; +}; // SMI LinkUp Oid class linkUpOid: public snmpTrapsOid { - public: + public: linkUpOid( void){*this+=".4";}; }; // SMI Authentication Failure Oid class authenticationFailureOid: public snmpTrapsOid { - public: + public: authenticationFailureOid( void){*this+=".5";}; -}; +}; // SMI egpneighborloss Oid class egpNeighborLossOid: public snmpTrapsOid { - public: + public: egpNeighborLossOid( void){*this+=".6";}; }; diff --git a/ASNMP/asnmp/pdu.h b/ASNMP/asnmp/pdu.h index c778b83f241..e748ac5b528 100644 --- a/ASNMP/asnmp/pdu.h +++ b/ASNMP/asnmp/pdu.h @@ -23,27 +23,27 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. =====================================================================*/ // TODO: this needs to be moved into the CLASS and modifyable at runtime // TODO: define an iterator object to traverse the vbs in a pdu #define MAX_VBS 25 -#include "asnmp/vb.h" // include Vb class definition +#include "asnmp/vb.h" // include Vb class definition -class ACE_Export Pdu +class ACE_Export Pdu // = TITLE // Protocol Data Unit (PDU) concrete class. An abstraction of the - // data packet used to by two SNMP sessions to communicate. + // data packet used to by two SNMP sessions to communicate. { public: Pdu( void); @@ -87,7 +87,7 @@ public: // return the error status char *agent_error_reason(); - // return the complete error info from this pdu + // return the complete error info from this pdu friend void set_error_status( Pdu *pdu, const int status); // set the error status @@ -126,7 +126,7 @@ public: // delete a Vb anywhere within the Pdu void delete_all_vbs(); - // delete_all vbs in pdu + // delete_all vbs in pdu void set_notify_timestamp( const TimeTicks & timestamp); // set notify timestamp @@ -151,51 +151,51 @@ public: protected: - Vb *vbs_[MAX_VBS]; + Vb *vbs_[MAX_VBS]; // pointer to array of Vbs - int vb_count_; + int vb_count_; // count of Vbs - int error_status_; + int error_status_; // SMI error status - int error_index_; + int error_index_; // SMI error index - int validity_; - // valid boolean status of object construction - unsigned long request_id_; + int validity_; + // valid boolean status of object construction + unsigned long request_id_; // SMI request id - unsigned short pdu_type_; + unsigned short pdu_type_; // derived at run time based on request type - TimeTicks notify_timestamp_; + TimeTicks notify_timestamp_; // a timestamp associated with an infor // for notify Pdu objects only // traps & notifies - Oid notify_id_; - // an id + Oid notify_id_; + // an id Oid notify_enterprise_; - + private: - char *output_; + char *output_; // buffer for to_string() }; -class VbIter +class VbIter // = TITLE - // Utility class to iterate once through a PDU varbind list + // Utility class to iterate once through a PDU varbind list { public: VbIter(Pdu& pdu); // default constructor - int next(Vb& vb); + int next(Vb& vb); // returns 1 if ok, else 0 if none left private: @@ -206,7 +206,7 @@ class VbIter // current object in list Pdu *pdu_; - // ptr to pdu being interated over + // ptr to pdu being interated over }; #endif //PDU_CLS_ diff --git a/ASNMP/asnmp/sagent.h b/ASNMP/asnmp/sagent.h index d2b64492679..e97d7839be5 100644 --- a/ASNMP/asnmp/sagent.h +++ b/ASNMP/asnmp/sagent.h @@ -13,56 +13,61 @@ // = DESCRIPTION // SNMP agent class defintion. The sagent class provides an object oriented // approach for creating SNMP Agents. The sagent class is an encapsulation of SNMP -// sessions, gets, sets, etc. +// sessions, gets, sets, etc. // // = AUTHOR -// Michael R. MacFaden +// Michael R. MacFaden // // ============================================================================ #include "ace/Reactor.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + #include "ace/SOCK_Dgram.h" #include "asnmp/oid.h" // snmp++ oid class #include "asnmp/vb.h" // snbmp++ vb class #include "asnmp/target.h" // snmp++ target class #include "asnmp/pdu.h" // snmp++ pdu class -#include "asnmp/snmperrs.h" // error macros and strings +#include "asnmp/snmperrs.h" // error macros and strings #include "asnmp/address.h" // snmp++ address class defs -#include "asnmp/snmp.h" // snmp interface +#include "asnmp/snmp.h" // snmp interface -// sagent - supports Version 1 operations in blocking mode +// sagent - supports Version 1 operations in blocking mode #define DEF_AGENT_PORT (161) class ACE_Export sagent : public ACE_Event_Handler, Snmp // = TITLE // Concrete class sagent defines the session and interface to - // communicate with another SNMP Version 1 manager + // communicate with another SNMP Version 1 manager { public: // override the next three methods (callbacks) to implment your agent // - + virtual int handle_get( Pdu &pdu, UdpTarget &target) = 0; // retrieve data from a peer agent for a given list of oid values - virtual int handle_get_next( Pdu &pdu, UdpTarget &target) = 0; + virtual int handle_get_next( Pdu &pdu, UdpTarget &target) = 0; // retrieve data lexically adjacent to the oids specified in the pdu - // from the peer agent + // from the peer agent - virtual int handle_set( Pdu &pdu, UdpTarget &target) = 0; + virtual int handle_set( Pdu &pdu, UdpTarget &target) = 0; // set data in the agent from the list of oids in the pdu - virtual int handle_input(ACE_HANDLE); + virtual int handle_input(ACE_HANDLE); // new pdu received from mgr (reactor calls this) virtual ACE_HANDLE get_handle() const; // retrieve io descriptor (reactor uses this) int respond(Pdu& pdu, UdpTarget& tgt); - // send a response pdu to the mgr + // send a response pdu to the mgr protected: sagent(unsigned short port = DEF_AGENT_PORT); @@ -70,8 +75,8 @@ class ACE_Export sagent : public ACE_Event_Handler, Snmp private: sagent(const sagent&); - Pdu pdu_; // current input pdu - UdpTarget tgt_; // addr & com strs + Pdu pdu_; // current input pdu + UdpTarget tgt_; // addr & com strs }; #endif //SAGENT_CLS_ diff --git a/ASNMP/asnmp/smi.h b/ASNMP/asnmp/smi.h index 6a67ebcd061..09b3927b220 100644 --- a/ASNMP/asnmp/smi.h +++ b/ASNMP/asnmp/smi.h @@ -8,14 +8,14 @@ // asnmp // // = FILENAME -// smi.h +// smi.h // // = DESCRIPTION -// Address class definition. Encapsulates various network +// Address class definition. Encapsulates various network // addresses into easy to use, safe and portable classes. // // = AUTHOR -// ?? +// ?? // // ============================================================================ /*=================================================================== @@ -23,52 +23,56 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. - + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. + =====================================================================*/ - + #include "ace/OS.h" +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + //----------[ ASN/BER Base Types ]----------------------------------------- // Basic Encoding Rules (BER) -// (used in forming SYNTAXes and certain SNMP types/values) +// (used in forming SYNTAXes and certain SNMP types/values) #define aSN_UNIVERSAL (0x00) #define aSN_APPLICATION (0x40) #define aSN_CONTEXT (0x80) #define aSN_PRIVATE (0xC0) #define aSN_PRIMITIVE (0x00) -#define aSN_CONSTRUCTOR (0x20) +#define aSN_CONSTRUCTOR (0x20) //------[ SNMP ObjectSyntax Values ]--------------------------------------- -#define sNMP_SYNTAX_SEQUENCE (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x10) +#define sNMP_SYNTAX_SEQUENCE (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x10) //------------------------------------------------------------------------- -// These values are used in the "syntax" member -// of the smiVALUE structure which follows. +// These values are used in the "syntax" member +// of the smiVALUE structure which follows. // Note: UInt32 is indistinguishable from Gauge32 per SNMPv2 Draft Standard // NsapAddr is obsoleted as unique SMI type per SNMPv2 Draft Standard -#define sNMP_SYNTAX_INT (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x02) -#define sNMP_SYNTAX_BITS (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x03) -#define sNMP_SYNTAX_OCTETS (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x04) -#define sNMP_SYNTAX_NULL (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x05) -#define sNMP_SYNTAX_OID (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x06) -#define sNMP_SYNTAX_INT32 sNMP_SYNTAX_INT -#define sNMP_SYNTAX_IPADDR (aSN_APPLICATION | aSN_PRIMITIVE | 0x00) -#define sNMP_SYNTAX_CNTR32 (aSN_APPLICATION | aSN_PRIMITIVE | 0x01) -#define sNMP_SYNTAX_GAUGE32 (aSN_APPLICATION | aSN_PRIMITIVE | 0x02) -#define sNMP_SYNTAX_TIMETICKS (aSN_APPLICATION | aSN_PRIMITIVE | 0x03) -#define sNMP_SYNTAX_OPAQUE (aSN_APPLICATION | aSN_PRIMITIVE | 0x04) -#define sNMP_SYNTAX_CNTR64 (aSN_APPLICATION | aSN_PRIMITIVE | 0x06) -#define sNMP_SYNTAX_UINT32 (aSN_APPLICATION | aSN_PRIMITIVE | 0x07) +#define sNMP_SYNTAX_INT (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x02) +#define sNMP_SYNTAX_BITS (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x03) +#define sNMP_SYNTAX_OCTETS (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x04) +#define sNMP_SYNTAX_NULL (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x05) +#define sNMP_SYNTAX_OID (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x06) +#define sNMP_SYNTAX_INT32 sNMP_SYNTAX_INT +#define sNMP_SYNTAX_IPADDR (aSN_APPLICATION | aSN_PRIMITIVE | 0x00) +#define sNMP_SYNTAX_CNTR32 (aSN_APPLICATION | aSN_PRIMITIVE | 0x01) +#define sNMP_SYNTAX_GAUGE32 (aSN_APPLICATION | aSN_PRIMITIVE | 0x02) +#define sNMP_SYNTAX_TIMETICKS (aSN_APPLICATION | aSN_PRIMITIVE | 0x03) +#define sNMP_SYNTAX_OPAQUE (aSN_APPLICATION | aSN_PRIMITIVE | 0x04) +#define sNMP_SYNTAX_CNTR64 (aSN_APPLICATION | aSN_PRIMITIVE | 0x06) +#define sNMP_SYNTAX_UINT32 (aSN_APPLICATION | aSN_PRIMITIVE | 0x07) //------------------------------------------------------------------------- @@ -80,23 +84,23 @@ //--------------[ different types of PDU's ]------------------------------- -#define sNMP_PDU_GET (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x0) -#define sNMP_PDU_GETNEXT (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x1) -#define sNMP_PDU_RESPONSE (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x2) -#define sNMP_PDU_SET (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x3) +#define sNMP_PDU_GET (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x0) +#define sNMP_PDU_GETNEXT (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x1) +#define sNMP_PDU_RESPONSE (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x2) +#define sNMP_PDU_SET (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x3) #define sNMP_PDU_V1TRAP (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x4) #define sNMP_PDU_GETBULK (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x5) #define sNMP_PDU_INFORM (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x6) #define sNMP_PDU_TRAP (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x7) - + //------[ smi typedefs ]--------------------------------------------------- -// SNMP-related types from RFC1442 (SMI) +// SNMP-related types from RFC1442 (SMI) typedef unsigned char SmiBYTE, *SmiLPBYTE; //------------------------------------------------------------------------- -// SNMP-related types from RFC1442 (SMI) +// SNMP-related types from RFC1442 (SMI) // int typedef long SmiINT, *SmiLPINT; @@ -112,7 +116,7 @@ typedef struct { SmiUINT32 len; SmiLPBYTE ptr;} SmiOCTETS, *SmiLPOCTETS; -// bits +// bits typedef SmiOCTETS SmiBITS, *SmiLPBITS; // SMI oid struct @@ -120,7 +124,7 @@ typedef struct { SmiUINT32 len; SmiLPUINT32 ptr;} SmiOID, *SmiLPOID; -// ipaddr +// ipaddr typedef SmiOCTETS SmiIPADDR, *SmiLPIPADDR; // 32bit counter @@ -143,7 +147,7 @@ typedef struct { SmiUINT32 hipart; SmiUINT32 lopart; } SmiCNTR64, *SmiLPCNTR64; - + #endif // SMIDEF_ - + diff --git a/ASNMP/asnmp/smival.h b/ASNMP/asnmp/smival.h index dff38438490..6e7c8c4c1b9 100644 --- a/ASNMP/asnmp/smival.h +++ b/ASNMP/asnmp/smival.h @@ -24,16 +24,16 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. -=====================================================================*/ + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. +=====================================================================*/ //----[ includes ]----------------------------------------------------- #include "asnmp/smi.h" @@ -42,10 +42,10 @@ //====================================================================== // SMI value structure conforming with SMI RFC -// -typedef struct { /* smiVALUE portion of VarBind */ - SmiUINT32 syntax; /* Insert SNMP_SYNTAX_<type> */ - union { +// +typedef struct { /* smiVALUE portion of VarBind */ + SmiUINT32 syntax; /* Insert SNMP_SYNTAX_<type> */ + union { SmiINT sNumber; /* SNMP_SYNTAX_INT SNMP_SYNTAX_INT32 */ SmiUINT32 uNumber; /* SNMP_SYNTAX_UINT32 @@ -63,9 +63,9 @@ typedef struct { /* smiVALUE portion of VarBind */ SNMP_SYNTAX_NOSUCHOBJECT SNMP_SYNTAX_NOSUCHINSTANCE SNMP_SYNTAX_ENDOFMIBVIEW */ - } value; + } value; } SmiVALUE, *SmiLPVALUE; - + // An "abstract" (pure virtual) class that serves as the base class // for all specific SNMP syntax types. // @@ -76,7 +76,7 @@ public: // virtual function for getting a printable ASCII value for any SNMP Value virtual SmiUINT32 get_syntax() = 0; - // return the current syntax + // return the current syntax virtual SnmpSyntax * clone() const = 0; // virtual clone operation for creating a new Value from an existing @@ -87,8 +87,8 @@ public: // virtual destructor to ensure deletion of derived classes... virtual SnmpSyntax& operator=( SnmpSyntax &/*val*/) - { - return *this; + { + return *this; } // overloaded assignment operator // This should be pure virtual, but WinNT compiler diff --git a/ASNMP/asnmp/snmp.h b/ASNMP/asnmp/snmp.h index 725a80dfadb..65a7700721b 100644 --- a/ASNMP/asnmp/snmp.h +++ b/ASNMP/asnmp/snmp.h @@ -18,7 +18,7 @@ // // = AUTHOR // Peter E Mellquist design, first implementation -// Michael R. MacFaden port to ACE / use Reactor pattern +// Michael R. MacFaden port to ACE / use Reactor pattern // // ============================================================================ /*=================================================================== @@ -26,25 +26,30 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. =====================================================================*/ #include "ace/Reactor.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + #include "ace/SOCK_Dgram.h" #include "asnmp/oid.h" // snmp++ oid class #include "asnmp/vb.h" // snbmp++ vb class #include "asnmp/target.h" // snmp++ target class #include "asnmp/pdu.h" // snmp++ pdu class -#include "asnmp/snmperrs.h" // error macros and strings +#include "asnmp/snmperrs.h" // error macros and strings #include "asnmp/address.h" // snmp++ address class defs #include "asnmp/transaction_result.h" @@ -56,11 +61,11 @@ class ACE_Export Snmp_Result virtual void result(Snmp *snmp, int result) = 0; }; -// Snmp session class - supports Version 1 operations in blocking mode +// Snmp session class - supports Version 1 operations in blocking mode class ACE_Export Snmp : public transaction_result // = TITLE // Concrete class Snmp defined the session and interface to - // communicate with another SNMP Version 1 agent + // communicate with another SNMP Version 1 agent { Snmp_Result * result_; Pdu * pdu_; @@ -73,25 +78,25 @@ class ACE_Export Snmp : public transaction_result // retrieve data from a peer agent for a given list of oid values // default port 161 - int get_next( Pdu &pdu, UdpTarget &target, Snmp_Result * cb = 0); + int get_next( Pdu &pdu, UdpTarget &target, Snmp_Result * cb = 0); // retrieve data lexically adjacent to the oids specified in the pdu - // from the peer agent + // from the peer agent // default port 161 - int set( Pdu &pdu, UdpTarget &target, Snmp_Result * cb = 0); + int set( Pdu &pdu, UdpTarget &target, Snmp_Result * cb = 0); // set data in the agent from the list of oids in the pdu // default port 161 int trap( Pdu &pdu, UdpTarget &target); // send an SNMPv1 trap (unreliable) to a remote system (def port 162) - int valid() const; - // status of object after construction + int valid() const; + // status of object after construction - static char * error_string(int code); + static char * error_string(int code); // given error code, return string reason - char * error_string(); + char * error_string(); // retrieve a reason string if any of the above commands fail void result(transaction * t, int rc); @@ -105,17 +110,17 @@ class ACE_Export Snmp : public transaction_result Snmp(const Snmp&); - ACE_SOCK_Dgram iv_snmp_session_; - // io object + ACE_SOCK_Dgram iv_snmp_session_; + // io object - int construct_status_; + int construct_status_; // status of construction - int last_transaction_status_; - // result code from last transaction + int last_transaction_status_; + // result code from last transaction - unsigned req_id_; - // transaction request id + unsigned req_id_; + // transaction request id }; #endif //SNMP_CLS_ diff --git a/ASNMP/asnmp/snmperrs.h b/ASNMP/asnmp/snmperrs.h index a51fcc68f48..bd7a5e9df56 100644 --- a/ASNMP/asnmp/snmperrs.h +++ b/ASNMP/asnmp/snmperrs.h @@ -22,15 +22,15 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. ============================================================================*/ @@ -39,11 +39,11 @@ // // The values can be returned via Pdu::get_error_status() // -#define SNMP_ERROR_SUCCESS 0 // Success Status -#define SNMP_ERROR_TOO_BIG 1 // Pdu encoding too big -#define SNMP_ERROR_NO_SUCH_NAME 2 // No such VB name, see error index +#define SNMP_ERROR_SUCCESS 0 // Success Status +#define SNMP_ERROR_TOO_BIG 1 // Pdu encoding too big +#define SNMP_ERROR_NO_SUCH_NAME 2 // No such VB name, see error index #define SNMP_ERROR_BAD_VALUE 3 // Bad Vb -#define SNMP_ERROR_READ_ONLY 4 // VB is read only, see error index +#define SNMP_ERROR_READ_ONLY 4 // VB is read only, see error index #define SNMP_ERROR_GENERAL_VB_ERR 5 // General VB error, see error index #define SNMP_ERROR_NO_ACCESS 6 // No access to MIBs data #define SNMP_ERROR_WRONG_TYPE 7 // Requested type was incorrect @@ -52,8 +52,8 @@ #define SNMP_ERROR_WRONG_VALUE 10 // Request Pdu has wrong value #define SNMP_ERROR_NO_CREATION 11 // Unable to create object specified #define SNMP_ERROR_INCONSIST_VAL 12 // Inconsistent value in request -#define SNMP_ERROR_RESOURCE_UNAVAIL 13 // Resources unavailable -#define SNMP_ERROR_COMITFAIL 14 // Unable to comit +#define SNMP_ERROR_RESOURCE_UNAVAIL 13 // Resources unavailable +#define SNMP_ERROR_COMITFAIL 14 // Unable to comit #define SNMP_ERROR_UNDO_FAIL 15 // Unable to undo #define SNMP_ERROR_AUTH_ERR 16 // Authentication failure #define SNMP_ERROR_NOT_WRITEABLE 17 // Mib Object not writeable @@ -65,7 +65,7 @@ // General #define SNMP_CLASS_SUCCESS 0 // success #define SNMP_CLASS_ERROR -1 // general error -#define SNMP_CLASS_RESOURCE_UNAVAIL -2 // e.g., malloc failed +#define SNMP_CLASS_RESOURCE_UNAVAIL -2 // e.g., malloc failed #define SNMP_CLASS_INTERNAL_ERROR -3 // unexpected / internal error #define SNMP_CLASS_UNSUPPORTED -4 // unsupported function @@ -74,7 +74,7 @@ #define SNMP_CLASS_ASYNC_RESPONSE -6 // received response for outstd request #define SNMP_CLASS_NOTIFICATION -7 // received notification (trap/inform) #define SNMP_CLASS_SESSION_DESTROYED -8 // snmp::destroyed with oustanding reqs pending - + // Snmp Class: #define SNMP_CLASS_INVALID -10 // snmp::mf called on invalid instance #define SNMP_CLASS_INVALID_PDU -11 // invalid pdu passed to mf @@ -82,14 +82,14 @@ #define SNMP_CLASS_INVALID_CALLBACK -13 // invalid callback to mf #define SNMP_CLASS_INVALID_REQID -14 // invalid request id to cancel #define SNMP_CLASS_INVALID_NOTIFYID -15 // missing trap/inform oid -#define SNMP_CLASS_INVALID_OPERATION -16 // snmp operation not allowed for specified target -#define SNMP_CLASS_INVALID_OID -17 // invalid oid passed to mf +#define SNMP_CLASS_INVALID_OPERATION -16 // snmp operation not allowed for specified target +#define SNMP_CLASS_INVALID_OID -17 // invalid oid passed to mf #define SNMP_CLASS_INVALID_ADDRESS -18 // invalid address passed to mf #define SNMP_CLASS_ERR_STATUS_SET -19 // agent returned response pdu with error_status set // Transport Errors: -#define SNMP_CLASS_TL_UNSUPPORTED -20 // transport unsupported -#define SNMP_CLASS_TL_IN_USE -21 // transport in use +#define SNMP_CLASS_TL_UNSUPPORTED -20 // transport unsupported +#define SNMP_CLASS_TL_IN_USE -21 // transport in use #define SNMP_CLASS_TL_FAILED -22 // transport operation failed // extras @@ -106,12 +106,12 @@ #define MAX_NEG_ERROR SNMP_CLASS_SHUTDOWN static char * pErrs[] = { - "Success", // 0 + "Success", // 0 "SNMP: Response PDU Too Big", // 1 - "SNMP: Variable does not exist", // 2 - "SNMP: Cannot modify variable: Bad Value", // 3 - "SNMP: Cannot modify object, Read Only", // 4 - "SNMP: Cannot perform operation, General Error", // 5 + "SNMP: Variable does not exist", // 2 + "SNMP: Cannot modify variable: Bad Value", // 3 + "SNMP: Cannot modify object, Read Only", // 4 + "SNMP: Cannot perform operation, General Error", // 5 "SNMP: Cannot access variable, No Access", // 6 "SNMP: Cannot create/modify variable, Wrong Type", // 7 "SNMP: Cannot create/set variable, Wrong Length", // 8 @@ -146,24 +146,24 @@ static char * nErrs[] = { "ASNMP: Unsupported function", // Callback reasons: - // 5 SNMP_CLASS_TIMEOUT + // 5 SNMP_CLASS_TIMEOUT "ASNMP: SNMP request timed out", - // 6 SNMP_CLASS_ASYNC_RESPONSE - "ASNMP: Received SNMP Response", + // 6 SNMP_CLASS_ASYNC_RESPONSE + "ASNMP: Received SNMP Response", - // 7 SNMP_CLASS_NOTIFICATION + // 7 SNMP_CLASS_NOTIFICATION "ASNMP: Received SNMP Notification (trap or inform)", - // 8 SNMP_CLASS_SESSION_DESTROYED + // 8 SNMP_CLASS_SESSION_DESTROYED "ASNMP: Closing session with outstanding requests", // 9 reserved for future - "Unknown error code", + "Unknown error code", // Snmp Class errors: // 10 SNMP_CLASS_INVALID - "ASNMP: Class not valid", + "ASNMP: Class not valid", // 11 SNMP_CLASS_INVALID_PDU "ASNMP: Invalid Pdu", @@ -181,30 +181,30 @@ static char * nErrs[] = { "ASNMP: Invalid Notification Id", // 16 SNMP_CLASS_INVALID_OPERATION - "ASNMP: SNMP Operation not supported on specified Target", + "ASNMP: SNMP Operation not supported on specified Target", - // 17 SNMP_CLASS_INVALID_OID + // 17 SNMP_CLASS_INVALID_OID "ASNMP: Invalid Object Identifier", - // 18 SNMP_CLASS_INVALID_ADDRESS + // 18 SNMP_CLASS_INVALID_ADDRESS "ASNMP: Invalid Address", - // 19 SNMP_CLASS_ERR_STATUS_SET + // 19 SNMP_CLASS_ERR_STATUS_SET "ASNMP: Agent indicates error in SNMP request", // Transport Errors: - // 20 SNMP_CLASS_TL_UNSUPPORTED + // 20 SNMP_CLASS_TL_UNSUPPORTED "ASNMP: Transport is not supported", - // 21 SNMP_CLASS_TL_IN_USE + // 21 SNMP_CLASS_TL_IN_USE "ASNMP: Transport is in use", - // 22 SNMP_CLASS_TL_FAILED + // 22 SNMP_CLASS_TL_FAILED "ASNMP: Transport operation failed", // 23 SNMP_CLASS_SHUTDOWN "ASNMP: Blocked Mode Shutdown", - + // unknown error code "Unknown error code", }; diff --git a/ASNMP/asnmp/target.h b/ASNMP/asnmp/target.h index fe1e3f8898d..7dfc14ab5d8 100644 --- a/ASNMP/asnmp/target.h +++ b/ASNMP/asnmp/target.h @@ -13,7 +13,7 @@ // = DESCRIPTION // // = AUTHOR -// Peter E Mellquist +// Peter E Mellquist // Michael R. MacFaden (ported to ACE) // ============================================================================ /*=================================================================== @@ -21,20 +21,25 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS" without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. -=====================================================================*/ + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS" without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. +=====================================================================*/ //----[ includes ]------------------------------------------------ #include "ace/INET_Addr.h" -#include "asnmp/address.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "asnmp/address.h" #include "asnmp/oid.h" #include "asnmp/octet.h" @@ -46,38 +51,38 @@ enum snmp_version { }; // targets contain the following default properties -enum ASNMP_Defs { - DEF_TIMEOUT = 1, // unit: seconds - DEF_RETRIES = 1, // no retry default - DEF_MAX_SNMP_PACKET = 1430, // maximum pdu len on the wire (eth mtu-ip hdr) +enum ASNMP_Defs { + DEF_TIMEOUT = 1, // unit: seconds + DEF_RETRIES = 1, // no retry default + DEF_MAX_SNMP_PACKET = 1430, // maximum pdu len on the wire (eth mtu-ip hdr) // split bigger pdus (not implemented yet) - DEF_AGENT_PORT = 161, // port # for SNMP agent + DEF_AGENT_PORT = 161, // port # for SNMP agent DEF_TRAP_PORT = 162, // port # for SNMP trap receiver DEF_VERSION = version1, // default SNMP version - MAX_COMM_STR_LEN = 255, // max value this impl will accept from client - MAX_TARGET_STRING_REP = 2048 // max value this impl will accept from client + MAX_COMM_STR_LEN = 255, // max value this impl will accept from client + MAX_TARGET_STRING_REP = 2048 // max value this impl will accept from client }; #define READ_COMM_STR "public" #define WRITE_COMM_STR "private" - + // Abstract class used to provide a virtual interface into Targets -// -class ACE_Export SnmpTarget +// +class ACE_Export SnmpTarget // = TITLE - // Abstract Base class SnmpTarget is used to Collect all transmission - // details to communicate with an SNMP -{ + // Abstract Base class SnmpTarget is used to Collect all transmission + // details to communicate with an SNMP +{ public: virtual ~SnmpTarget(); // allow destruction of derived classes - int valid() const; + int valid() const; // return validity of target void set_retry( const int r); - // set the retry value + // set the retry value void set_timeout( const unsigned long t); // set the object's timeout (in seconds) @@ -85,16 +90,16 @@ class ACE_Export SnmpTarget void set_version( const snmp_version v); // set the instance version - void set_max_pdu_size(const unsigned long max_pdu_sz); + void set_max_pdu_size(const unsigned long max_pdu_sz); // all classes constructed will have this write community string void set_default_timeout( const unsigned long t); // change the "class" default default timeout (in seconds) void set_default_retry( const int r); - // change the default send retries + // change the default send retries - void set_default_max_pdu_size(const unsigned long max_pdu_sz); + void set_default_max_pdu_size(const unsigned long max_pdu_sz); // all classes constructed will have this write community string void set_default_version( const snmp_version v); @@ -104,24 +109,24 @@ class ACE_Export SnmpTarget int get_default_retry() const; // get the retry value - + unsigned long get_timeout() const; // get the timeout (seconds) - unsigned long get_max_pdu_size() const; + unsigned long get_max_pdu_size() const; // get instance max buffer size - void get_default_max_pdu_size(const unsigned long max_pdu_sz); + void get_default_max_pdu_size(const unsigned long max_pdu_sz); // all classes constructed will have this write community string snmp_version get_version() const; // get the version snmp_version get_default_version() const; - + int get_retry() const; // return send retry number for this instancd - + virtual SnmpTarget *clone() const = 0; // virtual clone operation for creating a new SnmpTarget from an existing // SnmpTarget. The caller MUST use the delete operation on the return @@ -136,57 +141,57 @@ class ACE_Export SnmpTarget SnmpTarget(); // SnmpTarget(const SnmpTarget &); - int validity_; + int validity_; // used by derived class instances - unsigned long timeout_; + unsigned long timeout_; // instance value xmit timeout in milli secs - int retries_; - // instance value number of retries + int retries_; + // instance value number of retries - unsigned max_pdu_size_; + unsigned max_pdu_size_; // size of pdu - snmp_version version_; - // instance value the snmp version + snmp_version version_; + // instance value the snmp version - // class wide default values - static unsigned long default_timeout_; + // class wide default values + static unsigned long default_timeout_; // xmit timeout in secs - static int default_retries_; - // number of retries + static int default_retries_; + // number of retries static unsigned long default_max_pdu_size_; - static snmp_version default_version_; - // snmp protocol version + static snmp_version default_version_; + // snmp protocol version }; - -//----[ UdpTarget class ]---------------------------------------------- + +//----[ UdpTarget class ]---------------------------------------------- // UDP/IP transport using "community string" based agents (targets) // -class ACE_Export UdpTarget: public SnmpTarget +class ACE_Export UdpTarget: public SnmpTarget // = TITLE - // Concrete class UdpTarget contains all Details for communicating + // Concrete class UdpTarget contains all Details for communicating // with a SNMPv1 agent over UDP/IPv4 transport -{ - public: +{ + public: UdpTarget(); UdpTarget( const UdpAddress& udp); // constructor with only address - // assumes default as public, public + // assumes default as public, public // can be constructed with IP address object - UdpTarget( ACE_INET_Addr& ace_inet_addr); + UdpTarget( ACE_INET_Addr& ace_inet_addr); // can be constructed with Udp address object TODO: merge addresses - + ~UdpTarget(); // destructor - // ** set *** - + // ** set *** + void set_read_community( const OctetStr& new_read_community); // set the read community using an OctetStr @@ -196,7 +201,7 @@ class ACE_Export UdpTarget: public SnmpTarget int set_address( UdpAddress &udp_address); // set the address - // ** get *** + // ** get *** void get_read_community( OctetStr& read_community_oct) const; // get the read community as an Octet Str object @@ -220,27 +225,27 @@ class ACE_Export UdpTarget: public SnmpTarget // all classes constructed will have this write community string UdpTarget& operator=( const UdpTarget& target); - // overloaded assignment + // overloaded assignment friend int operator==( const UdpTarget &lhs, const UdpTarget &rhs); // compare two C targets - - char *to_string(); - // string representation of object - + + char *to_string(); + // string representation of object + SnmpTarget *clone() const; // clone from existing UdpTarget - + protected: static OctetStr default_rd_community_; static OctetStr default_wr_community_; - OctetStr read_community_; - OctetStr write_community_; - UdpAddress udp_address_; - snmp_version version_; + OctetStr read_community_; + OctetStr write_community_; + UdpAddress udp_address_; + snmp_version version_; - char output_buffer_[MAX_TARGET_STRING_REP]; - // to_string() rep of data + char output_buffer_[MAX_TARGET_STRING_REP]; + // to_string() rep of data }; diff --git a/ASNMP/asnmp/timetick.h b/ASNMP/asnmp/timetick.h index cc959df4f8b..8e4609c124b 100644 --- a/ASNMP/asnmp/timetick.h +++ b/ASNMP/asnmp/timetick.h @@ -22,15 +22,15 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. =====================================================================*/ #include "asnmp/integer.h" @@ -44,18 +44,18 @@ // class ACE_Export TimeTicks: public SnmpUInt32 // = TITLE - // Define RFC1155 TimeTicks Data object + // Define RFC1155 TimeTicks Data object { - + public: TimeTicks( const unsigned long i = 0); - + TimeTicks( const TimeTicks &t); // copy constructor ~TimeTicks(); - // destructor + // destructor SmiUINT32 get_syntax(); // syntax type @@ -68,18 +68,18 @@ class ACE_Export TimeTicks: public SnmpUInt32 SnmpSyntax& operator=(SnmpSyntax &val); // copy an instance of this Value - - TimeTicks& operator=( const TimeTicks &uli); + + TimeTicks& operator=( const TimeTicks &uli); // overloaded assignment - - TimeTicks& operator=( const unsigned long int i); + + TimeTicks& operator=( const unsigned long int i); // overloaded assignment - + operator unsigned long(); - // otherwise, behave like an unsigned long + // otherwise, behave like an unsigned long protected: - char output_buffer[TICKOUTBUF]; + char output_buffer[TICKOUTBUF]; // for storing printed form -}; +}; #endif // TIMETICKS_ diff --git a/ASNMP/asnmp/transaction.h b/ASNMP/asnmp/transaction.h index 4db2e83f63c..4ded5f34e1b 100644 --- a/ASNMP/asnmp/transaction.h +++ b/ASNMP/asnmp/transaction.h @@ -13,21 +13,26 @@ // = DESCRIPTION // // = AUTHOR -// Michael R. MacFaden port to ACE / use Reactor pattern +// Michael R. MacFaden port to ACE / use Reactor pattern // // ============================================================================ #include "ace/Event_Handler.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + #include "asnmp/target.h" #include "asnmp/pdu.h" #include "asnmp/transaction_result.h" -#include "asnmp/wpdu.h" // cmu adapter class +#include "asnmp/wpdu.h" // cmu adapter class #include "ace/SOCK_Dgram.h" -class ACE_Export transaction : public ACE_Event_Handler +class ACE_Export transaction : public ACE_Event_Handler // = TITLE // Used to manage the details of a particular transaction betwen - // two SNMP agents. Uses SnmpTarget class to implement retry/timeout + // two SNMP agents. Uses SnmpTarget class to implement retry/timeout { int retry_counter_; @@ -40,11 +45,11 @@ class ACE_Export transaction : public ACE_Event_Handler ~transaction(); // destructor - int run(); + int run(); int run(transaction_result *r); // Async interface, with callback object // begin polling for values - int result(Pdu& pdu, char *comm_str = 0, ACE_INET_Addr *from_addr = 0); + int result(Pdu& pdu, char *comm_str = 0, ACE_INET_Addr *from_addr = 0); // return pdu with result from agent after run() is completed rc = 0 // optionally get community str @@ -58,18 +63,18 @@ class ACE_Export transaction : public ACE_Event_Handler const ACE_INET_Addr& get_from_addr() const; // pre: handle_input called - // retrieve the sender's from address from the last pkt + // retrieve the sender's from address from the last pkt private: transaction(const transaction&); // disallow copy construction - wpdu wp_; // wire pdu - UdpTarget params_; // params - ACE_INET_Addr addr_; // to address - ACE_SOCK_Dgram session_; // io object - iovec receive_iovec_; // receive buffer - ACE_INET_Addr receive_addr_; // from address + wpdu wp_; // wire pdu + UdpTarget params_; // params + ACE_INET_Addr addr_; // to address + ACE_SOCK_Dgram session_; // io object + iovec receive_iovec_; // receive buffer + ACE_INET_Addr receive_addr_; // from address }; #endif // TRANSACTION_ diff --git a/ASNMP/asnmp/transaction_result.h b/ASNMP/asnmp/transaction_result.h index 9d0dbfc40b8..1c0472675ea 100644 --- a/ASNMP/asnmp/transaction_result.h +++ b/ASNMP/asnmp/transaction_result.h @@ -11,10 +11,10 @@ // transaction_result.h // // = DESCRIPTION -// An object respresenting a request/reply operation between mgr/agent +// An object respresenting a request/reply operation between mgr/agent // // = AUTHOR -// Michael R. MacFaden +// Michael R. MacFaden // // ============================================================================ diff --git a/ASNMP/asnmp/vb.h b/ASNMP/asnmp/vb.h index 1dd823fb2d6..dca6e7ae985 100644 --- a/ASNMP/asnmp/vb.h +++ b/ASNMP/asnmp/vb.h @@ -12,9 +12,9 @@ // // = DESCRIPTION // This module contains the class definition for the variable binding (VB) -// class. The VB class is an encapsulation of a SNMP VB. A VB object is +// class. The VB class is an encapsulation of a SNMP VB. A VB object is // composed of one SNMP++ Oid and one SMI value. The Vb class utilizes Oid -// objects and thus requires the Oid class. To use this class, +// objects and thus requires the Oid class. To use this class, // set oid, value then call valid() to be sure object was constructed correctly. // // = AUTHOR @@ -25,28 +25,32 @@ Hewlett-Packard Company ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. - Permission to use, copy, modify, distribute and/or sell this software - and/or its documentation is hereby granted without fee. User agrees - to display the above copyright notice and this license notice in all - copies of the software and any documentation of the software. User - agrees to assume all liability for the use of the software; Hewlett-Packard - makes no representations about the suitability of this software for any - purpose. It is provided "AS-IS without warranty of any kind,either express - or implied. User hereby grants a royalty-free license to any and all - derivatives based upon this software code base. -=====================================================================*/ - + Permission to use, copy, modify, distribute and/or sell this software + and/or its documentation is hereby granted without fee. User agrees + to display the above copyright notice and this license notice in all + copies of the software and any documentation of the software. User + agrees to assume all liability for the use of the software; Hewlett-Packard + makes no representations about the suitability of this software for any + purpose. It is provided "AS-IS without warranty of any kind,either express + or implied. User hereby grants a royalty-free license to any and all + derivatives based upon this software code base. +=====================================================================*/ + //----[ external calls ]---------------------------------------------- #include "ace/OS.h" +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + #include "asnmp/smival.h" #include "asnmp/snmperrs.h" // V2c error def -#include "asnmp/oid.h" // oid class def +#include "asnmp/oid.h" // oid class def #include "asnmp/timetick.h" // time ticks -#include "asnmp/counter.h" // counter +#include "asnmp/counter.h" // counter #include "asnmp/gauge.h" // gauge class #include "asnmp/ctr64.h" // 64 bit counters -#include "asnmp/octet.h" // octet class +#include "asnmp/octet.h" // octet class #include "asnmp/address.h" // address class def #include "asnmp/integer.h" // integer class @@ -56,63 +60,63 @@ // Variable binding lists in SNMP++ are represented as arrays of // Vb objects. Vb objects are passed to and from SNMP objects to // provide getting or setting MIB values. -// The vb class keeps its own memory for objects and does not +// The vb class keeps its own memory for objects and does not // utilize pointers to external data structures. // -class ACE_Export Vb +class ACE_Export Vb // = TITLE - // Implement the concrete Variable Bindings aka Varbind + // Implement the concrete Variable Bindings aka Varbind // composite type. Varbinds hold 1 Oid and 1 Value (Any SMI value) { public: Vb( void); - // constructor with no arguments + // constructor with no arguments // makes an vb, unitialized (does not make object valid) Vb( const Oid &oid); - // constructor to initialize the oid + // constructor to initialize the oid // makes a vb with oid portion initialized (does not make object valid) - + Vb( const Oid& vb, const SnmpSyntax &val, const SmiUINT32=SNMP_CLASS_SUCCESS); - // constructor to initialize the oid + // constructor to initialize the oid // makes a vb with oid portion and value portion initialized, (valid) - + Vb( const Vb &vb); // copy constructor - - ~Vb(); + + ~Vb(); // destructor // if the vb has a oid or an octect string then // the associated memory needs to be freed int valid() const; - // return validity of Vb object (both oid and value set return 1 else 0) - + // return validity of Vb object (both oid and value set return 1 else 0) + Vb& operator=( const Vb &vb); // assignment to another Vb object overloaded friend int operator==( const Vb &lhs, const Vb &rhs); // equivlence operator overloaded - + //-----[ set oid / get oid part]------------------------------------------ - + void set_oid( const Oid& oid); // set value oid only with another oid - + void get_oid( Oid &oid) const; // get oid portion - + //-----[ set value part]-------------------------------------------------- void set_null(); // set a Vb null, if its not already - + void set_value( const TimeTicks& ticks); // returns 0 on success and a value void set_value( const Oid& oid); // returns 0 on success and a value - + void set_value( const Counter32& ctr); // returns 0 on success and a value @@ -127,9 +131,9 @@ public: void set_value( const SnmpInt32& ctr); // returns 0 on success and a value - - void set_value( const OctetStr& oct_str); - // get an octet string object + + void set_value( const OctetStr& oct_str); + // get an octet string object //----[ get value ]------------------------------------------------ @@ -138,7 +142,7 @@ public: int get_value( Oid& oid); // returns 0 on success and a value - + int get_value( Counter32& ctr); // returns 0 on success and a value @@ -153,11 +157,11 @@ public: int get_value( SnmpInt32& ctr); // returns 0 on success and a value - - int get_value( OctetStr& oct_str); - // get an octet string object - // escape hatch + int get_value( OctetStr& oct_str); + // get an octet string object + + // escape hatch void set_value( const SnmpSyntax &val); // for other derived types that can be casted @@ -165,32 +169,32 @@ public: // gets a general value SmiUINT32 get_syntax(); - // return the current syntax + // return the current syntax // Or.. if a V2 VB exception is present then return the exception value friend void set_exception_status( Vb *vb, const SmiUINT32 status); // set the exception status - + char *to_string(); - // return fomatted version of this object + // return fomatted version of this object char *to_string_value(); // returns a formatted version of the value - + char *to_string_oid(); // returns a formatted version of the value protected: - char *output_; - // display vb as [ oid / value ] + char *output_; + // display vb as [ oid / value ] - Oid iv_vb_oid_; - // a vb is made up of a oid + Oid iv_vb_oid_; + // a vb is made up of a oid - SnmpSyntax *iv_vb_value_; + SnmpSyntax *iv_vb_value_; // and a value... - SmiUINT32 exception_status_; + SmiUINT32 exception_status_; // are there any vb exceptions?? void free_vb(); diff --git a/ASNMP/asnmp/wpdu.h b/ASNMP/asnmp/wpdu.h index 85caf6c33f7..a4d4bb1d0c1 100644 --- a/ASNMP/asnmp/wpdu.h +++ b/ASNMP/asnmp/wpdu.h @@ -21,6 +21,11 @@ // ============================================================================ #include "ace/OS.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + #include "asnmp/asn1.h" #include "asnmp/pdu.h" #include "asnmp/target.h" @@ -29,29 +34,29 @@ // PDU / Target -> iovec buffer // iovec buffer -> PDU / Target struct snmp_pdu; -class ACE_Export wpdu +class ACE_Export wpdu // = TITLE - // Implement an Adapter pattern between CMU SNMP and HP SNMP++ - // + // Implement an Adapter pattern between CMU SNMP and HP SNMP++ + // { public: wpdu(const Pdu& pdu, const UdpTarget& target); // construct CMU data from HP SNMP++ objects wpdu(const iovec& buffer); - // construct HP SNMP++ objects from raw buffer via CMU SNMP datatypes + // construct HP SNMP++ objects from raw buffer via CMU SNMP datatypes wpdu(); // same as using iovec? ~wpdu(); - int valid() const; + int valid() const; // constructor completed ok? rc = 1 else 0 - const iovec& get_buffer() const; + const iovec& get_buffer() const; // return raw data stream via CMU code int get_pdu(Pdu& pdu, snmp_version& version); - // return HP SNMP++ pdu + // return HP SNMP++ pdu const unsigned char *get_community() const; // return community strptr @@ -64,14 +69,14 @@ private: static void copy_iovec(iovec& dest, const iovec& src); int set_trap_info(snmp_pdu *raw_pdu, const Pdu& pdu) const; - iovec iovec_; + iovec iovec_; // raw format - int valid_flag_; + int valid_flag_; // object construction state - snmp_version version_; - // snmp version + snmp_version version_; + // snmp version unsigned char community_name[MAX_COMM_STR_LEN]; unsigned long comm_len; // = MAX_COMM_STR_LEN; diff --git a/ASNMP/tests/test_config.h b/ASNMP/tests/test_config.h index cec49951d40..b548ae88c22 100644 --- a/ASNMP/tests/test_config.h +++ b/ASNMP/tests/test_config.h @@ -8,10 +8,10 @@ // = AUTHOR // Prashant Jain <pjain@cs.wustl.edu>, Tim Harrison // <harrison@cs.wustl.edu>, and David Levine <levine@cs.wustl.edu> -// +// // ============================================================================ -#if !defined (ACE_TEST_CONFIG_H) +#ifndef ACE_TEST_CONFIG_H #define ACE_TEST_CONFIG_H #include <iostream.h> @@ -120,11 +120,11 @@ do {\ #define ACE_INIT_LOG(NAME) \ char temp[BUFSIZ]; \ ACE_OS::sprintf (temp, "%s%s%s", \ - ACE_LOG_DIRECTORY_A, \ - ACE::basename (NAME, ACE_DIRECTORY_SEPARATOR_CHAR_A), \ - ".log"); \ + ACE_LOG_DIRECTORY_A, \ + ACE::basename (NAME, ACE_DIRECTORY_SEPARATOR_CHAR_A), \ + ".log"); \ ACE_DEBUG ((LM_DEBUG, "Deleting old log file %s (if any)\n\n", temp)); \ - ACE_OS::unlink (temp); + ACE_OS::unlink (temp); const int ACE_NS_MAX_ENTRIES = 1000; @@ -153,23 +153,23 @@ private: static ACE_Test_Output ace_file_stream; ACE_Test_Output::ACE_Test_Output (void) -{ +{ } -ACE_Test_Output::~ACE_Test_Output (void) -{ +ACE_Test_Output::~ACE_Test_Output (void) +{ } -int +int ACE_Test_Output::set_output (const char *filename, int append) { char temp[BUFSIZ]; // Ignore the error value since the directory may already exist. ACE_OS::mkdir (ACE_LOG_DIRECTORY_A); - ACE_OS::sprintf (temp, "%s%s%s", - ACE_LOG_DIRECTORY_A, - ACE::basename (filename, ACE_DIRECTORY_SEPARATOR_CHAR_A), - ".log"); + ACE_OS::sprintf (temp, "%s%s%s", + ACE_LOG_DIRECTORY_A, + ACE::basename (filename, ACE_DIRECTORY_SEPARATOR_CHAR_A), + ".log"); int flags = ios::out; if (append) @@ -179,24 +179,24 @@ ACE_Test_Output::set_output (const char *filename, int append) if (this->output_file_.bad ()) return -1; - ACE_LOG_MSG->msg_ostream (ace_file_stream.output_file ()); - ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER ); - ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); + ACE_LOG_MSG->msg_ostream (ace_file_stream.output_file ()); + ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER ); + ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM); return 0; } ofstream * -ACE_Test_Output::output_file (void) -{ - return &this->output_file_; +ACE_Test_Output::output_file (void) +{ + return &this->output_file_; } - -void -ACE_Test_Output::close (void) -{ - this->output_file_.flush (); - this->output_file_.close (); + +void +ACE_Test_Output::close (void) +{ + this->output_file_.flush (); + this->output_file_.close (); } void @@ -206,9 +206,9 @@ randomize (int array[], size_t size) for (i = 0; i < size; i++) array [i] = i; - + ACE_OS::srand (ACE_OS::time (0L)); - + // Generate an array of random numbers from 0 .. size - 1. for (i = 0; i < size; i++) |