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 binary | serialize () const =0 |
| Serialize function for concrete PDUs. | |
Static Public Member Functions | |
| static shared_ptr< PDU > | parse_pdu (binary 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 (binary::const_iterator &pos, const binary::const_iterator &end, bool big_endian) | |
| Parse constructor. | |
| void | add_header (type_t type, binary &payload) const |
| Construct the PDU header and add it to the payload. | |
| PDU () | |
| Default constructor. | |
| virtual | ~PDU () |
| Destructor. | |
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.
|
protected |
The PDU types.
According to RFC 2741, section 6.1 "AgentX PDU Header".
|
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, agentxcpp::read32(), sessionID, and transactionID.
|
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.
|
inlineprotectedvirtual |
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 agentxcpp::write32().
Referenced by agentxcpp::CleanupSetPDU::serialize(), agentxcpp::UndoSetPDU::serialize(), agentxcpp::CommitSetPDU::serialize(), agentxcpp::ClosePDU::serialize(), agentxcpp::OpenPDU::serialize(), and agentxcpp::ResponsePDU::serialize().
|
inline |
|
inline |
|
inline |
Get packetID.
Definition at line 271 of file PDU.hpp.
References packetID.
Referenced by agentxcpp::master_proxy::connect(), and agentxcpp::master_proxy::disconnect().
|
inline |
|
inline |
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 agentxcpp::read32().
Referenced by agentxcpp::connector::receive_callback().
|
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().
|
inline |
|
inline |
|
inline |
Set packetID.
Definition at line 276 of file PDU.hpp.
References packetID.
Referenced by agentxcpp::master_proxy::handle_pdu().
|
inline |
Set sessionID.
Definition at line 256 of file PDU.hpp.
References sessionID.
Referenced by agentxcpp::ClosePDU::ClosePDU(), and agentxcpp::master_proxy::handle_pdu().
|
inline |
Set transactionID.
Definition at line 266 of file PDU.hpp.
References transactionID.
Referenced by agentxcpp::master_proxy::handle_pdu().
|
private |
the any_index flag
Definition at line 68 of file PDU.hpp.
Referenced by add_header(), get_any_index(), PDU(), and set_any_index().
|
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 107 of file PDU.hpp.
Referenced by add_header(), agentxcpp::RegisterPDU::get_instance_registration(), PDU(), and agentxcpp::RegisterPDU::set_instance_registration().
|
private |
the new_index flag
Definition at line 63 of file PDU.hpp.
Referenced by add_header(), get_new_index(), PDU(), and set_new_index().
|
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 116 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().
|
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 157 of file PDU.hpp.
Referenced by add_header(), get_packetID(), PDU(), and set_packetID().
|
staticprivate |
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 94 of file PDU.hpp.
Referenced by PDU().
|
private |
h.sessionID field
According to RFC 2741, 6.1. "AgentX PDU Header"
Definition at line 75 of file PDU.hpp.
Referenced by add_header(), get_sessionID(), PDU(), and set_sessionID().
|
private |
h.transactionID field
According to RFC 2741, 6.1. "AgentX PDU Header"
Definition at line 82 of file PDU.hpp.
Referenced by add_header(), get_transactionID(), PDU(), and set_transactionID().