SNMP++  3.3.4
Pdu Class Reference

Pdu class... More...

#include <pdu.h>

Collaboration diagram for Pdu:

Public Member Functions

 Pdu ()
 Constructor no args. More...
 
 Pdu (Vb *pvbs, const int pvb_count)
 Constructor with vbs. More...
 
 Pdu (const Pdu &pdu)
 Constructor with another Pdu instance. More...
 
virtual ~Pdu ()
 Destructor. More...
 
Pduoperator= (const Pdu &pdu)
 Overloaded assignment operator. More...
 
Pduoperator+= (const Vb &vb)
 Append a vb to the pdu. More...
 
Pduclone () const
 Clone a Pdu object. More...
 
int get_vblist (Vb *pvbs, const int pvb_count) const
 Get Pointers to all Vbs from Pdu. More...
 
int set_vblist (Vb const *pvbs, const int pvb_count)
 Deposit all Vbs to Pdu. More...
 
int get_vb (Vb &vb, const int index) const
 Get a particular Vb. More...
 
const Vbget_vb (const int index) const
 Return a reference to a particular Vb. More...
 
int set_vb (Vb const &vb, const int index)
 Set a particular vb. More...
 
int get_vb_count () const
 Get the number of vbs. More...
 
Vboperator[] (const int i)
 Get a Vb. More...
 
int get_error_status () const
 Get the error status. More...
 
void set_error_status (const int err)
 Set the error status. More...
 
void clear_error_status ()
 Clear the error status. More...
 
int get_error_index () const
 Get the error index. More...
 
void set_error_index (const int index)
 Set the error index. More...
 
void clear_error_index ()
 Clear the error index. More...
 
void clear_error ()
 Clear error status and error index. More...
 
unsigned long get_request_id () const
 Get the request id. More...
 
void set_request_id (const unsigned long rid)
 Set the request id. More...
 
unsigned short get_type () const
 Get the pdu type. More...
 
void set_type (unsigned short type)
 Set the pdu type. More...
 
bool valid () const
 Returns validity of Pdu instance. More...
 
int trim (const int count=1)
 Trim off vbs. More...
 
int delete_vb (const int position)
 Delete a Vb anywhere within the Pdu. More...
 
void set_notify_timestamp (const TimeTicks &ts)
 Set notify timestamp. More...
 
void get_notify_timestamp (TimeTicks &ts) const
 Get notify timestamp. More...
 
bool set_notify_id (const Oid &id)
 Set the notify id. More...
 
bool get_notify_id (Oid &id) const
 Get the notify id. More...
 
bool set_notify_enterprise (const Oid &e)
 Set the notify enterprise. More...
 
bool get_notify_enterprise (Oid &e) const
 Get the notify enterprise. More...
 
void set_security_level (const int level)
 Set the security level that should be used when this Pdu is sent. More...
 
int get_security_level () const
 Return the security level of the Pdu. More...
 
bool set_context_name (const OctetStr &name)
 Set the context name of the Pdu. More...
 
bool set_context_name (const char *name)
 Set the context name of the Pdu. More...
 
bool get_context_name (OctetStr &name) const
 Get the context name of the Pdu. More...
 
const OctetStrget_context_name () const
 Get the context name of the Pdu. More...
 
bool set_context_engine_id (const OctetStr &id)
 Set the context engine id of the Pdu. More...
 
bool set_context_engine_id (const char *id)
 Set the context engine id of the Pdu. More...
 
bool get_context_engine_id (OctetStr &id) const
 Get the context engine id of the Pdu. More...
 
const OctetStrget_context_engine_id () const
 Get the context engine id of the Pdu. More...
 
void set_message_id (const unsigned long msg_id)
 Set the SNMPv3 message id (msgID) More...
 
unsigned long get_message_id () const
 Get the SNMPv3 message id (msgID) More...
 
void set_maxsize_scopedpdu (unsigned long l)
 Set the maximum size of the scoped pdu to be included in a possible response message. More...
 
unsigned long get_maxsize_scopedpdu () const
 Get the maximum size of the scoped pdu to be included in a possible response message. More...
 
int get_v1_trap_address (GenAddress &address) const
 Get the SNMPv1 trap address. More...
 
