diff options
Diffstat (limited to 'ASNMP/asnmp/pdu.cpp')
-rw-r--r-- | ASNMP/asnmp/pdu.cpp | 124 |
1 files changed, 62 insertions, 62 deletions
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() |