AgentXcpp  Version:0.3
Internals Documentation
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Pages
agentxcpp::IpAddressVariable Class Reference

Represents an IP address as described in RFC 2741, section 5.4. More...

#include <IpAddressVariable.hpp>

Inheritance diagram for agentxcpp::IpAddressVariable:
Collaboration diagram for agentxcpp::IpAddressVariable:

Public Member Functions

 IpAddressVariable (binary::const_iterator &pos, const binary::const_iterator &end, bool big_endian=true)
 Parse Constructor. More...
 
binary serialize () const
 Encode the object as described in RFC 2741, section 5.4 / 5.3. More...
 
 IpAddressVariable (quint8 a, quint8 b, quint8 c, quint8 d)
 Construct an IpAddressValue object. More...
 
void set_value (quint8 a, quint8 b, quint8 c, quint8 d)
 Set the value. More...
 
quint8 & operator[] (unsigned index)
 Access a component of the stored IpAddress. 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 quint8 _v[4])
 Handle a TestSet request. More...
 
virtual void handle_cleanupset ()
 Handle a CleanupSet request. More...
 
virtual void perform_cleanupset (const quint8 _v[4])
 Perform an SNMP CleanupSet request. More...
 
virtual bool handle_commitset ()
 Handle a CommitSet request. More...
 
virtual bool perform_commitset (const quint8 _v[4])
 Perform an SNMP CommitSet request. More...
 
virtual bool handle_undoset ()
 Handle an UndoSet request. More...
 
virtual bool perform_undoset (const quint8 _v[4])
 Perform an SNMP UndoSet request. More...
 
- Public Member Functions inherited from agentxcpp::AbstractVariable
virtual ~AbstractVariable ()
 Virtual destructor. More...
 

Protected Attributes

quint8 v [4]
 The IP address. More...
 

Private Member Functions

 IpAddressVariable ()
 Hidden default constructor. More...
 

Private Attributes

QSharedPointer< IpAddressVariablenew_value
 The new value for the variable. Used during a Set operation. More...
 

Additional Inherited Members

- Public Types inherited from agentxcpp::AbstractVariable
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...
 

Detailed Description

Represents an IP address as described in RFC 2741, section 5.4.

Definition at line 34 of file IpAddressVariable.hpp.

Constructor & Destructor Documentation

agentxcpp::IpAddressVariable::IpAddressVariable ( )
private

Hidden default constructor.

This constructor is private so it cannot be used to construct objects.

IpAddressVariable::IpAddressVariable ( 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.

Parameters
posIterator pointing to the current stream position. The iterator is advanced while parsing.
endIterator pointing one element past the end of the current stream. This is needed to avoid buffer overrun.
big_endianWhether the input stream is in big endian format.

Definition at line 45 of file IpAddressVariable.cpp.

References agentxcpp::read32(), and v.

agentxcpp::IpAddressVariable::IpAddressVariable ( quint8  a,
quint8  b,
quint8  c,
quint8  d 
)
inline

Construct an IpAddressValue object.

The stored IpAddress is initialized to "a.b.c.d".

Exceptions
None.

Definition at line 87 of file IpAddressVariable.hpp.

Member Function Documentation

virtual void agentxcpp::IpAddressVariable::handle_cleanupset ( )
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 212 of file IpAddressVariable.hpp.

References perform_cleanupset().

virtual bool agentxcpp::IpAddressVariable::handle_commitset ( )
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).

Returns
The return value of perform_commitset().

Implements agentxcpp::AbstractVariable.

Definition at line 230 of file IpAddressVariable.hpp.

References perform_commitset().

virtual void agentxcpp::IpAddressVariable::handle_get ( )
inlinevirtual

Handle a Get Request.

This function calls perform_get() to update the internal value.

Implements agentxcpp::AbstractVariable.

Definition at line 164 of file IpAddressVariable.hpp.

References perform_get().

virtual testset_result_t agentxcpp::IpAddressVariable::handle_testset ( QSharedPointer< AbstractVariable _v)
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.

