Represents an SNMP OBJECT-IDENTENTIFIER variable. More...
#include <OidVariable.hpp>
Public Member Functions | |
OidVariable (const Oid &o) | |
Initialize an OidVariable object with an Oid. More... | |
OidVariable () | |
Default constructor. More... | |
Oid | value () |
Get the current value. More... | |
void | setValue (const Oid &_value) |
Set the value. More... | |
binary | serialize () const |
Encode the object as described in RFC 2741, section 5.4. More... | |
OidVariable (binary::const_iterator &pos, const binary::const_iterator &end, bool big_endian=true) | |
Parse Constructor. More... | |
virtual Oid | toOid () const |
Convert the value to an OID. More... | |
virtual void | handle_get () |
Handle a Get Request. More... | |
virtual void | perform_get () |
Perform a Get request. More... | |
virtual testset_result_t | handle_testset (QSharedPointer< AbstractVariable > _v) |
Handle a TestSet request. More... | |
virtual testset_result_t | perform_testset (const Oid &_v) |
Perform an SNMP TestSet request. More... | |
virtual void | handle_cleanupset () |
Handle a CleanupSet request. More... | |
virtual void | perform_cleanupset (const Oid &_v) |
Perform an SNMP CleanupSet request. More... | |
virtual bool | handle_commitset () |
Handle a CommitSet request. More... | |
virtual bool | perform_commitset (const Oid &_v) |
Perform an SNMP CommitSet request. More... | |
virtual bool | handle_undoset () |
Handle an UndoSet request. More... | |
virtual bool | perform_undoset (const Oid &_v) |
Perform an SNMP UndoSet request. More... | |
![]() | |
virtual | ~AbstractVariable () |
Virtual destructor. More... | |
Protected Attributes | |
Oid | v |
The value represented by this variable. More... | |
Private Attributes | |
QSharedPointer< OidVariable > | new_value |
The new value for the variable. Used during a Set operation. More... | |
Additional Inherited Members | |
![]() | |
enum | testset_result_t { noError = 0, genErr = 5, noAccess = 6, wrongType = 7, wrongLength = 8, wrongValue = 10, noCreation = 11, inconsistentValue = 12, resourceUnavailable = 13, notWritable = 17, inconsistentName = 18 } |
Result type for the TestSet validation. More... | |
Represents an SNMP OBJECT-IDENTENTIFIER variable.
The agentXcpp library distinguishes between Oid and OidVariable types. An Oid is a sequence of numbers, while OidVariable is an SNMP variable representing an Oid. That means, that Get and Set requests are possible on OidVariable's, but not on Oid's.
Definition at line 41 of file OidVariable.hpp.
OidVariable::OidVariable | ( | const Oid & | o | ) |
Initialize an OidVariable object with an Oid.
The internal value is set to the provided Oid.
o | The initial Oid. |
None. |
Definition at line 29 of file OidVariable.cpp.
|
inline |
Default constructor.
Initialize the value to the null Oid.
Definition at line 74 of file OidVariable.hpp.
OidVariable::OidVariable | ( | binary::const_iterator & | pos, |
const binary::const_iterator & | end, | ||
bool | big_endian = true |
||
) |
Parse Constructor.
This constructor parses the serialized form of the object. It takes an iterator, starts parsing at the position of the iterator and advances the iterator to the position right behind the object.
The constructor expects valid data from the stream; if parsing fails, parse_error is thrown. In this case, the iterator position is undefined.
pos | Iterator pointing to the current stream position. The iterator is advanced while parsing. |
end | Iterator pointing one element past the end of the current stream. This is needed to avoid buffer overrun. |
big_endian | Whether the input stream is in big endian format. |
Definition at line 106 of file OidVariable.cpp.
|
inlinevirtual |
Handle a CleanupSet request.
This function calls perform_cleanupset() with the internal value of new_value (which was updated by the last handle_testset() invocation).
Implements agentxcpp::AbstractVariable.
Definition at line 200 of file OidVariable.hpp.
References perform_cleanupset().
|
inlinevirtual |
Handle a CommitSet request.
This function calls perform_commitset() with the internal value of new_value (which was updated by the last handle_testset() invocation).
Implements agentxcpp::AbstractVariable.
Definition at line 218 of file OidVariable.hpp.
References perform_commitset().
|
inlinevirtual |
Handle a Get Request.
This function calls perform_get() to update the internal value.
Implements agentxcpp::AbstractVariable.
Definition at line 154 of file OidVariable.hpp.
References perform_get().
|
inlinevirtual |
Handle a TestSet request.
This function converts the argument, stores it in new_value and then calls perform_testset() with the internal value of new_value. If conversion fails, AbstractVariable::wrongType is returned and perform_testset() is not called.
_v | The new value for the variable. |
Implements agentxcpp::AbstractVariable.
Definition at line 171 of file OidVariable.hpp.
References perform_testset(), and agentxcpp::AbstractVariable::wrongType.
|
inlinevirtual |
Handle an UndoSet request.
This function calls perform_undoset() with the internal value of new_value (which was updated by the last handle_testset() invocation).
Implements agentxcpp::AbstractVariable.
Definition at line 236 of file OidVariable.hpp.
References perform_undoset().
|
inlinevirtual |
Perform an SNMP CleanupSet request.
This method is invoked when an SNMP CleanupSet request is received. It shall release any resources allocated by perform_testset().
The default implementation does nothing. If no action is required to perform the CleanupSet operation, this method need not be overridden.
_v | The value to which the variable was (possibly) set. |
Definition at line 208 of file OidVariable.hpp.
Referenced by handle_cleanupset().
|
inlinevirtual |
Perform an SNMP CommitSet request.
This method is invoked when an SNMP CommitSet request is received. It shall perform the actual write operation.
The default implementation returns false to indicate that the operation failed. To implement a writeable SNMP variable this method must be overridden.
_v | The value which shall be written. |
Definition at line 226 of file OidVariable.hpp.
Referenced by handle_commitset().
|
inlinevirtual |
Perform a Get request.
This method is invoked when an SNMP Get request is received. It should update the internal value v.
Definition at line 162 of file OidVariable.hpp.
Referenced by handle_get().
|
inlinevirtual |
Perform an SNMP TestSet request.
This method is invoked when an SNMP TestSet request is received. It shall check whether a Set operation is possible for the variable. It shall acquire the resources needed to perform the Set operation (but the Set operation shall not yet be performed).
The default implementation returns AbstractVariable::noAccess to indicate that this is a read-only variable. Thus, for read-only variables this method need not be overridden.
_v | The new value provided by the master agent. |
Definition at line 190 of file OidVariable.hpp.
References agentxcpp::AbstractVariable::noAccess.
Referenced by handle_testset().
|
inlinevirtual |
Perform an SNMP UndoSet request.
This method is invoked when an SNMP UndoSet request is received. It shall undo whatever perform_commitset() performed. It shall also release all resources allocated by perform_testset(), because perform_cleanupset() will not be called afterwards.
The default implementation returns false to indicate that the operation failed. It is strongly recommended that writeable variables override this method.
A default implementation is provided to allow implementing read-only variables.
_v | The value just set by perform_commitset(). |
Definition at line 245 of file OidVariable.hpp.
Referenced by handle_undoset().
|
virtual |
Encode the object as described in RFC 2741, section 5.4.
This function uses big endian.
Implements agentxcpp::AbstractVariable.
Definition at line 35 of file OidVariable.cpp.
Referenced by agentxcpp::GetPDU::serialize(), agentxcpp::GetNextPDU::serialize(), agentxcpp::RemoveAgentCapsPDU::serialize(), agentxcpp::UnregisterPDU::serialize(), agentxcpp::OpenPDU::serialize(), agentxcpp::AddAgentCapsPDU::serialize(), agentxcpp::RegisterPDU::serialize(), agentxcpp::GetBulkPDU::serialize(), and agentxcpp::Varbind::serialize().
|
inline |
|
inlinevirtual |
Convert the value to an OID.
The conversion is done according to RFC 2578, 7.7. "Mapping of the INDEX clause". First, the length of the OID (i.e. the number of subid's it has) is converted to a subid. Then, each subid of the value is appended.
None. |
Implements agentxcpp::AbstractVariable.
Definition at line 130 of file OidVariable.hpp.
References v.
|
inline |
Get the current value.
Definition at line 83 of file OidVariable.hpp.
References v.
Referenced by agentxcpp::AddAgentCapsPDU::AddAgentCapsPDU(), agentxcpp::GetBulkPDU::GetBulkPDU(), agentxcpp::GetNextPDU::GetNextPDU(), agentxcpp::OpenPDU::OpenPDU(), agentxcpp::RegisterPDU::RegisterPDU(), agentxcpp::RemoveAgentCapsPDU::RemoveAgentCapsPDU(), agentxcpp::UnregisterPDU::UnregisterPDU(), and agentxcpp::Varbind::Varbind().
|
private |
The new value for the variable. Used during a Set operation.
The Set operation is performed in up to four steps (TestSet, CommitSet, CleanupSet, UndoSet). Only the TestSet step actually receives the new value. This value is stored here so that it can be delivered to perform_commitset(), perform_undoset() and perform_cleanupset().
Definition at line 54 of file OidVariable.hpp.
|
protected |
The value represented by this variable.
Definition at line 47 of file OidVariable.hpp.