int set_v1_trap_address (const Address &address)
 Set the SNMPv1 trap address. More...
 
int get_asn1_length () const
 Return the length of the encoded vbs with pdu header. More...
 
void clear ()
 Clear the Pdu contents (destruct and construct in one go) More...
 

Static Public Member Functions

static bool match_type (const int request, const int response)
 Does the type of response match the type of request. More...
 

Protected Member Functions

bool extend_vbs ()
 Extend the vbs array. More...
 

Protected Attributes

Vb ** vbs
 
int vbs_size
 
int vb_count
 
int error_status
 
int error_index
 
bool validity
 
unsigned long request_id
 
unsigned short pdu_type
 
TimeTicks notify_timestamp
 
Oid notify_id
 
Oid notify_enterprise
 
GenAddress v1_trap_address
 
int v1_trap_address_set
 
int security_level
 
unsigned long message_id
 
unsigned long maxsize_scopedpdu
 
OctetStr context_name
 
OctetStr context_engine_id
 

Detailed Description

Pdu class...

Definition at line 81 of file pdu.h.

Constructor & Destructor Documentation

Pdu::Pdu ( )

Constructor no args.

This constructor creates a valid empty Pdu object.

Pdu::Pdu ( Vb pvbs,
const int  pvb_count 
)

Constructor with vbs.

The Pdu class does not take ownership of the array and the Vb objects, so if these were allocated with new, they must be freed by te user with delete.

Parameters
pvbs- Array of pointers to Vb objects
pvb_count- Length of the array
Pdu::Pdu ( const Pdu pdu)
inline

Constructor with another Pdu instance.

Parameters
pdu- source pdu object

Definition at line 109 of file pdu.h.

virtual Pdu::~Pdu ( )
virtual

Destructor.

Member Function Documentation

void Pdu::clear ( )

Clear the Pdu contents (destruct and construct in one go)

void Pdu::clear_error ( )
inline

Clear error status and error index.

Definition at line 257 of file pdu.h.

void Pdu::clear_error_index ( )
inline

Clear the error index.

Definition at line 252 of file pdu.h.

void Pdu::clear_error_status ( )
inline

Clear the error status.

Definition at line 233 of file pdu.h.

Pdu* Pdu::clone ( ) const
inline

Clone a Pdu object.

Returns
Pointer to a newly created Pdu object, that is identical to this

Definition at line 135 of file pdu.h.

int Pdu::delete_vb ( const int  position)

Delete a Vb anywhere within the Pdu.

Parameters
position- Delete the Vb at this position (starting with 0)
Returns
TRUE on success
bool Pdu::extend_vbs ( )
protected

Extend the vbs array.

Returns
true on success
int Pdu::get_asn1_length ( ) const

Return the length of the encoded vbs with pdu header.

Note
this method wll not work for v1 traps.
bool Pdu::get_context_engine_id ( OctetStr id) const
inline

Get the context engine id of the Pdu.

Parameters
id- Object for the context engine

Definition at line 416 of file pdu.h.

const OctetStr& Pdu::get_context_engine_id ( ) const
inline

Get the context engine id of the Pdu.

Returns
- Return the context engine id as an OctetStr

Definition at line 424 of file pdu.h.

bool Pdu::get_context_name ( OctetStr name) const
inline

Get the context name of the Pdu.

Parameters
name- Object fot the context name

Definition at line 385 of file pdu.h.

References OctetStr::valid().

const OctetStr& Pdu::get_context_name ( ) const
inline

Get the context name of the Pdu.

Returns
- Return the context name as an OctetStr

Definition at line 393 of file pdu.h.

int Pdu::get_error_index ( ) const
inline

Get the error index.

Returns
The SNMP error index

Definition at line 240 of file pdu.h.

int Pdu::get_error_status ( ) const
inline

Get the error status.

Returns
The SNMP error status

Definition at line 221 of file pdu.h.

unsigned long Pdu::get_maxsize_scopedpdu ( ) const
inline

Get the maximum size of the scoped pdu to be included in a possible response message.

Returns
- the maximum size

Definition at line 454 of file pdu.h.

unsigned long Pdu::get_message_id ( ) const
inline

