AgentXcpp  Revision:4ac4848
Internals Documentation
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends
agentxcpp::NotifyPDU Class Reference

Represents an Notify-PDU. More...

#include <NotifyPDU.hpp>

Inheritance diagram for agentxcpp::NotifyPDU:
[legend]
Collaboration diagram for agentxcpp::NotifyPDU:
[legend]

List of all members.

Public Types

enum  generic_trap_t {
  coldStart = 0, warmStart = 1, linkDown = 2, linkUp = 3,
  authenticationFailure = 4, egpNeighborLoss = 5, enterpriseSpecific = 6
}
 The allowed values for specific-trap. More...

Public Member Functions

 NotifyPDU (data_t::const_iterator &pos, const data_t::const_iterator &end, bool big_endian)
 Parse constructor.
 NotifyPDU ()
 Default Constructor.
vector< varbind > & get_vb ()
 Get the VarBind list.
virtual data_t serialize () const
 Serialize the PDU.
varbind trapToNotification (oid enterprise, generic_trap_t generic_trap, uint32_t specific_trap)
 Create snmpTrapOID.0 from SNMPv1 Trap data.

Private Attributes

vector< varbindvb
 The VarBind list.

Detailed Description

Represents an Notify-PDU.

Definition at line 35 of file NotifyPDU.hpp.


Member Enumeration Documentation

The allowed values for specific-trap.

According to RFC 1157, these values can be used for the generic-trap field in SNMPv1 Traps.

Enumerator:
coldStart 
warmStart 
linkDown 
linkUp 
authenticationFailure 
egpNeighborLoss 
enterpriseSpecific 

Definition at line 111 of file NotifyPDU.hpp.


Constructor & Destructor Documentation

NotifyPDU::NotifyPDU ( data_t::const_iterator &  pos,
const data_t::const_iterator &  end,
bool  big_endian 
)

Parse constructor.

Construct the object by parsing a stream. See Parsing incoming PDUs for details about PDU parsing.

Parameters:
posIterator pointing to the current stream position. The iterator is advanced while reading the header.
endIterator pointing one element past the end of the current stream. This is needed to mark the end of the buffer.
big_endianWhether the serialized form of the PDU is in big_endian format.
Exceptions:
parse_errorIf parsing fails, for example because reading the stream fails or the PDU is malformed.

Definition at line 25 of file NotifyPDU.cpp.

References vb.

Default Constructor.

Sets the state of the object to the defaults as set by the PDU::PDUwithContext() constructor, and initializes vb to be empty.

Definition at line 75 of file NotifyPDU.hpp.


Member Function Documentation

vector<varbind>& agentxcpp::NotifyPDU::get_vb ( ) [inline]

Get the VarBind list.

This function returns a reference to the internal VarBind list, which can then be modified in place.

Note:
  • There is no set_vb() function, because the VarBind list can be modified in place.
  • The following restrictions are placed on the vb's contents according to RFC 2741, 6.2.10. "The agentx-Notify-PDU":
    • If the subagent supplies sysUpTime.0, it must be present as the first varbind
    • snmpTrapOID.0 must be present, as the second varbind if sysUpTime.0 was supplied, as the first if it was not.

Definition at line 95 of file NotifyPDU.hpp.

References vb.

data_t NotifyPDU::serialize ( ) const [virtual]

Serialize the PDU.

Implements agentxcpp::PDU.

Definition at line 40 of file NotifyPDU.cpp.

References agentxcpp::PDUwithContext::add_header(), agentxcpp::PDU::agentxNotifyPDU, and vb.

varbind NotifyPDU::trapToNotification ( oid  enterprise,
generic_trap_t  generic_trap,
uint32_t  specific_trap 
)

Create snmpTrapOID.0 from SNMPv1 Trap data.

Each notification must have an snmpTrapOID.0 object. In SNMPv1 no notifications were available; instead Traps were used. This function takes parameters which would be present in an SNMPv1 Trap and converts them to an snmpTrapOID.0 object. The result is a varbind of the form "snmpTrapOID.0 = <calculated value>". Note that the master will convert the snmpTrapOID.0 value back when sending SNMPv1 traps; nevertheless the AgentX protocol requires the snmpTrapOID.0 object.

The conversion is done according to RFC 1908, 3.1.2 "SNMPv1 -> SNMPv2".

Parameters:
enterpriseType of object generating trap, see RFC 1155
generic_trap
specific_trap
Returns:
A varbind for the snmpTrapOID.0 object to be added to the VarBind list. Both the OID and the value of the varbind are allocated with new, and the user is responsible for calling delete for them.
Exceptions:
inval_paramIf the generic_trap parameter has an invalid value.

Definition at line 59 of file NotifyPDU.cpp.

References authenticationFailure, coldStart, egpNeighborLoss, enterpriseSpecific, linkDown, linkUp, and warmStart.


Member Data Documentation

vector<varbind> agentxcpp::NotifyPDU::vb [private]

The VarBind list.

Definition at line 41 of file NotifyPDU.hpp.

Referenced by get_vb(), NotifyPDU(), and serialize().


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