diff options
author | dhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-08-24 19:13:15 +0000 |
---|---|---|
committer | dhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-08-24 19:13:15 +0000 |
commit | e52e5f8e343c03ddf9ee67a8559f5203a0f22356 (patch) | |
tree | e403c1364507d63685d72b22654a033420b89f38 /ASNMP | |
parent | 6b82e03ef4fcc60e5ab57bd9fac65dc001323cf8 (diff) | |
download | ATCD-e52e5f8e343c03ddf9ee67a8559f5203a0f22356.tar.gz |
ChangeLogTag:Sun Aug 24 19:04:23 UTC 2003 Don Hinton <dhinton@dresystems.com>
Diffstat (limited to 'ASNMP')
-rw-r--r-- | ASNMP/agent/agent_impl.cpp | 4 | ||||
-rw-r--r-- | ASNMP/agent/snmp_agent.cpp | 3 | ||||
-rw-r--r-- | ASNMP/asnmp/address.cpp | 16 | ||||
-rw-r--r-- | ASNMP/asnmp/counter.cpp | 1 | ||||
-rw-r--r-- | ASNMP/asnmp/gauge.cpp | 1 | ||||
-rw-r--r-- | ASNMP/asnmp/integer.cpp | 2 | ||||
-rw-r--r-- | ASNMP/asnmp/octet.cpp | 4 | ||||
-rw-r--r-- | ASNMP/asnmp/octet.h | 4 | ||||
-rw-r--r-- | ASNMP/asnmp/oid.cpp | 3 | ||||
-rw-r--r-- | ASNMP/asnmp/oid.h | 2 | ||||
-rw-r--r-- | ASNMP/asnmp/pdu.cpp | 10 | ||||
-rw-r--r-- | ASNMP/asnmp/pdu.h | 4 | ||||
-rw-r--r-- | ASNMP/asnmp/smival.h | 2 | ||||
-rw-r--r-- | ASNMP/asnmp/snmp.cpp | 4 | ||||
-rw-r--r-- | ASNMP/asnmp/snmp.h | 62 | ||||
-rw-r--r-- | ASNMP/asnmp/snmperrs.h | 4 | ||||
-rw-r--r-- | ASNMP/asnmp/timetick.cpp | 1 | ||||
-rw-r--r-- | ASNMP/asnmp/transaction.cpp | 6 | ||||
-rw-r--r-- | ASNMP/asnmp/vb.cpp | 10 | ||||
-rw-r--r-- | ASNMP/asnmp/vb.h | 6 | ||||
-rw-r--r-- | ASNMP/asnmp/wpdu.cpp | 2 | ||||
-rw-r--r-- | ASNMP/examples/get/get.cpp | 9 | ||||
-rw-r--r-- | ASNMP/examples/get/get_async.cpp | 11 | ||||
-rw-r--r-- | ASNMP/examples/next/next.cpp | 9 | ||||
-rw-r--r-- | ASNMP/examples/set/set.cpp | 9 | ||||
-rw-r--r-- | ASNMP/examples/trap/trap.cpp | 9 | ||||
-rw-r--r-- | ASNMP/examples/walk/walk.cpp | 11 |
27 files changed, 108 insertions, 101 deletions
diff --git a/ASNMP/agent/agent_impl.cpp b/ASNMP/agent/agent_impl.cpp index 0c3f8da4078..def00df6176 100644 --- a/ASNMP/agent/agent_impl.cpp +++ b/ASNMP/agent/agent_impl.cpp @@ -108,13 +108,13 @@ int agent_impl::get_response(Vb& vb) return 0; } -int agent_impl::handle_get_next( Pdu &pdu, UdpTarget &target) +int agent_impl::handle_get_next( Pdu &, UdpTarget &) { ACE_TRACE("agent_impl::handle_get_next -NI"); return 0; } -int agent_impl::handle_set( Pdu &pdu, UdpTarget &target) +int agent_impl::handle_set( Pdu &, UdpTarget &) { ACE_TRACE("agent_impl::handle_set -NI"); return 0; diff --git a/ASNMP/agent/snmp_agent.cpp b/ASNMP/agent/snmp_agent.cpp index 43a5342a3ec..27d445929e7 100644 --- a/ASNMP/agent/snmp_agent.cpp +++ b/ASNMP/agent/snmp_agent.cpp @@ -36,7 +36,8 @@ int snmp_agent::set_args(int argc, char *argv[]) { ACE_TRACE("snmp_agent::set_args"); unsigned short port = SNMP_AGENT_PORT; - char *rd = RD_COM, *wr = WR_COM; + char *rd = const_cast <char*> RD_COM; + char *wr = const_cast <char*> WR_COM; ACE_Get_Opt get_opt (argc, argv, "p:w:r:hv"); for (int c; (c = get_opt ()) != -1; ) { diff --git a/ASNMP/asnmp/address.cpp b/ASNMP/asnmp/address.cpp index 230788e9f67..9517ef4deaf 100644 --- a/ASNMP/asnmp/address.cpp +++ b/ASNMP/asnmp/address.cpp @@ -222,6 +222,7 @@ SmiUINT32 IpAddress::get_syntax() //-----[ IP Address copy constructor ]--------------------------------- IpAddress::IpAddress(const IpAddress &ipaddr) + : Address (ipaddr) { // always initialize what type this object is smival.syntax = sNMP_SYNTAX_IPADDR; @@ -655,7 +656,7 @@ Address_Iter::Address_Iter(const char *hostname): valid_(0), count_(0), { ACE_OS::memset(&buffer_, 0, sizeof(ACE_HOSTENT_DATA)); ACE_OS::memset(&lookupResult_, 0, sizeof(struct hostent)); - if (ACE_OS::inet_addr(hostname) == -1) + if (ACE_OS::inet_addr(hostname) == (in_addr_t) -1) valid_ = query_dns(hostname); else { ACE_ASSERT(0); // don't support dot-quad lookup yet @@ -1024,6 +1025,7 @@ int NetbiosAddress::parse_address(const char *address) } NetbiosAddress::NetbiosAddress( const NetbiosAddress& nbaddr) + : Address (nbaddr) { // always initialize SMI info smival.syntax = sNMP_SYNTAX_OCTETS; @@ -1181,6 +1183,7 @@ IpxAddress::IpxAddress( const char *inaddr):Address( ) //-----[ IPX Address copy constructor ]---------------------------------- IpxAddress::IpxAddress(const IpxAddress &ipxaddr) + : Address (ipxaddr) { // always initialize SMI info smival.syntax = sNMP_SYNTAX_OCTETS; @@ -1735,6 +1738,7 @@ SmiUINT32 MacAddress::get_syntax() //-----[ MAC Address copy constructor ]--------------------------------- MacAddress::MacAddress(const MacAddress &macaddr) + : Address (macaddr) { // always initialize SMI info smival.syntax = sNMP_SYNTAX_OCTETS; @@ -2061,7 +2065,9 @@ GenAddress::GenAddress( const Address &addr): address(0) } //-----------------[ constructor with another GenAddress object ]------------- -GenAddress::GenAddress( const GenAddress &addr): address(0) +GenAddress::GenAddress( const GenAddress &addr) + : Address (addr), + address(0) { valid_flag = 0; @@ -2419,7 +2425,8 @@ DecNetAddress::DecNetAddress( const char *inaddr): Address() DecNetAddress::format_output(); } -DecNetAddress::DecNetAddress( const DecNetAddress&) +DecNetAddress::DecNetAddress( const DecNetAddress& addr) + : Address (addr) { } @@ -2554,7 +2561,8 @@ AppleTalkAddress::AppleTalkAddress( const char *inaddr): Address() valid_flag = parse_address( (char *) inaddr); AppleTalkAddress::format_output(); } -AppleTalkAddress::AppleTalkAddress( const AppleTalkAddress&) +AppleTalkAddress::AppleTalkAddress( const AppleTalkAddress& addr) + : Address (addr) { } diff --git a/ASNMP/asnmp/counter.cpp b/ASNMP/asnmp/counter.cpp index 04c50dd6475..c62b1d0a20a 100644 --- a/ASNMP/asnmp/counter.cpp +++ b/ASNMP/asnmp/counter.cpp @@ -43,6 +43,7 @@ Counter32::Counter32( const unsigned long i):SnmpUInt32(i) // copy constructor Counter32::Counter32( const Counter32 &c) + : SnmpUInt32 (c) { this->smival.value.uNumber = c.smival.value.uNumber; smival.syntax = sNMP_SYNTAX_CNTR32; diff --git a/ASNMP/asnmp/gauge.cpp b/ASNMP/asnmp/gauge.cpp index aac715f2730..9051e2f83fb 100644 --- a/ASNMP/asnmp/gauge.cpp +++ b/ASNMP/asnmp/gauge.cpp @@ -44,6 +44,7 @@ Gauge32::Gauge32( const unsigned long i):SnmpUInt32(i) // copy constructor Gauge32::Gauge32 ( const Gauge32 &g) + : SnmpUInt32 (g) { this->smival.value.uNumber = g.smival.value.uNumber; smival.syntax = sNMP_SYNTAX_GAUGE32; valid_flag = 1; diff --git a/ASNMP/asnmp/integer.cpp b/ASNMP/asnmp/integer.cpp index e0da5b6dfab..aa7f24b7f1f 100644 --- a/ASNMP/asnmp/integer.cpp +++ b/ASNMP/asnmp/integer.cpp @@ -46,6 +46,7 @@ SnmpUInt32::SnmpUInt32 (const u_long i) // copy constructor SnmpUInt32::SnmpUInt32( const SnmpUInt32 &c) + : SnmpSyntax (c) { smival.value.uNumber=c.smival.value.uNumber; smival.syntax = sNMP_SYNTAX_UINT32; @@ -142,6 +143,7 @@ SnmpInt32::SnmpInt32 (const long i) // constructor with value SnmpInt32::SnmpInt32 (const SnmpInt32 &c) + : SnmpSyntax (c) { smival.value.sNumber=c.smival.value.sNumber; smival.syntax = sNMP_SYNTAX_INT32; diff --git a/ASNMP/asnmp/octet.cpp b/ASNMP/asnmp/octet.cpp index 2a422a5fe88..c273348ac7e 100644 --- a/ASNMP/asnmp/octet.cpp +++ b/ASNMP/asnmp/octet.cpp @@ -472,7 +472,7 @@ SnmpSyntax * OctetStr::clone() const } //================[ ASCII format return ]============================= -char * OctetStr::to_string() +const char * OctetStr::to_string() { for ( unsigned long i=0; i < smival.value.string.len; i++) { if (( smival.value.string.ptr[i] != '\r')&& @@ -519,7 +519,7 @@ SnmpSyntax& OctetStr::operator=( SnmpSyntax &val) } //================[ format the output into hex ]======================== -char *OctetStr::to_string_hex() +const char *OctetStr::to_string_hex() { int cnt; char char_buf[80]; // holds ASCII representation of data diff --git a/ASNMP/asnmp/octet.h b/ASNMP/asnmp/octet.h index 28b3d9fda21..e335cd5e133 100644 --- a/ASNMP/asnmp/octet.h +++ b/ASNMP/asnmp/octet.h @@ -129,10 +129,10 @@ public: SmiBYTE *data() const; // returns pointer to internal data - char *to_string(); + const char *to_string(); // get a printable ASCII value - char *to_string_hex(); + const char *to_string_hex(); // get an ASCII formattted hex dump of the contents SnmpSyntax *clone() const; diff --git a/ASNMP/asnmp/oid.cpp b/ASNMP/asnmp/oid.cpp index d0bbcd3c4aa..03e65410a4a 100644 --- a/ASNMP/asnmp/oid.cpp +++ b/ASNMP/asnmp/oid.cpp @@ -93,6 +93,7 @@ Oid::Oid( const char * dotted_oid_string, size_t size) // // do an oid copy using the oid object passed in Oid::Oid ( const Oid &oid) + : SnmpSyntax (oid) { set_null(); @@ -485,7 +486,7 @@ Oid& Oid::operator+=( const Oid &o) // return string portion of the oid // -char * Oid::to_string() +const char * Oid::to_string() { unsigned long n; if (!valid()) diff --git a/ASNMP/asnmp/oid.h b/ASNMP/asnmp/oid.h index 16020e374c0..47af2f8f443 100644 --- a/ASNMP/asnmp/oid.h +++ b/ASNMP/asnmp/oid.h @@ -134,7 +134,7 @@ public: int valid() const; // is the Oid object valid - char *to_string(); + const char *to_string(); // return dotted string value from the right // where the user specifies how many positions to print diff --git a/ASNMP/asnmp/pdu.cpp b/ASNMP/asnmp/pdu.cpp index 6ac3acc04d5..49c14861af6 100644 --- a/ASNMP/asnmp/pdu.cpp +++ b/ASNMP/asnmp/pdu.cpp @@ -152,7 +152,7 @@ Pdu& Pdu::operator+=( Vb &vb) } // return fomatted version of this object -char * Pdu::to_string() +const char * Pdu::to_string() { // determine how big a buffer and allocate it const int HEADER_STR = 100; @@ -293,7 +293,7 @@ int Pdu::get_error_status() const return error_status_; } -char *Pdu::agent_error_reason() +const char *Pdu::agent_error_reason() { int pdu_err = get_error_status(); if (pdu_err == 0) // any real error? @@ -302,9 +302,9 @@ char *Pdu::agent_error_reason() int n_vbs = get_vb_count(); Vb bad; get_vb(bad, get_error_index() -1); // not zero based?? - char *pmsg = Snmp::error_string(get_error_status()); - char *id = bad.to_string_oid(); - char *val = bad.to_string_value(); + const char *pmsg = Snmp::error_string(get_error_status()); + const char *id = bad.to_string_oid(); + const char *val = bad.to_string_value(); const int HDR_SZ = 100; if (!output_) { diff --git a/ASNMP/asnmp/pdu.h b/ASNMP/asnmp/pdu.h index e748ac5b528..88cc57953d6 100644 --- a/ASNMP/asnmp/pdu.h +++ b/ASNMP/asnmp/pdu.h @@ -86,7 +86,7 @@ public: int get_error_status() const; // return the error status - char *agent_error_reason(); + const char *agent_error_reason(); // return the complete error info from this pdu friend void set_error_status( Pdu *pdu, const int status); @@ -146,7 +146,7 @@ public: void get_notify_enterprise( Oid & enterprise) const; // get the notify enterprise - char *to_string(); + const char *to_string(); // return fomatted version of this object diff --git a/ASNMP/asnmp/smival.h b/ASNMP/asnmp/smival.h index 6e7c8c4c1b9..bedbefa1dda 100644 --- a/ASNMP/asnmp/smival.h +++ b/ASNMP/asnmp/smival.h @@ -72,7 +72,7 @@ typedef struct { /* smiVALUE portion of VarBind */ class ACE_Export SnmpSyntax { public: - virtual char * to_string() = 0; + virtual const char * to_string() = 0; // virtual function for getting a printable ASCII value for any SNMP Value virtual SmiUINT32 get_syntax() = 0; diff --git a/ASNMP/asnmp/snmp.cpp b/ASNMP/asnmp/snmp.cpp index f6ad69fb25a..9c3b0d40af2 100644 --- a/ASNMP/asnmp/snmp.cpp +++ b/ASNMP/asnmp/snmp.cpp @@ -88,7 +88,7 @@ int Snmp::valid() const // given error code, return string definition // class version // static -char * Snmp::error_string(int last_transaction_status_) +const char * Snmp::error_string(int last_transaction_status_) { ACE_TRACE("Snmp::error_string"); @@ -100,7 +100,7 @@ char * Snmp::error_string(int last_transaction_status_) } // instance version -char * Snmp::error_string() +const char * Snmp::error_string() { return Snmp::error_string(last_transaction_status_); } diff --git a/ASNMP/asnmp/snmp.h b/ASNMP/asnmp/snmp.h index d57a9711324..1fa31cec71a 100644 --- a/ASNMP/asnmp/snmp.h +++ b/ASNMP/asnmp/snmp.h @@ -67,48 +67,48 @@ class ACE_Export Snmp : public transaction_result // Concrete class Snmp defined the session and interface to // communicate with another SNMP Version 1 agent { - Snmp_Result * result_; - Pdu * pdu_; - unsigned hold_req_id_; - public: - Snmp(unsigned short port = INADDR_ANY); - virtual ~Snmp(); + Snmp_Result * result_; + Pdu * pdu_; + unsigned hold_req_id_; +public: + Snmp(unsigned short port = INADDR_ANY); + virtual ~Snmp(); - int get( Pdu &pdu, UdpTarget &target, Snmp_Result * cb = 0); - // retrieve data from a peer agent for a given list of oid values - // default port 161 + int get( Pdu &pdu, UdpTarget &target, Snmp_Result * cb = 0); + // 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); - // retrieve data lexically adjacent to the oids specified in the pdu - // from the peer agent - // default port 161 + 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 + // default port 161 - 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 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 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); - // given error code, return string reason + static const char * error_string(int code); + // given error code, return string reason - char * error_string(); - // retrieve a reason string if any of the above commands fail + const char * error_string(); + // retrieve a reason string if any of the above commands fail - void result(transaction * t, int rc); - // for async transaction results + void result(transaction * t, int rc); + // for async transaction results - static void override_host_name(const char* name); - // allow the host name to be overriden + static void override_host_name(const char* name); + // allow the host name to be overriden - static void get_host_name(char* name, int len); - // returns the overriden host name + static void get_host_name(char* name, int len); + // returns the overriden host name - protected: +protected: void check_default_port(UdpTarget& target,unsigned short port=DEF_AGENT_PORT); int run_transaction(Pdu& pdu, UdpTarget& target); int run_transaction(Pdu& pdu, UdpTarget& target, Snmp_Result * cb); diff --git a/ASNMP/asnmp/snmperrs.h b/ASNMP/asnmp/snmperrs.h index bd7a5e9df56..08a4997217e 100644 --- a/ASNMP/asnmp/snmperrs.h +++ b/ASNMP/asnmp/snmperrs.h @@ -105,7 +105,7 @@ #define MAX_POS_ERROR SNMP_ERROR_INCONSIS_NAME #define MAX_NEG_ERROR SNMP_CLASS_SHUTDOWN -static char * pErrs[] = { +static const char * pErrs[] = { "Success", // 0 "SNMP: Response PDU Too Big", // 1 "SNMP: Variable does not exist", // 2 @@ -128,7 +128,7 @@ static char * pErrs[] = { }; -static char * nErrs[] = { +static const char * nErrs[] = { // General: // 0 SNMP_CLASS_SUCCESS "ASNMP: Success", diff --git a/ASNMP/asnmp/timetick.cpp b/ASNMP/asnmp/timetick.cpp index 06fd025797f..5b4128540d0 100644 --- a/ASNMP/asnmp/timetick.cpp +++ b/ASNMP/asnmp/timetick.cpp @@ -43,6 +43,7 @@ TimeTicks::TimeTicks( const unsigned long i):SnmpUInt32(i) // copy constructor TimeTicks::TimeTicks( const TimeTicks &t) + : SnmpUInt32 (t) { smival.value.uNumber = t.smival.value.uNumber; smival.syntax = sNMP_SYNTAX_TIMETICKS; diff --git a/ASNMP/asnmp/transaction.cpp b/ASNMP/asnmp/transaction.cpp index 8707ee2e797..5eccd735879 100644 --- a/ASNMP/asnmp/transaction.cpp +++ b/ASNMP/asnmp/transaction.cpp @@ -48,7 +48,7 @@ transaction::~transaction() ACE_Reactor::instance()->remove_handler(this, READ_MASK | DONT_CALL); ACE_Reactor::instance()->cancel_timer(this); - delete [] receive_iovec_.iov_base; + delete [] (char *) receive_iovec_.iov_base; } // implement state machine, send, wait (timeout/results) return @@ -118,11 +118,11 @@ int transaction::run(transaction_result * r) int transaction::handle_input (ACE_HANDLE) { // OS allocates iovec_.iov_base ptr and len - delete [] receive_iovec_.iov_base; + delete [] (char*) receive_iovec_.iov_base; reset_receive_buffer(receive_iovec_); int rc = session_.recv(&receive_iovec_, receive_addr_, 0); if (rc == -1) { - delete [] receive_iovec_.iov_base; + delete [] (char*) receive_iovec_.iov_base; reset_receive_buffer(receive_iovec_); if (result_) result_->result(this, SNMP_CLASS_RESOURCE_UNAVAIL); diff --git a/ASNMP/asnmp/vb.cpp b/ASNMP/asnmp/vb.cpp index ff9c22bb773..ab32e9639bb 100644 --- a/ASNMP/asnmp/vb.cpp +++ b/ASNMP/asnmp/vb.cpp @@ -346,7 +346,7 @@ SmiUINT32 Vb::get_syntax() } // return the printabel value -char *Vb::to_string_value() +const char *Vb::to_string_value() { if (iv_vb_value_) return iv_vb_value_->to_string(); @@ -355,18 +355,16 @@ char *Vb::to_string_value() } // return the printable oid -char *Vb::to_string_oid() +const char *Vb::to_string_oid() { return iv_vb_oid_.to_string(); } // generate string with name/ value format -char *Vb::to_string() +const char *Vb::to_string() { int len = ACE_OS::strlen(iv_vb_oid_.to_string()); - char *ptr = ""; - if (iv_vb_value_) - ptr = iv_vb_value_->to_string(); + const char *ptr = iv_vb_value_ ? iv_vb_value_->to_string() : ""; len += ACE_OS::strlen(ptr) + 3 + 1; // " / " + null ACE_NEW_RETURN(output_, char[len], ""); ACE_OS::sprintf(output_, "%s / %s", iv_vb_oid_.to_string(), ptr); diff --git a/ASNMP/asnmp/vb.h b/ASNMP/asnmp/vb.h index dca6e7ae985..09ccc298dd6 100644 --- a/ASNMP/asnmp/vb.h +++ b/ASNMP/asnmp/vb.h @@ -175,13 +175,13 @@ public: friend void set_exception_status( Vb *vb, const SmiUINT32 status); // set the exception status - char *to_string(); + const char *to_string(); // return fomatted version of this object - char *to_string_value(); + const char *to_string_value(); // returns a formatted version of the value - char *to_string_oid(); + const char *to_string_oid(); // returns a formatted version of the value protected: diff --git a/ASNMP/asnmp/wpdu.cpp b/ASNMP/asnmp/wpdu.cpp index 43c38d9a5e6..f4ac111fe0e 100644 --- a/ASNMP/asnmp/wpdu.cpp +++ b/ASNMP/asnmp/wpdu.cpp @@ -363,7 +363,7 @@ void wpdu::free_smival_descriptor( SmiVALUE *smival ) wpdu::~wpdu() { - delete [] iovec_.iov_base; + delete [] (char*) iovec_.iov_base; } const iovec& wpdu::get_buffer() const diff --git a/ASNMP/examples/get/get.cpp b/ASNMP/examples/get/get.cpp index 7cde6bb919c..a9e9ffb5fa9 100644 --- a/ASNMP/examples/get/get.cpp +++ b/ASNMP/examples/get/get.cpp @@ -161,11 +161,10 @@ int getapp::run() " GET SAMPLE PROGRAM \nOID: " << oid_.to_string() << "\n"; target_.get_address(address_); // target updates port used int rc; - char *name = address_.resolve_hostname(rc); - if (rc) - name = "<< did not resolve via gethostbyname() >>"; + const char *name = address_.resolve_hostname(rc); - cout << "Device: " << address_ << " " << name << "\n"; + cout << "Device: " << address_ << " "; + cout << (rc ? "<< did not resolve via gethostbyname() >>" : name) << "\n"; cout << "[ Retries=" << target_.get_retry() << " \ Timeout=" << target_.get_timeout() <<" ms " << "Community=" << \ community_.to_string() << " ]"<< endl; @@ -186,7 +185,7 @@ int getapp::run() } } else { - char *ptr = snmp_.error_string(); + const char *ptr = snmp_.error_string(); cout << "ASNMP:ERROR: get command failed reason: " << ptr << endl; } diff --git a/ASNMP/examples/get/get_async.cpp b/ASNMP/examples/get/get_async.cpp index ad670b6f9c6..35da693edc0 100644 --- a/ASNMP/examples/get/get_async.cpp +++ b/ASNMP/examples/get/get_async.cpp @@ -161,17 +161,16 @@ int getapp::run() " GET SAMPLE PROGRAM \nOID: " << oid_.to_string() << "\n"; target_.get_address(address_); // target updates port used int rc; - char *name = address_.resolve_hostname(rc); - if (rc) - name = "<< did not resolve via gethostbyname() >>"; + const char *name = address_.resolve_hostname(rc); - cout << "Device: " << address_ << " " << name << "\n"; + cout << "Device: " << address_ << " "; + cout << (rc ? "<< did not resolve via gethostbyname() >>" : name) << "\n"; cout << "[ Retries=" << target_.get_retry() << " \ Timeout=" << target_.get_timeout() <<" ms " << "Community=" << \ community_.to_string() << " ]"<< endl; if (snmp_.get( pdu_, target_, this) != SNMP_CLASS_SUCCESS) { - char *ptr = snmp_.error_string(); + const char *ptr = snmp_.error_string(); cout << "ASNMP:ERROR: get command failed reason: " << ptr << endl; } else { ACE_Reactor::instance()->run_event_loop(); @@ -184,7 +183,7 @@ void getapp::result(Snmp *, int rc) Vb vb; if (rc < 0) { - char *ptr = snmp_.error_string(); + const char *ptr = snmp_.error_string(); cout << "ASNMP:ERROR: get command failed reason: " << ptr << endl; } else { // check to see if there are any errors diff --git a/ASNMP/examples/next/next.cpp b/ASNMP/examples/next/next.cpp index 39714628aca..b4025278b42 100644 --- a/ASNMP/examples/next/next.cpp +++ b/ASNMP/examples/next/next.cpp @@ -160,11 +160,10 @@ int nextapp::run() " GET_NEXT SAMPLE PROGRAM \nOID: " << oid_.to_string() << "\n"; target_.get_address(address_); // target updates port used int rc; - char *name = address_.resolve_hostname(rc); - if (rc) - name = "<< did not resolve via gethostbyname() >>"; + const char *name = address_.resolve_hostname(rc); - cout << "Device: " << address_ << " " << name << "\n"; + cout << "Device: " << address_ << " "; + cout << (rc ? "<< did not resolve via gethostbyname() >>" : name) << "\n"; cout << "[ Retries=" << target_.get_retry() << " \ Timeout=" << target_.get_timeout() <<" ms " << "Community=" << \ community_.to_string() << " ]"<< endl; @@ -185,7 +184,7 @@ int nextapp::run() } } else { - char *ptr = snmp_.error_string(); + const char *ptr = snmp_.error_string(); cout << "ASNMP:ERROR: get_next command failed reason: " << ptr << endl; } cout << "ASNMP:INFO:command completed normally. ACE Rocks...\n"<< endl; diff --git a/ASNMP/examples/set/set.cpp b/ASNMP/examples/set/set.cpp index bb796fddefd..261cdedf235 100644 --- a/ASNMP/examples/set/set.cpp +++ b/ASNMP/examples/set/set.cpp @@ -231,11 +231,10 @@ int set::run() " SET SAMPLE PROGRAM \nOID: " << oid_.to_string() << "\n"; target_.get_address(address_); // target updates port used int rc; - char *name = address_.resolve_hostname(rc); - if (rc) - name = "<< did not resolve via gethostbyname() >>"; + const char *name = address_.resolve_hostname(rc); - cout << "Device: " << address_ << " " << name << "\n"; + cout << "Device: " << address_ << " "; + cout << (rc ? "<< did not resolve via gethostbyname() >>" : name) << "\n"; cout << "[ Retries=" << target_.get_retry() << " \ Timeout=" << target_.get_timeout() <<" ms " << "Community=" << \ community_.to_string() << " ]"<< endl; @@ -256,7 +255,7 @@ int set::run() } } else { - char *ptr = snmp_.error_string(); + const char *ptr = snmp_.error_string(); cout << "ASNMP:ERROR: set command failed reason: " << ptr << endl; } cout << "ASNMP:INFO:command completed normally.\n"<< endl; diff --git a/ASNMP/examples/trap/trap.cpp b/ASNMP/examples/trap/trap.cpp index 4c2d0e32f11..8977b708d78 100644 --- a/ASNMP/examples/trap/trap.cpp +++ b/ASNMP/examples/trap/trap.cpp @@ -162,18 +162,17 @@ int trapapp::run() " TRAP GENERATOR SAMPLE PROGRAM \nOID: " << oid_.to_string() << "\n"; target_.get_address(address_); // target updates port used int rc; - char *name = address_.resolve_hostname(rc); - if (rc) - name = "<< did not resolve via gethostbyname() >>"; + const char *name = address_.resolve_hostname(rc); - cout << "Device: " << address_ << " " << name << "\n"; + cout << "Device: " << address_ << " "; + cout << (rc ? "<< did not resolve via gethostbyname() >>" : name) << "\n"; cout << "[ Community=" << community_.to_string() << " ]"<< endl; if (snmp_.trap( pdu_, target_) == SNMP_CLASS_SUCCESS) { cout << "Trap was written to network...\n"; } else { - char *ptr = snmp_.error_string(); + const char *ptr = snmp_.error_string(); cout << "ASNMP:ERROR: trap command failed reason: " << ptr << endl; } diff --git a/ASNMP/examples/walk/walk.cpp b/ASNMP/examples/walk/walk.cpp index 620783484f2..91f3721f3fa 100644 --- a/ASNMP/examples/walk/walk.cpp +++ b/ASNMP/examples/walk/walk.cpp @@ -190,13 +190,13 @@ int MibIter::next(Vb& vb, char *& reason) } if (rc != SNMP_CLASS_SUCCESS) { - reason = snmp_->error_string(); + reason = const_cast <char*> (snmp_->error_string()); return 0; } // 2. check for problems if (pdu_.get_error_status()) { - reason = pdu_.agent_error_reason(); + reason = const_cast <char*> (pdu_.agent_error_reason()); return 0; } @@ -231,11 +231,10 @@ int walkapp::run() " WALK SAMPLE PROGRAM \nOID: " << oid_.to_string() << "\n"; target_.get_address(address_); // target updates port used int rc; - char *name = address_.resolve_hostname(rc); - if (rc) - name = "<< did not resolve via gethostbyname() >>"; + const char *name = address_.resolve_hostname(rc); - cout << "Device: " << address_ << " " << name << "\n"; + cout << "Device: " << address_ << " "; + cout << (rc ? "<< did not resolve via gethostbyname() >>" : name) << "\n"; cout << "[ Retries=" << target_.get_retry() << " \ Timeout=" << target_.get_timeout() <<" ms " << "Community=" << \ community_.to_string() << " ]"<< endl; |