Get the SNMPv3 message id (msgID)

Returns
- the message id of the received message

Definition at line 438 of file pdu.h.

bool Pdu::get_notify_enterprise ( Oid e) const
inline

Get the notify enterprise.

Returns
true if the get succeeded.

Definition at line 343 of file pdu.h.

References Oid::len().

bool Pdu::get_notify_id ( Oid id) const
inline

Get the notify id.

Returns
true if the get succeeded.

Definition at line 327 of file pdu.h.

void Pdu::get_notify_timestamp ( TimeTicks ts) const
inline

Get notify timestamp.

Definition at line 312 of file pdu.h.

unsigned long Pdu::get_request_id ( ) const
inline

Get the request id.

Returns
The SNMP request id

Definition at line 264 of file pdu.h.

int Pdu::get_security_level ( ) const
inline

Return the security level of the Pdu.

Returns
- the security level

Definition at line 362 of file pdu.h.

unsigned short Pdu::get_type ( ) const
inline

Get the pdu type.

Definition at line 276 of file pdu.h.

int Pdu::get_v1_trap_address ( GenAddress address) const

Get the SNMPv1 trap address.

int Pdu::get_vb ( Vb vb,
const int  index 
) const

Get a particular Vb.

Parameters
vb- Object to store the vb
index- The vb to get (zero is the first vb)
Returns
TRUE on success
const Vb& Pdu::get_vb ( const int  index) const
inline

Return a reference to a particular Vb.

Note
Before calling this method, make sure that there is a Vb using get_vb_count().
Parameters
index- The Vb to return starting with 0.
Returns
A const reference to the Vb

Definition at line 186 of file pdu.h.

int Pdu::get_vb_count ( ) const
inline

Get the number of vbs.

Returns
The number of Vb objects within the pdu.

Definition at line 205 of file pdu.h.

int Pdu::get_vblist ( Vb pvbs,
const int  pvb_count 
) const

Get Pointers to all Vbs from Pdu.

The caller has to allocate the array. The returned pointers point to the Vb objects that are internally used by the pdu. So any changes to the returned Vb objects will change the pdu. If the pdu is modified (e.g. through Pdu::trim()) afterwards, the returned array will contain invalid pointers.

Parameters
pvbs- Array of empty pointers of size pvb_count
pvb_count- Amount of Vb pointers to get
Returns
TRUE on success
static bool Pdu::match_type ( const int  request,
const int  response 
)
static

Does the type of response match the type of request.

Pdu& Pdu::operator+= ( const Vb vb)

Append a vb to the pdu.

Parameters
vb- The Vb that should be added (as last vb) to the pdu
Pdu& Pdu::operator= ( const Pdu pdu)

Overloaded assignment operator.

Parameters
pdu- Pdu that should be assigned to this object
Vb& Pdu::operator[] ( const int  i)
inline

Get a Vb.

Note
The index has to be checked by the caller.
Parameters
izero based index

Definition at line 214 of file pdu.h.

bool Pdu::set_context_engine_id ( const OctetStr id)
inline

Set the context engine id of the Pdu.

Parameters
id- The new context engine id

Definition at line 400 of file pdu.h.

bool Pdu::set_context_engine_id ( const char *  id)
inline

Set the context engine id of the Pdu.

Parameters
id- The new context engine id

Definition at line 408 of file pdu.h.

bool Pdu::set_context_name ( const OctetStr name)
inline

Set the context name of the Pdu.

Parameters
name- The context name

Definition at line 369 of file pdu.h.

References OctetStr::valid().

bool Pdu::set_context_name ( const char *  name)
inline

Set the context name of the Pdu.

Parameters
name- The context name

Definition at line 377 of file pdu.h.

void Pdu::set_error_index ( const int  index)
inline

Set the error index.

Parameters
err- The new SNMP error index.

Definition at line 247 of file pdu.h.

void Pdu::set_error_status ( const int  err)
inline

Set the error status.

Parameters
err- The new SNMP error status.

Definition at line 228 of file pdu.h.

void Pdu::set_maxsize_scopedpdu ( unsigned long  l)
inline

Set the maximum size of the scoped pdu to be included in a possible response message.

Parameters
l- the maximum size

