The base class of all PDU's. More...
#include <PDU.hpp>
Public Member Functions | |
| bool | get_new_index () |
| Get new_index flag. | |
| void | set_new_index (bool new_index) |
| Set new_index flag. | |
| bool | get_any_index () |
| Get any_index flag. | |
| void | set_any_index (bool any_index) |
| Set any_index flag. | |
| uint32_t | get_sessionID () |
| Get sessionID. | |
| void | set_sessionID (uint32_t id) |
| Set sessionID. | |
| uint32_t | get_transactionID () |
| Get transactionID. | |
| void | set_transactionID (uint32_t id) |
| Set transactionID. | |
| uint32_t | get_packetID () |
| Get packetID. | |
| void | set_packetID (uint32_t packetID) |
| Set packetID. | |
| virtual data_t | serialize () const =0 |
| Serialize function for concrete PDUs. | |
Static Public Member Functions | |
| static shared_ptr< PDU > | parse_pdu (data_t buf) |
| Parse a PDU from a buffer. | |
Protected Types | |
| enum | type_t { agentxOpenPDU = 1, agentxClosePDU = 2, agentxRegisterPDU = 3, agentxUnregisterPDU = 4, agentxGetPDU = 5, agentxGetNextPDU = 6, agentxGetBulkPDU = 7, agentxTestSetPDU = 8, agentxCommitSetPDU = 9, agentxUndoSetPDU = 10, agentxCleanupSetPDU = 11, agentxNotifyPDU = 12, agentxPingPDU = 13, agentxIndexAllocatePDU = 14, agentxIndexDeallocatePDU = 15, agentxAddAgentCapsPDU = 16, agentxRemoveAgentCapsPDU = 17, agentxResponsePDU = 18 } |
| The PDU types. More... | |
Protected Member Functions | |
| PDU (data_t::const_iterator &pos, const data_t::const_iterator &end, bool big_endian) | |
| Parse constructor. | |
| void | add_header (type_t type, data_t &payload) const |
| Construct the PDU header and add it to the payload. | |
| PDU () | |
| Default constructor. | |
Protected Attributes | |
| bool | instance_registration |
| the instance_registration flag | |
| bool | non_default_context |
| Whether the PDU has a non-default context. | |
| uint32_t | packetID |
| h.packetID field according to RFC 2741, 6.1. "AgentX PDU
Header". | |
Private Attributes | |
| bool | new_index |
| the new_index flag | |
| bool | any_index |
| the any_index flag | |
| uint32_t | sessionID |
| h.sessionID field | |
| uint32_t | transactionID |
| h.transactionID field | |
Static Private Attributes | |
| static uint32_t | packetID_cnt = 0 |
| Counter for automatic packetID generator. | |
The base class of all PDU's.
This class is never instantiated itself, but serves as the base class for concrete PDU classes which don't have a context field (e.g. OpenPDU). For concrete PDU's with context field, the class PDUwithContext is used.
This class represents the PDU header and contains data and functionality common to all PDU types. It provides an automatic packetID generator. Whenever a PDU object is created, the packetID is automatically incremented. The two exceptions are:
The mechanism uses a static class member packetID_cnt to store the last used packetID. The counter wraps at its limit.
enum agentxcpp::PDU::type_t [protected] |
The PDU types.
According to RFC 2741, section 6.1 "AgentX PDU Header".
| PDU::PDU | ( | data_t::const_iterator & | pos, |
| const data_t::const_iterator & | end, | ||
| bool | big_endian | ||
| ) | [protected] |
Parse constructor.
Read the PDU header from a buffer and initialize part of the PDU object. Is called by the parse constructors of derived classes. See Parsing incoming PDUs for details about PDU parsing.
| pos | Iterator pointing to the current stream position. The iterator is advanced while reading the header. |
| end | Iterator pointing one element past the end of the current stream. This is needed to mark the end of the buffer. |
| big_endian | Whether the serialized form of the PDU is in big_endian format. |
| parse_error | If parsing fails, for example because reading the stream fails or the PDU is malformed. |
Definition at line 63 of file PDU.cpp.
References any_index, instance_registration, new_index, non_default_context, packetID, read32(), sessionID, and transactionID.
| PDU::PDU | ( | ) | [protected] |
Default constructor.
The members are set as follows:
Definition at line 49 of file PDU.cpp.
References any_index, instance_registration, new_index, non_default_context, packetID, packetID_cnt, sessionID, and transactionID.
| void PDU::add_header | ( | type_t | type, |
| data_t & | payload | ||
| ) | const [protected] |
Construct the PDU header and add it to the payload.
Add the PDU header to the payload. Called by derived classes during serialization.
The header is encoded in big endian format.
| type | The PDU type, according to RFC 2741, 6.1. "AgentX PDU Header". |
| payload | The payload of the PDU. The header is added to the payload, i.e. payload is altered by this function. |
Reimplemented in agentxcpp::PDUwithContext.
Definition at line 191 of file PDU.cpp.
References any_index, instance_registration, new_index, non_default_context, packetID, sessionID, transactionID, and write32().
Referenced by agentxcpp::CleanupSetPDU::serialize(), agentxcpp::UndoSetPDU::serialize(), agentxcpp::CommitSetPDU::serialize(), agentxcpp::ClosePDU::serialize(), agentxcpp::OpenPDU::serialize(), and agentxcpp::ResponsePDU::serialize().
| bool agentxcpp::PDU::get_any_index | ( | ) | [inline] |
| bool agentxcpp::PDU::get_new_index | ( | ) | [inline] |
| uint32_t agentxcpp::PDU::get_packetID | ( | ) | [inline] |
Get packetID.
Definition at line 261 of file PDU.hpp.
References packetID.
Referenced by agentxcpp::master_proxy::connect(), and agentxcpp::master_proxy::disconnect().
| uint32_t agentxcpp::PDU::get_sessionID | ( | ) | [inline] |
| uint32_t agentxcpp::PDU::get_transactionID | ( | ) | [inline] |
| shared_ptr< PDU > PDU::parse_pdu | ( | data_t | buf | ) | [static] |
Parse a PDU from a buffer.
Create a PDU of the according type (e.g. ResponsePDU) from the given buffer. See Parsing incoming PDUs for details about PDU parsing.
| buf | The buffer containing exactly one PDU in serialized form. |
| parse_error | If parsing fails, because the PDU is malformed. |
| version_mismatch | If the AgentX version of the PDU is not 1. |
Definition at line 102 of file PDU.cpp.
References agentxCleanupSetPDU, agentxClosePDU, agentxCommitSetPDU, agentxGetBulkPDU, agentxGetNextPDU, agentxGetPDU, agentxNotifyPDU, agentxOpenPDU, agentxRegisterPDU, agentxResponsePDU, agentxTestSetPDU, agentxUndoSetPDU, agentxUnregisterPDU, and read32().
Referenced by agentxcpp::connector::receive_callback().
| virtual data_t agentxcpp::PDU::serialize | ( | ) | const [pure virtual] |
Serialize function for concrete PDUs.
Implemented in agentxcpp::ResponsePDU, agentxcpp::GetBulkPDU, agentxcpp::RegisterPDU, agentxcpp::OpenPDU, agentxcpp::UnregisterPDU, agentxcpp::ClosePDU, agentxcpp::NotifyPDU, agentxcpp::GetNextPDU, agentxcpp::GetPDU, agentxcpp::TestSetPDU, agentxcpp::CleanupSetPDU, agentxcpp::CommitSetPDU, and agentxcpp::UndoSetPDU.
Referenced by agentxcpp::connector::send().
| void agentxcpp::PDU::set_any_index | ( | bool | any_index | ) | [inline] |
| void agentxcpp::PDU::set_new_index | ( | bool | new_index | ) | [inline] |
| void agentxcpp::PDU::set_packetID | ( | uint32_t | packetID | ) | [inline] |
| void agentxcpp::PDU::set_sessionID | ( | uint32_t | id | ) | [inline] |
Set sessionID.
Definition at line 246 of file PDU.hpp.
References sessionID.
Referenced by agentxcpp::ClosePDU::ClosePDU().
| void agentxcpp::PDU::set_transactionID | ( | uint32_t | id | ) | [inline] |
bool agentxcpp::PDU::any_index [private] |
the any_index flag
Definition at line 65 of file PDU.hpp.
Referenced by add_header(), get_any_index(), PDU(), and set_any_index().
bool agentxcpp::PDU::instance_registration [protected] |
the instance_registration flag
This flag is used only in the RegisterPDU. It is located here, because it is part of the PDU header. It is parsed by the parse constructor of this class and serialized by the add_header() function.
Definition at line 104 of file PDU.hpp.
Referenced by add_header(), agentxcpp::RegisterPDU::get_instance_registration(), PDU(), and agentxcpp::RegisterPDU::set_instance_registration().
bool agentxcpp::PDU::new_index [private] |
the new_index flag
Definition at line 60 of file PDU.hpp.
Referenced by add_header(), get_new_index(), PDU(), and set_new_index().
bool agentxcpp::PDU::non_default_context [protected] |
Whether the PDU has a non-default context.
This field is only meaningful for certain PDU's (see RFC 2741, section 6.1.1 "Context" for a description).
Definition at line 113 of file PDU.hpp.
Referenced by agentxcpp::PDUwithContext::add_header(), add_header(), agentxcpp::PDUwithContext::has_context(), PDU(), agentxcpp::PDUwithContext::PDUwithContext(), agentxcpp::PDUwithContext::remove_context(), and agentxcpp::PDUwithContext::set_context().
uint32_t agentxcpp::PDU::packetID [protected] |
h.packetID field according to RFC 2741, 6.1. "AgentX PDU Header".
Is automatically filled by constructors, is set to another value by ResponsePDU. The PDU class has no setter for this member.
The ResponsePDU is a special case in resepect of packetIDs, therefore this member is protected to allow the ResponsePDU to alter it.
Definition at line 154 of file PDU.hpp.
Referenced by add_header(), get_packetID(), PDU(), and set_packetID().
uint32_t PDU::packetID_cnt = 0 [static, private] |
Counter for automatic packetID generator.
The packetID member is set automatically by the constructors; each new PDU gets a new packetID. This member contains the last used packetID.
The parse constructor does not use this member, because it reads the packetID from a stream.
Definition at line 91 of file PDU.hpp.
Referenced by PDU().
uint32_t agentxcpp::PDU::sessionID [private] |
h.sessionID field
According to RFC 2741, 6.1. "AgentX PDU Header"
Definition at line 72 of file PDU.hpp.
Referenced by add_header(), get_sessionID(), PDU(), and set_sessionID().
uint32_t agentxcpp::PDU::transactionID [private] |
h.transactionID field
According to RFC 2741, 6.1. "AgentX PDU Header"
Definition at line 79 of file PDU.hpp.
Referenced by add_header(), get_transactionID(), PDU(), and set_transactionID().