Parameters
_vThe new value for the variable.
Returns
AbstractVariable::wrongType if the conversion fails. Otherwise, the result of perform_testset() is returned.

Implements agentxcpp::AbstractVariable.

Definition at line 181 of file IpAddressVariable.hpp.

References perform_testset(), and agentxcpp::AbstractVariable::wrongType.

virtual bool agentxcpp::IpAddressVariable::handle_undoset ( )
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).

Returns
The return value of perform_undoset().

Implements agentxcpp::AbstractVariable.

Definition at line 248 of file IpAddressVariable.hpp.

References perform_undoset().

quint8& agentxcpp::IpAddressVariable::operator[] ( unsigned  index)
inline

Access a component of the stored IpAddress.

This function returns the component with the given index. Note that exactly 4 components are stored. The return value is a reference to the component, so that it can be read/written, in other words, the IpAddressValue object can be accessed like an ordinary array.

Parameters
indexThe index (value in the range 0...3).
Returns
A reference to the component.
Exceptions
inval_paramIf the index is out of bound.

Definition at line 132 of file IpAddressVariable.hpp.

virtual void agentxcpp::IpAddressVariable::perform_cleanupset ( const quint8  _v[4])
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.

Parameters
_vThe value to which the variable was (possibly) set.

Definition at line 220 of file IpAddressVariable.hpp.

Referenced by handle_cleanupset().

virtual bool agentxcpp::IpAddressVariable::perform_commitset ( const quint8  _v[4])
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.

Parameters
_vThe value which shall be written.
Returns
True if the operation succeeded, false otherwise.

Definition at line 238 of file IpAddressVariable.hpp.

Referenced by handle_commitset().

virtual void agentxcpp::IpAddressVariable::perform_get ( )
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 172 of file IpAddressVariable.hpp.

Referenced by handle_get().

virtual testset_result_t agentxcpp::IpAddressVariable::perform_testset ( const quint8  _v[4])
inlinevirtual

Handle a TestSet request.

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.

Parameters
_vThe new value provided by the master agent.
Returns
The result of the check (this is reported to the master agent).

Definition at line 202 of file IpAddressVariable.hpp.

References agentxcpp::AbstractVariable::noAccess.

Referenced by handle_testset().

virtual bool agentxcpp::IpAddressVariable::perform_undoset ( const quint8  _v[4])
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.

Parameters
_vThe value just set by perform_commitset().
Returns
True on success, false otherwise.

Definition at line 256 of file IpAddressVariable.hpp.

Referenced by handle_undoset().

binary IpAddressVariable::serialize ( ) const
virtual

Encode the object as described in RFC 2741, section 5.4 / 5.3.

Note: We always use big endian.

Implements agentxcpp::AbstractVariable.

Definition at line 25 of file IpAddressVariable.cpp.

References v.

void agentxcpp::IpAddressVariable::set_value ( quint8  a,
quint8  b,
quint8  c,
quint8  d 
)
inline

Set the value.

The stored IpAddress is updated to "a.b.c.d".

Exceptions
None.

Definition at line 106 of file IpAddressVariable.hpp.

virtual Oid agentxcpp::IpAddressVariable::toOid ( ) const
inlinevirtual

Convert the value to an OID.

The conversion is done according to RFC 2578, 7.7. "Mapping of the INDEX clause". The created OID has exactly 4 subids which corresponds to the 4 integers of the IP address.

Implements agentxcpp::AbstractVariable.

Definition at line 149 of file IpAddressVariable.hpp.

Member Data Documentation

QSharedPointer<IpAddressVariable> agentxcpp::IpAddressVariable::new_value
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 56 of file IpAddressVariable.hpp.

quint8 agentxcpp::IpAddressVariable::v[4]
protected

The IP address.

According to RFC 2578, IpAddress is a 32-bit number.

Definition at line 42 of file IpAddressVariable.hpp.

Referenced by IpAddressVariable(), and serialize().


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