Definition at line 446 of file pdu.h.

void Pdu::set_message_id ( const unsigned long  msg_id)
inline

Set the SNMPv3 message id (msgID)

Parameters
msg_id- the message id of the received message

Definition at line 431 of file pdu.h.

bool Pdu::set_notify_enterprise ( const Oid e)
inline

Set the notify enterprise.

Returns
true if the set succeeded.

Definition at line 335 of file pdu.h.

References Oid::len().

bool Pdu::set_notify_id ( const Oid id)
inline

Set the notify id.

Returns
true if the set succeeded.

Definition at line 319 of file pdu.h.

void Pdu::set_notify_timestamp ( const TimeTicks ts)
inline

Set notify timestamp.

Definition at line 307 of file pdu.h.

void Pdu::set_request_id ( const unsigned long  rid)
inline

Set the request id.

Parameters
rid- The new SNMP request id

Definition at line 271 of file pdu.h.

void Pdu::set_security_level ( const int  level)
inline

Set the security level that should be used when this Pdu is sent.

The default security level of a Pdu is SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV.

Parameters
level- One of SNMP_SECURITY_LEVEL_NOAUTH_NOPRIV, SNMP_SECURITY_LEVEL_AUTH_NOPRIV, SNMP_SECURITY_LEVEL_AUTH_PRIV

Definition at line 355 of file pdu.h.

void Pdu::set_type ( unsigned short  type)
inline

Set the pdu type.

Definition at line 281 of file pdu.h.

int Pdu::set_v1_trap_address ( const Address address)

Set the SNMPv1 trap address.

int Pdu::set_vb ( Vb const &  vb,
const int  index 
)

Set a particular vb.

If this method returns FALSE, the pdu has not been modified.

Parameters
vb- Source vb
index- The vb to set (zero is the first vb)
Returns
TRUE on success
int Pdu::set_vblist ( Vb const *  pvbs,
const int  pvb_count 
)

Deposit all Vbs to Pdu.

The vb objects of the pdu will be freed and the objects from the array will be cloned and added to the pdu. If this method returns FALSE, the pdu will not conatin any Vb objects.

Parameters
pvbs- Array of valid pointers of size pvb_count
pvb_count- Amount of Vb pointers i the array
Returns
TRUE on success
int Pdu::trim ( const int  count = 1)

Trim off vbs.

Parameters
count- number of vbs to trim of, starting with the last
Returns
TRUE on success, FALSE if nothing was done
bool Pdu::valid ( ) const
inline

Returns validity of Pdu instance.

Definition at line 286 of file pdu.h.

Member Data Documentation

OctetStr Pdu::context_engine_id
protected

Definition at line 517 of file pdu.h.

OctetStr Pdu::context_name
protected

Definition at line 516 of file pdu.h.

int Pdu::error_index
protected

Definition at line 499 of file pdu.h.

int Pdu::error_status
protected

Definition at line 498 of file pdu.h.

unsigned long Pdu::maxsize_scopedpdu
protected

Definition at line 515 of file pdu.h.

unsigned long Pdu::message_id
protected

Definition at line 514 of file pdu.h.

Oid Pdu::notify_enterprise
protected

Definition at line 507 of file pdu.h.

Oid Pdu::notify_id
protected

Definition at line 506 of file pdu.h.

TimeTicks Pdu::notify_timestamp
protected

Definition at line 505 of file pdu.h.

unsigned short Pdu::pdu_type
protected

Definition at line 502 of file pdu.h.

unsigned long Pdu::request_id
protected

Definition at line 501 of file pdu.h.

int Pdu::security_level
protected

Definition at line 512 of file pdu.h.

GenAddress Pdu::v1_trap_address
protected

Definition at line 508 of file pdu.h.

int Pdu::v1_trap_address_set
protected

Definition at line 509 of file pdu.h.

bool Pdu::validity
protected

Definition at line 500 of file pdu.h.

int Pdu::vb_count
protected

Definition at line 497 of file pdu.h.

Vb** Pdu::vbs
protected

Definition at line 495 of file pdu.h.

int Pdu::vbs_size
protected

Definition at line 496 of file pdu.h.


The documentation for this class was generated from the following file: