summaryrefslogtreecommitdiff
path: root/ASNMP
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-03-16 22:27:45 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-03-16 22:27:45 +0000
commitad598a27060ce2e1b23831122b8614c408d9e6c3 (patch)
tree4037c28aaae99d807282a468c6ff5258c3d5147e /ASNMP
parent270be8f62920676ab389191be0f677eeaac6fef8 (diff)
downloadATCD-ad598a27060ce2e1b23831122b8614c408d9e6c3.tar.gz
replace TRUE with 1, and FALSE and NULL with 0
Diffstat (limited to 'ASNMP')
-rw-r--r--ASNMP/asnmp/address.cpp848
-rw-r--r--ASNMP/asnmp/address.h2
-rw-r--r--ASNMP/asnmp/asn1.cpp963
-rw-r--r--ASNMP/asnmp/asn1.h2
-rw-r--r--ASNMP/asnmp/counter.cpp63
-rw-r--r--ASNMP/asnmp/ctr64.cpp121
-rw-r--r--ASNMP/asnmp/gauge.cpp63
-rw-r--r--ASNMP/asnmp/integer.cpp165
-rw-r--r--ASNMP/asnmp/octet.cpp274
-rw-r--r--ASNMP/asnmp/oid.cpp221
-rw-r--r--ASNMP/asnmp/pdu.cpp124
-rw-r--r--ASNMP/asnmp/sagent.cpp13
-rw-r--r--ASNMP/asnmp/snmp.cpp65
-rw-r--r--ASNMP/asnmp/target.cpp158
-rw-r--r--ASNMP/asnmp/timetick.cpp71
-rw-r--r--ASNMP/asnmp/transaction.cpp66
-rw-r--r--ASNMP/asnmp/vb.cpp103
-rw-r--r--ASNMP/asnmp/wpdu.cpp129
18 files changed, 1719 insertions, 1732 deletions
diff --git a/ASNMP/asnmp/address.cpp b/ASNMP/asnmp/address.cpp
index 5296f86ef21..230788e9f67 100644
--- a/ASNMP/asnmp/address.cpp
+++ b/ASNMP/asnmp/address.cpp
@@ -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.
=====================================================================*/
#include "asnmp/address.h"
@@ -45,7 +45,7 @@ ACE_RCSID(asnmp, address, "$Id$")
//=================================================================
// allow destruction of derived classes
-Address::~Address()
+Address::~Address()
{
}
@@ -53,8 +53,8 @@ Address::~Address()
//-----------------------------------------------------------------
// is the address object valid?
int Address::valid() const
-{
- return valid_flag;
+{
+ return valid_flag;
}
//------------[ Address::trim_white_space( char * ptr) ]------------
@@ -76,11 +76,11 @@ void Address::trim_white_space( char * ptr)
//TM: this is not used nor needed, remove?
//-----[ element access ]----------------------------------------------
unsigned char& Address::operator[]( const int position)
-{
+{
if ( position < MAX_ADDR_SZ)
return address_buffer[ position];
else
- return address_buffer[0];
+ return address_buffer[0];
}
@@ -89,9 +89,9 @@ unsigned char& Address::operator[]( const int position)
int operator==( const Address &lhs, const Address &rhs)
{
if ( strcmp( (const char*) lhs, (const char*)rhs)==0)
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//-----------------------------------------------------------------------
@@ -107,27 +107,27 @@ int operator!=( const Address &lhs, const Address &rhs)
int operator>( const Address &lhs, const Address &rhs)
{
if ( strcmp( (const char*) lhs, (const char*)rhs)>0)
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
// overloaded >= operator, is a1 > a2
int operator>=( const Address &lhs,const Address &rhs)
{
if (( lhs > rhs) || ( lhs == rhs))
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
// overloaded < operator, is a1 <= a2
int operator<=( const Address &lhs,const Address &rhs)
{
if (( lhs < rhs) || ( lhs == rhs))
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
@@ -137,9 +137,9 @@ int operator<=( const Address &lhs,const Address &rhs)
int operator<( const Address &lhs, const Address &rhs)
{
if ( strcmp( (const char*) lhs, (const char*)rhs)<0)
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//------------------------------------------------------------------
@@ -147,11 +147,11 @@ int operator<( const Address &lhs, const Address &rhs)
int operator==( const Address &lhs,const char *rhs)
{
if (!rhs && !lhs.valid())
- return TRUE;
+ return 1;
if (strcmp( (const char *) lhs, rhs)== 0)
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//------------------------------------------------------------------
@@ -166,11 +166,11 @@ int operator!=( const Address &lhs,const char *rhs)
int operator>( const Address &lhs,const char *rhs)
{
if (!rhs)
- return lhs.valid(); // if lhs valid then > NULL, else invalid !> NULL
+ return lhs.valid(); // if lhs valid then > 0, else invalid !> 0
if (strcmp( (const char *) lhs, rhs)> 0)
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//------------------------------------------------------------------
@@ -178,11 +178,11 @@ int operator>( const Address &lhs,const char *rhs)
int operator>=( const Address &lhs,const char *rhs)
{
if (!rhs)
- return TRUE; // always >= NULL
+ return 1; // always >= 0
if (strcmp( (const char *) lhs, rhs)>= 0)
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//-----------------------------------------------------------------
@@ -190,11 +190,11 @@ int operator>=( const Address &lhs,const char *rhs)
int operator<( const Address &lhs,const char *rhs)
{
if (!rhs)
- return FALSE; // always >= NULL
+ return 0; // always >= 0
if (strcmp( (const char *) lhs, rhs)< 0)
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//-----------------------------------------------------------------
@@ -202,11 +202,11 @@ int operator<( const Address &lhs,const char *rhs)
int operator<=( const Address &lhs,const char *rhs)
{
if (!rhs)
- return !lhs.valid(); // invalid == NULL, else valid > NULL
+ return !lhs.valid(); // invalid == 0, else valid > 0
if (strcmp( (const char *) lhs, rhs)<= 0)
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
@@ -216,8 +216,8 @@ int operator<=( const Address &lhs,const char *rhs)
//-----------[ syntax type ]----------------------------------------------
SmiUINT32 IpAddress::get_syntax()
-{
- return sNMP_SYNTAX_IPADDR;
+{
+ return sNMP_SYNTAX_IPADDR;
}
//-----[ IP Address copy constructor ]---------------------------------
@@ -229,8 +229,8 @@ IpAddress::IpAddress(const IpAddress &ipaddr)
smival.value.string.ptr = address_buffer;
iv_friendly_name_[0] = 0;
- iv_friendly_name_status_ = 0;
- valid_flag = ipaddr.valid_flag;
+ iv_friendly_name_status_ = 0;
+ valid_flag = ipaddr.valid_flag;
if (valid_flag) {
ACE_OS::memcpy(address_buffer, ipaddr.address_buffer,IPV4LEN);
ACE_OS::strcpy( iv_friendly_name_, ipaddr.iv_friendly_name_);
@@ -242,7 +242,7 @@ IpAddress::IpAddress(const IpAddress &ipaddr)
//-------[ default construct, an IP address with a string ]---------------------
IpAddress::IpAddress( const char *inaddr): Address()
-{
+{
// always initialize what type this object is
smival.syntax = sNMP_SYNTAX_IPADDR;
smival.value.string.len = IPV4LEN;
@@ -250,15 +250,15 @@ IpAddress::IpAddress( const char *inaddr): Address()
if (ACE_OS::strlen(inaddr) == 0) {
- valid_flag = FALSE;
- iv_friendly_name_[0] = 0;
- iv_friendly_name_status_ = 0;
+ valid_flag = 0;
+ iv_friendly_name_[0] = 0;
+ iv_friendly_name_status_ = 0;
IpAddress::format_output();
return;
}
// parse_address initializes valid, address_buffer & iv_friendly_name_
- valid_flag = parse_address(inaddr);
+ valid_flag = parse_address(inaddr);
IpAddress::format_output();
}
@@ -271,7 +271,7 @@ IpAddress::IpAddress( const GenAddress &genaddr)
smival.value.string.len = IPV4LEN;
smival.value.string.ptr = address_buffer;
- valid_flag = FALSE;
+ valid_flag = 0;
iv_friendly_name_[0] = 0;
iv_friendly_name_status_ = 0;
// allow use of an ip or udp genaddress
@@ -282,16 +282,16 @@ IpAddress::IpAddress( const GenAddress &genaddr)
IpAddress temp_ip( (const char *) genaddr);
*this = temp_ip;
}
- }
+ }
else
if (genaddr.get_type() == type_udp) {
valid_flag = genaddr.valid();
if ( valid_flag) {
- // copy in the IP address data
- UdpAddress temp_udp( (const char *) genaddr);
- *this = temp_udp;
+ // copy in the IP address data
+ UdpAddress temp_udp( (const char *) genaddr);
+ *this = temp_udp;
}
- }
+ }
IpAddress::format_output();
}
@@ -306,7 +306,7 @@ int IpAddress::is_loopback() const
if (valid()) {
return (*(u_long *)&address_buffer == INADDR_LOOPBACK);
}
- return FALSE;
+ return 0;
}
int IpAddress::is_multicast() const
@@ -314,29 +314,29 @@ int IpAddress::is_multicast() const
if (valid()) {
return (IN_MULTICAST(*(u_long *)&address_buffer));
}
- return FALSE;
+ return 0;
}
// Private addressess not are not assignable in the Internet, they are
// defined in RFC 1597 as: 10, 172.16, and 192.168.0
-// Some companies use them internally and apply NAT to allow translation
-// instead of paying for ip networks.
+// Some companies use them internally and apply NAT to allow translation
+// instead of paying for ip networks.
// Cisco IOS devices can provide NAT aka Network Address Translation
-// but don't expect SNMP based networks to handle cross-NAT address spaces.
+// but don't expect SNMP based networks to handle cross-NAT address spaces.
// assumes storage in network byte order mrm@cisco.com 7/28/97
int IpAddress::is_private() const
{
if (valid()) {
if (address_buffer[0] == 10)
- return TRUE;
+ return 1;
if (address_buffer[0] == 172 && address_buffer[1] == 16)
- return TRUE;
+ return 1;
if (address_buffer[0] == 192 && address_buffer[1] == 168 &&
address_buffer[2] == 0)
- return TRUE;
+ return 1;
}
- return FALSE;
+ return 0;
}
@@ -345,14 +345,14 @@ void IpAddress::to_octet(OctetStr& octet) const
{
octet.set_data( smival.value.string.ptr, smival.value.string.len);
}
-
+
int IpAddress::is_broadcast() const
{
if (valid()) {
return ( (*(u_long *)&address_buffer) & INADDR_BROADCAST);
}
- return FALSE;
+ return 0;
}
//-----[ IP Address general = operator ]-------------------------------
@@ -362,22 +362,22 @@ SnmpSyntax& IpAddress::operator=( SnmpSyntax &val)
if ( this == &val )
return *this;
- valid_flag = 0; // will get set TRUE if really valid
- iv_friendly_name_[0]=0;
+ valid_flag = 0; // will get set 1 if really valid
+ iv_friendly_name_[0]=0;
if (val.valid()) {
switch (val.get_syntax()) {
case sNMP_SYNTAX_IPADDR:
case sNMP_SYNTAX_OCTETS:
if (((IpAddress &)val).smival.value.string.len ==IPV4LEN) {
- ACE_OS::memcpy(address_buffer,
- ((IpAddress &)val).smival.value.string.ptr,IPV4LEN);
- valid_flag = 1;
+ ACE_OS::memcpy(address_buffer,
+ ((IpAddress &)val).smival.value.string.ptr,IPV4LEN);
+ valid_flag = 1;
}
break;
// NOTE: as a value add, other types could have "logical"
- // mappings, i.e. integer32 and unsigned32
+ // mappings, i.e. integer32 and unsigned32
}
}
IpAddress::format_output();
@@ -391,8 +391,8 @@ IpAddress& IpAddress::operator=( const IpAddress &ipaddress)
if ( this == &ipaddress )
return *this;
- valid_flag = ipaddress.valid_flag;
- iv_friendly_name_[0]=0;
+ valid_flag = ipaddress.valid_flag;
+ iv_friendly_name_[0]=0;
if (valid_flag) {
ACE_OS::memcpy(address_buffer, ipaddress.address_buffer, IPV4LEN);
@@ -404,18 +404,18 @@ IpAddress& IpAddress::operator=( const IpAddress &ipaddress)
//--------[ create a new instance of this Value ]-----------------------
-SnmpSyntax *IpAddress::clone() const
-{
- return (SnmpSyntax *) new IpAddress(*this);
+SnmpSyntax *IpAddress::clone() const
+{
+ return (SnmpSyntax *) new IpAddress(*this);
}
//-------[ return the Fully Qualified Domain Name ]----------------------
char *IpAddress::resolve_hostname(int &status)
-{
+{
if ((iv_friendly_name_[0] == 0) && valid_flag)
addr_to_friendly();
status = iv_friendly_name_status_;
- return iv_friendly_name_;
+ return iv_friendly_name_;
}
// parse a dotted string
@@ -424,19 +424,19 @@ int IpAddress::parse_dotted_ipstring( const char *inaddr)
char *ip_token;
int token_count=0;
unsigned int value;
- int error_status = FALSE;
+ int error_status = 0;
char temp[MAXHOSTNAMELEN +1]; // temp buffer for destruction
int z,w;
// check len, an ip can never be bigger than 15
// 123456789012345
// XXX.XXX.XXX.XXX
- if ( !inaddr || (ACE_OS::strlen( inaddr) > 30))
- return FALSE;
+ if ( !inaddr || (ACE_OS::strlen( inaddr) > 30))
+ return 0;
ACE_OS::strcpy( temp, inaddr);
trim_white_space( temp);
- if ( ACE_OS::strlen( temp) > 15)
- return FALSE;
+ if ( ACE_OS::strlen( temp) > 15)
+ return 0;
// must only have three dots
// strtok will not catch this !
@@ -447,42 +447,42 @@ int IpAddress::parse_dotted_ipstring( const char *inaddr)
ptr++;
}
if ( dot_count != 3)
- return FALSE;
+ return 0;
// look for dot token separator
ip_token = strtok( (char *) temp,".");
// while more tokens..
- while ( ip_token != NULL) {
+ while ( ip_token != 0) {
// verify that the token is all numerics
w = ACE_OS::strlen( ip_token);
- if (w>3)
- return FALSE;
+ if (w>3)
+ return 0;
for (z=0;z<w;z++)
if (( ip_token[z] < '0') || ( ip_token[z] > '9'))
- return FALSE;
+ return 0;
- value = ( unsigned int) strtod(ip_token,NULL);
+ value = ( unsigned int) strtod(ip_token,0);
if (( value > 0)&& ( value <=255))
address_buffer[token_count] = (unsigned char) value;
else
if ( strcmp(ip_token,"0")==0)
- address_buffer[token_count]= (unsigned char) 0;
+ address_buffer[token_count]= (unsigned char) 0;
else
- error_status = TRUE;
+ error_status = 1;
token_count++;
- ip_token = strtok( NULL, ".");
+ ip_token = strtok( 0, ".");
}
// gota be four in len
if ( token_count != 4)
- return FALSE;
+ return 0;
// any parsing errors?
if ( error_status)
- return FALSE;
+ return 0;
- return TRUE;
+ return 1;
}
//-----[ IP Address parse Address ]---------------------------------
@@ -505,29 +505,29 @@ int IpAddress::parse_address( const char *inaddr)
// since this is a valid dotted string
// don't do any DNS (Performance!)
- return TRUE;
+ return 1;
}
else {
int rc;
if ((rc = resolve_to_address(inaddr, ipAddr)) == 0) {
- // now lets check out the dotted string
- ACE_OS::strncpy( ds, ACE_OS::inet_ntoa(ipAddr), MAXHOSTNAMELEN);
+ // now lets check out the dotted string
+ ACE_OS::strncpy( ds, ACE_OS::inet_ntoa(ipAddr), MAXHOSTNAMELEN);
- if ( !parse_dotted_ipstring( ds))
- return FALSE;
+ if ( !parse_dotted_ipstring( ds))
+ return 0;
- // save the friendly name
- ACE_OS::strcpy( iv_friendly_name_, inaddr);
- return TRUE;
+ // save the friendly name
+ ACE_OS::strcpy( iv_friendly_name_, inaddr);
+ return 1;
- } // end if lookup result
+ } // end if lookup result
else {
iv_friendly_name_status_ = rc;
- return FALSE;
+ return 0;
}
} // end else not a dotted string
- return TRUE;
+ return 1;
}
// using the currently defined address, do a DNS
@@ -561,22 +561,22 @@ int IpAddress::resolve_to_hostname(const in_addr& quad_addr, char *hostname)
ACE_OS::memset(&buffer, 0, sizeof(ACE_HOSTENT_DATA));
// reverse lookup (requires in-addr.arpa to be setup in DNS
- if (ACE_OS::gethostbyaddr_r((const char *)&quad_addr.s_addr, IPV4LEN,
+ if (ACE_OS::gethostbyaddr_r((const char *)&quad_addr.s_addr, IPV4LEN,
AF_INET, &lookupResult, buffer, &loc_errno)) {
// verify right type of record
- if (lookupResult.h_addrtype == AF_INET &&
- lookupResult.h_length == IPV4LEN) {
- ACE_OS::strcpy( hostname, lookupResult.h_name);
+ if (lookupResult.h_addrtype == AF_INET &&
+ lookupResult.h_length == IPV4LEN) {
+ ACE_OS::strcpy( hostname, lookupResult.h_name);
// setup multiple entries
return 0;
}
else {
- ACE_ASSERT(0); // todo add trace and debug and dump
- return -1; // wrong resource record type
+ ACE_ASSERT(0); // todo add trace and debug and dump
+ return -1; // wrong resource record type
}
}
-
+
return loc_errno;
}
@@ -589,11 +589,11 @@ int IpAddress::resolve_to_address(const char *hostname, in_addr& quad_addr)
ACE_OS::memset(&lookupResult, 0, sizeof(struct hostent));
int loc_errno = 0;
if (ACE_OS::gethostbyname_r( hostname, &lookupResult, buffer, &loc_errno)) {
- if (lookupResult.h_length == sizeof(in_addr) &&
- lookupResult.h_addrtype == AF_INET) {
+ if (lookupResult.h_length == sizeof(in_addr) &&
+ lookupResult.h_addrtype == AF_INET) {
ACE_OS::memcpy((void *) &quad_addr,
(void *) lookupResult.h_addr_list[0], sizeof(in_addr));
- return 0;
+ return 0;
}
else
return -1; // wrong address size
@@ -619,22 +619,22 @@ void IpAddress::format_output()
// if valid format else null it
if ( valid_flag)
ACE_OS::sprintf( (char *) output_buffer,"%d.%d.%d.%d",address_buffer[0],
- address_buffer[1], address_buffer[2], address_buffer[3]);
+ address_buffer[1], address_buffer[2], address_buffer[3]);
else
output_buffer[0] = 0;
}
//------[ return the type ]----------------------------------
-addr_type IpAddress::get_type() const
-{
- return type_ip;
+addr_type IpAddress::get_type() const
+{
+ return type_ip;
}
//-----------------------------------------------------------------
// logically and two IPaddresses and
// return the new one
void IpAddress::mask( const IpAddress& ipaddr)
-{
+{
if ( this->valid() && ipaddr.valid()) {
this->address_buffer[0] = this->address_buffer[0] & ipaddr.address_buffer[0];
this->address_buffer[1] = this->address_buffer[1] & ipaddr.address_buffer[1];
@@ -642,7 +642,7 @@ void IpAddress::mask( const IpAddress& ipaddr)
this->address_buffer[3] = this->address_buffer[3] & ipaddr.address_buffer[3];
format_output();
}
-
+
}
//=======================================================================
@@ -650,7 +650,7 @@ void IpAddress::mask( const IpAddress& ipaddr)
//=======================================================================
-Address_Iter::Address_Iter(const char *hostname): valid_(FALSE), count_(0),
+Address_Iter::Address_Iter(const char *hostname): valid_(0), count_(0),
entry_(0)
{
ACE_OS::memset(&buffer_, 0, sizeof(ACE_HOSTENT_DATA));
@@ -658,20 +658,20 @@ Address_Iter::Address_Iter(const char *hostname): valid_(FALSE), count_(0),
if (ACE_OS::inet_addr(hostname) == -1)
valid_ = query_dns(hostname);
else {
- ACE_ASSERT(0); // don't support dot-quad lookup yet
+ ACE_ASSERT(0); // don't support dot-quad lookup yet
}
// count number of hostnames
int n;
char **pc;
- for (n = 0, pc = lookupResult_.h_addr_list; *pc != NULL; ++n, ++pc);
- count_ = n; // plus first one
+ for (n = 0, pc = lookupResult_.h_addr_list; *pc != 0; ++n, ++pc);
+ count_ = n; // plus first one
entry_ = lookupResult_.h_addr_list;
}
int Address_Iter::valid() const
{
- return (valid_ == TRUE);
+ return (valid_ == 1);
}
int Address_Iter::how_many_addresses()
@@ -687,7 +687,7 @@ int Address_Iter::next(IpAddress& addr)
IpAddress tmp(*entry_++); // return data
addr = tmp;
- if (*entry_ == NULL)
+ if (*entry_ == 0)
return 1;
return 0;
}
@@ -696,11 +696,11 @@ int Address_Iter::next(IpAddress& addr)
int Address_Iter::query_dns(const char *hostname)
{
int loc_errno = 0;
- if (ACE_OS::gethostbyname_r( hostname, &lookupResult_, buffer_,
- &loc_errno)) {
- if (lookupResult_.h_length == sizeof(IPV4LEN) &&
- lookupResult_.h_addrtype == AF_INET) {
- return 0;
+ if (ACE_OS::gethostbyname_r( hostname, &lookupResult_, buffer_,
+ &loc_errno)) {
+ if (lookupResult_.h_length == sizeof(IPV4LEN) &&
+ lookupResult_.h_addrtype == AF_INET) {
+ return 0;
}
else
return -1; // wrong address size
@@ -714,8 +714,8 @@ int Address_Iter::query_dns(const char *hostname)
//-----------[ syntax type ]----------------------------------------------
SmiUINT32 UdpAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
+{
+ return sNMP_SYNTAX_OCTETS;
}
//-----------------[ construct an Udp address with another Udp address ]---
@@ -750,7 +750,7 @@ UdpAddress::UdpAddress( const char *inaddr):IpAddress()
smival.value.string.len = UDPIPV4LEN;
smival.value.string.ptr = address_buffer;
- valid_flag = parse_address( (char *)inaddr);
+ valid_flag = parse_address( (char *)inaddr);
format_output();
}
@@ -763,7 +763,7 @@ UdpAddress::UdpAddress( const GenAddress &genaddr):IpAddress()
smival.value.string.ptr = address_buffer;
unsigned int port = 0;
- valid_flag = FALSE;
+ valid_flag = 0;
// allow use of an ip or udp genaddress
if (genaddr.get_type() == type_udp)
@@ -821,27 +821,27 @@ SnmpSyntax& UdpAddress::operator=( SnmpSyntax &val)
if ( this == &val )
return *this;
- valid_flag=0; // will get set TRUE if really valid
+ valid_flag=0; // will get set 1 if really valid
if (val.valid()){
switch (val.get_syntax()){
- case sNMP_SYNTAX_IPADDR:
+ case sNMP_SYNTAX_IPADDR:
{
UdpAddress temp_udp(val.to_string());
- *this = temp_udp; // valid_flag is set by the udp assignment
+ *this = temp_udp; // valid_flag is set by the udp assignment
}
break;
case sNMP_SYNTAX_OCTETS:
if (((UdpAddress &)val).smival.value.string.len == UDPIPV4LEN){
ACE_OS::memcpy(address_buffer,
- ((UdpAddress &)val).smival.value.string.ptr, UDPIPV4LEN);
+ ((UdpAddress &)val).smival.value.string.ptr, UDPIPV4LEN);
iv_friendly_name_[0] = 0;
valid_flag = 1;
}
break;
// NOTE: as a value add, other types could have "logical"
- // mappings, i.e. integer32 and unsigned32
+ // mappings, i.e. integer32 and unsigned32
}
}
format_output();
@@ -856,7 +856,7 @@ UdpAddress& UdpAddress::operator=( const UdpAddress &udpaddr)
return *this;
(IpAddress &)*this = udpaddr; // use ancestor assignment for ipaddr value
- set_port(udpaddr.get_port()); // copy to port value
+ set_port(udpaddr.get_port()); // copy to port value
format_output();
return *this;
}
@@ -871,19 +871,19 @@ int UdpAddress::parse_address( const char *inaddr)
if (inaddr && (ACE_OS::strlen( inaddr)< MAXHOSTNAMELEN +1))
ACE_OS::strcpy( buffer, inaddr);
else {
- valid_flag = FALSE;
- return FALSE;
+ valid_flag = 0;
+ return 0;
}
// look for port info @ the end of the string
// port can be delineated by a ':' or a '/'
- // if neither are present then just treat it
+ // if neither are present then just treat it
// like a normal IpAddress
char *tmp;
tmp = ACE_OS::strstr( buffer,":");
- if (tmp==NULL)
+ if (tmp==0)
tmp = ACE_OS::strstr(buffer,"/");
- if ( tmp != NULL) {
+ if ( tmp != 0) {
*tmp=0; // null terminator
tmp++;
port = ACE_OS::atoi( tmp);
@@ -895,14 +895,14 @@ int UdpAddress::parse_address( const char *inaddr)
//----------[ create a new instance of this Value ]------------------------
-SnmpSyntax *UdpAddress::clone() const
-{
- return (SnmpSyntax *) new UdpAddress(*this);
+SnmpSyntax *UdpAddress::clone() const
+{
+ return (SnmpSyntax *) new UdpAddress(*this);
}
//--------[ set the port number ]---------------------------------------
void UdpAddress::set_port( const unsigned short p)
-{
+{
unsigned short port_nbo = htons(p);
ACE_OS::memcpy(&address_buffer[IPV4LEN], &port_nbo, 2);
format_output();
@@ -910,20 +910,20 @@ void UdpAddress::set_port( const unsigned short p)
//---------[ get the port number ]--------------------------------------
unsigned short UdpAddress::get_port() const
-{
+{
if (valid_flag) {
unsigned short port_nbo;
ACE_OS::memcpy(&port_nbo, &address_buffer[IPV4LEN], 2);
- return ntohs(port_nbo);
+ return ntohs(port_nbo);
}
else
- return 0; // don't use uninitialized memory
+ return 0; // don't use uninitialized memory
}
//------[ return the type ]--------------------------------------------
addr_type UdpAddress::get_type() const
-{
- return type_udp;
+{
+ return type_udp;
}
//----[ UDP address char * cast ]--------------------------------------
@@ -946,8 +946,8 @@ void UdpAddress::format_output()
// if valid format else null it
if ( valid_flag)
ACE_OS::sprintf( (char *) output_buffer,"%s:%d",
- IpAddress::to_string(),
- get_port() );
+ IpAddress::to_string(),
+ get_port() );
else
output_buffer[0] = 0;
}
@@ -963,7 +963,7 @@ void NetbiosAddress::format_output()
ACE_OS::memcpy(output_buffer, address_buffer, NETBIOSLEN);
else
output_buffer[0] = 0;
-}
+}
void NetbiosAddress::InitNBAddr(const char *inaddr)
{
@@ -972,8 +972,8 @@ void NetbiosAddress::InitNBAddr(const char *inaddr)
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = NETBIOSLEN;
smival.value.string.ptr = address_buffer;
-
- valid_flag=FALSE;
+
+ valid_flag=0;
NetbiosAddress::format_output();
return;
}
@@ -982,7 +982,7 @@ void NetbiosAddress::InitNBAddr(const char *inaddr)
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = IPXLEN;
smival.value.string.ptr = address_buffer;
-
+
valid_flag = parse_address( (char *) inaddr);
NetbiosAddress::format_output();
}
@@ -1001,26 +1001,26 @@ NetbiosAddress::NetbiosAddress( const char *inaddr, nb_service svc)
}
// TODO: go back over ms/ibm specs and verify this
-// 16 chars, 15 can be any character, 16th is service number between 0 and 20
-// names beginning with IBM are reserved, and hence invalid
+// 16 chars, 15 can be any character, 16th is service number between 0 and 20
+// names beginning with IBM are reserved, and hence invalid
// and doubt IBM would use this class anyway
int NetbiosAddress::parse_address(const char *address)
{
if (ACE_OS::strlen(address) > NETBIOSLEN)
- return FALSE; // invalid
+ return 0; // invalid
if (ACE_OS::strncmp(address, "IBM", 3) == 0)
- return FALSE; // invalid
+ return 0; // invalid
// addresses are free form but this check may need to be expose to user
//
//if (address[15] < nb_workstation || address[15] > nb_server)
- // return FALSE; //invalid service type
+ // return 0; //invalid service type
ACE_OS::memset(address_buffer, 0, NETBIOSLEN);
ACE_OS::memcpy(address_buffer, address, NETBIOSLEN);
- return TRUE; // valid
+ return 1; // valid
}
NetbiosAddress::NetbiosAddress( const NetbiosAddress& nbaddr)
@@ -1029,21 +1029,21 @@ NetbiosAddress::NetbiosAddress( const NetbiosAddress& nbaddr)
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = NETBIOSLEN;
smival.value.string.ptr = address_buffer;
-
+
valid_flag = nbaddr.valid_flag;
if (valid_flag)
ACE_OS::memcpy(address_buffer, nbaddr.address_buffer, NETBIOSLEN);
NetbiosAddress::format_output();
}
-
+
NetbiosAddress::NetbiosAddress( const GenAddress& genaddr)
{
// always initialize SMI info
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = NETBIOSLEN;
smival.value.string.ptr = address_buffer;
-
- valid_flag = FALSE;
+
+ valid_flag = 0;
// allow use of an ipx or ipxsock address
if ( (genaddr.get_type() == type_nb) ) {
valid_flag = genaddr.valid();
@@ -1055,11 +1055,11 @@ NetbiosAddress::NetbiosAddress( const GenAddress& genaddr)
}
NetbiosAddress::format_output();
}
-
+
NetbiosAddress::~NetbiosAddress()
{
}
-
+
char *NetbiosAddress::to_string()
{
return (char *)output_buffer;
@@ -1069,18 +1069,18 @@ void NetbiosAddress::to_octet(OctetStr& octet) const
{
octet.set_data( smival.value.string.ptr, smival.value.string.len);
}
-
+
NetbiosAddress& NetbiosAddress::operator=( const NetbiosAddress &val)
{
// protect against assignment from itself
if ( this == &val )
return *this;
-
- valid_flag = 0; // will set to TRUE if really valid
+
+ valid_flag = 0; // will set to 1 if really valid
if (val.valid()) {
switch (((NetbiosAddress *) &val)->get_syntax()) {
case sNMP_SYNTAX_OCTETS:
- ACE_OS::memcpy(address_buffer,
+ ACE_OS::memcpy(address_buffer,
((NetbiosAddress &)val).smival.value.string.ptr, NETBIOSLEN);
valid_flag = 1;
break;
@@ -1089,7 +1089,7 @@ NetbiosAddress& NetbiosAddress::operator=( const NetbiosAddress &val)
NetbiosAddress::format_output();
return *this;
}
-
+
nb_service NetbiosAddress::get_service_type() const
{
return (nb_service) address_buffer[15];
@@ -1100,24 +1100,24 @@ void NetbiosAddress::set_service_type(nb_service nbservice)
address_buffer[15] = nbservice;
NetbiosAddress::format_output();
}
-
+
NetbiosAddress::operator const char *() const
{
return (char *)output_buffer;
}
-
+
SnmpSyntax& NetbiosAddress::operator=( SnmpSyntax &val)
{
// protect against assignment from itself
if ( this == &val )
return *this;
-
- valid_flag = 0; // will set to TRUE if really valid
+
+ valid_flag = 0; // will set to 1 if really valid
if (val.valid()) {
switch (val.get_syntax()) {
case sNMP_SYNTAX_OCTETS:
if (((NetbiosAddress &)val).smival.value.string.len == NETBIOSLEN) {
- ACE_OS::memcpy(address_buffer,
+ ACE_OS::memcpy(address_buffer,
((NetbiosAddress &)val).smival.value.string.ptr, NETBIOSLEN);
valid_flag=1;
}
@@ -1132,15 +1132,15 @@ SnmpSyntax *NetbiosAddress::clone() const
{
return (SnmpSyntax *) new NetbiosAddress(*this);
}
-
+
SmiUINT32 NetbiosAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
+{
+ return sNMP_SYNTAX_OCTETS;
}
addr_type NetbiosAddress::get_type() const
-{
- return type_nb;
+{
+ return type_nb;
}
//=======================================================================
@@ -1149,22 +1149,22 @@ addr_type NetbiosAddress::get_type() const
//-----------[ syntax type ]----------------------------------------------
SmiUINT32 IpxAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
+{
+ return sNMP_SYNTAX_OCTETS;
}
//----------[ default constructor with a string arg ]---------------------------
IpxAddress::IpxAddress( const char *inaddr):Address( )
-{
+{
if (ACE_OS::strlen(inaddr) == 0) {
// always initialize SMI info
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = IPXLEN;
smival.value.string.ptr = address_buffer;
-
+
separator = '\0';
- valid_flag=FALSE;
+ valid_flag=0;
IpxAddress::format_output();
return;
}
@@ -1174,7 +1174,7 @@ IpxAddress::IpxAddress( const char *inaddr):Address( )
smival.value.string.ptr = address_buffer;
separator = '\0';
- valid_flag = parse_address( (char *) inaddr);
+ valid_flag = parse_address( (char *) inaddr);
IpxAddress::format_output();
}
@@ -1203,7 +1203,7 @@ IpxAddress::IpxAddress( const GenAddress &genaddr)
smival.value.string.len = IPXLEN;
smival.value.string.ptr = address_buffer;
- valid_flag = FALSE;
+ valid_flag = 0;
// allow use of an ipx or ipxsock address
if ( (genaddr.get_type() == type_ipx) ) {
valid_flag = genaddr.valid();
@@ -1217,9 +1217,9 @@ IpxAddress::IpxAddress( const GenAddress &genaddr)
if ( (genaddr.get_type() == type_ipxsock) ) {
valid_flag = genaddr.valid();
if ( valid_flag) {
- // copy in the Ipx address data
- IpxSockAddress temp_ipxsock( (const char *) genaddr);
- *this = temp_ipxsock;
+ // copy in the Ipx address data
+ IpxSockAddress temp_ipxsock( (const char *) genaddr);
+ *this = temp_ipxsock;
}
}
IpxAddress::format_output();
@@ -1239,13 +1239,13 @@ SnmpSyntax& IpxAddress::operator=( SnmpSyntax &val)
if ( this == &val )
return *this;
- valid_flag=0; // will set to TRUE if really valid
+ valid_flag=0; // will set to 1 if really valid
if (val.valid()){
switch (val.get_syntax()){
- case sNMP_SYNTAX_OCTETS:
+ case sNMP_SYNTAX_OCTETS:
if (((IpxAddress &)val).smival.value.string.len == IPXLEN){
- ACE_OS::memcpy(address_buffer, ((IpxAddress &)val).smival.value.string.ptr, IPXLEN);
- valid_flag=1;
+ ACE_OS::memcpy(address_buffer, ((IpxAddress &)val).smival.value.string.ptr, IPXLEN);
+ valid_flag=1;
}
break;
}
@@ -1261,7 +1261,7 @@ IpxAddress& IpxAddress::operator=( const IpxAddress &ipxaddress)
if ( this == &ipxaddress )
return *this;
- valid_flag = ipxaddress.valid_flag;
+ valid_flag = ipxaddress.valid_flag;
if (valid_flag)
ACE_OS::memcpy(address_buffer, ipxaddress.address_buffer, IPXLEN);
IpxAddress::format_output();
@@ -1270,14 +1270,14 @@ IpxAddress& IpxAddress::operator=( const IpxAddress &ipxaddress)
// create a new instance of this Value
-SnmpSyntax *IpxAddress::clone() const
-{
- return (SnmpSyntax *) new IpxAddress(*this);
+SnmpSyntax *IpxAddress::clone() const
+{
+ return (SnmpSyntax *) new IpxAddress(*this);
}
//-----[ IPX Address parse Address ]-----------------------------------
// Convert a string to a ten byte ipx address
-// On success sets validity TRUE or FALSE
+// On success sets validity 1 or 0
//
// IPX address format
//
@@ -1296,7 +1296,7 @@ SnmpSyntax *IpxAddress::clone() const
//
//
// Input formats recognized
-//
+//
// XXXXXXXX.XXXXXXXXXXXX
// XXXXXXXX:XXXXXXXXXXXX
// XXXXXXXX-XXXXXXXXXXXX
@@ -1312,7 +1312,7 @@ int IpxAddress::parse_address( const char *inaddr)
// save the orginal source
- if (!inaddr || (ACE_OS::strlen( inaddr) >(sizeof(temp)-1))) return FALSE;
+ if (!inaddr || (ACE_OS::strlen( inaddr) >(sizeof(temp)-1))) return 0;
ACE_OS::strcpy( temp, inaddr);
trim_white_space( temp);
tmplen = ACE_OS::strlen(temp);
@@ -1323,8 +1323,8 @@ int IpxAddress::parse_address( const char *inaddr)
//
// XXXXXXXX-XXXXXX-XXXXXX 22 len
// need at least 21 chars and no more than 22
- if ( (tmplen <21) || (tmplen >22))
- return FALSE;
+ if ( (tmplen <21) || (tmplen >22))
+ return 0;
// convert the string to all lower case
// this allows hex values to be in upper or lower
@@ -1342,11 +1342,11 @@ int IpxAddress::parse_address( const char *inaddr)
// no dot or colon separator check
separator = temp[8];
- if (( separator != ':') &&
- ( separator != '.') &&
- ( separator != '-') &&
+ if (( separator != ':') &&
+ ( separator != '.') &&
+ ( separator != '-') &&
( separator != ' '))
- return FALSE;
+ return 0;
// separate the strings
str1 = ( unsigned char *) temp;
@@ -1356,31 +1356,31 @@ int IpxAddress::parse_address( const char *inaddr)
str1= ( unsigned char *) temp;
// check len of the network portion
- if ( ACE_OS::strlen((char *) str1) != 8)
- return FALSE;
+ if ( ACE_OS::strlen((char *) str1) != 8)
+ return 0;
// check len of mac portion
- if ( ACE_OS::strlen( (char *) str2) != 12)
- return FALSE;
+ if ( ACE_OS::strlen( (char *) str2) != 12)
+ return 0;
// ok we like then lens, make sure that all chars are 0-f
// check out the net id
tmp = str1;
while( *tmp != 0)
if (((*tmp >= '0') && (*tmp <= '9'))|| // good 0-9
- ((*tmp >= 'a') && (*tmp <= 'f'))) // or a-f
+ ((*tmp >= 'a') && (*tmp <= 'f'))) // or a-f
tmp++;
else
- return FALSE;
+ return 0;
// check out the MAC address
tmp = str2;
while( *tmp != 0)
if (((*tmp >= '0') && (*tmp <= '9'))|| // good 0-9
- ((*tmp >= 'a') && (*tmp <= 'f'))) // or a-f
+ ((*tmp >= 'a') && (*tmp <= 'f'))) // or a-f
tmp++;
else
- return FALSE;
+ return 0;
// convert to target string
tmp = str1;
@@ -1416,7 +1416,7 @@ int IpxAddress::parse_address( const char *inaddr)
address_buffer[8] = (str2[8]*16) + str2[9];
address_buffer[9] = (str2[10]*16) + str2[11];
- return TRUE;
+ return 1;
}
//----[ IPX address char * cast ]--------------------------------------
@@ -1437,12 +1437,12 @@ void IpxAddress::format_output()
{
if ( valid_flag)
ACE_OS::sprintf((char *) output_buffer,
- "%02x%02x%02x%02x%c%02x%02x%02x%02x%02x%02x",
- address_buffer[0],address_buffer[1],
- address_buffer[2],address_buffer[3],'-',
- address_buffer[4],address_buffer[5],
- address_buffer[6],address_buffer[7],
- address_buffer[8],address_buffer[9]);
+ "%02x%02x%02x%02x%c%02x%02x%02x%02x%02x%02x",
+ address_buffer[0],address_buffer[1],
+ address_buffer[2],address_buffer[3],'-',
+ address_buffer[4],address_buffer[5],
+ address_buffer[6],address_buffer[7],
+ address_buffer[8],address_buffer[9]);
else
output_buffer[0] = 0;
}
@@ -1454,27 +1454,27 @@ int IpxAddress::get_hostid( MacAddress& mac)
if ( valid_flag)
{
char buffer[18];
- ACE_OS::sprintf( buffer,"%02x:%02x:%02x:%02x:%02x:%02x",
- address_buffer[4],
+ ACE_OS::sprintf( buffer,"%02x:%02x:%02x:%02x:%02x:%02x",
+ address_buffer[4],
address_buffer[5], address_buffer[6], address_buffer[7],
address_buffer[8], address_buffer[9]);
MacAddress temp( buffer);
// mac = (SnmpSyntax&) temp;
mac = temp;
if ( mac.valid())
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
else
- return FALSE;
+ return 0;
}
//------[ return the type ]----------------------------------
addr_type IpxAddress::get_type() const
-{
- return type_ipx;
+{
+ return type_ipx;
}
void IpxAddress::to_octet(OctetStr& octet) const
@@ -1489,8 +1489,8 @@ void IpxAddress::to_octet(OctetStr& octet) const
//-----------[ syntax type ]----------------------------------------------
SmiUINT32 IpxSockAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
+{
+ return sNMP_SYNTAX_OCTETS;
}
//-----------[ construct an IpxSockAddress with another IpxSockAddress]----
@@ -1515,7 +1515,7 @@ IpxSockAddress::IpxSockAddress( const char *inaddr):IpxAddress()
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = IPXSOCKLEN;
smival.value.string.ptr = address_buffer;
-
+
set_socket(0);
format_output();
return;
@@ -1526,7 +1526,7 @@ IpxSockAddress::IpxSockAddress( const char *inaddr):IpxAddress()
smival.value.string.len = IPXSOCKLEN;
smival.value.string.ptr = address_buffer;
- valid_flag = parse_address( (char *) inaddr);
+ valid_flag = parse_address( (char *) inaddr);
format_output();
}
@@ -1539,7 +1539,7 @@ IpxSockAddress::IpxSockAddress( const GenAddress &genaddr):IpxAddress()
smival.value.string.len = IPXSOCKLEN;
smival.value.string.ptr = address_buffer;
- valid_flag = FALSE;
+ valid_flag = 0;
unsigned short socketid = 0;
// allow use of an ipx or ipxsock address
if ( (genaddr.get_type() == type_ipx) )
@@ -1594,23 +1594,23 @@ SnmpSyntax& IpxSockAddress::operator=( SnmpSyntax &val)
if ( this == &val )
return *this;
- valid_flag=0; // will set to TRUE if really valid
+ valid_flag=0; // will set to 1 if really valid
if (val.valid()){
switch (val.get_syntax()){
- case sNMP_SYNTAX_OCTETS:
+ case sNMP_SYNTAX_OCTETS:
{
// See if it is of the Ipx address family
// This handles IpxSockAddress == IpxAddress
IpxSockAddress temp_ipx(val.to_string());
if (temp_ipx.valid()){
- *this = temp_ipx; // ipxsock = ipxsock
+ *this = temp_ipx; // ipxsock = ipxsock
}
// See if it is an OctetStr of appropriate length
else if (((IpxSockAddress &)val).smival.value.string.len == IPXSOCKLEN){
- ACE_OS::memcpy(address_buffer,
- ((IpxSockAddress &)val).smival.value.string.ptr,
- IPXSOCKLEN);
- valid_flag=1;
+ ACE_OS::memcpy(address_buffer,
+ ((IpxSockAddress &)val).smival.value.string.ptr,
+ IPXSOCKLEN);
+ valid_flag=1;
}
}
break;
@@ -1627,17 +1627,17 @@ IpxSockAddress& IpxSockAddress::operator=( const IpxSockAddress &ipxaddr)
if ( this == &ipxaddr )
return *this;
- (IpxAddress&)*this = ipxaddr; // use ancestor assignment for ipx addr
- set_socket(ipxaddr.get_socket()); // copy socket value
+ (IpxAddress&)*this = ipxaddr; // use ancestor assignment for ipx addr
+ set_socket(ipxaddr.get_socket()); // copy socket value
format_output();
return *this;
}
//----------[ create a new instance of this Value ]------------------------
-SnmpSyntax *IpxSockAddress::clone() const
-{
- return (SnmpSyntax *) new IpxSockAddress(*this);
+SnmpSyntax *IpxSockAddress::clone() const
+{
+ return (SnmpSyntax *) new IpxSockAddress(*this);
}
//----[ IPXSock address char * cast ]--------------------------------------
@@ -1659,7 +1659,7 @@ void IpxSockAddress::format_output()
if ( valid_flag)
ACE_OS::sprintf((char *) output_buffer,"%s/%d",
- IpxAddress::to_string(), get_socket());
+ IpxAddress::to_string(), get_socket());
else
output_buffer[0] = 0;
}
@@ -1674,17 +1674,17 @@ int IpxSockAddress::parse_address( const char *inaddr)
ACE_OS::strcpy( buffer, inaddr);
else
{
- valid_flag = FALSE;
- return FALSE;
+ valid_flag = 0;
+ return 0;
}
// look for port info @ the end of the string
// port can be delineated by a ':' or a '/'
- // if neither are present then just treat it
+ // if neither are present then just treat it
// like a normal IpAddress
char *tmp;
tmp = ACE_OS::strstr( buffer,"/");
- if (tmp != NULL)
+ if (tmp != 0)
{
*tmp=0; // null terminator
tmp++;
@@ -1698,19 +1698,19 @@ int IpxSockAddress::parse_address( const char *inaddr)
//-------------[ set the socket number ]----------------------------------
void IpxSockAddress::set_socket( const unsigned short s)
-{
+{
unsigned short sock_nbo = htons(s);
ACE_OS::memcpy(&address_buffer[IPXLEN], &sock_nbo, 2);
}
//--------------[ get the socket number ]---------------------------------
unsigned short IpxSockAddress::get_socket() const
-{
+{
if (valid_flag)
{
unsigned short sock_nbo;
ACE_OS::memcpy(&sock_nbo, &address_buffer[IPXLEN], 2);
- return ntohs(sock_nbo);
+ return ntohs(sock_nbo);
}
else
return 0; // don't use uninitialized memory
@@ -1719,7 +1719,7 @@ unsigned short IpxSockAddress::get_socket() const
//------[ return the type ]----------------------------------------------
addr_type IpxSockAddress::get_type() const
{
- return type_ipxsock;
+ return type_ipxsock;
}
@@ -1729,8 +1729,8 @@ addr_type IpxSockAddress::get_type() const
//-----------[ syntax type ]----------------------------------------------
SmiUINT32 MacAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
+{
+ return sNMP_SYNTAX_OCTETS;
}
//-----[ MAC Address copy constructor ]---------------------------------
@@ -1749,14 +1749,14 @@ MacAddress::MacAddress(const MacAddress &macaddr)
//---------[ constructor with a string argument ]-------------------------
MacAddress::MacAddress( const char *inaddr):Address( )
-{
+{
if (ACE_OS::strlen(inaddr) == 0) {
// always initialize SMI info
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = MACLEN;
smival.value.string.ptr = address_buffer;
-
- valid_flag=FALSE;
+
+ valid_flag=0;
format_output();
return;
}
@@ -1766,7 +1766,7 @@ MacAddress::MacAddress( const char *inaddr):Address( )
smival.value.string.len = MACLEN;
smival.value.string.ptr = address_buffer;
- valid_flag = parse_address( (char *) inaddr);
+ valid_flag = parse_address( (char *) inaddr);
format_output();
}
@@ -1778,7 +1778,7 @@ MacAddress::MacAddress( const GenAddress &genaddr)
smival.value.string.len = MACLEN;
smival.value.string.ptr = address_buffer;
- valid_flag = FALSE;
+ valid_flag = 0;
// allow use of mac address
if (genaddr.get_type() == type_mac)
{
@@ -1800,8 +1800,8 @@ MacAddress::~MacAddress()
//---------[ MacAddress clone ]-------------------------------------------
SnmpSyntax *MacAddress::clone() const
-{
- return (SnmpSyntax *) new MacAddress(*this);
+{
+ return (SnmpSyntax *) new MacAddress(*this);
}
//------[ assignment to another ipaddress object overloaded ]--------------
@@ -1811,7 +1811,7 @@ MacAddress& MacAddress::operator=( const MacAddress &macaddress)
if ( this == &macaddress )
return *this;
- valid_flag = macaddress.valid_flag;
+ valid_flag = macaddress.valid_flag;
if (valid_flag)
ACE_OS::memcpy(address_buffer, macaddress.address_buffer, MACLEN);
format_output();
@@ -1827,14 +1827,14 @@ SnmpSyntax& MacAddress::operator=( SnmpSyntax &val)
if ( this == &val )
return *this;
- valid_flag=0; // will set to TRUE if really valid
+ valid_flag=0; // will set to 1 if really valid
if (val.valid()){
switch (val.get_syntax()){
case sNMP_SYNTAX_OCTETS:
if (((MacAddress &)val).smival.value.string.len == MACLEN){
- ACE_OS::memcpy(address_buffer,
- ((MacAddress &)val).smival.value.string.ptr, MACLEN);
- valid_flag=1;
+ ACE_OS::memcpy(address_buffer,
+ ((MacAddress &)val).smival.value.string.ptr, MACLEN);
+ valid_flag=1;
}
break;
}
@@ -1845,7 +1845,7 @@ SnmpSyntax& MacAddress::operator=( SnmpSyntax &val)
//-----[ MAC Address parse Address ]--------------------------------------
// Convert a string to a six byte MAC address
-// On success sets validity TRUE or FALSE
+// On success sets validity 1 or 0
//
// MAC address format
//
@@ -1867,18 +1867,18 @@ int MacAddress::parse_address( const char *inaddr)
// save the orginal source
- if ( !inaddr || (ACE_OS::strlen( inaddr) > 30)) return FALSE;
+ if ( !inaddr || (ACE_OS::strlen( inaddr) > 30)) return 0;
ACE_OS::strcpy( temp, inaddr);
trim_white_space( temp);
// bad total length check
- if ( ACE_OS::strlen(temp) != 17)
- return FALSE;
+ if ( ACE_OS::strlen(temp) != 17)
+ return 0;
// check for colons
if ((temp[2] != ':')||(temp[5] != ':')||(temp[8]!=':')||(temp[11]!=':')
||(temp[14] !=':'))
- return FALSE;
+ return 0;
// strip off the colons
tmp = ( unsigned char *) temp;
@@ -1893,20 +1893,20 @@ int MacAddress::parse_address( const char *inaddr)
tmp++;
}
temp[i] = 0;
-
+
// convert to lower
for(z=0;z<ACE_OS::strlen(temp);z++)
temp[z] = tolower( temp[z]);
-
+
// check out the MAC address
tmp = ( unsigned char *) temp;
while( *tmp != 0)
if (((*tmp >= '0') && (*tmp <= '9'))|| // good 0-9
- ((*tmp >= 'a') && (*tmp <= 'f'))) // or a-f
+ ((*tmp >= 'a') && (*tmp <= 'f'))) // or a-f
tmp++;
else
- return FALSE;
+ return 0;
// convert to target string
tmp = (unsigned char *) temp;
@@ -1926,7 +1926,7 @@ int MacAddress::parse_address( const char *inaddr)
address_buffer[4] = (temp[8]*16) + temp[9];
address_buffer[5] = (temp[10]*16) + temp[11];
- return TRUE;
+ return 1;
}
//----[ MAC address char * cast ]--------------------------------------
@@ -1945,16 +1945,16 @@ void MacAddress::format_output()
{
if ( valid_flag)
sprintf(output_buffer,"%02x:%02x:%02x:%02x:%02x:%02x",address_buffer[0],
- address_buffer[1],address_buffer[2],address_buffer[3],
- address_buffer[4],address_buffer[5]);
+ address_buffer[1],address_buffer[2],address_buffer[3],
+ address_buffer[4],address_buffer[5]);
else
output_buffer[0] = 0;
}
//------[ return the type ]----------------------------------
addr_type MacAddress::get_type() const
-{
- return type_mac;
+{
+ return type_mac;
}
@@ -1976,7 +1976,7 @@ void MacAddress::to_octet(OctetStr& octet) const
//-----------[ get the syntax]----------------------------------------------
SmiUINT32 GenAddress::get_syntax()
-{
+{
if (address != 0)
return address->get_syntax();
@@ -1993,11 +1993,11 @@ void GenAddress::init_smi()
//-----------[ constructor with a string argument ]----------------------
GenAddress::GenAddress( const char *addr): address(0)
{
- valid_flag = FALSE;
+ valid_flag = 0;
// initialize SMI info
- // BOK: smival is generally not used for GenAddress, but
+ // BOK: smival is generally not used for GenAddress, but
// we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
+ // smival info so that <class>::operator=SnmpSyntax
// will work.
init_smi();
@@ -2009,15 +2009,15 @@ GenAddress::GenAddress( const char *addr): address(0)
parse_address(addr);
// Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
+ // BOK: smival is generally not used for GenAddress, but
// we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
+ // smival info so that <class>::operator=SnmpSyntax
// will work.
if ( valid_flag ) {
smival.syntax = ((GenAddress *)address)->smival.syntax;
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
+ smival.value.string.len =
+ ((GenAddress *)address)->smival.value.string.len;
+ ACE_OS::memcpy(smival.value.string.ptr,
((GenAddress *)address)->smival.value.string.ptr,
(size_t)smival.value.string.len);
}
@@ -2026,7 +2026,7 @@ GenAddress::GenAddress( const char *addr): address(0)
//-----------[ constructor with an Address argument ]--------------------
GenAddress::GenAddress( const Address &addr): address(0)
{
- valid_flag = FALSE;
+ valid_flag = 0;
// initialize SMI info
// BOK: this is generally not used for GenAddress,
@@ -2038,21 +2038,21 @@ GenAddress::GenAddress( const Address &addr): address(0)
format_output();
return;
}
-
+
address = (Address*)addr.clone();
if (address)
valid_flag = address->valid();
-
+
// Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
+ // BOK: smival is generally not used for GenAddress, but
// we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
+ // smival info so that <class>::operator=SnmpSyntax
// will work.
if ( valid_flag ) {
smival.syntax = address->get_syntax();
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
+ smival.value.string.len =
+ ((GenAddress *)address)->smival.value.string.len;
+ ACE_OS::memcpy(smival.value.string.ptr,
((GenAddress *)address)->smival.value.string.ptr,
(size_t)smival.value.string.len);
}
@@ -2063,7 +2063,7 @@ GenAddress::GenAddress( const Address &addr): address(0)
//-----------------[ constructor with another GenAddress object ]-------------
GenAddress::GenAddress( const GenAddress &addr): address(0)
{
- valid_flag = FALSE;
+ valid_flag = 0;
// initialize SMI info
// BOK: this is generally not used for GenAddress,
@@ -2076,21 +2076,21 @@ GenAddress::GenAddress( const GenAddress &addr): address(0)
format_output();
return;
}
-
+
address = (Address *)addr.address->clone();
if (address)
valid_flag = address->valid();
-
+
// Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
+ // BOK: smival is generally not used for GenAddress, but
// we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
+ // smival info so that <class>::operator=SnmpSyntax
// will work.
if ( valid_flag ) {
smival.syntax = ((GenAddress *)address)->smival.syntax;
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
+ smival.value.string.len =
+ ((GenAddress *)address)->smival.value.string.len;
+ ACE_OS::memcpy(smival.value.string.ptr,
((GenAddress *)address)->smival.value.string.ptr,
(size_t)smival.value.string.len);
}
@@ -2099,16 +2099,16 @@ GenAddress::GenAddress( const GenAddress &addr): address(0)
}
//----------[ destructor ] ------------------------------------------------
-GenAddress::~GenAddress()
+GenAddress::~GenAddress()
{
if ( address != 0)
delete address;
}
//----------[ create a new instance of this Value ]------------------------
-SnmpSyntax *GenAddress::clone() const
-{
- return (SnmpSyntax *) new GenAddress(*this);
+SnmpSyntax *GenAddress::clone() const
+{
+ return (SnmpSyntax *) new GenAddress(*this);
}
//------[ assignment GenAddress = GenAddress ]-----------------------------
@@ -2118,7 +2118,7 @@ GenAddress& GenAddress::operator=( const GenAddress &addr)
if ( this == &addr )
return *this;
- valid_flag = FALSE;
+ valid_flag = 0;
if (address) {
delete address;
address = 0;
@@ -2129,17 +2129,17 @@ GenAddress& GenAddress::operator=( const GenAddress &addr)
if (address)
valid_flag = address->valid();
-
+
// Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
+ // BOK: smival is generally not used for GenAddress, but
// we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
+ // smival info so that <class>::operator=SnmpSyntax
// will work.
if ( valid_flag ) {
smival.syntax = ((GenAddress *)address)->smival.syntax;
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
+ smival.value.string.len =
+ ((GenAddress *)address)->smival.value.string.len;
+ ACE_OS::memcpy(smival.value.string.ptr,
((GenAddress *)address)->smival.value.string.ptr,
(size_t)smival.value.string.len);
}
@@ -2156,7 +2156,7 @@ SnmpSyntax& GenAddress::operator=( SnmpSyntax &val)
if ( this == &val )
return *this;
- valid_flag = FALSE; // will get set to TRUE if really valid
+ valid_flag = 0; // will get set to 1 if really valid
if ( address != 0) {
delete address;
address = 0;
@@ -2165,26 +2165,26 @@ SnmpSyntax& GenAddress::operator=( SnmpSyntax &val)
if (val.valid()) {
switch ( val.get_syntax() ) {
//-----[ ip address case ]-------------
- // BOK: this case shouldn't be needed since there is an explicit
- // GenAddr=Address assignment that will override this assignment.
+ // BOK: this case shouldn't be needed since there is an explicit
+ // GenAddr=Address assignment that will override this assignment.
// Left here for posterity.
case sNMP_SYNTAX_IPADDR:
{
address = (Address *)val.clone();
if (address)
- valid_flag = address->valid();
+ valid_flag = address->valid();
}
break;
//-----[ udp address case ]------------
//-----[ ipx address case ]------------
//-----[ mac address case ]------------
- // BOK: This is here only to support GenAddr = primitive OctetStr.
- // The explicit GenAddr=Address assignment will handle the cases
- // GenAddr = [UdpAdd|IpxAddr|IpxSock|MacAddr|DecNetAddr|NetbiosAddr|AppleTlk].
- // Note, using the heuristic of octet str len to determine type of
+ // BOK: This is here only to support GenAddr = primitive OctetStr.
+ // The explicit GenAddr=Address assignment will handle the cases
+ // GenAddr = [UdpAdd|IpxAddr|IpxSock|MacAddr|DecNetAddr|NetbiosAddr|AppleTlk].
+ // Note, using the heuristic of octet str len to determine type of
// address to create is not accurate when address lengths are equal
- // (e.g., UDPIPV4LEN == MACLEN). It gets worse if we add AppleTalk or
+ // (e.g., UDPIPV4LEN == MACLEN). It gets worse if we add AppleTalk or
// OSI which use variable length addresses! assume AppleTalk as used in IOS Mibs
// is defined in CISCO-TC.my as fixed length of 3 octets
@@ -2194,33 +2194,33 @@ SnmpSyntax& GenAddress::operator=( SnmpSyntax &val)
val_len = ((GenAddress &)val).smival.value.string.len;
if (val_len == UDPIPV4LEN) {
- ACE_NEW_RETURN(address, UdpAddress, *this);
+ ACE_NEW_RETURN(address, UdpAddress, *this);
}
else if (val_len ==IPV4LEN) {
- ACE_NEW_RETURN(address, IpAddress, *this);
+ ACE_NEW_RETURN(address, IpAddress, *this);
}
else if (val_len == IPXLEN) {
- ACE_NEW_RETURN(address, IpxAddress, *this);
+ ACE_NEW_RETURN(address, IpxAddress, *this);
}
else if (val_len == IPXSOCKLEN) {
- ACE_NEW_RETURN(address, IpxSockAddress, *this);
+ ACE_NEW_RETURN(address, IpxSockAddress, *this);
}
else if (val_len == MACLEN) {
- ACE_NEW_RETURN(address, MacAddress, *this);
+ ACE_NEW_RETURN(address, MacAddress, *this);
}
else if (val_len == APPLETKLEN) {
- ACE_NEW_RETURN(address, AppleTalkAddress, *this);
+ ACE_NEW_RETURN(address, AppleTalkAddress, *this);
}
else if (val_len == DECNETLEN) {
- ACE_NEW_RETURN(address, DecNetAddress, *this);
+ ACE_NEW_RETURN(address, DecNetAddress, *this);
}
else if (val_len == NETBIOSLEN) {
- ACE_NEW_RETURN(address, DecNetAddress, *this);
+ ACE_NEW_RETURN(address, DecNetAddress, *this);
}
if (address) {
- *address = val;
- valid_flag = address->valid();
+ *address = val;
+ valid_flag = address->valid();
}
}
break;
@@ -2228,15 +2228,15 @@ SnmpSyntax& GenAddress::operator=( SnmpSyntax &val)
}
// Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
+ // BOK: smival is generally not used for GenAddress, but
// we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
+ // smival info so that <class>::operator=SnmpSyntax
// will work.
if ( valid_flag ) {
smival.syntax = ((GenAddress *)address)->smival.syntax;
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
+ smival.value.string.len =
+ ((GenAddress *)address)->smival.value.string.len;
+ ACE_OS::memcpy(smival.value.string.ptr,
((GenAddress *)address)->smival.value.string.ptr,
(size_t)smival.value.string.len);
}
@@ -2265,9 +2265,9 @@ int GenAddress::parse_address( const char *addr)
valid_flag = address->valid();
if ( valid_flag && ((IpxSockAddress*)address)->get_socket()) {
format_output();
- return TRUE; // ok its an ipxsock address
+ return 1; // ok its an ipxsock address
}
- // otherwise delete it and try another
+ // otherwise delete it and try another
delete address;
// ipx address
@@ -2275,9 +2275,9 @@ int GenAddress::parse_address( const char *addr)
valid_flag = address->valid();
if ( valid_flag) {
format_output();
- return TRUE; // ok its an ipx address
+ return 1; // ok its an ipx address
}
- // otherwise delete it and try another
+ // otherwise delete it and try another
delete address;
//TM: Must try the derived classes first...one pitfall of the
@@ -2290,7 +2290,7 @@ int GenAddress::parse_address( const char *addr)
valid_flag = address->valid();
if ( valid_flag && ((UdpAddress*)address)->get_port()) {
format_output();
- return TRUE; // ok its a udp address
+ return 1; // ok its a udp address
}
// otherwise delete it and try another
@@ -2299,12 +2299,12 @@ int GenAddress::parse_address( const char *addr)
// ip address
ACE_NEW_RETURN(address, IpAddress( addr), -1);
valid_flag = address->valid();
- if ( valid_flag)
+ if ( valid_flag)
{
format_output();
- return TRUE; // ok its an ip address
+ return 1; // ok its an ip address
}
- // otherwise delete it and try another
+ // otherwise delete it and try another
delete address;
// mac address
@@ -2312,59 +2312,59 @@ int GenAddress::parse_address( const char *addr)
valid_flag = address->valid();
if ( valid_flag) {
format_output();
- return TRUE; // ok, its a mac
+ return 1; // ok, its a mac
}
// guess by length of argument the type of address
switch (ACE_OS::strlen(addr)) {
case NETBIOSLEN:
ACE_NEW_RETURN(address, NetbiosAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag) {
- format_output();
- return TRUE; // ok, its a mac
- }
- break;
+ valid_flag = address->valid();
+ if ( valid_flag) {
+ format_output();
+ return 1; // ok, its a mac
+ }
+ break;
case APPLETKLEN:
ACE_NEW_RETURN(address, AppleTalkAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag) {
- format_output();
- return TRUE; // ok, its a mac
- }
- break;
+ valid_flag = address->valid();
+ if ( valid_flag) {
+ format_output();
+ return 1; // ok, its a mac
+ }
+ break;
case DECNETLEN:
ACE_NEW_RETURN(address, DecNetAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag) {
- format_output();
- return TRUE; // ok, its a mac
- }
- break;
+ valid_flag = address->valid();
+ if ( valid_flag) {
+ format_output();
+ return 1; // ok, its a mac
+ }
+ break;
}
- // otherwise its invalid
+ // otherwise its invalid
delete address;
address = 0;
format_output();
- return FALSE;
+ return 0;
}
GenAddress::operator const char *() const
{
if ( address != 0)
- return (const char *)*address; // pass thru
+ return (const char *)*address; // pass thru
else
return (char *)output_buffer;
}
// to_string form of the contained address
-char * GenAddress::to_string()
+char * GenAddress::to_string()
{
if ( address != 0)
- return address->to_string(); // pass thru
+ return address->to_string(); // pass thru
else
return (char *)output_buffer;
}
@@ -2377,7 +2377,7 @@ void GenAddress::format_output()
//------[ return the type ]----------------------------------
addr_type GenAddress::get_type() const
-{
+{
if (!valid())
return type_invalid;
else
@@ -2388,7 +2388,7 @@ addr_type GenAddress::get_type() const
void GenAddress::to_octet(OctetStr& octet) const
{
if (!valid())
- return;
+ return;
address->to_octet(octet);
}
@@ -2404,8 +2404,8 @@ DecNetAddress::DecNetAddress( const char *inaddr): Address()
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = DECNETLEN;
smival.value.string.ptr = address_buffer;
-
- valid_flag=FALSE;
+
+ valid_flag=0;
DecNetAddress::format_output();
return;
}
@@ -2414,7 +2414,7 @@ DecNetAddress::DecNetAddress( const char *inaddr): Address()
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = DECNETLEN;
smival.value.string.ptr = address_buffer;
-
+
valid_flag = parse_address( (char *) inaddr);
DecNetAddress::format_output();
}
@@ -2428,8 +2428,8 @@ DecNetAddress::DecNetAddress( const GenAddress& genaddr)
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = DECNETLEN;
smival.value.string.ptr = address_buffer;
-
- valid_flag = FALSE;
+
+ valid_flag = 0;
// allow use of an ipx or ipxsock address
if ( (genaddr.get_type() == type_decnet) ) {
valid_flag = genaddr.valid();
@@ -2445,12 +2445,12 @@ DecNetAddress::DecNetAddress( const GenAddress& genaddr)
DecNetAddress::~DecNetAddress()
{
}
-
+
char *DecNetAddress::to_string()
{
return (char *)output_buffer;
}
-
+
DecNetAddress& DecNetAddress::operator=( const DecNetAddress &decaddr)
{
// protect against assignment from itself
@@ -2462,7 +2462,7 @@ DecNetAddress& DecNetAddress::operator=( const DecNetAddress &decaddr)
format_output();
return *this;
}
-
+
void DecNetAddress::to_octet(OctetStr& octet) const
{
octet.set_data( smival.value.string.ptr, smival.value.string.len);
@@ -2483,9 +2483,9 @@ SnmpSyntax& DecNetAddress::operator=( SnmpSyntax &val)
// protect against assignment from itself
if ( this == &val )
return *this;
-
- valid_flag = 0; // will get set TRUE if really valid
-
+
+ valid_flag = 0; // will get set 1 if really valid
+
if (val.valid()) {
if (((DecNetAddress &)val).smival.value.string.len ==DECNETLEN) {
ACE_OS::memcpy(address_buffer,
@@ -2503,8 +2503,8 @@ SnmpSyntax *DecNetAddress::clone() const
}
addr_type DecNetAddress::get_type() const
-{
- return type_decnet;
+{
+ return type_decnet;
}
void DecNetAddress::format_output()
@@ -2520,13 +2520,13 @@ void DecNetAddress::format_output()
int DecNetAddress::parse_address( const char *address)
{
if (ACE_OS::strlen(address) > DECNETLEN)
- return FALSE; // invalid
-
+ return 0; // invalid
+
ACE_OS::memset(address_buffer, 0, DECNETLEN);
ACE_OS::memcpy(address_buffer, address, DECNETLEN);
-
- return TRUE; // valid
-}
+
+ return 1; // valid
+}
//------------------------------------------------------------------------
@@ -2540,8 +2540,8 @@ AppleTalkAddress::AppleTalkAddress( const char *inaddr): Address()
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = APPLETKLEN;
smival.value.string.ptr = address_buffer;
-
- valid_flag=FALSE;
+
+ valid_flag=0;
AppleTalkAddress::format_output();
return;
}
@@ -2550,7 +2550,7 @@ AppleTalkAddress::AppleTalkAddress( const char *inaddr): Address()
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = APPLETKLEN;
smival.value.string.ptr = address_buffer;
-
+
valid_flag = parse_address( (char *) inaddr);
AppleTalkAddress::format_output();
}
@@ -2563,8 +2563,8 @@ AppleTalkAddress::AppleTalkAddress( const GenAddress& genaddr)
smival.syntax = sNMP_SYNTAX_OCTETS;
smival.value.string.len = APPLETKLEN;
smival.value.string.ptr = address_buffer;
-
- valid_flag = FALSE;
+
+ valid_flag = 0;
// allow use of an ipx or ipxsock address
if ( (genaddr.get_type() == type_atk) ) {
valid_flag = genaddr.valid();
@@ -2580,12 +2580,12 @@ AppleTalkAddress::AppleTalkAddress( const GenAddress& genaddr)
AppleTalkAddress::~AppleTalkAddress()
{
}
-
+
char *AppleTalkAddress::to_string()
{
return (char *)output_buffer;
}
-
+
AppleTalkAddress& AppleTalkAddress::operator=( const AppleTalkAddress &ataddr)
{
// protect against assignment from itself
@@ -2597,7 +2597,7 @@ AppleTalkAddress& AppleTalkAddress::operator=( const AppleTalkAddress &ataddr)
format_output();
return *this;
}
-
+
void AppleTalkAddress::to_octet(OctetStr& octet) const
{
octet.set_data( smival.value.string.ptr, smival.value.string.len);
@@ -2618,9 +2618,9 @@ SnmpSyntax& AppleTalkAddress::operator=( SnmpSyntax &val)
// protect against assignment from itself
if ( this == &val )
return *this;
-
- valid_flag = 0; // will get set TRUE if really valid
-
+
+ valid_flag = 0; // will get set 1 if really valid
+
if (val.valid()) {
if (((AppleTalkAddress &)val).smival.value.string.len ==APPLETKLEN) {
ACE_OS::memcpy(address_buffer,
@@ -2638,8 +2638,8 @@ SnmpSyntax *AppleTalkAddress::clone() const
}
addr_type AppleTalkAddress::get_type() const
-{
- return type_atk;
+{
+ return type_atk;
}
void AppleTalkAddress::format_output()
@@ -2655,13 +2655,13 @@ void AppleTalkAddress::format_output()
int AppleTalkAddress::parse_address( const char *address)
{
if (ACE_OS::strlen(address) > APPLETKLEN)
- return FALSE; // invalid
-
+ return 0; // invalid
+
ACE_OS::memset(address_buffer, 0, APPLETKLEN);
ACE_OS::memcpy(address_buffer, address, APPLETKLEN);
-
- return TRUE; // valid
-}
+
+ return 1; // valid
+}
char AppleTalkAddress::get_host_address() const
{
@@ -2684,5 +2684,3 @@ void AppleTalkAddress::set_net_address(const short atknet)
{
ACE_OS::memcpy(address_buffer, &atknet, APPLETKLEN -1);
}
-
-
diff --git a/ASNMP/asnmp/address.h b/ASNMP/asnmp/address.h
index a9250b8244d..5258304e109 100644
--- a/ASNMP/asnmp/address.h
+++ b/ASNMP/asnmp/address.h
@@ -177,7 +177,7 @@ public:
protected:
int valid_flag;
- // state of constructed object (TRUE/FALSE)
+ // state of constructed object (1/0)
unsigned char address_buffer[MAX_ADDR_SZ];
// addr internal representation
diff --git a/ASNMP/asnmp/asn1.cpp b/ASNMP/asnmp/asn1.cpp
index da2e936349b..77dc9baa5ec 100644
--- a/ASNMP/asnmp/asn1.cpp
+++ b/ASNMP/asnmp/asn1.cpp
@@ -33,13 +33,13 @@
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
@@ -63,39 +63,39 @@ ACE_RCSID(asnmp, asn1, "$Id$")
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
-u_char * asn1::parse_int( u_char *data,
- int *datalength,
- u_char *type,
- long int *intp,
- int intsize)
+u_char * asn1::parse_int( u_char *data,
+ int *datalength,
+ u_char *type,
+ long int *intp,
+ int intsize)
{
ACE_TRACE("asn1::parse_int");
/*
* ASN.1 integer ::= 0x02 asnlength byte {byte}*
*/
u_char *bufp = data;
- u_long asn_length;
+ u_long asn_length;
long value = 0;
if (intsize != sizeof (long)){
ASNERROR("not long");
- return NULL;
+ return 0;
}
*type = *bufp++;
bufp =asn1::parse_length(bufp, &asn_length);
- if (bufp == NULL){
+ if (bufp == 0){
ASNERROR("bad length");
- return NULL;
+ return 0;
}
if ((int)(asn_length + (bufp - data)) > *datalength){
ASNERROR("overflow of message");
- return NULL;
+ return 0;
}
if ((int)asn_length > intsize){
ASNERROR("I don't support such large integers");
- return NULL;
+ return 0;
}
*datalength -= (int)asn_length + (bufp - data);
if (*bufp & 0x80)
@@ -115,44 +115,44 @@ u_char * asn1::parse_int( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
-u_char * asn1::parse_unsigned_int( u_char *data,
- int *datalength,
- u_char *type,
- u_long *intp,
- int intsize)
+u_char * asn1::parse_unsigned_int( u_char *data,
+ int *datalength,
+ u_char *type,
+ u_long *intp,
+ int intsize)
{
ACE_TRACE("asn1::parse_unsigned_int");
/*
* ASN.1 integer ::= 0x02 asnlength byte {byte}*
*/
u_char *bufp = data;
- u_long asn_length;
+ u_long asn_length;
u_long value = 0;
if (intsize != sizeof (long)){
ASNERROR("not long");
- return NULL;
+ return 0;
}
*type = *bufp++;
bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == NULL){
+ if (bufp == 0){
ASNERROR("bad length");
- return NULL;
+ return 0;
}
if ((int)(asn_length + (bufp - data)) > *datalength){
ASNERROR("overflow of message");
- return NULL;
+ return 0;
}
if (((int)asn_length > (intsize + 1)) ||
(((int)asn_length == intsize + 1) && *bufp != 0x00)){
ASNERROR("I don't support such large integers");
- return NULL;
+ return 0;
}
*datalength -= (int)asn_length + (bufp - data);
if (*bufp & 0x80)
- value = (u_long) -1;
+ value = (u_long) -1;
while(asn_length--)
value = (value << 8) | *bufp++;
*intp = value;
@@ -168,13 +168,13 @@ u_char * asn1::parse_unsigned_int( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char * asn1::build_int( u_char *data,
- int *datalength,
- u_char type,
- long *intp,
- int intsize)
+ int *datalength,
+ u_char type,
+ long *intp,
+ int intsize)
{
ACE_TRACE("asn1::build_int");
/*
@@ -185,7 +185,7 @@ u_char * asn1::build_int( u_char *data,
u_long mask;
if (intsize != sizeof (long))
- return NULL;
+ return 0;
integer = *intp;
/*
* Truncate "unnecessary" bytes off of the most significant end of this
@@ -196,15 +196,15 @@ u_char * asn1::build_int( u_char *data,
mask = 0x1FF << ((8 * (sizeof(long) - 1)) - 1);
/* mask is 0xFF800000 on a big-endian machine */
while((((integer & mask) == 0) || ((integer & mask) == mask))
- && intsize > 1){
+ && intsize > 1){
intsize--;
integer <<= 8;
}
data = asn1::build_header(data, datalength, type, intsize);
- if (data == NULL)
- return NULL;
+ if (data == 0)
+ return 0;
if (*datalength < intsize)
- return NULL;
+ return 0;
*datalength -= intsize;
mask = 0xFF << (8 * (sizeof(long) - 1));
/* mask is 0xFF000000 on a big-endian machine */
@@ -224,13 +224,13 @@ u_char * asn1::build_int( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char * asn1::build_unsigned_int( u_char *data,
- int *datalength,
- u_char type,
- u_long *intp,
- int intsize)
+ int *datalength,
+ u_char type,
+ u_long *intp,
+ int intsize)
{
ACE_TRACE("asn1::build_unsigned_int");
/*
@@ -242,7 +242,7 @@ u_char * asn1::build_unsigned_int( u_char *data,
int add_null_byte = 0;
if (intsize != sizeof (long))
- return NULL;
+ return 0;
integer = *intp;
mask = 0xFF << (8 * (sizeof(long) - 1));
/* mask is 0xFF000000 on a big-endian machine */
@@ -263,10 +263,10 @@ u_char * asn1::build_unsigned_int( u_char *data,
integer <<= 8;
}
data = asn1::build_header(data, datalength, type, intsize);
- if (data == NULL)
- return NULL;
+ if (data == 0)
+ return 0;
if (*datalength < intsize)
- return NULL;
+ return 0;
*datalength -= intsize;
if (add_null_byte == 1){
*data++ = '\0';
@@ -292,13 +292,13 @@ u_char * asn1::build_unsigned_int( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
-u_char * asn1::parse_string( u_char *data,
- int *datalength,
- u_char *type,
- u_char *string,
- int *strlength)
+u_char * asn1::parse_string( u_char *data,
+ int *datalength,
+ u_char *type,
+ u_char *string,
+ int *strlength)
{
ACE_TRACE("asn1::parse_string");
/*
@@ -307,19 +307,19 @@ u_char * asn1::parse_string( u_char *data,
* cmpdstring ::= 0x24 asnlength string {string}*
*/
u_char *bufp = data;
- u_long asn_length;
+ u_long asn_length;
*type = *bufp++;
bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == NULL)
- return NULL;
+ if (bufp == 0)
+ return 0;
if ((int)(asn_length + (bufp - data)) > *datalength){
ASNERROR("overflow of message");
- return NULL;
+ return 0;
}
if ((int)asn_length > *strlength){
ASNERROR("I don't support such long strings");
- return NULL;
+ return 0;
}
// fixed
ACE_OS::memcpy((char *)string, (char *)bufp, (int)asn_length);
@@ -337,13 +337,13 @@ u_char * asn1::parse_string( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char * asn1::build_string( u_char *data,
- int *datalength,
- u_char type,
- u_char *string,
- int strlength)
+ int *datalength,
+ u_char type,
+ u_char *string,
+ int strlength)
{
ACE_TRACE("asn1::build_string");
/*
@@ -353,10 +353,10 @@ u_char * asn1::build_string( u_char *data,
* This code will never send a compound string.
*/
data = asn1::build_header(data, datalength, type, strlength);
- if (data == NULL)
- return NULL;
+ if (data == 0)
+ return 0;
if (*datalength < strlength)
- return NULL;
+ return 0;
// fixed
ACE_OS::memcpy((u_char *)data,(u_char *)string, strlength);
*datalength -= strlength;
@@ -371,30 +371,30 @@ u_char * asn1::build_string( u_char *data,
* in this object following the id and length.
*
* Returns a pointer to the first byte of the contents of this object.
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char *asn1::parse_header( u_char *data,
- int *datalength,
- u_char *type)
+ int *datalength,
+ u_char *type)
{
ACE_TRACE("asn1::parse_header");
u_char *bufp = data;
register int header_len;
- u_long asn_length;
+ u_long asn_length;
/* this only works on data types < 30, i.e. no extension octets */
if (IS_EXTENSION_ID(*bufp)){
ASNERROR("can't process ID >= 30");
- return NULL;
+ return 0;
}
*type = *bufp;
bufp = asn1::parse_length(bufp + 1, &asn_length);
- if (bufp == NULL)
- return NULL;
+ if (bufp == 0)
+ return 0;
header_len = bufp - data;
if ((int)(header_len + asn_length) > *datalength){
ASNERROR("asn length too long");
- return NULL;
+ return 0;
}
*datalength = (int)asn_length;
return bufp;
@@ -411,20 +411,20 @@ u_char *asn1::parse_header( u_char *data,
* The maximum length is 0xFFFF;
*
* Returns a pointer to the first byte of the contents of this object.
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char * asn1::build_header( u_char *data,
- int *datalength,
- u_char type,
- int length)
+ int *datalength,
+ u_char type,
+ int length)
{
ACE_TRACE("asn1::build_header");
if (*datalength < 1)
- return NULL;
+ return 0;
*data++ = type;
(*datalength)--;
return asn1::build_length(data, datalength, length);
-
+
}
/*
@@ -438,18 +438,18 @@ u_char * asn1::build_header( u_char *data,
* The maximum length is 0xFFFF;
*
* Returns a pointer to the first byte of the contents of this object.
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char * asn1::build_sequence( u_char *data,
- int *datalength,
- u_char type,
- int length)
+ int *datalength,
+ u_char type,
+ int length)
{
ACE_TRACE("asn1::build_sequence");
*datalength -= 4;
if (*datalength < 0){
- *datalength += 4; /* fix up before punting */
- return NULL;
+ *datalength += 4; /* fix up before punting */
+ return 0;
}
*data++ = type;
*data++ = (u_char)(0x02 | ASN_LONG_LEN);
@@ -464,23 +464,23 @@ u_char * asn1::build_sequence( u_char *data,
*
* Returns a pointer to the first byte after this length
* field (aka: the start of the data field).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char * asn1::parse_length( u_char *data,
- u_long *length)
+ u_long *length)
{
ACE_TRACE("asn1::parse_length");
u_char lengthbyte = *data;
if (lengthbyte & ASN_LONG_LEN){
- lengthbyte &= ~ASN_LONG_LEN; /* turn MSb off */
+ lengthbyte &= ~ASN_LONG_LEN; /* turn MSb off */
if (lengthbyte == 0){
ASNERROR("We don't support indefinite lengths");
- return NULL;
+ return 0;
}
if (lengthbyte > sizeof(long)){
ASNERROR("we can't support data lengths that long");
- return NULL;
+ return 0;
}
// fixed
ACE_OS::memcpy((char *)length, (char *)data + 1, (int)lengthbyte);
@@ -494,8 +494,8 @@ u_char * asn1::parse_length( u_char *data,
};
u_char *asn1::build_length( u_char *data,
- int *datalength,
- int length)
+ int *datalength,
+ int length)
{
ACE_TRACE("asn1::build_length");
u_char *start_data = data;
@@ -504,21 +504,21 @@ u_char *asn1::build_length( u_char *data,
if (length < 0x80){
if (*datalength < 1){
ASNERROR("build_length");
- return NULL;
- }
+ return 0;
+ }
*data++ = (u_char)length;
} else if (length <= 0xFF){
if (*datalength < 2){
ASNERROR("build_length");
- return NULL;
- }
+ return 0;
+ }
*data++ = (u_char)(0x01 | ASN_LONG_LEN);
*data++ = (u_char)length;
} else { /* 0xFF < length <= 0xFFFF */
if (*datalength < 3){
ASNERROR("build_length");
- return NULL;
- }
+ return 0;
+ }
*data++ = (u_char)(0x02 | ASN_LONG_LEN);
*data++ = (u_char)((length >> 8) & 0xFF);
*data++ = (u_char)(length & 0xFF);
@@ -538,13 +538,13 @@ u_char *asn1::build_length( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char *asn1::parse_objid( u_char *data,
- int *datalength,
- u_char *type,
- oid *objid,
- int *objidlength)
+ int *datalength,
+ u_char *type,
+ oid *objid,
+ int *objidlength)
{
ACE_TRACE("asn1::parse_objid");
/*
@@ -557,15 +557,15 @@ u_char *asn1::parse_objid( u_char *data,
oid *oidp = objid + 1;
u_long subidentifier;
long length;
- u_long asn_length;
+ u_long asn_length;
*type = *bufp++;
bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == NULL)
- return NULL;
+ if (bufp == 0)
+ return 0;
if ((int)asn_length + (bufp - data) > *datalength){
ASNERROR("overflow of message");
- return NULL;
+ return 0;
}
*datalength -= (int)asn_length + (bufp - data);
@@ -574,16 +574,16 @@ u_char *asn1::parse_objid( u_char *data,
objid[0] = objid[1] = 0;
length = asn_length;
- (*objidlength)--; /* account for expansion of first byte */
+ (*objidlength)--; /* account for expansion of first byte */
while (length > 0 && (*objidlength)-- > 0){
subidentifier = 0;
- do { /* shift and add in low order 7 bits */
+ do { /* shift and add in low order 7 bits */
subidentifier = (subidentifier << 7) + (*(u_char *)bufp & ~ASN_BIT8);
length--;
- } while (*(u_char *)bufp++ & ASN_BIT8); /* last byte has high bit clear */
+ } while (*(u_char *)bufp++ & ASN_BIT8); /* last byte has high bit clear */
if (subidentifier > (u_long)MAX_SUBID){
ASNERROR("subidentifier too long");
- return NULL;
+ return 0;
}
*oidp++ = (oid)subidentifier;
}
@@ -591,7 +591,7 @@ u_char *asn1::parse_objid( u_char *data,
/*
* The first two subidentifiers are encoded into the first component
* with the value (X * 40) + Y, where:
- * X is the value of the first subidentifier.
+ * X is the value of the first subidentifier.
* Y is the value of the second subidentifier.
*/
subidentifier = (u_long)objid[1];
@@ -616,13 +616,13 @@ u_char *asn1::parse_objid( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char *asn1::build_objid( u_char *data,
- int *datalength,
- u_char type,
- oid *objid,
- int objidlength)
+ int *datalength,
+ u_char type,
+ oid *objid,
+ int objidlength)
{
ACE_TRACE("asn1::build_objid");
/*
@@ -656,28 +656,28 @@ u_char *asn1::build_objid( u_char *data,
bits = 0;
/* testmask *MUST* !!!! be of an u_type */
for(testmask = 0x7F, testbits = 0; testmask != 0;
- testmask <<= 7, testbits += 7){
- if (subid & testmask){ /* if any bits set */
- mask = testmask;
- bits = testbits;
- }
+ testmask <<= 7, testbits += 7){
+ if (subid & testmask){ /* if any bits set */
+ mask = testmask;
+ bits = testbits;
+ }
}
/* mask can't be zero here */
for(;mask != 0x7F; mask >>= 7, bits -= 7){
- /* fix a mask that got truncated above */
- if (mask == 0x1E00000)
- mask = 0xFE00000;
- *bp++ = (u_char)(((subid & mask) >> bits) | ASN_BIT8);
+ /* fix a mask that got truncated above */
+ if (mask == 0x1E00000)
+ mask = 0xFE00000;
+ *bp++ = (u_char)(((subid & mask) >> bits) | ASN_BIT8);
}
*bp++ = (u_char)(subid & mask);
}
}
asnlength = bp - buf;
data = asn1::build_header(data, datalength, type, asnlength);
- if (data == NULL)
- return NULL;
+ if (data == 0)
+ return 0;
if (*datalength < asnlength)
- return NULL;
+ return 0;
// fixed
ACE_OS::memcpy((char *)data, (char *)buf, asnlength);
*datalength -= asnlength;
@@ -692,26 +692,26 @@ u_char *asn1::build_objid( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
-u_char *asn1::parse_null(u_char *data,
- int *datalength,
- u_char *type)
+u_char *asn1::parse_null(u_char *data,
+ int *datalength,
+ u_char *type)
{
ACE_TRACE("asn1::parse_null");
/*
* ASN.1 null ::= 0x05 0x00
*/
u_char *bufp = data;
- u_long asn_length;
+ u_long asn_length;
*type = *bufp++;
bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == NULL)
- return NULL;
+ if (bufp == 0)
+ return 0;
if (asn_length != 0){
- ASNERROR("Malformed NULL");
- return NULL;
+ ASNERROR("Malformed 0");
+ return 0;
}
*datalength -= (bufp - data);
return bufp + asn_length;
@@ -726,11 +726,11 @@ u_char *asn1::parse_null(u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char *asn1::build_null( u_char *data,
- int *datalength,
- u_char type)
+ int *datalength,
+ u_char type)
{
ACE_TRACE("asn1::build_null");
/*
@@ -749,40 +749,40 @@ u_char *asn1::build_null( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char *asn1::parse_bitstring( u_char *data,
- int *datalength,
- u_char *type,
- u_char *string,
- int *strlength)
+ int *datalength,
+ u_char *type,
+ u_char *string,
+ int *strlength)
{
ACE_TRACE("asn1::parse_bitstring");
/*
* bitstring ::= 0x03 asnlength unused {byte}*
*/
u_char *bufp = data;
- u_long asn_length;
+ u_long asn_length;
*type = *bufp++;
bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == NULL)
- return NULL;
+ if (bufp == 0)
+ return 0;
if ((int)(asn_length + (bufp - data)) > *datalength){
ASNERROR("overflow of message");
- return NULL;
+ return 0;
}
if ((int) asn_length > *strlength){
ASNERROR("I don't support such long bitstrings");
- return NULL;
+ return 0;
}
if (asn_length < 1){
ASNERROR("Invalid bitstring");
- return NULL;
+ return 0;
}
if (*bufp > 7){
ASNERROR("Invalid bitstring");
- return NULL;
+ return 0;
}
// fixed
ACE_OS::memcpy((char *)string,(char *)bufp, (int)asn_length);
@@ -801,13 +801,13 @@ u_char *asn1::parse_bitstring( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char *asn1::build_bitstring( u_char *data,
- int *datalength,
- u_char type,
- u_char *string,
- int strlength)
+ int *datalength,
+ u_char type,
+ u_char *string,
+ int strlength)
{
ACE_TRACE("asn1::build_bitstring");
/*
@@ -815,13 +815,13 @@ u_char *asn1::build_bitstring( u_char *data,
*/
if (strlength < 1 || *string || *string > 7){
ASNERROR("Building invalid bitstring");
- return NULL;
+ return 0;
}
data = asn1::build_header(data, datalength, type, strlength);
- if (data == NULL)
- return NULL;
+ if (data == 0)
+ return 0;
if (*datalength < strlength)
- return NULL;
+ return 0;
// fixed
ACE_OS::memcpy((char *)data,(char *)string, strlength);
*datalength -= strlength;
@@ -838,46 +838,46 @@ u_char *asn1::build_bitstring( u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char * asn1::parse_unsigned_int64(u_char *data,
- int *datalength,
- u_char *type,
- struct counter64 *cp,
- int countersize)
+ int *datalength,
+ u_char *type,
+ struct counter64 *cp,
+ int countersize)
{
ACE_TRACE("asn1::parse_unsigned_int64");
/*
* ASN.1 integer ::= 0x02 asnlength byte {byte}*
*/
u_char *bufp = data;
- u_long asn_length;
+ u_long asn_length;
u_long low = 0, high = 0;
int intsize = 4;
-
+
if (countersize != sizeof(struct counter64)){
ASNERROR("not right size");
- return NULL;
+ return 0;
}
*type = *bufp++;
bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == NULL){
+ if (bufp == 0){
ASNERROR("bad length");
- return NULL;
+ return 0;
}
if ((int)(asn_length + (bufp - data)) > *datalength){
ASNERROR("overflow of message");
- return NULL;
+ return 0;
}
if (((int)asn_length > (intsize * 2 + 1)) ||
(((int)asn_length == (intsize * 2) + 1) && *bufp != 0x00)){
ASNERROR("I don't support such large integers");
- return NULL;
+ return 0;
}
*datalength -= (int)asn_length + (bufp - data);
if (*bufp & 0x80){
- low = (u_long) -1; // integer is negative
- high = (u_long) -1;
+ low = (u_long) -1; // integer is negative
+ high = (u_long) -1;
}
while(asn_length--){
high = (high << 8) | ((low & 0xFF000000) >> 24);
@@ -897,13 +897,13 @@ u_char * asn1::parse_unsigned_int64(u_char *data,
*
* Returns a pointer to the first byte past the end
* of this object (i.e. the start of the next object).
- * Returns NULL on any error.
+ * Returns 0 on any error.
*/
u_char * asn1::build_unsigned_int64( u_char *data,
- int *datalength,
- u_char type,
- struct counter64 *cp,
- int countersize)
+ int *datalength,
+ u_char type,
+ struct counter64 *cp,
+ int countersize)
{
ACE_TRACE("asn1::build_unsigned_int64");
/*
@@ -916,7 +916,7 @@ u_char * asn1::build_unsigned_int64( u_char *data,
int intsize;
if (countersize != sizeof (struct counter64))
- return NULL;
+ return 0;
intsize = 8;
low = cp->low;
high = cp->high;
@@ -936,17 +936,17 @@ u_char * asn1::build_unsigned_int64( u_char *data,
mask2 = 0x1FF << ((8 * (sizeof(long) - 1)) - 1);
/* mask2 is 0xFF800000 on a big-endian machine */
while((((high & mask2) == 0) || ((high & mask2) == mask2))
- && intsize > 1){
+ && intsize > 1){
intsize--;
high = (high << 8)
| ((low & mask) >> (8 * (sizeof(long) - 1)));
low <<= 8;
}
data = asn1::build_header(data, datalength, type, intsize);
- if (data == NULL)
- return NULL;
+ if (data == 0)
+ return 0;
if (*datalength < intsize)
- return NULL;
+ return 0;
*datalength -= intsize;
if (add_null_byte == 1){
*data++ = '\0';
@@ -957,7 +957,7 @@ u_char * asn1::build_unsigned_int64( u_char *data,
high = (high << 8)
| ((low & mask) >> (8 * (sizeof(long) - 1)));
low <<= 8;
-
+
}
return data;
}
@@ -969,14 +969,14 @@ struct snmp_pdu * cmu_snmp::pdu_create( int command)
ACE_TRACE("cmu_snmp::snmp_pdu_create");
struct snmp_pdu *pdu;
- ACE_NEW_RETURN(pdu, snmp_pdu, 0);
+ ACE_NEW_RETURN(pdu, snmp_pdu, 0);
ACE_OS::memset((char *)pdu, 0,sizeof(struct snmp_pdu));
pdu->command = command;
pdu->errstat = 0;
pdu->errindex = 0;
- pdu->enterprise = NULL;
+ pdu->enterprise = 0;
pdu->enterprise_length = 0;
- pdu->variables = NULL;
+ pdu->variables = 0;
return pdu;
}
@@ -1009,21 +1009,21 @@ void cmu_snmp::free_pdu( struct snmp_pdu *pdu)
// add a null var to a pdu
-void cmu_snmp::add_var(struct snmp_pdu *pdu,
- oid *name,
- int name_length,
- SmiVALUE *smival)
+void cmu_snmp::add_var(struct snmp_pdu *pdu,
+ oid *name,
+ int name_length,
+ SmiVALUE *smival)
{
ACE_TRACE("cmu_snmp::add_var");
struct variable_list *vars;
// if we don't have a vb list ,create one
- if (pdu->variables == NULL) {
+ if (pdu->variables == 0) {
ACE_NEW(pdu->variables, variable_list);
vars = pdu->variables;
}
- else
+ else
{ // we have one, find the end
for(vars = pdu->variables; vars->next_variable; vars = vars->next_variable);
// create one
@@ -1033,7 +1033,7 @@ void cmu_snmp::add_var(struct snmp_pdu *pdu,
}
// add the oid with no data
- vars->next_variable = NULL;
+ vars->next_variable = 0;
// hook in the Oid portion
ACE_NEW(vars->name, oid[(name_length)]);
@@ -1051,9 +1051,9 @@ void cmu_snmp::add_var(struct snmp_pdu *pdu,
case sNMP_SYNTAX_NOSUCHINSTANCE:
case sNMP_SYNTAX_ENDOFMIBVIEW:
{
- vars->type = (u_char) smival->syntax;
- vars->val.string = NULL;
- vars->val_len = 0;
+ vars->type = (u_char) smival->syntax;
+ vars->val.string = 0;
+ vars->val_len = 0;
}
break;
@@ -1062,68 +1062,68 @@ void cmu_snmp::add_var(struct snmp_pdu *pdu,
case sNMP_SYNTAX_OPAQUE:
case sNMP_SYNTAX_IPADDR:
{
- vars->type = (u_char) smival->syntax;
- ACE_NEW(vars->val.string,
+ vars->type = (u_char) smival->syntax;
+ ACE_NEW(vars->val.string,
u_char[(unsigned)smival->value.string.len]);
- vars->val_len = (int) smival->value.string.len;
- ACE_OS::memcpy( (u_char *) vars->val.string,
- (u_char *) smival->value.string.ptr,
- (unsigned) smival->value.string.len);
+ vars->val_len = (int) smival->value.string.len;
+ ACE_OS::memcpy( (u_char *) vars->val.string,
+ (u_char *) smival->value.string.ptr,
+ (unsigned) smival->value.string.len);
}
break;
// oid
case sNMP_SYNTAX_OID:
{
- vars->type = (u_char) smival->syntax;
+ vars->type = (u_char) smival->syntax;
vars->val_len = (int) smival->value.oid.len * sizeof(oid);
- ACE_NEW(vars->val.objid, oid[(unsigned)vars->val_len]);
- ACE_OS::memcpy((u_long *)vars->val.objid,
- (u_long *)smival->value.oid.ptr,
- (unsigned) vars->val_len);
+ ACE_NEW(vars->val.objid, oid[(unsigned)vars->val_len]);
+ ACE_OS::memcpy((u_long *)vars->val.objid,
+ (u_long *)smival->value.oid.ptr,
+ (unsigned) vars->val_len);
}
break;
-
+
case sNMP_SYNTAX_TIMETICKS:
case sNMP_SYNTAX_CNTR32:
case sNMP_SYNTAX_GAUGE32:
case sNMP_SYNTAX_UINT32:
{
- long templong;
- vars->type = (u_char) smival->syntax;
- ACE_NEW(vars->val.integer, long);
- vars->val_len = sizeof(long);
- templong = (long) smival->value.uNumber;
- ACE_OS::memcpy( (long*) vars->val.integer,
- (long*) &templong,
- sizeof(long));
+ long templong;
+ vars->type = (u_char) smival->syntax;
+ ACE_NEW(vars->val.integer, long);
+ vars->val_len = sizeof(long);
+ templong = (long) smival->value.uNumber;
+ ACE_OS::memcpy( (long*) vars->val.integer,
+ (long*) &templong,
+ sizeof(long));
}
break;
case sNMP_SYNTAX_INT32:
{
- long templong;
- vars->type = (u_char) smival->syntax;
- ACE_NEW(vars->val.integer, long);
- vars->val_len = sizeof(long);
- templong = (long) smival->value.sNumber;
- ACE_OS::memcpy( (long*) vars->val.integer,
- (long*) &templong,
- sizeof(long));
+ long templong;
+ vars->type = (u_char) smival->syntax;
+ ACE_NEW(vars->val.integer, long);
+ vars->val_len = sizeof(long);
+ templong = (long) smival->value.sNumber;
+ ACE_OS::memcpy( (long*) vars->val.integer,
+ (long*) &templong,
+ sizeof(long));
}
break;
// 64 bit counter
case sNMP_SYNTAX_CNTR64:
{
- vars->type = ( u_char) smival->syntax;
- ACE_NEW(vars->val.counter64, counter64);
- vars->val_len = sizeof(struct counter64);
- ACE_OS::memcpy( (struct counter64*) vars->val.counter64,
- (SmiLPCNTR64) &(smival->value.hNumber),
- sizeof( SmiCNTR64));
+ vars->type = ( u_char) smival->syntax;
+ ACE_NEW(vars->val.counter64, counter64);
+ vars->val_len = sizeof(struct counter64);
+ ACE_OS::memcpy( (struct counter64*) vars->val.counter64,
+ (SmiLPCNTR64) &(smival->value.hNumber),
+ sizeof( SmiCNTR64));
}
break;
@@ -1134,11 +1134,11 @@ void cmu_snmp::add_var(struct snmp_pdu *pdu,
// build the authentication
// works for v1 or v2c
u_char *cmu_snmp::auth_build( u_char *data,
- int *length,
- long int version,
- u_char *community,
- int community_len,
- int messagelen)
+ int *length,
+ long int version,
+ u_char *community,
+ int community_len,
+ int messagelen)
{
ACE_TRACE("cmu_snmp::auth_build");
u_char *params;
@@ -1147,32 +1147,32 @@ u_char *cmu_snmp::auth_build( u_char *data,
params = community;
plen = community_len;
- data = asn1::build_sequence(data,
- length,
- (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
- messagelen + plen + 5);
- if (data == NULL){
+ data = asn1::build_sequence(data,
+ length,
+ (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
+ messagelen + plen + 5);
+ if (data == 0){
ASNERROR("buildheader");
- return NULL;
- }
- data = asn1::build_int(data,
- length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&version,
- sizeof(version));
- if (data == NULL){
+ return 0;
+ }
+ data = asn1::build_int(data,
+ length,
+ (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
+ (long *)&version,
+ sizeof(version));
+ if (data == 0){
ASNERROR("buildint");
- return NULL;
+ return 0;
}
- data = asn1::build_string(data,
- length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
- params,
- plen );
- if (data == NULL){
+ data = asn1::build_string(data,
+ length,
+ (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
+ params,
+ plen );
+ if (data == 0){
ASNERROR("buildstring");
- return NULL;
+ return 0;
}
return (u_char *)data;
@@ -1180,11 +1180,11 @@ u_char *cmu_snmp::auth_build( u_char *data,
// build a variable binding
-u_char * cmu_snmp::build_var_op(u_char *data, oid * var_name,
- int *var_name_len,
- u_char var_val_type,
- int var_val_len, u_char *var_val,
- int *listlength)
+u_char * cmu_snmp::build_var_op(u_char *data, oid * var_name,
+ int *var_name_len,
+ u_char var_val_type,
+ int var_val_len, u_char *var_val,
+ int *listlength)
{
ACE_TRACE("cmu_snmp::build_var_op");
@@ -1197,42 +1197,42 @@ u_char * cmu_snmp::build_var_op(u_char *data, oid * var_name,
data += 4;
dummyLen -=4;
if (dummyLen < 0)
- return NULL;
+ return 0;
headerLen = data - dataPtr;
*listlength -= headerLen;
data = asn1::build_objid( data, listlength,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),
- var_name, *var_name_len);
- if (data == NULL) {
+ (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),
+ var_name, *var_name_len);
+ if (data == 0) {
ASNERROR("");
- return NULL;
+ return 0;
}
// based on the type...
switch(var_val_type) {
case ASN_INTEGER:
- data = asn1::build_int( data, listlength, var_val_type, (long *)var_val,
- var_val_len);
+ data = asn1::build_int( data, listlength, var_val_type, (long *)var_val,
+ var_val_len);
break;
case SMI_GAUGE:
case SMI_COUNTER:
case SMI_TIMETICKS:
case SMI_UINTEGER:
- data = asn1::build_unsigned_int( data,
- listlength,
- var_val_type,
- (u_long *)var_val,
- var_val_len);
+ data = asn1::build_unsigned_int( data,
+ listlength,
+ var_val_type,
+ (u_long *)var_val,
+ var_val_len);
break;
case SMI_COUNTER64:
- data = asn1::build_unsigned_int64(data,
- listlength,
- var_val_type,
- (struct counter64 *)var_val,
- var_val_len);
+ data = asn1::build_unsigned_int64(data,
+ listlength,
+ var_val_type,
+ (struct counter64 *)var_val,
+ var_val_len);
break;
case ASN_OCTET_STR:
@@ -1240,12 +1240,12 @@ u_char * cmu_snmp::build_var_op(u_char *data, oid * var_name,
case SMI_OPAQUE:
case SMI_NSAP:
data = asn1::build_string(data, listlength, var_val_type,
- var_val, var_val_len);
+ var_val, var_val_len);
break;
case ASN_OBJECT_ID:
data = asn1::build_objid(data, listlength, var_val_type,
- (oid *)var_val, var_val_len / sizeof(oid));
+ (oid *)var_val, var_val_len / sizeof(oid));
break;
case ASN_NULL:
@@ -1254,7 +1254,7 @@ u_char * cmu_snmp::build_var_op(u_char *data, oid * var_name,
case ASN_BIT_STR:
data = asn1::build_bitstring(data, listlength, var_val_type,
- var_val, var_val_len);
+ var_val, var_val_len);
break;
case SNMP_NOSUCHOBJECT:
@@ -1265,25 +1265,25 @@ u_char * cmu_snmp::build_var_op(u_char *data, oid * var_name,
default:
ASNERROR("wrong type");
- return NULL;
+ return 0;
}
- if (data == NULL) {
+ if (data == 0) {
ASNERROR("");
- return NULL;
+ return 0;
}
dummyLen = (data - dataPtr) - headerLen;
asn1::build_sequence(dataPtr, &dummyLen,
- (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
- dummyLen);
+ (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
+ dummyLen);
return data;
}
// serialize the pdu
-int cmu_snmp::build( struct snmp_pdu *pdu, u_char *packet,
- int *out_length, long version,
- u_char* community, int community_len)
+int cmu_snmp::build( struct snmp_pdu *pdu, u_char *packet,
+ int *out_length, long version,
+ u_char* community, int community_len)
{
ACE_TRACE("cmu_snmp::build");
u_char buf[SNMP_MSG_LENGTH];
@@ -1295,22 +1295,22 @@ int cmu_snmp::build( struct snmp_pdu *pdu, u_char *packet,
length = *out_length;
cp = packet;
for(vp = pdu->variables; vp; vp = vp->next_variable) {
- cp = cmu_snmp::build_var_op( cp, vp->name,
- &vp->name_length, vp->type,
- vp->val_len, (u_char *)vp->val.string,
- &length);
- if (cp == NULL)
+ cp = cmu_snmp::build_var_op( cp, vp->name,
+ &vp->name_length, vp->type,
+ vp->val_len, (u_char *)vp->val.string,
+ &length);
+ if (cp == 0)
return -1;
}
totallength = cp - packet;
length = SNMP_MSG_LENGTH;
-
+
// encode the total len
- cp = asn1::build_header( buf, &length,
- (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
- totallength);
- if (cp == NULL)
+ cp = asn1::build_header( buf, &length,
+ (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
+ totallength);
+ if (cp == 0)
return -1;
ACE_OS::memcpy( (char *)cp, (char *)packet,totallength);
totallength += cp - buf;
@@ -1318,80 +1318,80 @@ int cmu_snmp::build( struct snmp_pdu *pdu, u_char *packet,
length = *out_length;
if (pdu->command != TRP_REQ_MSG) {
- // request id
- cp = asn1::build_int( packet,
- &length,
- (u_char )(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->reqid,
- sizeof(pdu->reqid));
- if (cp == NULL)
+ // request id
+ cp = asn1::build_int( packet,
+ &length,
+ (u_char )(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
+ (long *)&pdu->reqid,
+ sizeof(pdu->reqid));
+ if (cp == 0)
return -1;
- // error status
- cp = asn1::build_int(cp,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->errstat, sizeof(pdu->errstat));
- if (cp == NULL)
+ // error status
+ cp = asn1::build_int(cp,
+ &length,
+ (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
+ (long *)&pdu->errstat, sizeof(pdu->errstat));
+ if (cp == 0)
return -1;
- // error index
- cp = asn1::build_int(cp,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->errindex, sizeof(pdu->errindex));
- if (cp == NULL)
+ // error index
+ cp = asn1::build_int(cp,
+ &length,
+ (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
+ (long *)&pdu->errindex, sizeof(pdu->errindex));
+ if (cp == 0)
return -1;
- }
- else { // this is a trap message
-
- // enterprise
- cp = asn1::build_objid( packet,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),
- (oid *)pdu->enterprise,
- pdu->enterprise_length);
- if (cp == NULL)
+ }
+ else { // this is a trap message
+
+ // enterprise
+ cp = asn1::build_objid( packet,
+ &length,
+ (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),
+ (oid *)pdu->enterprise,
+ pdu->enterprise_length);
+ if (cp == 0)
return -1;
- // agent-addr
- cp = asn1::build_string(cp,
- &length,
- // HDN Fixed to use correct tag
- (u_char)SMI_IPADDRESS,
- //(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
- (u_char *)&pdu->agent_addr.sin_addr.s_addr,
- sizeof(pdu->agent_addr.sin_addr.s_addr));
- if (cp == NULL)
+ // agent-addr
+ cp = asn1::build_string(cp,
+ &length,
+ // HDN Fixed to use correct tag
+ (u_char)SMI_IPADDRESS,
+ //(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
+ (u_char *)&pdu->agent_addr.sin_addr.s_addr,
+ sizeof(pdu->agent_addr.sin_addr.s_addr));
+ if (cp == 0)
return -1;
- // generic trap
- cp = asn1::build_int(cp,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->trap_type,
- sizeof(pdu->trap_type));
- if (cp == NULL)
+ // generic trap
+ cp = asn1::build_int(cp,
+ &length,
+ (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
+ (long *)&pdu->trap_type,
+ sizeof(pdu->trap_type));
+ if (cp == 0)
return -1;
- // specific trap
- cp = asn1::build_int( cp,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->specific_type,
- sizeof(pdu->specific_type));
- if (cp == NULL)
+ // specific trap
+ cp = asn1::build_int( cp,
+ &length,
+ (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
+ (long *)&pdu->specific_type,
+ sizeof(pdu->specific_type));
+ if (cp == 0)
return -1;
- // timestamp
- cp = asn1::build_int(cp,
- &length,
- // HDN Fixed to use correct tag
- (u_char)SMI_TIMETICKS,
- //(u_char )(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->time,
- sizeof(pdu->time));
- if (cp == NULL)
+ // timestamp
+ cp = asn1::build_int(cp,
+ &length,
+ // HDN Fixed to use correct tag
+ (u_char)SMI_TIMETICKS,
+ //(u_char )(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
+ (long *)&pdu->time,
+ sizeof(pdu->time));
+ if (cp == 0)
return -1;
}
@@ -1402,11 +1402,11 @@ int cmu_snmp::build( struct snmp_pdu *pdu, u_char *packet,
totallength += cp - packet;
length = SNMP_MSG_LENGTH;
- cp = asn1::build_header(buf,
- &length,
- (u_char)pdu->command,
- totallength);
- if (cp == NULL)
+ cp = asn1::build_header(buf,
+ &length,
+ (u_char)pdu->command,
+ totallength);
+ if (cp == 0)
return -1;
if (length < totallength)
return -1;
@@ -1416,13 +1416,13 @@ int cmu_snmp::build( struct snmp_pdu *pdu, u_char *packet,
length = *out_length;
- cp = cmu_snmp::auth_build( packet,
- &length,
- version,
- community,
- community_len,
- totallength );
- if (cp == NULL)
+ cp = cmu_snmp::auth_build( packet,
+ &length,
+ version,
+ community,
+ community_len,
+ totallength );
+ if (cp == 0)
return -1;
if ((*out_length - (cp - packet)) < totallength)
return -1;
@@ -1437,81 +1437,81 @@ int cmu_snmp::build( struct snmp_pdu *pdu, u_char *packet,
// parse the authentication header
u_char *cmu_snmp::auth_parse(u_char *data,
int *length, u_char *sid,
- int *slen, long *version)
+ int *slen, long *version)
{
ACE_TRACE("cmu_snmp::auth_parse");
u_char type;
// get the type
data = asn1::parse_header( data, length, &type);
- if (data == NULL){
+ if (data == 0){
ASNERROR("bad header");
- return NULL;
+ return 0;
}
if (type != (ASN_SEQUENCE | ASN_CONSTRUCTOR)) {
ASNERROR("wrong auth header type");
- return NULL;
+ return 0;
}
// get the version
data = asn1::parse_int(data, length, &type, version, sizeof(*version));
- if (data == NULL) {
+ if (data == 0) {
ASNERROR("bad parse of version");
- return NULL;
+ return 0;
}
// get the community name
data = asn1::parse_string(data, length, &type, sid, slen);
- if (data == NULL) {
+ if (data == 0) {
ASNERROR("bad parse of community");
- return NULL;
+ return 0;
}
return (u_char *)data;
}
-/* u_char *data, // IN - pointer to the start of object
- oid *var_name, // OUT - object id of variable
- int *var_name_len, // IN/OUT - length of variable name
- u_char *var_val_type, // OUT - type of variable
- (int or octet string) (one byte)
- int *var_val_len, // OUT - length of variable
+/* u_char *data, // IN - pointer to the start of object
+ oid *var_name, // OUT - object id of variable
+ int *var_name_len, // IN/OUT - length of variable name
+ u_char *var_val_type, // OUT - type of variable
+ (int or octet string) (one byte)
+ int *var_val_len, // OUT - length of variable
u_char **var_val, // OUT - pointer to ASN1 encoded value of variable
*/
u_char *
-cmu_snmp::parse_var_op( u_char *data, oid *var_name,
- int *var_name_len, u_char *var_val_type,
- int *var_val_len, u_char **var_val,
+cmu_snmp::parse_var_op( u_char *data, oid *var_name,
+ int *var_name_len, u_char *var_val_type,
+ int *var_val_len, u_char **var_val,
int *listlength)
{
ACE_TRACE("cmu_snmp::parse_var_op");
u_char var_op_type;
- int var_op_len = *listlength;
+ int var_op_len = *listlength;
u_char *var_op_start = data;
data = asn1::parse_header(data, &var_op_len, &var_op_type);
- if (data == NULL){
+ if (data == 0){
ASNERROR("");
- return NULL;
+ return 0;
}
if (var_op_type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR))
- return NULL;
+ return 0;
data = asn1::parse_objid(data, &var_op_len, &var_op_type, var_name, var_name_len);
- if (data == NULL) {
+ if (data == 0) {
ASNERROR("");
- return NULL;
+ return 0;
}
if (var_op_type != (u_char)
(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID))
- return NULL;
- *var_val = data; /* save pointer to this object */
+ return 0;
+ *var_val = data; /* save pointer to this object */
/* find out what type of object this is */
data = asn1::parse_header(data, &var_op_len, var_val_type);
- if (data == NULL) {
+ if (data == 0) {
ASNERROR("");
- return NULL;
+ return 0;
}
*var_val_len = var_op_len;
data += var_op_len;
@@ -1523,36 +1523,36 @@ cmu_snmp::parse_var_op( u_char *data, oid *var_name,
// build a pdu from a data and length
int cmu_snmp::parse( struct snmp_pdu *pdu,
- u_char *data,
- u_char *community_name,
- u_long &community_len,
- snmp_version &spp_version,
- int length)
+ u_char *data,
+ u_char *community_name,
+ u_long &community_len,
+ snmp_version &spp_version,
+ int length)
{
ACE_TRACE("cmu_snmp::parse");
u_char msg_type;
u_char type;
u_char *var_val;
long version;
- int len, four;
+ int len, four;
u_char community[256];
int community_length = 256;
struct variable_list *vp = 0;
- oid objid[MAX_NAME_LEN], *op;
-
- // authenticates message and returns length if valid
- data = cmu_snmp::auth_parse(data,
- &length,
- community,
- &community_length,
- &version);
- if (data == NULL)
+ oid objid[MAX_NAME_LEN], *op;
+
+ // authenticates message and returns length if valid
+ data = cmu_snmp::auth_parse(data,
+ &length,
+ community,
+ &community_length,
+ &version);
+ if (data == 0)
return -1;
// copy the returned community name
- ACE_OS::memcpy( (u_char *) community_name,
- (u_char *) community,
- community_length);
+ ACE_OS::memcpy( (u_char *) community_name,
+ (u_char *) community,
+ community_length);
community_len = (long) community_length;
if( version != SNMP_VERSION_1 && version != SNMP_VERSION_2C ) {
@@ -1562,109 +1562,109 @@ int cmu_snmp::parse( struct snmp_pdu *pdu,
spp_version = (snmp_version) version;
- data = asn1::parse_header(data,
- &length,
- &msg_type);
- if (data == NULL)
+ data = asn1::parse_header(data,
+ &length,
+ &msg_type);
+ if (data == 0)
return -1;
pdu->command = msg_type;
if (pdu->command != TRP_REQ_MSG){
// get the rid
- data = asn1::parse_int(data,
- &length, &type,
- (long *)&pdu->reqid,
- sizeof(pdu->reqid));
- if (data == NULL)
+ data = asn1::parse_int(data,
+ &length, &type,
+ (long *)&pdu->reqid,
+ sizeof(pdu->reqid));
+ if (data == 0)
return -1;
// get the error status
- data = asn1::parse_int(data,
- &length,
- &type,
- (long *)&pdu->errstat,
- sizeof(pdu->errstat));
- if (data == NULL)
+ data = asn1::parse_int(data,
+ &length,
+ &type,
+ (long *)&pdu->errstat,
+ sizeof(pdu->errstat));
+ if (data == 0)
return -1;
// get the error index
- data = asn1::parse_int(data,
- &length,
- &type,
- (long *)&pdu->errindex,
- sizeof(pdu->errindex));
- if (data == NULL)
+ data = asn1::parse_int(data,
+ &length,
+ &type,
+ (long *)&pdu->errindex,
+ sizeof(pdu->errindex));
+ if (data == 0)
return -1;
- }
+ }
else { // is a trap
// get the enterprise
pdu->enterprise_length = MAX_NAME_LEN;
- data = asn1::parse_objid(data,
- &length,
- &type,
- objid,
- &pdu->enterprise_length);
- if (data == NULL)
+ data = asn1::parse_objid(data,
+ &length,
+ &type,
+ objid,
+ &pdu->enterprise_length);
+ if (data == 0)
return -1;
- ACE_NEW_RETURN(pdu->enterprise,
+ ACE_NEW_RETURN(pdu->enterprise,
oid[pdu->enterprise_length*sizeof(oid)],-1);
// fixed
- ACE_OS::memcpy((char *)pdu->enterprise,(char *)objid,
+ ACE_OS::memcpy((char *)pdu->enterprise,(char *)objid,
pdu->enterprise_length * sizeof(oid));
// get source address
four = 4;
- data = asn1::parse_string(data, &length, &type,
- (u_char *)&pdu->agent_addr.sin_addr.s_addr,
- &four);
- if (data == NULL)
+ data = asn1::parse_string(data, &length, &type,
+ (u_char *)&pdu->agent_addr.sin_addr.s_addr,
+ &four);
+ if (data == 0)
return -1;
// get trap type
- data = asn1::parse_int(data, &length, &type, (long *)&pdu->trap_type,
- sizeof(pdu->trap_type));
- if (data == NULL)
+ data = asn1::parse_int(data, &length, &type, (long *)&pdu->trap_type,
+ sizeof(pdu->trap_type));
+ if (data == 0)
return -1;
// trap type
- data = asn1::parse_int(data, &length, &type, (long *)&pdu->specific_type,
- sizeof(pdu->specific_type));
- if (data == NULL)
+ data = asn1::parse_int(data, &length, &type, (long *)&pdu->specific_type,
+ sizeof(pdu->specific_type));
+ if (data == 0)
return -1;
// timestamp
- data = asn1::parse_int(data, &length, &type, (long *)&pdu->time,
+ data = asn1::parse_int(data, &length, &type, (long *)&pdu->time,
sizeof(pdu->time));
- if (data == NULL)
+ if (data == 0)
return -1;
}
// get the vb list
data = asn1::parse_header(data, &length, &type);
- if (data == NULL)
+ if (data == 0)
return -1;
if (type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR))
return -1;
while((int)length > 0) {
- if (pdu->variables == NULL) {
+ if (pdu->variables == 0) {
ACE_NEW_RETURN(pdu->variables, variable_list, -1);
vp = pdu->variables;
} else {
ACE_NEW_RETURN(vp->next_variable, variable_list, -1);
vp = vp->next_variable;
}
- vp->next_variable = NULL;
- vp->val.string = NULL;
- vp->name = NULL;
+ vp->next_variable = 0;
+ vp->val.string = 0;
+ vp->name = 0;
vp->name_length = MAX_NAME_LEN;
- data = cmu_snmp::parse_var_op( data, objid,
- &vp->name_length, &vp->type,
- &vp->val_len, &var_val,
- (int *)&length);
- if (data == NULL)
+ data = cmu_snmp::parse_var_op( data, objid,
+ &vp->name_length, &vp->type,
+ &vp->val_len, &var_val,
+ (int *)&length);
+ if (data == 0)
return -1;
ACE_NEW_RETURN(op, oid[(unsigned)vp->name_length * sizeof(oid)], -1);
@@ -1688,16 +1688,16 @@ int cmu_snmp::parse( struct snmp_pdu *pdu,
ACE_NEW_RETURN(vp->val.counter64, counter64, -1);
vp->val_len = sizeof(struct counter64);
asn1::parse_unsigned_int64(var_val, &len, &vp->type,
- (struct counter64 *)vp->val.counter64,
- sizeof(*vp->val.counter64));
+ (struct counter64 *)vp->val.counter64,
+ sizeof(*vp->val.counter64));
break;
-
+
case ASN_OCTET_STR:
case SMI_IPADDRESS:
case SMI_OPAQUE:
case SMI_NSAP:
ACE_NEW_RETURN(vp->val.string, u_char[(unsigned)vp->val_len + 1], -1);
- asn1::parse_string(var_val, &len, &vp->type, vp->val.string,
+ asn1::parse_string(var_val, &len, &vp->type, vp->val.string,
&vp->val_len);
break;
@@ -1710,8 +1710,8 @@ int cmu_snmp::parse( struct snmp_pdu *pdu,
// fixed
ACE_OS::memcpy((char *)vp->val.objid,
- (char *)objid,
- vp->val_len * sizeof(oid));
+ (char *)objid,
+ vp->val_len * sizeof(oid));
break;
case SNMP_NOSUCHOBJECT:
@@ -1726,4 +1726,3 @@ int cmu_snmp::parse( struct snmp_pdu *pdu,
}
return 0;
}
-
diff --git a/ASNMP/asnmp/asn1.h b/ASNMP/asnmp/asn1.h
index dd84e8f5b00..82a81f4a561 100644
--- a/ASNMP/asnmp/asn1.h
+++ b/ASNMP/asnmp/asn1.h
@@ -141,7 +141,7 @@ struct snmp_pdu {
// vb list
struct variable_list {
- struct variable_list *next_variable; // NULL for last variable
+ struct variable_list *next_variable; // 0 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
diff --git a/ASNMP/asnmp/counter.cpp b/ASNMP/asnmp/counter.cpp
index 363c4b632f7..04c50dd6475 100644
--- a/ASNMP/asnmp/counter.cpp
+++ b/ASNMP/asnmp/counter.cpp
@@ -18,17 +18,17 @@
/*===================================================================
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/counter.h"
@@ -37,13 +37,13 @@ ACE_RCSID(asnmp, counter, "$Id$")
// constructor with a value
Counter32::Counter32( const unsigned long i):SnmpUInt32(i)
-{
- smival.syntax = sNMP_SYNTAX_CNTR32;
+{
+ smival.syntax = sNMP_SYNTAX_CNTR32;
}
// copy constructor
Counter32::Counter32( const Counter32 &c)
-{
+{
this->smival.value.uNumber = c.smival.value.uNumber;
smival.syntax = sNMP_SYNTAX_CNTR32;
valid_flag = 1;
@@ -51,29 +51,29 @@ Counter32::Counter32( const Counter32 &c)
// syntax type
SmiUINT32 Counter32::get_syntax()
-{
- return sNMP_SYNTAX_CNTR32;
+{
+ return sNMP_SYNTAX_CNTR32;
}
// general assignment from any Value
SnmpSyntax& Counter32::operator=( SnmpSyntax &in_val){
- if ( this == &in_val ) // handle assignement from itself
+ if ( this == &in_val ) // handle assignement from itself
return *this;
- valid_flag = 0; // will get set true if really valid
+ valid_flag = 0; // will get set true if really valid
if (in_val.valid())
- {
+ {
switch (in_val.get_syntax())
{
case sNMP_SYNTAX_UINT32:
- // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
+ // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
case sNMP_SYNTAX_CNTR32:
case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_INT32: // implied cast int -> uint
- this->smival.value.uNumber =
- ((Counter32 &)in_val).smival.value.uNumber;
- valid_flag = 1;
- break;
+ case sNMP_SYNTAX_INT32: // implied cast int -> uint
+ this->smival.value.uNumber =
+ ((Counter32 &)in_val).smival.value.uNumber;
+ valid_flag = 1;
+ break;
}
}
return *this;
@@ -81,27 +81,26 @@ SnmpSyntax& Counter32::operator=( SnmpSyntax &in_val){
// overloaded assignment
Counter32& Counter32::operator=( const unsigned long int i)
-{
- this->smival.value.uNumber=i;
+{
+ this->smival.value.uNumber=i;
return *this;
}
// overloaded assignment
Counter32& Counter32::operator=( const Counter32 &uli)
-{
+{
this->smival.value.uNumber = uli.smival.value.uNumber;
return *this;
}
// otherwise, behave like an unsigned long int
Counter32::operator unsigned long()
-{
- return this->smival.value.uNumber;
+{
+ return this->smival.value.uNumber;
}
// clone
SnmpSyntax * Counter32::clone() const
-{
- return ( SnmpSyntax *) new Counter32(*this);
+{
+ return ( SnmpSyntax *) new Counter32(*this);
}
-
diff --git a/ASNMP/asnmp/ctr64.cpp b/ASNMP/asnmp/ctr64.cpp
index 6106eb83bf8..264c97a3ac2 100644
--- a/ASNMP/asnmp/ctr64.cpp
+++ b/ASNMP/asnmp/ctr64.cpp
@@ -18,32 +18,32 @@
/*===================================================================
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/ctr64.h"
ACE_RCSID(asnmp, ctr64, "$Id$")
-#define MAX32 4294967295
+#define MAX32 4294967295u
//-----------[ syntax type ]----------------------------------------------
SmiUINT32 Counter64::get_syntax()
-{
- return sNMP_SYNTAX_CNTR64;
+{
+ return sNMP_SYNTAX_CNTR64;
}
-//------------------[ constructor with values ]--------------------------
+//------------------[ constructor with values ]--------------------------
Counter64::Counter64( unsigned long hiparm, unsigned long loparm)
{
smival.syntax = sNMP_SYNTAX_CNTR64;
@@ -51,7 +51,7 @@ Counter64::Counter64( unsigned long hiparm, unsigned long loparm)
smival.value.hNumber.lopart = loparm;
}
-//------------------[ constructor with low value only ]------------------
+//------------------[ constructor with low value only ]------------------
Counter64::Counter64( unsigned long long llw )
{
smival.syntax = sNMP_SYNTAX_CNTR64;
@@ -59,7 +59,7 @@ Counter64::Counter64( unsigned long long llw )
smival.value.hNumber.lopart = (unsigned long) llw & 0xffffffff;
}
-//------------------[ copy constructor ]---------------------------------
+//------------------[ copy constructor ]---------------------------------
Counter64::Counter64( const Counter64 &ctr64 )
{
smival.syntax = sNMP_SYNTAX_CNTR64;
@@ -67,41 +67,41 @@ Counter64::Counter64( const Counter64 &ctr64 )
smival.value.hNumber.lopart = ctr64.low();
}
-//------------------[ destructor ]---------------------------------
+//------------------[ destructor ]---------------------------------
Counter64::~Counter64()
{
}
-//------------------[ Counter64::high() ]------------------------------
-// return the high part
+//------------------[ Counter64::high() ]------------------------------
+// return the high part
unsigned long Counter64::high() const
-{
- return smival.value.hNumber.hipart;
+{
+ return smival.value.hNumber.hipart;
}
-//------------------[ Counter64::low() ]-------------------------------
-// return the low part
+//------------------[ Counter64::low() ]-------------------------------
+// return the low part
unsigned long Counter64::low() const
-{
+{
return smival.value.hNumber.lopart;
}
-//------------------[ set_high( const unsigned long h) ]-----------
-// set the high part
+//------------------[ set_high( const unsigned long h) ]-----------
+// set the high part
void Counter64::set_high( const unsigned long h)
-{
- smival.value.hNumber.hipart = h;
+{
+ smival.value.hNumber.hipart = h;
}
-
-//------------------[ set_low( const unsigned long l) ]------------
-// set the low part
+
+//------------------[ set_low( const unsigned long l) ]------------
+// set the low part
void Counter64::set_low( const unsigned long l)
-{
- smival.value.hNumber.lopart = l;
-}
-
+{
+ smival.value.hNumber.lopart = l;
+}
+
//-----------[ to_long_double( Counter64 c64) ]-----------------------------
// convert a Counter 64 to a long double
@@ -114,7 +114,7 @@ long double Counter64::to_long_double() const
}
-//-----------[ ld_to_c64( long double ld) ]----------------------------
+//-----------[ ld_to_c64( long double ld) ]----------------------------
// convert a long double to a Counter64
// semantics changed from prior version
Counter64& Counter64::assign( long double ld)
@@ -132,28 +132,28 @@ SnmpSyntax& Counter64::operator=( SnmpSyntax &val)
if ( this == &val )
return *this;
- smival.value.hNumber.lopart = 0; // pessimsitic - assume no mapping
+ smival.value.hNumber.lopart = 0; // pessimsitic - assume no mapping
smival.value.hNumber.hipart = 0;
// try to make assignment valid
if (val.valid()){
switch (val.get_syntax()){
case sNMP_SYNTAX_CNTR64:
- smival.value.hNumber.hipart =
- ((Counter64 &)val).smival.value.hNumber.hipart;
- smival.value.hNumber.lopart =
- ((Counter64 &)val).smival.value.hNumber.lopart;
- break;
+ smival.value.hNumber.hipart =
+ ((Counter64 &)val).smival.value.hNumber.hipart;
+ smival.value.hNumber.lopart =
+ ((Counter64 &)val).smival.value.hNumber.lopart;
+ break;
case sNMP_SYNTAX_CNTR32:
case sNMP_SYNTAX_TIMETICKS:
case sNMP_SYNTAX_GAUGE32:
- // case sNMP_SYNTAX_UINT32: .. indistinguishable from GAUGE32
+ // case sNMP_SYNTAX_UINT32: .. indistinguishable from GAUGE32
case sNMP_SYNTAX_INT32:
- // take advantage of union...
- smival.value.hNumber.lopart = ((Counter64 &)val).smival.value.uNumber;
- smival.value.hNumber.hipart = 0;
- break;
+ // take advantage of union...
+ smival.value.hNumber.lopart = ((Counter64 &)val).smival.value.uNumber;
+ smival.value.hNumber.hipart = 0;
+ break;
}
}
return *this;
@@ -166,7 +166,7 @@ Counter64& Counter64::operator=( const unsigned long long rhs)
smival.value.hNumber.lopart = (unsigned long) rhs;
return *this;
}
-
+
// overloaded assignment
Counter64& Counter64::operator=( const Counter64 &rhs)
{
@@ -174,27 +174,27 @@ Counter64& Counter64::operator=( const Counter64 &rhs)
smival.value.hNumber.lopart = rhs.low();
return *this;
}
-
+
// otherwise, behave like an unsigned long int
Counter64::operator unsigned long long()
{
- unsigned long long val = smival.value.hNumber.hipart;
+ unsigned long long val = smival.value.hNumber.hipart;
val = val << 32; // shift right 4 bytes
val |= smival.value.hNumber.lopart;
- return val;
+ return val;
}
//----------------[ Counter64::clone() ]-----------------------------------
// create a new instance of this Value
-SnmpSyntax* Counter64::clone() const
-{
- return ( SnmpSyntax *) new Counter64(*this);
+SnmpSyntax* Counter64::clone() const
+{
+ return ( SnmpSyntax *) new Counter64(*this);
}
//----------------[ Counter64::valid() ]-------------------------------------
int Counter64::valid() const
-{
- return 1;
+{
+ return 1;
}
//----------[ return ASCII format ]-------------------------
@@ -203,10 +203,9 @@ int Counter64::valid() const
char * Counter64::to_string()
{
if ( high() != 0 )
- sprintf(output_buffer, "0x%X%08X",
- (unsigned int)high(), (unsigned int)low());
+ sprintf(output_buffer, "0x%X%08X",
+ (unsigned int)high(), (unsigned int)low());
else
sprintf(output_buffer, "%d", (int) low());
return output_buffer;
}
-
diff --git a/ASNMP/asnmp/gauge.cpp b/ASNMP/asnmp/gauge.cpp
index 8f97556a660..aac715f2730 100644
--- a/ASNMP/asnmp/gauge.cpp
+++ b/ASNMP/asnmp/gauge.cpp
@@ -19,26 +19,26 @@
/*===================================================================
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/gauge.h" // header file for gauge class
+#include "asnmp/gauge.h" // header file for gauge class
ACE_RCSID(asnmp, gauge, "$Id$")
// constructor with a value
Gauge32::Gauge32( const unsigned long i):SnmpUInt32(i)
-{
+{
smival.syntax = sNMP_SYNTAX_GAUGE32;
}
@@ -50,26 +50,26 @@ Gauge32::Gauge32 ( const Gauge32 &g)
}
// destructor
-Gauge32::~Gauge32()
+Gauge32::~Gauge32()
{
}
// syntax type
SmiUINT32 Gauge32::get_syntax()
-{
- return sNMP_SYNTAX_GAUGE32;
+{
+ return sNMP_SYNTAX_GAUGE32;
}
// overloaded assignment
Gauge32& Gauge32::operator=( const Gauge32 &uli)
-{
+{
this->smival.value.uNumber = uli.smival.value.uNumber;
return *this;
}
// overloaded assignment
Gauge32& Gauge32::operator=( const unsigned long int i)
-{
+{
smival.value.uNumber=i; return *this;
}
@@ -78,23 +78,23 @@ Gauge32& Gauge32::operator=( const unsigned long int i)
SnmpSyntax& Gauge32::operator=( SnmpSyntax &in_val)
{
- if ( this == &in_val ) // handle assignement from itself
+ if ( this == &in_val ) // handle assignement from itself
return *this;
- valid_flag = 0; // will get set true if really valid
+ valid_flag = 0; // will get set true if really valid
if (in_val.valid())
- {
+ {
switch (in_val.get_syntax())
{
case sNMP_SYNTAX_UINT32:
- case sNMP_SYNTAX_GAUGE32:
+ case sNMP_SYNTAX_GAUGE32:
case sNMP_SYNTAX_CNTR32:
case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_INT32: // implied cast int -> uint
- this->smival.value.uNumber =
- ((Gauge32 &)in_val).smival.value.uNumber;
- valid_flag = 1;
- break;
+ case sNMP_SYNTAX_INT32: // implied cast int -> uint
+ this->smival.value.uNumber =
+ ((Gauge32 &)in_val).smival.value.uNumber;
+ valid_flag = 1;
+ break;
}
}
return *this;
@@ -102,13 +102,12 @@ SnmpSyntax& Gauge32::operator=( SnmpSyntax &in_val)
// otherwise, act as unsigned long
Gauge32::operator unsigned long()
-{
- return smival.value.uNumber;
+{
+ return smival.value.uNumber;
}
// clone - create a new instance of this Value
-SnmpSyntax* Gauge32::clone() const
-{
- return ( SnmpSyntax *) new Gauge32(*this);
+SnmpSyntax* Gauge32::clone() const
+{
+ return ( SnmpSyntax *) new Gauge32(*this);
}
-
diff --git a/ASNMP/asnmp/integer.cpp b/ASNMP/asnmp/integer.cpp
index 295046ab955..e0da5b6dfab 100644
--- a/ASNMP/asnmp/integer.cpp
+++ b/ASNMP/asnmp/integer.cpp
@@ -21,24 +21,24 @@
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" // header file for gauge class
+#include "asnmp/integer.h" // header file for gauge class
ACE_RCSID(asnmp, integer, "$Id$")
// constructor with value
SnmpUInt32::SnmpUInt32 (const u_long i)
-{
+{
smival.value.uNumber=i;
smival.syntax = sNMP_SYNTAX_UINT32;
valid_flag = 1;
@@ -46,83 +46,83 @@ SnmpUInt32::SnmpUInt32 (const u_long i)
// copy constructor
SnmpUInt32::SnmpUInt32( const SnmpUInt32 &c)
-{
+{
smival.value.uNumber=c.smival.value.uNumber;
smival.syntax = sNMP_SYNTAX_UINT32;
valid_flag = 1;
}
// destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden)
-SnmpUInt32::~SnmpUInt32()
+SnmpUInt32::~SnmpUInt32()
{
}
// syntax type
SmiUINT32 SnmpUInt32::get_syntax()
-{
- return sNMP_SYNTAX_UINT32;
+{
+ return sNMP_SYNTAX_UINT32;
}
-// object validity
+// object validity
int SnmpUInt32::valid( void) const
-{
- return valid_flag;
-}
-
-// overloaded assignment
-SnmpUInt32& SnmpUInt32::operator=( const unsigned long int i)
-{
- smival.value.uNumber=i;
+{
+ return valid_flag;
+}
+
+// overloaded assignment
+SnmpUInt32& SnmpUInt32::operator=( const unsigned long int i)
+{
+ smival.value.uNumber=i;
valid_flag = 1;
return *this;
}
-
+
// general assignment from any Value
SnmpSyntax& SnmpUInt32::operator=( SnmpSyntax &in_val)
{
- if ( this == &in_val ) // handle assignement from itself
+ if ( this == &in_val ) // handle assignement from itself
return *this;
- valid_flag = 0; // will get set true if really valid
+ valid_flag = 0; // will get set true if really valid
if (in_val.valid())
- {
+ {
switch (in_val.get_syntax())
{
case sNMP_SYNTAX_UINT32:
- // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
+ // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
case sNMP_SYNTAX_CNTR32:
case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_INT32: // implied cast int -> uint
- this->smival.value.uNumber =
- ((SnmpUInt32 &)in_val).smival.value.uNumber;
- valid_flag = 1;
- break;
+ case sNMP_SYNTAX_INT32: // implied cast int -> uint
+ this->smival.value.uNumber =
+ ((SnmpUInt32 &)in_val).smival.value.uNumber;
+ valid_flag = 1;
+ break;
}
}
return *this;
}
-// overloaded assignment
-SnmpUInt32& SnmpUInt32::operator=( const SnmpUInt32 &uli)
-{
+// overloaded assignment
+SnmpUInt32& SnmpUInt32::operator=( const SnmpUInt32 &uli)
+{
this->smival.value.uNumber = uli.smival.value.uNumber; return *this;
}
// otherwise, behave like an unsigned long int
SnmpUInt32::operator unsigned long()
-{
- return smival.value.uNumber;
+{
+ return smival.value.uNumber;
}
// create a new instance of this Value
SnmpSyntax* SnmpUInt32::clone() const
-{
- return (SnmpSyntax *) new SnmpUInt32(*this);
+{
+ return (SnmpSyntax *) new SnmpUInt32(*this);
}
// ASCII format return
-char * SnmpUInt32::to_string()
-{
+char * SnmpUInt32::to_string()
+{
sprintf(output_buffer, "%d", (int) (this->smival.value.uNumber));
return output_buffer;
}
@@ -132,51 +132,51 @@ char * SnmpUInt32::to_string()
// INT 32 Implementation
//====================================================================
-// default constructor
-SnmpInt32::SnmpInt32 (const long i)
-{
+// default constructor
+SnmpInt32::SnmpInt32 (const long i)
+{
smival.value.sNumber=i;
smival.syntax = sNMP_SYNTAX_INT32;
valid_flag = 1;
}
// constructor with value
-SnmpInt32::SnmpInt32 (const SnmpInt32 &c)
-{
+SnmpInt32::SnmpInt32 (const SnmpInt32 &c)
+{
smival.value.sNumber=c.smival.value.sNumber;
smival.syntax = sNMP_SYNTAX_INT32;
valid_flag = 1;
}
-// destructor
-SnmpInt32::~SnmpInt32()
+// destructor
+SnmpInt32::~SnmpInt32()
{
}
// syntax type
SmiUINT32 SnmpInt32::get_syntax()
-{
- return sNMP_SYNTAX_INT32;
+{
+ return sNMP_SYNTAX_INT32;
}
-// object validity
+// object validity
int SnmpInt32::valid( void) const
-{
- return valid_flag;
-}
-
-// overloaded assignment
-SnmpInt32& SnmpInt32::operator=( const long i)
-{
- this->smival.value.sNumber = (unsigned long) i;
+{
+ return valid_flag;
+}
+
+// overloaded assignment
+SnmpInt32& SnmpInt32::operator=( const long i)
+{
+ this->smival.value.sNumber = (unsigned long) i;
valid_flag = 1;
return *this;
}
-
-// overloaded assignment
-SnmpInt32& SnmpInt32::operator=( const SnmpInt32 &uli)
-{
- this->smival.value.sNumber = uli.smival.value.sNumber;
+
+// overloaded assignment
+SnmpInt32& SnmpInt32::operator=( const SnmpInt32 &uli)
+{
+ this->smival.value.sNumber = uli.smival.value.sNumber;
valid_flag = 1;
return *this;
}
@@ -184,23 +184,23 @@ SnmpInt32& SnmpInt32::operator=( const SnmpInt32 &uli)
// general assignment from any Value
SnmpSyntax& SnmpInt32::operator=( SnmpSyntax &in_val)
{
- if ( this == &in_val ) // handle assignement from itself
+ if ( this == &in_val ) // handle assignement from itself
return *this;
- valid_flag = 0; // will get set true if really valid
+ valid_flag = 0; // will get set true if really valid
if (in_val.valid())
- {
+ {
switch (in_val.get_syntax())
{
case sNMP_SYNTAX_INT32:
- case sNMP_SYNTAX_UINT32: // implied cast uint -> int
- // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
- case sNMP_SYNTAX_CNTR32: // implied cast uint -> int
- case sNMP_SYNTAX_TIMETICKS: // implied cast uint -> int
- this->smival.value.sNumber =
- ((SnmpInt32 &)in_val).smival.value.sNumber;
- valid_flag = 1;
- break;
+ case sNMP_SYNTAX_UINT32: // implied cast uint -> int
+ // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
+ case sNMP_SYNTAX_CNTR32: // implied cast uint -> int
+ case sNMP_SYNTAX_TIMETICKS: // implied cast uint -> int
+ this->smival.value.sNumber =
+ ((SnmpInt32 &)in_val).smival.value.sNumber;
+ valid_flag = 1;
+ break;
}
}
return *this;
@@ -208,21 +208,20 @@ SnmpSyntax& SnmpInt32::operator=( SnmpSyntax &in_val)
// otherwise, behave like a long int
SnmpInt32::operator long()
-{
- return (long) smival.value.sNumber;
+{
+ return (long) smival.value.sNumber;
}
// clone - create a new instance of this Value
SnmpSyntax* SnmpInt32::clone() const
-{
- return ( SnmpSyntax *) new SnmpInt32(*this);
+{
+ return ( SnmpSyntax *) new SnmpInt32(*this);
}
// ASCII format return
char *SnmpInt32::to_string()
-{
+{
sprintf(output_buffer, "%d", (int) (long) this->smival.value.sNumber);
return output_buffer;
}
-
diff --git a/ASNMP/asnmp/octet.cpp b/ASNMP/asnmp/octet.cpp
index b08bf5482f1..2a422a5fe88 100644
--- a/ASNMP/asnmp/octet.cpp
+++ b/ASNMP/asnmp/octet.cpp
@@ -6,15 +6,15 @@
// asnmp
//
// = FILENAME
-// octet.cpp
+// octet.cpp
//
// = DESCRIPTION
-// Implements the SMI Octet datatype (RFC 1155)
+// Implements the SMI Octet datatype (RFC 1155)
// This class is fully contained and does not rely on or any other
-// SNMP libraries. Ported to ACE by Michael MacFaden mrm@cisco.com
+// SNMP libraries. Ported to ACE by Michael MacFaden mrm@cisco.com
//
// = AUTHOR
-// Peter E Mellquist
+// Peter E Mellquist
//
// ============================================================================
/*===================================================================
@@ -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 "ace/OS.h"
@@ -40,8 +40,8 @@ ACE_RCSID(asnmp, octet, "$Id$")
//============[ syntax type ]=========================================
SmiUINT32 OctetStr::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
+{
+ return sNMP_SYNTAX_OCTETS;
}
inline
@@ -52,18 +52,18 @@ void init_octet_smi(SmiVALUE& smi)
smi.value.string.len = 0;
}
-inline
+inline
void reset_octet_smi(SmiVALUE& smi)
{
delete [] smi.value.string.ptr;
- smi.value.string.ptr = NULL;
+ smi.value.string.ptr = 0;
smi.value.string.len = 0;
}
-inline
+inline
int copy_octet_smi(SmiVALUE& smi, int size, const char *src, int& valid_flag)
{
- valid_flag = FALSE;
+ valid_flag = 0;
if (smi.value.string.ptr)
delete [] smi.value.string.ptr;
@@ -71,20 +71,20 @@ int copy_octet_smi(SmiVALUE& smi, int size, const char *src, int& valid_flag)
ACE_NEW_RETURN(smi.value.string.ptr, SmiBYTE[size], 1);
ACE_OS::memcpy( smi.value.string.ptr, src, size);
smi.value.string.len = size;
- valid_flag = TRUE;
+ valid_flag = 1;
return 0;
}
//============[ default constructor ]=========================
OctetStr::OctetStr( const char * string, long size):
- output_buffer(NULL), validity(FALSE)
+ output_buffer(0), validity(0)
{
size_t z;
init_octet_smi(smival);
// check for null string
- if ( !string)
+ if ( !string)
return;
if (size == -1) // calc if no length given - assume c style string
@@ -100,13 +100,13 @@ void OctetStr::set_data( const SmiBYTE* string, long size)
{
size_t z;
- // invalid args, set octetStr to not valid
+ // invalid args, set octetStr to not valid
if ( !string || !size) {
- validity = FALSE;
+ validity = 0;
return;
}
- // assume non-zero terminated string
+ // assume non-zero terminated string
if (size == -1) // calc if no length given - assume c style string
size = z = ACE_OS::strlen( (char *)string);
@@ -121,8 +121,8 @@ void OctetStr::set_data( const SmiBYTE* string, long size)
}
//============[ constructor using another octet object ]==============
-OctetStr::OctetStr ( const OctetStr &octet):
- output_buffer(NULL), validity(TRUE)
+OctetStr::OctetStr ( const OctetStr &octet):
+ output_buffer(0), validity(1)
{
init_octet_smi(smival);
// check for zero len case
@@ -131,13 +131,13 @@ OctetStr::OctetStr ( const OctetStr &octet):
}
// must be a valid object
- if ( octet.validity == FALSE) {
- validity = FALSE;
+ if ( octet.validity == 0) {
+ validity = 0;
return;
}
// get the mem needed
- copy_octet_smi(smival, octet.smival.value.string.len,
+ copy_octet_smi(smival, octet.smival.value.string.len,
(const char *)octet.smival.value.string.ptr, validity);
}
@@ -159,10 +159,10 @@ OctetStr& OctetStr::operator=( const char *string)
if ( smival.value.string.ptr ) {
reset_octet_smi(smival);
}
-
+
// if empty then we are done
if (!string || !(nz = ACE_OS::strlen( string))) {
- validity = TRUE;
+ validity = 1;
return *this;
}
@@ -189,41 +189,41 @@ OctetStr& OctetStr::operator=( const OctetStr &octet)
}
if (!octet.smival.value.string.len) {
- validity = TRUE;
+ validity = 1;
return *this;
}
// get some memory
- copy_octet_smi(smival, octet.smival.value.string.len,
+ copy_octet_smi(smival, octet.smival.value.string.len,
(const char*) octet.smival.value.string.ptr, validity);
- return *this; // return self reference
+ return *this; // return self reference
}
//==============[ equivlence operator overloaded ]====================
int operator==( const OctetStr &lhs, const OctetStr &rhs)
{
- if( lhs.left_comparison( rhs.smival.value.string.len, rhs)==0)
- return TRUE;
- else
- return FALSE;
+ if( lhs.left_comparison( rhs.smival.value.string.len, rhs)==0)
+ return 1;
+ else
+ return 0;
}
//==============[ not equivlence operator overloaded ]================
int operator!=( const OctetStr &lhs, const OctetStr &rhs)
{
- if( lhs.left_comparison( rhs.smival.value.string.len, rhs)!=0)
- return TRUE;
- else
- return FALSE;
+ if( lhs.left_comparison( rhs.smival.value.string.len, rhs)!=0)
+ return 1;
+ else
+ return 0;
}
//==============[ less than < overloaded ]============================
int operator<( const OctetStr &lhs, const OctetStr &rhs)
{
- if( lhs.left_comparison( rhs.smival.value.string.len, rhs)<0)
- return TRUE;
- else
- return FALSE;
+ if( lhs.left_comparison( rhs.smival.value.string.len, rhs)<0)
+ return 1;
+ else
+ return 0;
}
//==============[ less than <= overloaded ]===========================
@@ -231,18 +231,18 @@ int operator<=( const OctetStr &lhs, const OctetStr &rhs)
{
if(( lhs.left_comparison( rhs.smival.value.string.len, rhs)<0) ||
( lhs.left_comparison( rhs.smival.value.string.len, rhs)==0))
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//===============[ greater than > overloaded ]========================
int operator>( const OctetStr &lhs, const OctetStr &rhs)
{
- if( lhs.left_comparison( rhs.smival.value.string.len, rhs)>0)
- return TRUE;
- else
- return FALSE;
+ if( lhs.left_comparison( rhs.smival.value.string.len, rhs)>0)
+ return 1;
+ else
+ return 0;
}
//===============[ greater than >= overloaded ]=======================
@@ -250,39 +250,39 @@ int operator>=( const OctetStr &lhs, const OctetStr &rhs)
{
if(( lhs.left_comparison( rhs.smival.value.string.len, rhs)>0) ||
( lhs.left_comparison( rhs.smival.value.string.len, rhs)==0))
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//===============[ equivlence operator overloaded ]===================
int operator==( const OctetStr &lhs,const char *rhs)
{
OctetStr to( rhs);
- if( lhs.left_comparison( to.smival.value.string.len,to)==0)
- return TRUE;
- else
- return FALSE;
+ if( lhs.left_comparison( to.smival.value.string.len,to)==0)
+ return 1;
+ else
+ return 0;
}
//===============[ not equivlence operator overloaded ]===============
int operator!=( const OctetStr &lhs,const char *rhs)
{
OctetStr to( rhs);
- if ( lhs.left_comparison( to.smival.value.string.len,to)!=0)
- return TRUE;
- else
- return FALSE;
+ if ( lhs.left_comparison( to.smival.value.string.len,to)!=0)
+ return 1;
+ else
+ return 0;
}
//===============[ less than < operator overloaded ]==================
int operator<( const OctetStr &lhs,const char *rhs)
{
OctetStr to( rhs);
- if ( lhs.left_comparison( to.smival.value.string.len,to)<0)
- return TRUE;
- else
- return FALSE;
+ if ( lhs.left_comparison( to.smival.value.string.len,to)<0)
+ return 1;
+ else
+ return 0;
}
//===============[ less than <= operator overloaded ]=================
@@ -291,19 +291,19 @@ int operator<=( const OctetStr &lhs,char *rhs)
OctetStr to( rhs);
if (( lhs.left_comparison( to.smival.value.string.len,to)<0) ||
( lhs.left_comparison( to.smival.value.string.len,to)==0))
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//===============[ greater than > operator overloaded ]===============
int operator>( const OctetStr &lhs,const char *rhs)
{
OctetStr to( rhs);
- if ( lhs.left_comparison( to.smival.value.string.len,to)>0)
- return TRUE;
- else
- return FALSE;
+ if ( lhs.left_comparison( to.smival.value.string.len,to)>0)
+ return 1;
+ else
+ return 0;
}
//===============[ greater than >= operator overloaded ]==============
@@ -312,29 +312,29 @@ int operator>=( const OctetStr &lhs,const char *rhs)
OctetStr to( rhs);
if (( lhs.left_comparison( to.smival.value.string.len,to)>0) ||
( lhs.left_comparison( to.smival.value.string.len,to)==0))
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
//===============[ append operator, appends a string ]================
OctetStr& OctetStr::operator+=( const char *a)
{
- SmiBYTE *tmp; // temp pointer
+ SmiBYTE *tmp; // temp pointer
size_t slen,nlen;
// get len of string
- if ( !a || ((slen = ACE_OS::strlen( a)) == 0))
+ if ( !a || ((slen = ACE_OS::strlen( a)) == 0))
return *this;
// total len of octet
nlen = slen + (size_t) smival.value.string.len;
ACE_NEW_RETURN(tmp, SmiBYTE [ nlen], *this);
- ACE_OS::memcpy ( tmp, smival.value.string.ptr,
+ ACE_OS::memcpy ( tmp, smival.value.string.ptr,
(size_t) smival.value.string.len);
ACE_OS::memcpy( tmp + smival.value.string.len, a, (size_t) slen);
// delete the original
- if ( smival.value.string.ptr )
+ if ( smival.value.string.ptr )
reset_octet_smi(smival);
smival.value.string.ptr = tmp;
smival.value.string.len = nlen;
@@ -344,10 +344,10 @@ OctetStr& OctetStr::operator+=( const char *a)
//================[ append one OctetStr to another ]==================
OctetStr& OctetStr::operator+=( const OctetStr& octetstr)
{
- SmiBYTE *tmp; // temp pointer
+ SmiBYTE *tmp; // temp pointer
size_t slen,nlen;
- if (!octetstr.validity ||
+ if (!octetstr.validity ||
!(slen = (size_t)octetstr.length()))
return *this;
@@ -355,9 +355,9 @@ OctetStr& OctetStr::operator+=( const OctetStr& octetstr)
nlen = slen + (size_t) smival.value.string.len;
// get mem needed
ACE_NEW_RETURN(tmp, SmiBYTE[ nlen], *this);
- ACE_OS::memcpy ( tmp, smival.value.string.ptr,
+ ACE_OS::memcpy ( tmp, smival.value.string.ptr,
(size_t) smival.value.string.len);
- ACE_OS::memcpy( tmp + smival.value.string.len, octetstr.data(),
+ ACE_OS::memcpy( tmp + smival.value.string.len, octetstr.data(),
(size_t) slen);
if ( smival.value.string.ptr )
reset_octet_smi(smival);
@@ -373,13 +373,13 @@ OctetStr& OctetStr::operator+=( const char c)
// get the memory needed plus one extra byte
ACE_NEW_RETURN(tmp, SmiBYTE[ smival.value.string.len + 1], *this);
ACE_OS::memcpy ( tmp, smival.value.string.ptr,
- (size_t) smival.value.string.len); // len of original
- tmp[ smival.value.string.len ] = c; // assign in byte
- if ( smival.value.string.ptr ) // delete the original
+ (size_t) smival.value.string.len); // len of original
+ tmp[ smival.value.string.len ] = c; // assign in byte
+ if ( smival.value.string.ptr ) // delete the original
reset_octet_smi(smival);
- smival.value.string.ptr = tmp; // point to one
- smival.value.string.len++; // up the len
+ smival.value.string.ptr = tmp; // point to one
+ smival.value.string.len++; // up the len
return *this;
}
@@ -387,55 +387,55 @@ OctetStr& OctetStr::operator+=( const char c)
//================[ compare n elements of an Octet ]==================
int OctetStr::left_comparison( const long n, const OctetStr &o) const
{
- long z, w;
+ long z, w;
// both are empty, they are equal
if (( smival.value.string.len == 0) &&
- ( o.smival.value.string.len == 0))
- return 0; // equal
-
+ ( o.smival.value.string.len == 0))
+ return 0; // equal
+
// self is empty and param has something
if (( smival.value.string.len == 0) &&
- ( o.smival.value.string.len >0) &&
- (n>0))
- return -1;
+ ( o.smival.value.string.len >0) &&
+ (n>0))
+ return -1;
// self has something and param has nothing
if (( smival.value.string.len > 0) &&
- ( o.smival.value.string.len ==0) &&
- (n>0))
- return 1;
+ ( o.smival.value.string.len ==0) &&
+ (n>0))
+ return 1;
// special case
if (( smival.value.string.len == 0) &&
- ( o.smival.value.string.len > 0) &&
- ( n == 0))
- return 0;
-
+ ( o.smival.value.string.len > 0) &&
+ ( n == 0))
+ return 0;
+
// pick the Min of n, this and the param len
// this is the maximum # to iterate a search
w = smival.value.string.len < o.smival.value.string.len
- ? smival.value.string.len : o.smival.value.string.len;
+ ? smival.value.string.len : o.smival.value.string.len;
if (n<w) w=n;
z = 0;
while( z < w) {
- if ( smival.value.string.ptr[z] < o.smival.value.string.ptr[z])
- return -1; // less than
+ if ( smival.value.string.ptr[z] < o.smival.value.string.ptr[z])
+ return -1; // less than
if ( smival.value.string.ptr[z] > o.smival.value.string.ptr[z])
- return 1; // greater than
+ return 1; // greater than
z++;
}
if (( z == 0) &&
- ( smival.value.string.len == 0) &&
- ( o.smival.value.string.len > 0))
- return -1;
+ ( smival.value.string.len == 0) &&
+ ( o.smival.value.string.len > 0))
+ return -1;
if (( z == 0) &&
- ( o.smival.value.string.len == 0) &&
- ( smival.value.string.len > 0))
- return 1;
+ ( o.smival.value.string.len == 0) &&
+ ( smival.value.string.len > 0))
+ return 1;
return 0;
}
@@ -448,7 +448,7 @@ size_t OctetStr::length() const
//================[ operator[]: access as if array ]==================
SmiBYTE& OctetStr::operator[]( int position)
-{
+{
return smival.value.string.ptr[position];
}
@@ -465,9 +465,9 @@ int OctetStr::valid() const
}
//================[ clone() ]=========================================
-SnmpSyntax * OctetStr::clone() const
-{
- OctetStr *tmp = new OctetStr(*this);
+SnmpSyntax * OctetStr::clone() const
+{
+ OctetStr *tmp = new OctetStr(*this);
return ( SnmpSyntax *) tmp;
}
@@ -475,18 +475,18 @@ SnmpSyntax * OctetStr::clone() const
char * OctetStr::to_string()
{
for ( unsigned long i=0; i < smival.value.string.len; i++) {
- if (( smival.value.string.ptr[i] != '\r')&&
- ( smival.value.string.ptr[i] != '\n')&&
- (isprint((int) (smival.value.string.ptr[i]))==0))
+ if (( smival.value.string.ptr[i] != '\r')&&
+ ( smival.value.string.ptr[i] != '\n')&&
+ (isprint((int) (smival.value.string.ptr[i]))==0))
return(to_string_hex());
}
- if ( output_buffer != NULL)
- delete [] output_buffer;
+ if ( output_buffer != 0)
+ delete [] output_buffer;
ACE_NEW_RETURN(output_buffer, char[smival.value.string.len + 1], "");
if (smival.value.string.len)
- ACE_OS::memcpy(output_buffer, smival.value.string.ptr,
+ ACE_OS::memcpy(output_buffer, smival.value.string.ptr,
(int) smival.value.string.len);
output_buffer[smival.value.string.len] = '\0';
return output_buffer;
@@ -501,7 +501,7 @@ SnmpSyntax& OctetStr::operator=( SnmpSyntax &val)
return *this;
// blow away the old value
- validity=FALSE;
+ validity=0;
if (smival.value.string.ptr) {
reset_octet_smi(smival);
}
@@ -510,9 +510,9 @@ SnmpSyntax& OctetStr::operator=( SnmpSyntax &val)
switch (val.get_syntax()) {
case sNMP_SYNTAX_OCTETS:
case sNMP_SYNTAX_IPADDR:
- set_data( ((OctetStr &)val).smival.value.string.ptr,
- ((OctetStr &)val).smival.value.string.len);
- break;
+ set_data( ((OctetStr &)val).smival.value.string.ptr,
+ ((OctetStr &)val).smival.value.string.len);
+ break;
}
}
return *this;
@@ -522,28 +522,28 @@ SnmpSyntax& OctetStr::operator=( SnmpSyntax &val)
char *OctetStr::to_string_hex()
{
int cnt;
- char char_buf[80]; // holds ASCII representation of data
- char *buf_ptr; // pointer into ASCII listing
- char *line_ptr; // pointer into Hex listing
+ char char_buf[80]; // holds ASCII representation of data
+ char *buf_ptr; // pointer into ASCII listing
+ char *line_ptr; // pointer into Hex listing
int storageNeeded; // how much space do we need ?
int local_len = (int) smival.value.string.len;
SmiBYTE *bytes = smival.value.string.ptr;
-
+
storageNeeded = (int) ((smival.value.string.len/16)+1) * 72 + 1;
- if ( output_buffer != NULL)
- delete [] output_buffer;
+ if ( output_buffer != 0)
+ delete [] output_buffer;
ACE_NEW_RETURN(output_buffer, char[storageNeeded], "");
-
+
line_ptr = output_buffer;
/*----------------------------------------*/
/* processing loop for entire data buffer */
/*----------------------------------------*/
while (local_len > 0) {
- cnt = 16; /* print 16 bytes per line */
+ cnt = 16; /* print 16 bytes per line */
buf_ptr = char_buf;
sprintf(line_ptr, " ");
line_ptr += 2; /* indent */
@@ -556,9 +556,9 @@ char *OctetStr::to_string_hex()
line_ptr +=3; /* the display of a byte always 3 chars long */
if (isprint(*bytes))
- sprintf(buf_ptr, "%c", *bytes);
+ sprintf(buf_ptr, "%c", *bytes);
else
- sprintf(buf_ptr, ".");
+ sprintf(buf_ptr, ".");
bytes++;
buf_ptr++;
}
@@ -566,7 +566,7 @@ char *OctetStr::to_string_hex()
/*----------------------------------------------------------*/
/* this is to make sure that the ASCII displays line up for */
- /* incomplete lines of hex */
+ /* incomplete lines of hex */
/*----------------------------------------------------------*/
while (cnt-- > 0) {
sprintf(line_ptr," ");
diff --git a/ASNMP/asnmp/oid.cpp b/ASNMP/asnmp/oid.cpp
index b1b47ef3e70..d0bbcd3c4aa 100644
--- a/ASNMP/asnmp/oid.cpp
+++ b/ASNMP/asnmp/oid.cpp
@@ -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.
=====================================================================*/
//---------[ external C libaries used ]--------------------------------
@@ -40,14 +40,14 @@
ACE_RCSID(asnmp, oid, "$Id$")
enum Defs {SNMPBUFFSIZE=300,
- SNMPCHARSIZE=15}; // max oid value (4294967295UL)
+ SNMPCHARSIZE=15}; // max oid value (4294967295UL)
#define NO_MEM_STR "ERROR: Oid::to_string: memory allocation failure"
//=============[Oid::get_syntax(void)]====================================
SmiUINT32 Oid::get_syntax()
-{
- return sNMP_SYNTAX_OID;
+{
+ return sNMP_SYNTAX_OID;
}
@@ -55,7 +55,7 @@ SmiUINT32 Oid::get_syntax()
// constructor using a dotted string
//
// do a string to oid using the string passed in
-Oid::Oid( const char * dotted_oid_string, size_t size)
+Oid::Oid( const char * dotted_oid_string, size_t size)
{
// can't init enum SmiValue so just memset it clean
set_null();
@@ -73,11 +73,11 @@ Oid::Oid( const char * dotted_oid_string, size_t size)
char *ptr = (char *)dotted_oid_string;;
if (size < z) {
- // create new buffer if needed
+ // create new buffer if needed
ACE_NEW(ptr, char [size]);
// sz should be in StrToOid?
- ACE_OS::memcpy( (void *)ptr, dotted_oid_string, size);
+ ACE_OS::memcpy( (void *)ptr, dotted_oid_string, size);
}
size_t byte_counter;
@@ -95,15 +95,15 @@ Oid::Oid( const char * dotted_oid_string, size_t size)
Oid::Oid ( const Oid &oid)
{
set_null();
-
+
// allocate some memory for the oid
// in this case the size to allocate is the same
// size as the source oid
if (oid.smival.value.oid.len) {
ACE_NEW(smival.value.oid.ptr, SmiUINT32[ oid.smival.value.oid.len]);
size_t byte_counter;
- OidCopy( (SmiLPOID) &(oid.smival.value.oid),(SmiLPOID)
- &smival.value.oid, byte_counter);
+ OidCopy( (SmiLPOID) &(oid.smival.value.oid),(SmiLPOID)
+ &smival.value.oid, byte_counter);
}
}
@@ -118,7 +118,7 @@ Oid::Oid(const unsigned long *raw_oid, size_t oid_len)
smival.syntax = sNMP_SYNTAX_OID;
set_invalid();
-
+
if (raw_oid && oid_len > 0) {
ACE_NEW(smival.value.oid.ptr, SmiUINT32[ oid_len]);
smival.value.oid.len = oid_len;
@@ -179,20 +179,20 @@ Oid& Oid::operator=( const Oid &oid)
set_invalid();
// check for zero len on source
- if ( oid.smival.value.oid.len == 0)
+ if ( oid.smival.value.oid.len == 0)
return *this;
- init_value((const SmiLPOID) &(oid.smival.value.oid),
+ init_value((const SmiLPOID) &(oid.smival.value.oid),
oid.smival.value.oid.len);
return *this;
}
-// assign this object the oid, set to invalid if copy fails
-void Oid::init_value(const SmiLPOID srcOid, size_t len)
+// assign this object the oid, set to invalid if copy fails
+void Oid::init_value(const SmiLPOID srcOid, size_t len)
{
// allocate some memory for the oid
ACE_NEW(smival.value.oid.ptr, SmiUINT32[ len]);
- size_t byte_counter;
+ size_t byte_counter;
OidCopy( srcOid, (SmiLPOID) &smival.value.oid, byte_counter);
}
@@ -203,8 +203,8 @@ void Oid::init_value(const unsigned long *raw_oid, size_t oid_len)
ACE_NEW(smival.value.oid.ptr, SmiUINT32[ oid_len]);
ACE_OS::memcpy((SmiLPBYTE) smival.value.oid.ptr,
- (SmiLPBYTE) raw_oid,
- (size_t) (oid_len * sizeof(SmiUINT32)));
+ (SmiLPBYTE) raw_oid,
+ (size_t) (oid_len * sizeof(SmiUINT32)));
smival.value.oid.len = oid_len;
}
@@ -229,14 +229,14 @@ Oid& Oid::operator+=( const char *a)
size_t sz = ACE_OS::strlen(a);
if (valid()) {
- n = (smival.value.oid.len *SNMPCHARSIZE) + smival.value.oid.len + 1 + sz;
+ n = (smival.value.oid.len *SNMPCHARSIZE) + smival.value.oid.len + 1 + sz;
char *ptr;
ACE_NEW_RETURN(ptr, char[ n], *this);
size_t byte_counter;
if (OidToStr(&smival.value.oid, n,ptr, byte_counter) > 0) {
- delete [] ptr;
- set_invalid();
- return *this;
+ delete [] ptr;
+ set_invalid();
+ return *this;
}
if (ACE_OS::strlen(ptr))
@@ -259,83 +259,83 @@ Oid& Oid::operator+=( const char *a)
set_invalid();
}
}
-
+
return *this;
}
//=============[ int operator == oid,oid ]=================================
// equivlence operator overloaded
int operator==( const Oid &lhs, const Oid &rhs)
-{
+{
// ensure same len, then use left_comparison
- if (rhs.length() != lhs.length())
+ if (rhs.length() != lhs.length())
return 0;
- if( lhs.left_comparison( rhs.length(), rhs) == 0)
- return 1;
- else
+ if( lhs.left_comparison( rhs.length(), rhs) == 0)
+ return 1;
+ else
return 0;
-}
+}
-//==============[ operator!=( Oid &x,Oid &y) ]=============================
+//==============[ operator!=( Oid &x,Oid &y) ]=============================
//not equivlence operator overloaded
int operator!=( const Oid &lhs,const Oid &rhs)
-{
+{
return (!(lhs == rhs));
-}
+}
-//==============[ operator<( Oid &x,Oid &y) ]=============================
+//==============[ operator<( Oid &x,Oid &y) ]=============================
// less than < overloaded
int operator<( const Oid &lhs,const Oid &rhs)
-{
+{
int result;
// call left_comparison with the current
// Oidx, Oidy and len of Oidx
- if ((result = lhs.left_comparison( rhs.length(), rhs)) < 0)
- return 1;
- else if (result > 0)
+ if ((result = lhs.left_comparison( rhs.length(), rhs)) < 0)
+ return 1;
+ else if (result > 0)
return 0;
else{
// if here, equivalent substrings, call the shorter one <
- if (lhs.length() < rhs.length())
+ if (lhs.length() < rhs.length())
return 1;
- else
+ else
return 0;
}
-}
+}
-//==============[ operator<=( Oid &x,Oid &y) ]=============================
+//==============[ operator<=( Oid &x,Oid &y) ]=============================
// less than <= overloaded
int operator<=( const Oid &x,const Oid &y)
-{
- if ( (x < y) || (x == y) )
+{
+ if ( (x < y) || (x == y) )
return 1;
- else
+ else
return 0;
-}
+}
-//==============[ operator>( Oid &x,Oid &y) ]=============================
+//==============[ operator>( Oid &x,Oid &y) ]=============================
// greater than > overloaded
int operator>( const Oid &x,const Oid &y)
-{
+{
// just invert existing <=
- if (!(x<=y))
+ if (!(x<=y))
return 1;
- else
+ else
return 0;
-}
+}
-//==============[ operator>=( Oid &x,Oid &y) ]=============================
+//==============[ operator>=( Oid &x,Oid &y) ]=============================
// greater than >= overloaded
int operator>=( const Oid &x,const Oid &y)
-{
+{
// just invert existing <
- if (!(x<y))
+ if (!(x<y))
return 1;
- else
+ else
return 0;
-}
+}
//===============[Oid::oidval ]=============================================
// return the WinSnmp oid part
@@ -384,16 +384,16 @@ void Oid::trim( const size_t n)
// make this object invalid by resetting all values
void Oid::set_invalid() {
delete [] smival.value.oid.ptr;
- smival.value.oid.ptr = NULL;
+ smival.value.oid.ptr = 0;
smival.value.oid.len = 0;
- delete [] iv_str;
+ delete [] iv_str;
iv_str = 0;
}
//===============[Oid::set_null() ]====================
void Oid::set_null() {
smival.syntax = sNMP_SYNTAX_OID;
- smival.value.oid.ptr = NULL;
+ smival.value.oid.ptr = 0;
smival.value.oid.len = 0;
iv_str = 0;
}
@@ -409,8 +409,8 @@ void Oid::set_null() {
// delete allocated space
Oid& Oid::operator+=( const unsigned long i)
{
- unsigned long n = (smival.value.oid.len * SNMPCHARSIZE)
- + ( smival.value.oid.len -1) + 1 + 4;
+ unsigned long n = (smival.value.oid.len * SNMPCHARSIZE)
+ + ( smival.value.oid.len -1) + 1 + 4;
char buffer[SNMPBUFFSIZE];
// two cases: null oid, existing oid
@@ -422,9 +422,9 @@ Oid& Oid::operator+=( const unsigned long i)
if (OidToStr(&smival.value.oid, n, ptr, byte_counter) < 0) {
set_invalid();
delete [] ptr;
- return *this;
+ return *this;
}
-
+
if (ACE_OS::strlen(ptr))
ACE_OS::strcat(ptr,".");
@@ -440,9 +440,9 @@ Oid& Oid::operator+=( const unsigned long i)
}
}
else {
- init_value((const unsigned long *)&i, (size_t)1);
+ init_value((const unsigned long *)&i, (size_t)1);
}
-
+
return *this;
}
@@ -462,12 +462,12 @@ Oid& Oid::operator+=( const Oid &o)
if (o.smival.value.oid.len == 0)
return *this;
- ACE_NEW_RETURN(new_oid,
+ ACE_NEW_RETURN(new_oid,
SmiUINT32[ smival.value.oid.len + o.smival.value.oid.len], *this);
if (smival.value.oid.ptr) {
ACE_OS::memcpy((SmiLPBYTE) new_oid,
- (SmiLPBYTE) smival.value.oid.ptr,
- (size_t) (smival.value.oid.len*sizeof(SmiUINT32)));
+ (SmiLPBYTE) smival.value.oid.ptr,
+ (size_t) (smival.value.oid.len*sizeof(SmiUINT32)));
delete [] smival.value.oid.ptr;
}
@@ -476,8 +476,8 @@ Oid& Oid::operator+=( const Oid &o)
smival.value.oid.ptr = new_oid;
ACE_OS::memcpy((SmiLPBYTE) &new_oid[smival.value.oid.len],
- (SmiLPBYTE) o.smival.value.oid.ptr,
- (size_t) (o.smival.value.oid.len*sizeof(SmiUINT32)));
+ (SmiLPBYTE) o.smival.value.oid.ptr,
+ (size_t) (o.smival.value.oid.len*sizeof(SmiUINT32)));
smival.value.oid.len += o.smival.value.oid.len;
return *this;
@@ -494,11 +494,11 @@ char * Oid::to_string()
// the worst case char len of an oid can be..
// oid.len*3 + dots in between if each oid is XXXX
// so.. size = (len*4) + (len-1) + 1 , extra for a null
-
+
n = (smival.value.oid.len *SNMPCHARSIZE) + ( smival.value.oid.len -1) + 1 ;
- if (n == 0)
+ if (n == 0)
n = 1; // need at least 1 byte for a null string
-
+
// adjust the len of output array in case size was adjusted
if ( iv_str != 0)
delete [] iv_str;
@@ -509,7 +509,7 @@ char * Oid::to_string()
size_t how_many;
if ( valid() && iv_str != 0)
if (OidToStr(&smival.value.oid,n,iv_str, how_many) < 0)
- return "ERROR: Oid::OidToStr failed";
+ return "ERROR: Oid::OidToStr failed";
return iv_str;
}
@@ -529,16 +529,16 @@ int Oid::suboid(Oid& new_oid, size_t start, size_t how_many)
new_oid.set_invalid();
size_t new_size = how_many - start;
- if (new_size == 0)
+ if (new_size == 0)
new_size++;
- new_oid.smival.value.oid.len = new_size;
+ new_oid.smival.value.oid.len = new_size;
ACE_NEW_RETURN(new_oid.smival.value.oid.ptr,
SmiUINT32 [ new_oid.smival.value.oid.len], -1);
// copy source to destination
ACE_OS::memcpy( (SmiLPBYTE) new_oid.smival.value.oid.ptr,
(SmiLPBYTE) (smival.value.oid.ptr + start),
- new_size * sizeof(SmiLPBYTE));
- return 0;
+ new_size * sizeof(SmiLPBYTE));
+ return 0;
}
@@ -558,7 +558,7 @@ int Oid::StrToOid( const char *string, SmiLPOID dstOid, size_t& how_many)
}
else {
dstOid->len = 0;
- dstOid->ptr = NULL;
+ dstOid->ptr = 0;
return -1;
}
@@ -567,7 +567,7 @@ int Oid::StrToOid( const char *string, SmiLPOID dstOid, size_t& how_many)
// init the number for each token
number = 0;
// skip over the dot
- if (*string=='.')
+ if (*string=='.')
string++;
// grab a digit token and convert it to a long int
@@ -616,8 +616,8 @@ int Oid::OidCopy( SmiLPOID srcOid, SmiLPOID dstOid, size_t& how_many_bytes)
// copy source to destination
ACE_OS::memcpy((SmiLPBYTE) dstOid->ptr,
- (SmiLPBYTE) srcOid->ptr,
- (size_t) (srcOid->len * sizeof(SmiUINT32)));
+ (SmiLPBYTE) srcOid->ptr,
+ (size_t) (srcOid->len * sizeof(SmiUINT32)));
//set the new len
dstOid->len = srcOid->len;
@@ -629,22 +629,22 @@ int Oid::OidCopy( SmiLPOID srcOid, SmiLPOID dstOid, size_t& how_many_bytes)
//===============[Oid::left_comparison( n, Oid) ]=================================
// compare the n leftmost values of two oids ( left-to_right )
-//
+//
// self == Oid then return 0, they are equal
// self < Oid then return -1, <
// self > Oid then return 1, >
int Oid::left_comparison( const unsigned long n, const Oid &o) const
-{
+{
unsigned long z;
unsigned long len = n;
int reduced_len = 0;
-
+
// 1st case they both are null
- if (( len==0)&&( this->smival.value.oid.len==0))
+ if (( len==0)&&( this->smival.value.oid.len==0))
return 0; // equal
-
+
// verify that n is valid, must be >= 0
- if ( len <=0)
+ if ( len <=0)
return 1; // ! equal
// only compare for the minimal length
@@ -656,16 +656,16 @@ int Oid::left_comparison( const unsigned long n, const Oid &o) const
len = o.smival.value.oid.len;
reduced_len = 1;
}
-
+
z = 0;
while(z < len) {
if ( this->smival.value.oid.ptr[z] < o.smival.value.oid.ptr[z])
return -1; // less than
if ( this->smival.value.oid.ptr[z] > o.smival.value.oid.ptr[z])
return 1; // greater than
- z++;
- }
-
+ z++;
+ }
+
// if we truncated the len then these may not be equal
if (reduced_len) {
if (this->smival.value.oid.len < o.smival.value.oid.len)
@@ -674,7 +674,7 @@ int Oid::left_comparison( const unsigned long n, const Oid &o) const
return 1;
}
return 0; // equal
-
+
}
@@ -686,7 +686,7 @@ int Oid::left_comparison( const unsigned long n, const Oid &o) const
int Oid::right_comparison( const unsigned long n, const Oid &o) const
{
// oid to compare must have at least the same number
- // of sub-ids to comparison else the argument Oid is
+ // of sub-ids to comparison else the argument Oid is
// less than THIS
if ( o.length() < n)
return -1;
@@ -708,7 +708,7 @@ int Oid::right_comparison( const unsigned long n, const Oid &o) const
return 0; // they are equal
-}
+}
//================[ Oid::valid() ]========================================
@@ -716,13 +716,13 @@ int Oid::right_comparison( const unsigned long n, const Oid &o) const
// returns validity
int Oid::valid() const
{
- return ( smival.value.oid.ptr ? TRUE : FALSE );
+ return ( smival.value.oid.ptr ? 1 : 0 );
}
//================[Oid::OidToStr ]=========================================
// convert an oid to a string
int Oid::OidToStr( SmiLPOID srcOid, unsigned long size,
- char *string, size_t& how_many_bytes)
+ char *string, size_t& how_many_bytes)
{
unsigned long index = 0;
unsigned totLen = 0;
@@ -739,7 +739,7 @@ int Oid::OidToStr( SmiLPOID srcOid, unsigned long size,
for (index=0; index < srcOid->len; index++) {
// convert data element to a string
- if (ACE_OS::sprintf( szNumber,"%u", srcOid->ptr[index]) == -1)
+ if (ACE_OS::sprintf( szNumber,"%u", srcOid->ptr[index]) == -1)
return -1;
// verify len is not over
@@ -758,7 +758,7 @@ int Oid::OidToStr( SmiLPOID srcOid, unsigned long size,
}
how_many_bytes = totLen + 1;
- return 0;
+ return 0;
}
@@ -779,8 +779,8 @@ SnmpSyntax& Oid::operator=( SnmpSyntax &val)
if (val.valid()) {
switch (val.get_syntax()) {
case sNMP_SYNTAX_OID:
- set_data( ((Oid &)val).smival.value.oid.ptr,
- (unsigned int)((Oid &)val).smival.value.oid.len);
+ set_data( ((Oid &)val).smival.value.oid.ptr,
+ (unsigned int)((Oid &)val).smival.value.oid.len);
break;
}
}
@@ -795,7 +795,6 @@ unsigned long& Oid::operator[](size_t position)
//================[ clone ]===========================================
SnmpSyntax *Oid::clone() const
-{
- return (SnmpSyntax *) new Oid(*this);
+{
+ return (SnmpSyntax *) new Oid(*this);
}
-
diff --git a/ASNMP/asnmp/pdu.cpp b/ASNMP/asnmp/pdu.cpp
index a15ede7886e..6ac3acc04d5 100644
--- a/ASNMP/asnmp/pdu.cpp
+++ b/ASNMP/asnmp/pdu.cpp
@@ -21,15 +21,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/snmp.h"
@@ -38,47 +38,47 @@
ACE_RCSID(asnmp, pdu, "$Id$")
//=====================[ constructor no args ]=========================
-Pdu::Pdu( void): vb_count_(0), error_status_(0), error_index_(0),
-validity_(FALSE), request_id_(0), pdu_type_(0), notify_timestamp_(0),
+Pdu::Pdu( void): vb_count_(0), error_status_(0), error_index_(0),
+validity_(0), request_id_(0), pdu_type_(0), notify_timestamp_(0),
output_(0)
{
}
//=====================[ constructor with vbs_ and count ]==============
-Pdu::Pdu( Vb* pvbs, const int pvb_count): vb_count_(0), error_index_(0),
-validity_(FALSE), request_id_(0), pdu_type_(0), notify_timestamp_(0),
+Pdu::Pdu( Vb* pvbs, const int pvb_count): vb_count_(0), error_index_(0),
+validity_(0), request_id_(0), pdu_type_(0), notify_timestamp_(0),
output_(0)
{
int z; // looping variable
// zero is ok
if ( pvb_count == 0) {
- validity_ = TRUE;
+ validity_ = 1;
return;
}
// check for over then max
if ( pvb_count > MAX_VBS) {
- validity_ = FALSE;
+ validity_ = 0;
return;
}
// loop through and assign internal vbs_
for (z = 0;z < pvb_count; z++) {
- validity_ = FALSE;
+ validity_ = 0;
ACE_NEW(vbs_[z], Vb( pvbs[z]));
- validity_ = TRUE;
+ validity_ = 1;
}
// assign the vb count
vb_count_ = pvb_count;
- validity_ = TRUE;
+ validity_ = 1;
}
//=====================[ constructor with another Pdu instance ]========
-Pdu::Pdu( const Pdu &pdu): vb_count_(0),
-error_index_(0), validity_(FALSE), request_id_(0), pdu_type_(0),
+Pdu::Pdu( const Pdu &pdu): vb_count_(0),
+error_index_(0), validity_(0), request_id_(0), pdu_type_(0),
notify_timestamp_(0), output_(0)
{
*this = pdu;
@@ -91,7 +91,7 @@ Pdu::~Pdu()
delete_all_vbs();
delete [] output_;
}
-
+
//=====================[ assignment to another Pdu object overloaded ]===
Pdu& Pdu::operator=( const Pdu &pdu)
@@ -106,7 +106,7 @@ Pdu& Pdu::operator=( const Pdu &pdu)
notify_id_ = pdu.notify_id_;
notify_timestamp_ = pdu.notify_timestamp_;
notify_enterprise_ = pdu.notify_enterprise_;
- validity_ = TRUE;
+ validity_ = 1;
// free up old vbs_
for ( z = 0;z < vb_count_; z++)
@@ -120,9 +120,9 @@ Pdu& Pdu::operator=( const Pdu &pdu)
// loop through and fill em up
for (z = 0; z < pdu.vb_count_; z++) {
- validity_ = FALSE;
+ validity_ = 0;
ACE_NEW_RETURN(vbs_[z], Vb ( *(pdu.vbs_[z])), *this);
- validity_ = TRUE;
+ validity_ = 1;
}
vb_count_ = pdu.vb_count_;
@@ -135,13 +135,13 @@ Pdu& Pdu::operator+=( Vb &vb)
// do we have room?
if ( vb_count_ + 1 > MAX_VBS)
- return *this;
+ return *this;
// add the new one
- validity_ = FALSE;
+ validity_ = 0;
ACE_NEW_RETURN(vbs_[vb_count_], Vb (vb), *this);
// set up validity_
- validity_ = TRUE;
+ validity_ = 1;
// up the vb count
vb_count_++;
@@ -159,7 +159,7 @@ char * Pdu::to_string()
unsigned size = HEADER_STR; // header takes up this much room
int z;
- for ( z = 0; z < vb_count_; z++)
+ for ( z = 0; z < vb_count_; z++)
size += ACE_OS::strlen(vbs_[z]->to_string());
ACE_NEW_RETURN(output_, char[size], "");
@@ -177,7 +177,7 @@ char * Pdu::to_string()
return output_;
}
-
+
//=====================[ extract Vbs from Pdu ]==========================
// how do you know that the caler has enough memory???
@@ -186,14 +186,14 @@ char * Pdu::to_string()
int Pdu::get_vblist( Vb* pvbs, const int pvb_count)
{
if ((!pvbs) || ( pvb_count < 0) || ( pvb_count > vb_count_))
- return FALSE;
+ return 0;
// loop through all vbs_ and assign to params
int z;
for (z = 0; z < pvb_count; z++)
pvbs[z] = *vbs_[z];
- return TRUE;
+ return 1;
}
@@ -203,7 +203,7 @@ int Pdu::set_vblist( Vb* pvbs, const int pvb_count)
// if invalid then don't destroy
if ((!pvbs) || ( pvb_count < 0) || ( pvb_count > MAX_VBS))
- return FALSE;
+ return 0;
// free up current vbs_
int z;
@@ -212,31 +212,31 @@ int Pdu::set_vblist( Vb* pvbs, const int pvb_count)
vb_count_ = 0;
// check for zero case
- if ( pvb_count == 0) {
- validity_ = TRUE;
+ if ( pvb_count == 0) {
+ validity_ = 1;
error_status_ = 0;
error_index_ = 0;
request_id_ = 0;
- return FALSE;
+ return 0;
}
-
+
// loop through all vbs_ and reassign them
for ( z = 0; z < pvb_count; z++) {
- validity_ = FALSE;
- ACE_NEW_RETURN(vbs_[z], Vb (pvbs[z]), FALSE);
- validity_ = TRUE;
+ validity_ = 0;
+ ACE_NEW_RETURN(vbs_[z], Vb (pvbs[z]), 0);
+ validity_ = 1;
}
-
+
vb_count_ = pvb_count;
// clear error status and index since no longer valid
// request id may still apply so don't reassign it
error_status_ = 0;
error_index_ = 0;
- validity_ = TRUE;
+ validity_ = 1;
- return TRUE;
+ return 1;
}
//===================[ get a particular vb ]=============================
@@ -245,17 +245,17 @@ int Pdu::set_vblist( Vb* pvbs, const int pvb_count)
int Pdu::get_vb( Vb &vb, const int index) const
{
// can't have an index less than 0
- if ( index < 0)
- return FALSE;
+ if ( index < 0)
+ return 0;
// can't ask for something not there
if ( index > (vb_count_ - 1))
- return FALSE;
+ return 0;
// asssign it
vb = *vbs_[index];
- return TRUE;
+ return 1;
}
//===================[ set a particular vb ]=============================
@@ -263,21 +263,21 @@ int Pdu::set_vb( Vb &vb, const int index)
{
// can't set a vb at index less than 0
if ( index < 0)
- return FALSE;
+ return 0;
// can't ask for something not there
if ( index > (vb_count_ - 1))
- return FALSE;
+ return 0;
// delete what is there
delete vbs_[index];
// assign it
- validity_ = FALSE;
- ACE_NEW_RETURN(vbs_[index], Vb (vb), FALSE);
- validity_ = TRUE;
+ validity_ = 0;
+ ACE_NEW_RETURN(vbs_[index], Vb (vb), 0);
+ validity_ = 1;
- return TRUE;
+ return 1;
}
@@ -298,7 +298,7 @@ char *Pdu::agent_error_reason()
int pdu_err = get_error_status();
if (pdu_err == 0) // any real error?
return "not in error state";
-
+
int n_vbs = get_vb_count();
Vb bad;
get_vb(bad, get_error_index() -1); // not zero based??
@@ -308,15 +308,15 @@ char *Pdu::agent_error_reason()
const int HDR_SZ = 100;
if (!output_) {
- int size = ACE_OS::strlen(pmsg) + ACE_OS::strlen(id) +
+ int size = ACE_OS::strlen(pmsg) + ACE_OS::strlen(id) +
ACE_OS::strlen(val);
ACE_NEW_RETURN(output_, char[size + HDR_SZ], "");
}
- ACE_OS::sprintf(output_,
+ ACE_OS::sprintf(output_,
"FAIL PDU REPORT: pdu id: %d vb cnt: %d vb idx: %d \n\
msg: %s vb oid: %s value: %s",
- get_request_id(), n_vbs, get_error_index(), pmsg, id, val);
+ get_request_id(), n_vbs, get_error_index(), pmsg, id, val);
return output_;
}
@@ -372,7 +372,7 @@ void set_request_id( Pdu *pdu, const unsigned long rid)
}
//=====================[ returns validity_ of Pdu instance ]===============
-int Pdu::valid() const
+int Pdu::valid() const
{
return validity_;
}
@@ -397,7 +397,7 @@ int Pdu::trim(const int p)
// verify that lp is legal
if ( lp < 0 || lp > vb_count_)
- return FALSE;
+ return 0;
while ( lp != 0) {
if ( vb_count_ > 0) {
@@ -406,7 +406,7 @@ int Pdu::trim(const int p)
}
lp--;
}
- return TRUE;
+ return 1;
}
@@ -416,17 +416,17 @@ int Pdu::delete_vb( const int p)
{
// position has to be in range
if (( p < 0) || ( p > (vb_count_ - 1)))
- return FALSE;
+ return 0;
// safe to remove it
delete vbs_[ p];
for ( int z=p;z < (vb_count_-1);z++) {
vbs_[z] = vbs_[z+1];
- }
+ }
vb_count_--;
- return TRUE;
+ return 1;
}
void Pdu::delete_all_vbs()
diff --git a/ASNMP/asnmp/sagent.cpp b/ASNMP/asnmp/sagent.cpp
index 489975afbc1..fc56a2c728f 100644
--- a/ASNMP/asnmp/sagent.cpp
+++ b/ASNMP/asnmp/sagent.cpp
@@ -10,11 +10,11 @@
//
// = DESCRIPTION
// SNMP agent class definition. The sagent class provides an object oriented
-// approach for creating SNMP Agents. The sagent class is an encapsulation
-// of SNMP sessions, gets, sets, etc.
+// approach for creating SNMP Agents. The sagent class is an encapsulation
+// of SNMP sessions, gets, sets, etc.
//
// = AUTHOR
-// Michael R. MacFaden
+// Michael R. MacFaden
//
// ============================================================================
#include "ace/Reactor.h"
@@ -24,11 +24,11 @@
#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" // manager snmp interface
+#include "asnmp/snmp.h" // manager snmp interface
#include "asnmp/sagent.h" // agent interface
-#include "asnmp/transaction.h" // convert from wire to API
+#include "asnmp/transaction.h" // convert from wire to API
ACE_RCSID(asnmp, sagent, "$Id$")
@@ -95,4 +95,3 @@ int sagent::respond(Pdu& pdu,UdpTarget& tgt)
tr.send();
return 0;
}
-
diff --git a/ASNMP/asnmp/snmp.cpp b/ASNMP/asnmp/snmp.cpp
index c3184cb3aef..f14d07bcccb 100644
--- a/ASNMP/asnmp/snmp.cpp
+++ b/ASNMP/asnmp/snmp.cpp
@@ -19,7 +19,7 @@
/*===================================================================
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
@@ -39,7 +39,7 @@
#include "asnmp/snmp.h" // class def for this module
#include "asnmp/oid.h" // class def for oids
#include "asnmp/enttraps.h" // class def for well known trap oids
-#include "asnmp/vb.h" // class def for vbs
+#include "asnmp/vb.h" // class def for vbs
#include "asnmp/address.h" // class def for addresses
#include "asnmp/wpdu.h" // adapter to cmu_library / wire protocol
#include "asnmp/transaction.h" // synchronous transaction processor
@@ -60,13 +60,13 @@ Snmp::Snmp(unsigned short port): result_(0), construct_status_(SNMP_CLASS_ERROR)
ACE_INET_Addr addr(port); // any port,address is ok
if (iv_snmp_session_.open(addr) < 0) {
- last_transaction_status_ = errno; // open udp/ipv4 socket
+ last_transaction_status_ = errno; // open udp/ipv4 socket
ACE_DEBUG((LM_DEBUG, "Snmp::snmp::open port %d failed", port));
return;
- }
+ }
- // initial request id randomly generated then monotonically incremented
- req_id_ = (unsigned) ACE_OS::time(NULL);
+ // initial request id randomly generated then monotonically incremented
+ req_id_ = (unsigned) ACE_OS::time(0);
construct_status_ = SNMP_CLASS_SUCCESS;
return;
@@ -86,15 +86,15 @@ int Snmp::valid() const
// given error code, return string definition
// class version
// static
-char * Snmp::error_string(int last_transaction_status_)
+char * Snmp::error_string(int last_transaction_status_)
{
ACE_TRACE("Snmp::error_string");
return ((last_transaction_status_ < 0) ?
- ((last_transaction_status_ < MAX_NEG_ERROR)?
- nErrs[ abs(MAX_NEG_ERROR) + 1] : nErrs[abs(last_transaction_status_)]):
- ((last_transaction_status_ > MAX_POS_ERROR)?
- pErrs[MAX_POS_ERROR+1] : pErrs[last_transaction_status_]));
+ ((last_transaction_status_ < MAX_NEG_ERROR)?
+ nErrs[ abs(MAX_NEG_ERROR) + 1] : nErrs[abs(last_transaction_status_)]):
+ ((last_transaction_status_ > MAX_POS_ERROR)?
+ pErrs[MAX_POS_ERROR+1] : pErrs[last_transaction_status_]));
}
// instance version
@@ -109,8 +109,8 @@ void Snmp::check_default_port(UdpTarget& target, unsigned short port)
target.get_address(tmp);
if (tmp.get_port() == 0) {
tmp.set_port(port);
- target.set_address(tmp);
- }
+ target.set_address(tmp);
+ }
}
int Snmp::run_transaction(Pdu& pdu, UdpTarget& target)
@@ -119,7 +119,7 @@ int Snmp::run_transaction(Pdu& pdu, UdpTarget& target)
// 1. set unique id to match this packet on return
size_t hold_req_id = req_id_++;
- set_request_id(&pdu, hold_req_id);
+ set_request_id(&pdu, hold_req_id);
// 2. write request to agent
transaction trans(pdu, target, iv_snmp_session_);
@@ -127,16 +127,16 @@ int Snmp::run_transaction(Pdu& pdu, UdpTarget& target)
// this call blocks while it attempts to retrieve agent response
while (!done) {
if ((rc = trans.run()) < 0) {
- last_transaction_status_ = rc;
+ last_transaction_status_ = rc;
return rc;
}
else {
- trans.result(pdu);
+ trans.result(pdu);
// verify this is the pdu we are after
if (pdu.get_request_id() == hold_req_id)
done = 1 ;
}
- }
+ }
return 0;
}
@@ -147,7 +147,7 @@ int Snmp::run_transaction(Pdu& pdu, UdpTarget& target, Snmp_Result * cb)
// 1. set unique id to match this packet on return
hold_req_id_ = req_id_++;
- set_request_id(&pdu, hold_req_id_);
+ set_request_id(&pdu, hold_req_id_);
pdu_ = &pdu;
result_ = cb;
@@ -158,39 +158,39 @@ int Snmp::run_transaction(Pdu& pdu, UdpTarget& target, Snmp_Result * cb)
void Snmp::result(transaction *t, int rc)
{
- t->result(*pdu_);
+ t->result(*pdu_);
// verify this is the pdu we are after
if (pdu_->get_request_id() == hold_req_id_)
{
- last_transaction_status_ = rc;
- delete t;
- result_->result(this, rc);
+ last_transaction_status_ = rc;
+ delete t;
+ result_->result(this, rc);
}
else
{
- rc = t->run(this);
- if (rc < 0)
- {
- delete t;
- result_->result(this, rc);
- }
+ rc = t->run(this);
+ if (rc < 0)
+ {
+ delete t;
+ result_->result(this, rc);
+ }
}
}
int Snmp::validate_args(const Pdu& pdu, const UdpTarget& target) const
{
- // 0. check object status
+ // 0. check object status
if (construct_status_ != SNMP_CLASS_SUCCESS)
return construct_status_;
- // 1. check args passed
+ // 1. check args passed
if ( !pdu.valid() || !target.valid() )
return SNMP_INVALID_ARGS;
return 0;
}
// SYNC API: write request to wire then wait for reply or timeout
-int Snmp::get( Pdu &pdu, UdpTarget &target, Snmp_Result * cb)
+int Snmp::get( Pdu &pdu, UdpTarget &target, Snmp_Result * cb)
{
ACE_TRACE("Snmp::get");
int rc;
@@ -235,7 +235,7 @@ int Snmp::trap( Pdu &pdu, UdpTarget &target)
return rc;
pdu.set_type( sNMP_PDU_V1TRAP);
- check_default_port(target, DEF_TRAP_PORT);
+ check_default_port(target, DEF_TRAP_PORT);
// 2. write request to agent
transaction trans(pdu, target, iv_snmp_session_);
@@ -247,4 +247,3 @@ int Snmp::trap( Pdu &pdu, UdpTarget &target)
}
Snmp_Result::~Snmp_Result() {}
-
diff --git a/ASNMP/asnmp/target.cpp b/ASNMP/asnmp/target.cpp
index 1eac9d641e5..c9e27865f31 100644
--- a/ASNMP/asnmp/target.cpp
+++ b/ASNMP/asnmp/target.cpp
@@ -9,7 +9,7 @@
// target.cpp
//
// = DESCRIPTION
-// Target class defines target SNMP agents.
+// Target class defines target SNMP agents.
//
// = AUTHOR
// Peter E Mellquist
@@ -18,17 +18,17 @@
/*===================================================================
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/target.h"
@@ -38,10 +38,10 @@ ACE_RCSID(asnmp, target, "$Id$")
//----------------------------------------------------------------------
//--------[ Class default values ]----------------------
//----------------------------------------------------------------------
-u_long SnmpTarget::default_timeout_ = DEF_TIMEOUT;
-int SnmpTarget::default_retries_ = DEF_RETRIES;
+u_long SnmpTarget::default_timeout_ = DEF_TIMEOUT;
+int SnmpTarget::default_retries_ = DEF_RETRIES;
u_long SnmpTarget::default_max_pdu_size_ = DEF_MAX_SNMP_PACKET;
-snmp_version SnmpTarget::default_version_ = version1;
+snmp_version SnmpTarget::default_version_ = version1;
OctetStr UdpTarget::default_rd_community_(READ_COMM_STR);
OctetStr UdpTarget::default_wr_community_(WRITE_COMM_STR);
@@ -49,45 +49,45 @@ OctetStr UdpTarget::default_wr_community_(WRITE_COMM_STR);
//----------------------------------------------------------------------
//--------[ Abstract SnmpTarget Member Functions ]----------------------
//----------------------------------------------------------------------
-SnmpTarget::SnmpTarget():
- validity_(FALSE), timeout_(default_timeout_), retries_(default_retries_),
+SnmpTarget::SnmpTarget():
+ validity_(0), timeout_(default_timeout_), retries_(default_retries_),
max_pdu_size_(default_max_pdu_size_), version_(default_version_)
{
}
// return validity of target
int SnmpTarget::valid() const
-{
+{
return validity_;
-}
+}
// allow destruction of derived classes
-SnmpTarget::~SnmpTarget()
+SnmpTarget::~SnmpTarget()
{
}
-// set the timeout
+// set the timeout
void SnmpTarget::set_timeout( const u_long t)
-{
- timeout_ = t;
+{
+ timeout_ = t;
}
-// change the default timeout
+// change the default timeout
void SnmpTarget::set_default_timeout( const u_long t)
-{
- default_timeout_ = t;
+{
+ default_timeout_ = t;
}
-// set the retry value
+// set the retry value
void SnmpTarget::set_retry( const int r)
-{
- retries_ = r;
-}
+{
+ retries_ = r;
+}
-// change the default retries
+// change the default retries
void SnmpTarget::set_default_retry( const int r)
-{
- default_retries_ = r;
+{
+ default_retries_ = r;
}
void SnmpTarget:: set_max_pdu_size(const u_long max_pdu_sz)
@@ -95,54 +95,54 @@ void SnmpTarget:: set_max_pdu_size(const u_long max_pdu_sz)
max_pdu_size_ = max_pdu_sz;
}
-
+
void SnmpTarget::set_default_max_pdu_size(const u_long max_pdu_sz)
{
default_max_pdu_size_ = max_pdu_sz;
}
void SnmpTarget::set_version( const snmp_version v)
-{
- version_ = v;
+{
+ version_ = v;
}
void SnmpTarget::set_default_version( const snmp_version v)
-{
- default_version_ = v;
+{
+ default_version_ = v;
}
snmp_version SnmpTarget::get_version() const
-{
+{
return version_;
}
snmp_version SnmpTarget::get_default_version() const
-{
+{
return default_version_;
}
u_long SnmpTarget::get_max_pdu_size() const
-{
+{
return max_pdu_size_;
}
// get the retry value
int SnmpTarget::get_retry() const
-{
- return retries_;
+{
+ return retries_;
}
// get the retry value
int SnmpTarget::get_default_retry() const
-{
- return default_retries_;
+{
+ return default_retries_;
}
// get the timeout
u_long SnmpTarget::get_timeout() const
-{
- return timeout_;
-}
+{
+ return timeout_;
+}
SnmpTarget& SnmpTarget::operator=(const SnmpTarget& lhs)
{
@@ -178,65 +178,65 @@ int operator==(const SnmpTarget& lhs, const SnmpTarget& rhs)
}
-//----------------------------------------------------------------------
+//----------------------------------------------------------------------
//--------[ IpTarget Member Functions ]----------------------------------
//----------------------------------------------------------------------
-//---------[ UdpTarget::UdpTarget( void) ]----------------------------------
+//---------[ UdpTarget::UdpTarget( void) ]----------------------------------
UdpTarget::UdpTarget()
{
- validity_ = FALSE;
+ validity_ = 0;
read_community_ = default_rd_community_; // assign by init fails
write_community_ = default_wr_community_;
-}
+}
UdpTarget::UdpTarget(const UdpAddress& udp) : udp_address_(udp)
{
if (udp_address_.valid())
- validity_ = TRUE;
+ validity_ = 1;
read_community_ = default_rd_community_;
write_community_ = default_wr_community_;
}
-// - copy constructor can be synthesised by compiler
+// - copy constructor can be synthesised by compiler
//-----------[ UdpTarget::~UdpTarget() ]--------------------------------
-UdpTarget::~UdpTarget()
+UdpTarget::~UdpTarget()
{
}
//-----------[ UdpTarget::clone() ]--------------------------------
SnmpTarget * UdpTarget::clone() const
-{
- return (SnmpTarget *) new UdpTarget(*this);
+{
+ return (SnmpTarget *) new UdpTarget(*this);
}
void UdpTarget::set_default_read_community(const OctetStr& rd_community)
{
- default_rd_community_ = rd_community;
+ default_rd_community_ = rd_community;
}
-
+
void UdpTarget::set_default_write_community(const OctetStr& wr_community)
{
- default_wr_community_ = wr_community;
+ default_wr_community_ = wr_community;
}
// get the read community name as an u_char and len
void UdpTarget::get_read_community( OctetStr& read_community_oct) const
-{
- read_community_oct = read_community_;
-}
+{
+ read_community_oct = read_community_;
+}
//---------[ UdpTarget::set_getcommunity ]---------------------------------
// set the read community name
void UdpTarget::set_read_community( const OctetStr& new_read_community)
{
read_community_ = new_read_community;
-}
+}
//---------[ UdpTarget::get_writecommunity ]----------------------------
// get the write community
@@ -245,35 +245,35 @@ void UdpTarget::get_write_community( OctetStr &write_community_oct) const
write_community_oct = write_community_;
}
-//-----------[ UdpTarget::set_writecommunity ]---------------------------
+//-----------[ UdpTarget::set_writecommunity ]---------------------------
// set the write community
void UdpTarget::set_write_community( const OctetStr& write_community_oct)
{
write_community_ = write_community_oct;
}
-//------------[ Address& UdpTarget::get_address() ]---------------------
+//------------[ Address& UdpTarget::get_address() ]---------------------
// get the address
void UdpTarget::get_address( UdpAddress &address) const
-{
+{
address = udp_address_;
return;
}
-//-------------[ UdpTarget::set_address ]--------------------------------
+//-------------[ UdpTarget::set_address ]--------------------------------
// set the address
int UdpTarget::set_address( UdpAddress &udp_address)
-{
+{
udp_address_ = udp_address;
if ( udp_address_.valid())
- validity_ = TRUE;
+ validity_ = 1;
else
- validity_ = FALSE;
+ validity_ = 0;
return validity_;
-}
+}
-// overloaded assignment
+// overloaded assignment
UdpTarget& UdpTarget::operator=( const UdpTarget& lhs)
{
if (this == &lhs)
@@ -288,14 +288,14 @@ UdpTarget& UdpTarget::operator=( const UdpTarget& lhs)
validity_ = lhs.validity_;
return *this;
-}
+}
char *UdpTarget::to_string()
{
sprintf(output_buffer_,"UdpTarget: [ valid: %d addr: %s rd: %s wr: %s \
-ver: %d, timeout: %d, retries: %d max_pdu_size: %d]",
- valid(), udp_address_.to_string(), read_community_.to_string(),
- write_community_.to_string(), version_, (int) timeout_,
+ver: %d, timeout: %d, retries: %d max_pdu_size: %d]",
+ valid(), udp_address_.to_string(), read_community_.to_string(),
+ write_community_.to_string(), version_, (int) timeout_,
retries_, max_pdu_size_);
return output_buffer_;
}
@@ -303,13 +303,13 @@ ver: %d, timeout: %d, retries: %d max_pdu_size: %d]",
//=============[ int operator == UdpTarget, UdpTarget ]===============
// equivlence operator overloaded
int operator==( const UdpTarget &lhs,const UdpTarget &rhs)
-{
+{
// need to compare all the members of a UdpTarget
if ( lhs.read_community_ != rhs.read_community_)
return 0; // !=
if ( lhs.write_community_ != rhs.write_community_)
- return 0; // !=
+ return 0; // !=
if ( lhs.udp_address_ != rhs.udp_address_)
return 0;
@@ -321,4 +321,4 @@ int operator==( const UdpTarget &lhs,const UdpTarget &rhs)
return 0;
return 1; // they are equal
-}
+}
diff --git a/ASNMP/asnmp/timetick.cpp b/ASNMP/asnmp/timetick.cpp
index 4855605b313..06fd025797f 100644
--- a/ASNMP/asnmp/timetick.cpp
+++ b/ASNMP/asnmp/timetick.cpp
@@ -18,83 +18,83 @@
/*===================================================================
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/timetick.h" // include header file for timetick class
+#include "asnmp/timetick.h" // include header file for timetick class
ACE_RCSID(asnmp, timetick, "$Id$")
-// constructor with a value
+// constructor with a value
TimeTicks::TimeTicks( const unsigned long i):SnmpUInt32(i)
-{
+{
smival.syntax = sNMP_SYNTAX_TIMETICKS;
-}
-
+}
+
// copy constructor
TimeTicks::TimeTicks( const TimeTicks &t)
-{
+{
smival.value.uNumber = t.smival.value.uNumber;
smival.syntax = sNMP_SYNTAX_TIMETICKS;
}
// destructor
-TimeTicks::~TimeTicks()
+TimeTicks::~TimeTicks()
{
}
// syntax type
SmiUINT32 TimeTicks::get_syntax()
-{
- return sNMP_SYNTAX_TIMETICKS;
+{
+ return sNMP_SYNTAX_TIMETICKS;
}
// create a new instance of this Value
-SnmpSyntax *TimeTicks::clone() const
-{
- return (SnmpSyntax *) new TimeTicks(*this);
+SnmpSyntax *TimeTicks::clone() const
+{
+ return (SnmpSyntax *) new TimeTicks(*this);
}
// overloaded assignement from ulong
TimeTicks& TimeTicks::operator=( const unsigned long int i)
-{
+{
smival.value.uNumber =i; return *this;
}
// overloaded assignment from TimeTicks
TimeTicks& TimeTicks::operator=( const TimeTicks &uli)
-{
+{
this->smival.value.uNumber = uli.smival.value.uNumber; return *this;
}
// general assignment from any Value
SnmpSyntax& TimeTicks::operator=( SnmpSyntax &in_val)
{
- if ( this == &in_val ) // handle assignement from itself
+ if ( this == &in_val ) // handle assignement from itself
return *this;
- valid_flag = 0; // will get set true if really valid
- if (in_val.valid()) {
+ valid_flag = 0; // will get set true if really valid
+ if (in_val.valid()) {
switch (in_val.get_syntax()) {
case sNMP_SYNTAX_UINT32:
- // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
+ // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
case sNMP_SYNTAX_CNTR32:
case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_INT32: // implied cast int -> uint
- this->smival.value.uNumber =
- ((TimeTicks &)in_val).smival.value.uNumber;
- valid_flag = 1;
- break;
+ case sNMP_SYNTAX_INT32: // implied cast int -> uint
+ this->smival.value.uNumber =
+ ((TimeTicks &)in_val).smival.value.uNumber;
+ valid_flag = 1;
+ break;
}
}
return *this;
@@ -102,8 +102,8 @@ SnmpSyntax& TimeTicks::operator=( SnmpSyntax &in_val)
// otherwise, behave like an unsigned long
TimeTicks::operator unsigned long()
-{
- return smival.value.uNumber;
+{
+ return smival.value.uNumber;
}
@@ -140,4 +140,3 @@ char * TimeTicks::to_string()
return output_buffer;
}
-
diff --git a/ASNMP/asnmp/transaction.cpp b/ASNMP/asnmp/transaction.cpp
index 57abe2f0faf..4c22b0f51e4 100644
--- a/ASNMP/asnmp/transaction.cpp
+++ b/ASNMP/asnmp/transaction.cpp
@@ -13,7 +13,7 @@
// transactions over UDP/IP networks
//
// = AUTHOR
-// Michael R MacFaden mrm@cisco.com - remove v2c, async, rework for ACE
+// Michael R MacFaden mrm@cisco.com - remove v2c, async, rework for ACE
// ============================================================================
#include "ace/Reactor.h"
@@ -29,10 +29,10 @@ inline void reset_receive_buffer(iovec& io)
io.iov_len = 0;
}
-transaction::transaction(const Pdu& pdu, const UdpTarget& target,
- ACE_SOCK_Dgram& io):
+transaction::transaction(const Pdu& pdu, const UdpTarget& target,
+ ACE_SOCK_Dgram& io):
result_(0),
- wp_(pdu,target), params_(target), session_(io)
+ wp_(pdu,target), params_(target), session_(io)
{
// last step, convert address (get ride of this once we have merged address
UdpAddress udp;
@@ -54,25 +54,25 @@ transaction::~transaction()
// implement state machine, send, wait (timeout/results) return
int transaction::run()
{
- int rc, done = FALSE;
+ int rc, done = 0;
int retry_counter = 0;
ACE_Time_Value to(params_.get_timeout(), 0); // seconds
ACE_Reactor reactor;
// 1. register io port for read access
- if (reactor.register_handler(session_.get_handle(), this,
- ACE_Event_Handler::READ_MASK) == -1)
+ if (reactor.register_handler(session_.get_handle(), this,
+ ACE_Event_Handler::READ_MASK) == -1)
return SNMP_CLASS_INTERNAL_ERROR;
- // register a time handler and a socket with this
-
+ // register a time handler and a socket with this
+
while (!done) {
-
- if ((rc = send()) < 0) // send pkt to agent
- return rc;
+
+ if ((rc = send()) < 0) // send pkt to agent
+ return rc;
else {
if (retry_counter++ > params_.get_retry())
- return SNMP_CLASS_TIMEOUT;
+ return SNMP_CLASS_TIMEOUT;
}
// 2. wait for events (timeout, returned msg)
@@ -83,7 +83,7 @@ int transaction::run()
to.set(params_.get_timeout(), 0);
}
else
- return SNMP_CLASS_INTERNAL_ERROR;
+ return SNMP_CLASS_INTERNAL_ERROR;
}
}
return SNMP_CLASS_INTERNAL_ERROR;
@@ -97,20 +97,20 @@ int transaction::run(transaction_result * r)
// 1. register io port for read access
ACE_Reactor * reactor = ACE_Reactor::instance();
- if (reactor->register_handler(session_.get_handle(),
- this,
- READ_MASK) == -1)
- return SNMP_CLASS_INTERNAL_ERROR;
+ if (reactor->register_handler(session_.get_handle(),
+ this,
+ READ_MASK) == -1)
+ return SNMP_CLASS_INTERNAL_ERROR;
retry_counter_ = 0;
- // register a time handler and a socket with this
+ // register a time handler and a socket with this
ACE_Time_Value to = params_.get_timeout();
if (reactor->schedule_timer(this, 0, to, to) < 0)
- return SNMP_CLASS_INTERNAL_ERROR;
+ return SNMP_CLASS_INTERNAL_ERROR;
- if ((rc = send()) < 0) // send pkt to agent
- return rc;
+ if ((rc = send()) < 0) // send pkt to agent
+ return rc;
return 0;
}
@@ -120,12 +120,12 @@ int transaction::handle_input (ACE_HANDLE)
// OS allocates iovec_.iov_base ptr and len
delete [] receive_iovec_.iov_base;
reset_receive_buffer(receive_iovec_);
- int rc = session_.recv(&receive_iovec_, receive_addr_, 0);
+ int rc = session_.recv(&receive_iovec_, receive_addr_, 0);
if (rc == -1) {
delete [] receive_iovec_.iov_base;
reset_receive_buffer(receive_iovec_);
if (result_)
- result_->result(this, SNMP_CLASS_RESOURCE_UNAVAIL);
+ result_->result(this, SNMP_CLASS_RESOURCE_UNAVAIL);
return SNMP_CLASS_RESOURCE_UNAVAIL;
}
if (result_)
@@ -137,14 +137,14 @@ int transaction::handle_input (ACE_HANDLE)
}
int transaction::handle_timeout(const ACE_Time_Value &,
- const void *)
+ const void *)
{
int rc;
- if ((rc = send()) < 0) // send pkt to agent
- result_->result(this, 0);
+ if ((rc = send()) < 0) // send pkt to agent
+ result_->result(this, 0);
else
- if (retry_counter_++ > params_.get_retry())
- result_->result(this, SNMP_CLASS_TIMEOUT);
+ if (retry_counter_++ > params_.get_retry())
+ result_->result(this, SNMP_CLASS_TIMEOUT);
return 0;
}
@@ -157,7 +157,7 @@ const ACE_INET_Addr& transaction::get_from_addr() const
// return pdu to caller
-int transaction::result(Pdu& pdu, char *comm_str, ACE_INET_Addr *from)
+int transaction::result(Pdu& pdu, char *comm_str, ACE_INET_Addr *from)
{
// TODO: check to see the sender matches the receiver address..
@@ -169,7 +169,7 @@ int transaction::result(Pdu& pdu, char *comm_str, ACE_INET_Addr *from)
return -1;
wpdu tmp(receive_iovec_);
-
+
snmp_version ver;
// return comm str and from address of incomming pdu if requested
@@ -177,7 +177,7 @@ int transaction::result(Pdu& pdu, char *comm_str, ACE_INET_Addr *from)
if (comm_str)
ACE_OS::strcpy(comm_str, (char *)tmp.get_community());
if (from)
- *from = receive_addr_;
+ *from = receive_addr_;
return rc;
}
@@ -196,7 +196,7 @@ int transaction::send()
return -1;
}
ssize_t rc = session_.send (io.iov_base, io.iov_len, addr_ , 0);
- return rc;
+ return rc;
}
transaction_result::~transaction_result() {}
diff --git a/ASNMP/asnmp/vb.cpp b/ASNMP/asnmp/vb.cpp
index 2a840e91015..ff9c22bb773 100644
--- a/ASNMP/asnmp/vb.cpp
+++ b/ASNMP/asnmp/vb.cpp
@@ -17,27 +17,27 @@
// set oid, value then call valid() to be sure object was constructed correctly.
//
// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
+// Peter E Mellquist
+// Michael R MacFaden mrm@cisco.com - rework & ACE port
// ============================================================================
/*===================================================================
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/oid.h" // include oid class defs
-#include "asnmp/vb.h" // include vb class defs
+#include "asnmp/oid.h" // include oid class defs
+#include "asnmp/vb.h" // include vb class defs
#include "asnmp/snmperrs.h" // error codes
ACE_RCSID(asnmp, vb, "$Id$")
@@ -45,32 +45,32 @@ ACE_RCSID(asnmp, vb, "$Id$")
//---------------[ Vb::Vb( void) ]--------------------------------------
// constructor with no arguments
// makes an vb, unitialized
-Vb::Vb( void): output_(NULL), iv_vb_value_(NULL),
+Vb::Vb( void): output_(0), iv_vb_value_(0),
exception_status_(SNMP_CLASS_SUCCESS)
-{
+{
}
//---------------[ Vb::Vb( const Oid &oid) ]-----------------------------
// constructor to initialize the oid
// makes a vb with oid portion initialized
-Vb::Vb( const Oid &oid): output_(NULL), iv_vb_oid_(oid), iv_vb_value_(NULL),
+Vb::Vb( const Oid &oid): output_(0), iv_vb_oid_(oid), iv_vb_value_(0),
exception_status_(SNMP_CLASS_SUCCESS)
-{
+{
}
//---------------[ Vb::Vb( const Oid &oid, const SmiSyntax &val) ]-------
Vb::Vb( const Oid &oid, const SnmpSyntax &val, const SmiUINT32 status):
- output_(NULL), iv_vb_oid_(oid), iv_vb_value_(NULL), exception_status_(status)
-{
+ output_(0), iv_vb_oid_(oid), iv_vb_value_(0), exception_status_(status)
+{
// iv_vb_value_ = recast_smi_object(val); // allocate and construct object
iv_vb_value_ = val.clone();
}
//---------------[ Vb::Vb( const Vb &vb) ]-----------------------------
// copy constructor
-Vb::Vb( const Vb &vb): output_(NULL), iv_vb_value_(NULL)
-{
- *this = vb;
+Vb::Vb( const Vb &vb): output_(0), iv_vb_value_(0)
+{
+ *this = vb;
}
//---------------[ Vb::~Vb() ]------------------------------------------
@@ -78,8 +78,8 @@ Vb::Vb( const Vb &vb): output_(NULL), iv_vb_value_(NULL)
// if the vb has a oid or an octect string then
// the associated memory needs to be freed
Vb::~Vb()
-{
- free_vb();
+{
+ free_vb();
delete [] output_; // formatting buffer if it exists
}
@@ -90,9 +90,9 @@ Vb::~Vb()
int Vb::valid() const
{
if ( iv_vb_oid_.valid() && (iv_vb_value_ && iv_vb_value_->valid()) )
- return TRUE;
+ return 1;
else
- return FALSE;
+ return 0;
}
@@ -102,14 +102,14 @@ int Vb::valid() const
// before assigning source
Vb& Vb::operator=( const Vb &vb)
{
- free_vb(); // free up target to begin with
+ free_vb(); // free up target to begin with
//-----[ reassign the Oid portion 1st ]
vb.get_oid( iv_vb_oid_);
//-----[ next set the vb value portion ]
- if (vb.iv_vb_value_ == NULL) {
- iv_vb_value_ = NULL;
+ if (vb.iv_vb_value_ == 0) {
+ iv_vb_value_ = 0;
}
else {
iv_vb_value_ = vb.iv_vb_value_->clone();
@@ -128,14 +128,14 @@ void Vb::set_null()
//---------------[ Vb::set_oid( const Oid oid ) ]-----------------------
// set value oid only with another oid
void Vb::set_oid( const Oid& oid)
-{
+{
iv_vb_oid_ = oid;
}
//---------------[ Vb::get_oid( Oid &oid) ]-----------------------------
// get oid portion
void Vb::get_oid( Oid &oid) const
-{
+{
oid = iv_vb_oid_;
}
@@ -149,7 +149,7 @@ void Vb::free_vb()
if (iv_vb_value_)
delete iv_vb_value_;
exception_status_ = SNMP_CLASS_SUCCESS;
- iv_vb_value_ = NULL;
+ iv_vb_value_ = 0;
}
void Vb::set_value( const SnmpInt32& i)
@@ -223,19 +223,19 @@ int Vb::get_value( SnmpUInt32 &u)
if (iv_vb_value_ && iv_vb_value_->valid())
{
SmiUINT32 syntax = iv_vb_value_->get_syntax();
- if (syntax == sNMP_SYNTAX_GAUGE32 ||
- syntax == sNMP_SYNTAX_CNTR32 ||
- syntax == sNMP_SYNTAX_TIMETICKS ||
- syntax == sNMP_SYNTAX_UINT32)
+ if (syntax == sNMP_SYNTAX_GAUGE32 ||
+ syntax == sNMP_SYNTAX_CNTR32 ||
+ syntax == sNMP_SYNTAX_TIMETICKS ||
+ syntax == sNMP_SYNTAX_UINT32)
{
- u = *((SnmpUInt32 *) iv_vb_value_);
- return SNMP_CLASS_SUCCESS;
+ u = *((SnmpUInt32 *) iv_vb_value_);
+ return SNMP_CLASS_SUCCESS;
}
}
return SNMP_CLASS_INVALID;
}
-/* return a uint or a gauge. this is casting, but no semantic difference
+/* return a uint or a gauge. this is casting, but no semantic difference
* at this level
*/
int Vb::get_value( Gauge32 &g)
@@ -318,9 +318,9 @@ int Vb::get_value( SnmpSyntax &val)
if (iv_vb_value_) {
val = *iv_vb_value_;
if (val.valid())
- return SNMP_CLASS_SUCCESS;
+ return SNMP_CLASS_SUCCESS;
else
- return SNMP_CLASS_INVALID;
+ return SNMP_CLASS_INVALID;
}
else
{
@@ -338,7 +338,7 @@ int Vb::get_value( SnmpSyntax &val)
// the caller has a vb object and does not know what it is.
// This would be useful in the implementation of a browser.
SmiUINT32 Vb::get_syntax()
-{
+{
if ( exception_status_ != SNMP_CLASS_SUCCESS)
return exception_status_;
else
@@ -356,20 +356,20 @@ char *Vb::to_string_value()
// return the printable oid
char *Vb::to_string_oid()
-{
- return iv_vb_oid_.to_string();
+{
+ return iv_vb_oid_.to_string();
}
// generate string with name/ value format
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();
+ ptr = 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);
+ ACE_NEW_RETURN(output_, char[len], "");
+ ACE_OS::sprintf(output_, "%s / %s", iv_vb_oid_.to_string(), ptr);
return output_;
}
@@ -383,8 +383,8 @@ void set_exception_status( Vb *vb, const SmiUINT32 status)
// hack, by side effect, compare based on string formatting output_
int operator==( const Vb &lhs, const Vb &rhs)
{
- if ( lhs.iv_vb_oid_ != rhs.iv_vb_oid_)
- return FALSE;
+ if ( lhs.iv_vb_oid_ != rhs.iv_vb_oid_)
+ return 0;
if (lhs.iv_vb_value_ != 0 && rhs.iv_vb_value_ != 0) {
int val = strcmp(lhs.iv_vb_value_->to_string(),
@@ -392,6 +392,5 @@ int operator==( const Vb &lhs, const Vb &rhs)
return !val;
}
else
- return FALSE;
+ return 0;
}
-
diff --git a/ASNMP/asnmp/wpdu.cpp b/ASNMP/asnmp/wpdu.cpp
index 71e7fc1da1d..973d8fe430f 100644
--- a/ASNMP/asnmp/wpdu.cpp
+++ b/ASNMP/asnmp/wpdu.cpp
@@ -25,7 +25,7 @@
ACE_RCSID(asnmp, wpdu, "$Id$")
-#define MAX_COMM_STR_LEN 255
+#define MAX_COMM_STR_LEN 255
#define V1_COLD_START 0
#define V1_WARM_START 1
#define V1_LINK_DOWN 2
@@ -41,7 +41,7 @@ void reset_iov(iovec& iov)
iov.iov_len = 0;
}
-wpdu::wpdu(const Pdu& pdu, const UdpTarget& target):
+wpdu::wpdu(const Pdu& pdu, const UdpTarget& target):
valid_flag_(SNMP_CLASS_INVALID ), comm_len(MAX_COMM_STR_LEN)
{
reset_iov(iovec_);
@@ -63,14 +63,14 @@ wpdu::wpdu(const Pdu& pdu, const UdpTarget& target):
raw_pdu->errindex= (unsigned long) pdu.get_error_index();
switch (raw_pdu->command) {
- case sNMP_PDU_GET:
+ case sNMP_PDU_GET:
case sNMP_PDU_GETNEXT:
target.get_read_community(comm_str);
break;
case sNMP_PDU_SET:
target.get_write_community(comm_str);
- break;
+ break;
case sNMP_PDU_V1TRAP:
target.get_read_community(comm_str);
@@ -96,11 +96,11 @@ wpdu::wpdu(const Pdu& pdu, const UdpTarget& target):
ACE_NEW(iovec_.iov_base, char [iovec_.iov_len]);
// create raw byte stream
- status = cmu_snmp::build( raw_pdu,
- (unsigned char *)iovec_.iov_base,
- (int *) &iovec_.iov_len,
- target.get_version(),
- comm_str.data(), comm_str.length());
+ status = cmu_snmp::build( raw_pdu,
+ (unsigned char *)iovec_.iov_base,
+ (int *) &iovec_.iov_len,
+ target.get_version(),
+ comm_str.data(), comm_str.length());
if ( status != 0) {
valid_flag_ = SNMP_ERROR_WRONG_ENCODING;
cmu_snmp::free_pdu( raw_pdu);
@@ -124,8 +124,8 @@ int wpdu::set_trap_info(snmp_pdu *raw_pdu, const Pdu& pdu) const
raw_pdu->specific_type=0;
- // TODO: object should emit numeric instead of this kind of mess...
- if ( trapid == coldStart)
+ // TODO: object should emit numeric instead of this kind of mess...
+ if ( trapid == coldStart)
raw_pdu->trap_type = V1_COLD_START; // cold start
else if ( trapid == warmStart)
raw_pdu->trap_type = V1_WARM_START; // warm start
@@ -163,13 +163,13 @@ int wpdu::set_trap_info(snmp_pdu *raw_pdu, const Pdu& pdu) const
// HDN - enterprise is a local object, cannot simply assign pointer
//raw_pdu->enterprise = rawOid->ptr;
raw_pdu->enterprise_length = (int) rawOid->len;
- ACE_NEW_RETURN(raw_pdu->enterprise,
- oid[raw_pdu->enterprise_length],-1);
- ACE_OS::memcpy((char *)raw_pdu->enterprise,(char *)rawOid->ptr,
- raw_pdu->enterprise_length * sizeof(oid));
+ ACE_NEW_RETURN(raw_pdu->enterprise,
+ oid[raw_pdu->enterprise_length],-1);
+ ACE_OS::memcpy((char *)raw_pdu->enterprise,(char *)rawOid->ptr,
+ raw_pdu->enterprise_length * sizeof(oid));
}
-
- TimeTicks timestamp;
+
+ TimeTicks timestamp;
pdu.get_notify_timestamp( timestamp);
raw_pdu->time = ( unsigned long) timestamp;
@@ -177,7 +177,7 @@ int wpdu::set_trap_info(snmp_pdu *raw_pdu, const Pdu& pdu) const
char localHostName[MAXHOSTNAMELEN];
if (ACE_OS::hostname(localHostName, sizeof(localHostName)) != -1) {
struct hostent* hostInfo;
- if (hostInfo = ACE_OS::gethostbyname(localHostName)) {
+ if ((hostInfo = ACE_OS::gethostbyname(localHostName))) {
ACE_OS::memcpy(&(raw_pdu->agent_addr.sin_addr), hostInfo->h_addr, hostInfo->h_length);
}
}
@@ -185,26 +185,26 @@ int wpdu::set_trap_info(snmp_pdu *raw_pdu, const Pdu& pdu) const
return 0;
}
-wpdu::wpdu(const iovec& iov): valid_flag_(FALSE),comm_len(MAX_COMM_STR_LEN)
+wpdu::wpdu(const iovec& iov): valid_flag_(0),comm_len(MAX_COMM_STR_LEN)
{
community_name[0] = 0;
reset_iov(iovec_);
- version_ = version1; // TODO: figure where this should come from
+ version_ = version1; // TODO: figure where this should come from
ACE_NEW(iovec_.iov_base, char[iov.iov_len]);
if (!iovec_.iov_base) {
valid_flag_ = SNMP_CLASS_RESOURCE_UNAVAIL;
return;
}
- copy_iovec(iovec_, iov);
+ copy_iovec(iovec_, iov);
valid_flag_ = SNMP_CLASS_SUCCESS;
}
-wpdu::wpdu(): valid_flag_(FALSE), comm_len(MAX_COMM_STR_LEN)
+wpdu::wpdu(): valid_flag_(0), comm_len(MAX_COMM_STR_LEN)
{
community_name[0] = 0;
reset_iov(iovec_);
- version_ = version1; // TODO: figure where this should come from
+ version_ = version1; // TODO: figure where this should come from
}
int wpdu::valid() const
@@ -223,7 +223,7 @@ int wpdu::load_vbs(snmp_pdu *raw_pdu, const Pdu& pdu)
Oid tempoid;
SmiLPOID smioid;
SmiVALUE smival;
-
+
vb_count = pdu.get_vb_count();
for (int z = 0; z < vb_count; z++) {
@@ -234,7 +234,7 @@ int wpdu::load_vbs(snmp_pdu *raw_pdu, const Pdu& pdu)
status = convert_vb_to_smival( tempvb, &smival );
if ( status != SNMP_CLASS_SUCCESS)
return status;
-
+
// add the var to the raw pdu
cmu_snmp::add_var(raw_pdu, smioid->ptr, (int) smioid->len, &smival);
free_smival_descriptor( &smival);
@@ -244,7 +244,7 @@ int wpdu::load_vbs(snmp_pdu *raw_pdu, const Pdu& pdu)
}
// supports overlapped copies
-// static
+// static
void wpdu::copy_iovec(iovec& dest, const iovec& src)
{
if (&dest == &src)
@@ -259,10 +259,10 @@ int wpdu::convert_vb_to_smival( Vb &tempvb, SmiVALUE *smival )
smival->syntax = tempvb.get_syntax();
switch ( smival->syntax ) {
-
+
case sNMP_SYNTAX_NULL:
break;
-
+
// case sNMP_SYNTAX_INT32:
case sNMP_SYNTAX_INT:
{
@@ -271,7 +271,7 @@ int wpdu::convert_vb_to_smival( Vb &tempvb, SmiVALUE *smival )
smival->value.sNumber = tmp;
}
break;
-
+
// case sNMP_SYNTAX_UINT32:
case sNMP_SYNTAX_GAUGE32:
case sNMP_SYNTAX_CNTR32:
@@ -282,7 +282,7 @@ int wpdu::convert_vb_to_smival( Vb &tempvb, SmiVALUE *smival )
smival->value.uNumber = tmp;
}
break;
-
+
// case Counter64
case sNMP_SYNTAX_CNTR64:
{
@@ -301,32 +301,32 @@ int wpdu::convert_vb_to_smival( Vb &tempvb, SmiVALUE *smival )
tempvb.get_value(tmpoid);
SmiLPOID smi = tmpoid.oidval();
smival->value.oid.len = tmpoid.length();
- ACE_NEW_RETURN(smival->value.oid.ptr,
+ ACE_NEW_RETURN(smival->value.oid.ptr,
SmiUINT32 [smival->value.oid.len], 1);
- ACE_OS::memcpy(smival->value.oid.ptr, smi->ptr,
+ ACE_OS::memcpy(smival->value.oid.ptr, smi->ptr,
smival->value.oid.len *sizeof(SmiUINT32));
}
break;
-
+
case sNMP_SYNTAX_BITS:
case sNMP_SYNTAX_OCTETS:
case sNMP_SYNTAX_IPADDR:
{
OctetStr os;
tempvb.get_value(os);
- smival->value.string.ptr = NULL;
+ smival->value.string.ptr = 0;
smival->value.string.len = os.length();
if ( smival->value.string.len > 0 ) {
- ACE_NEW_RETURN(smival->value.string.ptr,
- SmiBYTE [smival->value.string.len], 1);
- if ( smival->value.string.ptr ) {
- for (int i=0; i<(int) smival->value.string.len ; i++)
- smival->value.string.ptr[i] = os[i];
- }
- else {
- smival->syntax = sNMP_SYNTAX_NULL; // invalidate the smival
- return SNMP_CLASS_RESOURCE_UNAVAIL;
- }
+ ACE_NEW_RETURN(smival->value.string.ptr,
+ SmiBYTE [smival->value.string.len], 1);
+ if ( smival->value.string.ptr ) {
+ for (int i=0; i<(int) smival->value.string.len ; i++)
+ smival->value.string.ptr[i] = os[i];
+ }
+ else {
+ smival->syntax = sNMP_SYNTAX_NULL; // invalidate the smival
+ return SNMP_CLASS_RESOURCE_UNAVAIL;
+ }
}
}
break;
@@ -337,7 +337,7 @@ int wpdu::convert_vb_to_smival( Vb &tempvb, SmiVALUE *smival )
} // switch
return 0;
-}
+}
// free a SMI value
void wpdu::free_smival_descriptor( SmiVALUE *smival )
@@ -349,7 +349,7 @@ void wpdu::free_smival_descriptor( SmiVALUE *smival )
case sNMP_SYNTAX_BITS: // obsoleted in SNMPv2 Draft Std
delete [] smival->value.string.ptr;
break;
-
+
case sNMP_SYNTAX_OID:
delete [] smival->value.oid.ptr;
break;
@@ -369,7 +369,7 @@ const iovec& wpdu::get_buffer() const
}
// return a pdu from a buffer
-int wpdu::get_pdu(Pdu& pdu, snmp_version& version)
+int wpdu::get_pdu(Pdu& pdu, snmp_version& version)
{
if (iovec_.iov_len == 0)
return -1; // NO DATA
@@ -378,10 +378,10 @@ int wpdu::get_pdu(Pdu& pdu, snmp_version& version)
raw_pdu = cmu_snmp::pdu_create(0);
if (!raw_pdu) {
return SNMP_CLASS_RESOURCE_UNAVAIL;
- }
+ }
// max value a client can send us - TODO: replace this with an
- // api to get actual string length
+ // api to get actual string length
int status = cmu_snmp::parse( raw_pdu, (unsigned char *)iovec_.iov_base,
community_name, comm_len,
version, iovec_.iov_len);
@@ -400,7 +400,7 @@ int wpdu::get_pdu(Pdu& pdu, snmp_version& version)
}
cmu_snmp::free_pdu(raw_pdu);
- return 0;
+ return 0;
}
int wpdu::restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const
@@ -410,15 +410,15 @@ int wpdu::restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const
struct variable_list *vp;
for(vp = raw_pdu->variables; vp; vp = vp->next_variable) {
-
+
// extract the oid portion
tempoid.set_data( (unsigned long *)vp->name,
( unsigned int) vp->name_length);
tempvb.set_oid( tempoid);
-
+
// extract the value portion
switch(vp->type) {
-
+
// octet string
case sNMP_SYNTAX_OCTETS:
case sNMP_SYNTAX_OPAQUE:
@@ -428,7 +428,7 @@ int wpdu::restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const
tempvb.set_value( octets);
}
break;
-
+
// object id
case sNMP_SYNTAX_OID:
{
@@ -437,7 +437,7 @@ int wpdu::restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const
tempvb.set_value( oid);
}
break;
-
+
// timeticks
case sNMP_SYNTAX_TIMETICKS:
{
@@ -445,7 +445,7 @@ int wpdu::restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const
tempvb.set_value( timeticks);
}
break;
-
+
// 32 bit counter
case sNMP_SYNTAX_CNTR32:
{
@@ -467,7 +467,7 @@ int wpdu::restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const
tempvb.set_value( ipaddress);
}
break;
-
+
// 32 bit integer
case sNMP_SYNTAX_INT:
{
@@ -475,7 +475,7 @@ int wpdu::restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const
tempvb.set_value( int32);
}
break;
-
+
// 32 bit unsigned integer
case sNMP_SYNTAX_UINT32:
{
@@ -483,27 +483,27 @@ int wpdu::restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const
tempvb.set_value( uint32);
}
break;
-
+
// v2 counter 64's
case sNMP_SYNTAX_CNTR64:
break;
-
+
case sNMP_SYNTAX_NULL:
tempvb.set_null();
break;
-
+
// v2 vb exceptions
case sNMP_SYNTAX_NOSUCHOBJECT:
case sNMP_SYNTAX_NOSUCHINSTANCE:
case sNMP_SYNTAX_ENDOFMIBVIEW:
set_exception_status( &tempvb, vp->type);
break;
-
+
default:
tempvb.set_null();
-
+
} // end switch
-
+
// append the vb to the pdu
pdu += tempvb;
}
@@ -515,4 +515,3 @@ const unsigned char *wpdu::get_community() const
{
return community_name;
}
-