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

This class represents the master agent in a subagent program. More...

#include <MasterProxy.hpp>

Inheritance diagram for agentxcpp::MasterProxy:
Collaboration diagram for agentxcpp::MasterProxy:

Public Slots

virtual void handle_pdu (QSharedPointer< PDU >)
 The dispatcher for incoming PDU's. More...
 
void send_notification (const Oid &snmpTrapOID, const TimeTicksVariable *sysUpTime, const std::vector< Varbind > &varbinds=vector< Varbind >())
 Send a notification or trap. More...
 
void send_notification (const Oid &snmpTrapOID, const std::vector< Varbind > &varbinds=vector< Varbind >())
 Writing aid: Send notification without sysUpTime.0. More...
 

Public Member Functions

 MasterProxy (std::string description="", quint8 default_timeout=0, Oid ID=Oid(), std::string unix_domain_socket="/var/agentx/master")
 Create a session object connected via unix domain socket. More...
 
void register_subtree (Oid subtree, quint8 priority=127, quint8 timeout=0)
 Register a subtree with the master agent. More...
 
void unregister_subtree (Oid subtree, quint8 priority=127)
 Unregister a subtree with the master agent. More...
 
bool is_connected ()
 Check whether the session is in state connected. More...
 
void connect ()
 Connect to the master agent. More...
 
void disconnect (ClosePDU::reason_t reason=ClosePDU::reasonShutdown)
 Shutdown the session. More...
 
void reconnect ()
 Reconnect to the master agent. More...
 
quint32 get_sessionID ()
 Get the sessionID of the session. More...
 
 ~MasterProxy ()
 Destructor. More...
 
void add_variable (const Oid &id, QSharedPointer< AbstractVariable > v)
 Add an SNMP variable for serving. More...
 
void addVariables (QVector< QPair< Oid, QSharedPointer< AbstractVariable > > > vars)
 Add several SNMP variables for serving. More...
 
void remove_variable (const Oid &id)
 Remove an SNMP variable so that is not longer accessible. More...
 
void removeVariables (const QVector< Oid > &ids)
 Remove several SNMP variables so that they are not longer accessible. More...
 
bool isRegistered (Oid id)
 Check whether an OID is within the registered ranges. More...
 

Private Member Functions

void do_registration (QSharedPointer< RegisterPDU > pdu)
 Send a RegisterPDU to the master agent. More...
 
void undo_registration (QSharedPointer< UnregisterPDU > pdu)
 Send a UnregisterPDU to the master agent. More...
 
QSharedPointer< UnregisterPDUcreate_unregister_pdu (QSharedPointer< RegisterPDU > pdu)
 Create UnregisterPDU for undoing a registration. More...
 
void handle_getpdu (QSharedPointer< ResponsePDU > response, QSharedPointer< GetPDU > get_pdu)
 Handle incoming GetPDU's. More...
 
void handle_getnextpdu (QSharedPointer< ResponsePDU > response, QSharedPointer< GetNextPDU > getnext_pdu)
 Handle incoming GetNextPDU's. More...
 
void handle_testsetpdu (QSharedPointer< ResponsePDU > response, QSharedPointer< TestSetPDU > testset_pdu)
 Handle incoming TestSetPDU's. More...
 
void handle_cleanupsetpdu ()
 Handle incoming CleanupSetPDU's. More...
 
void handle_commitsetpdu (QSharedPointer< ResponsePDU > response, QSharedPointer< CommitSetPDU > commitset_pdu)
 Handle incoming CommitSetPDU's. More...
 
void handle_undosetpdu (QSharedPointer< ResponsePDU > response, QSharedPointer< UndoSetPDU > undoset_pdu)
 Handle incoming UndoSetPDU's. More...
 

Private Attributes

QThread m_thread
 The thread running a UnixDomainConnector. More...
 
std::string socket_file
 The path to the unix domain socket. More...
 
UnixDomainConnectorconnection
 The connector object used for networking. More...
 
quint32 sessionID
 The session ID of the current session. More...
 
std::string description
 A string describing the subagent. More...
 
quint8 default_timeout
 Default timeout of the session (in seconds). More...
 
Oid id
 An Object Identifier that identifies the subagent. May be the null OID. More...
 
std::list< QSharedPointer
< RegisterPDU > > 
registrations
 The registrations. More...
 
std::map< Oid, QSharedPointer
< AbstractVariable > > 
variables
 Storage for all SNMP variables known to the MasterProxy. More...
 
std::list< QSharedPointer
< AbstractVariable > > 
setlist
 The variables affected by the Set operation currently in progress. More...
 

Detailed Description

This class represents the master agent in a subagent program.

Introduction

This class is used on the subagent's side of a connection between subagent and master agent. It serves as a proxy which represents the master agent. It is possible for a subagent to hold connections to more than one master agents. For each connection one MasterProxy object is created. Multiple connections to the same master agent are possible, too, in which case one MasterProxy per connection is needed.

Connection State

The MasterProxy is always in one of the following states:

  • connected
  • disconnected

The session to the master agent is established when creating a MasterProxy object, thus the object usually starts in connected state. If that fails, the object starts in disconnected state. A connected MasterProxy object may also loose the connection to the master agent and consequently become disconnected, without informing the user. It is possible to re-connect with the reconnect() function at any time (even if the session is currently established - it will be shut down and re-established in this case). When the object is destroyed, the session will be cleanly shut down. The connection state can be inspected with the is_connected() function. Some functions throw a disconnected exception if the session is not currently established.

The QApplication object

The agentXcpp library uses the QT library. Processing SNMP requests (such as get and set) is performed within the QApplication event loop. Therefore, a program using agentXcpp must create a QApplication object and call exec() on it to start the event loop. The agentXcpp library also creates a QThread object for the networking part. Networking is done within the event loop of that thread.

Registrations

Before the master agent sends requests to a subagent, the subagent must register a subtree. Doing so informs the master agent that the subagent wishes to handle requests for these OIDs. A subtree is an OID which denotes the root of a subtree in which the offered objects resides. For example, when two objects shall be offered with the OIDs 1.3.6.1.4.1.42.1.1 and 1.3.6.1.4.1.42.1.2, then a subtree with OID 1.3.6.1.4.1.42.1 should be registered, which includes both objects. The master agent will then forward all requests concerning objects in this subtree to this subagent. Requests to non-existing objects (e.g. 1.3.6.1.4.1.42.1.3) are also forwarded, and the agentXcpp library will take care of them and return an appropriate error to the master agent.

The function register_subtree() is used to register a subtree. It is typically called for the highest-level OID of the MIB which is implemented by the subagent. However, it is entirely possible to register multiple subtrees.

Identical subtrees are subtrees with the exact same root OID. Each registration is done with a priority value. The higher the value, the lower the priority. When identical subtrees are registered (by the same subagent or by different subagents), the priority value is used to decide which subagent gets the requests. The master refuses identical registrations with the same priority values. Note however, that in case of overlapping subtrees which are not identical (e.g. 1.3.6.1.4.1.42.1 and 1.3.6.1.4.1.42.1.33.1), the most specific subtree (i.e. the one with the longest OID) wins regardless of the priority values.

It is also possible to unregister subtrees using the unregister_subtree() function. This informs the master agent that the MIB region is no longer available from this subagent.

The MasterProxy object generates a RegisterPDU object each time a registration is performed. These RegisterPDU objects are stored in the MasterProxy::registrations member.

When unregistering, the matching RegisterPDU is removed from the registration member.

The MasterProxy::registration member becomes invalid on connection loss. Since a connection loss is not signaled, the member cannot be cleared in such situations. Therefore, it is cleared in the connect() method if the object is currently disconnected. If connect() is called on a connected MasterProxy object, the registrations member is not cleared.

Adding and Removing Variables

Registering a subtree does not make any SNMP variables accessible yet. To provide SNMP variables, they must be added to the MasterProxy object, e.g. using add_variable(). The MasterProxy object will then dispatch incoming requests to the variables it knows about. If a request is received for an OID for which no variable has been added, an appropriate error is returned to the master agent.

Added variables can be removed again using remove_variable(). This makes a variable inaccessible for the master agent.

The variables are stored in the member variables, which is a std::map<Oid, QSharedPointer<variable> >. The key is the OID for which the variable was added. This allows easy lookup for the request dispatcher.

When removing a variable, it is removed from the variables member.

The variables member becomes invalid on connection loss. Since a connection loss is not signaled, the member cannot be cleared in such situations. Therefore, it is cleared in the connect() method if the object is currently disconnected. If connect() is called on a connected MasterProxy object, the variables member is not cleared.

Internals

Receiving and processing PDU's coming from the master is done using the UnixDomainConnector class. The MasterProxy implements the handle_pdu() slot, which is connected to the UnixDomainConnector::pduArrived() signal.

Todo:

Describe timeout handling

Byte ordering is constant for a session. See rfc 2741, 7.1.1

Definition at line 194 of file MasterProxy.hpp.

Constructor & Destructor Documentation

MasterProxy::MasterProxy ( std::string  description = "",
quint8  default_timeout = 0,
Oid  ID = Oid(),
std::string  unix_domain_socket = "/var/agentx/master" 
)

Create a session object connected via unix domain socket.

This constructor tries to connect to the master agent. If that fails, the object is created nevertheless and will be in state disconnected.

Parameters
descriptionA string describing the subagent. This description cannot be changed later.
default_timeoutThe length of time, in seconds, that the master agent should allow to elapse before it regards the subagent as not responding. The value is also used when waiting synchronously for data from the master agent (e.g. when registering stuff). Allowed values are 0-255, with 0 meaning "no default for this session".
IDAn Object Identifier that identifies the subagent. Default is the null OID (no ID).
unix_domain_socketThe socket file to connect to. Defaults to /var/agentx/master, as described in RFC 2741, section 8.2.1 "Well-known Values".

Definition at line 43 of file MasterProxy.cpp.

References connect(), connection, default_timeout, and m_thread.

MasterProxy::~MasterProxy ( )

Destructor.

The destructor cleanly shuts down the session (if it is currently established) with the reason 'Shutdown' and destroys the MasterProxy object.

Definition at line 198 of file MasterProxy.cpp.

References connection, disconnect(), and agentxcpp::ClosePDU::reasonShutdown.

Member Function Documentation

void MasterProxy::add_variable ( const Oid id,
QSharedPointer< AbstractVariable v 
)

Add an SNMP variable for serving.

This adds an SNMP variable which can then be read and/or written.

Variables can only be added to MIB regions which were registered in advance.

If adding a variable with an id for which another variable is already registered, it replaces the old one.

Parameters
idThe OID of the variable.
vThe variable.
Exceptions
unknown_registrationIf trying to add a variable with an id which does not reside within a registered MIB region.

Definition at line 872 of file MasterProxy.cpp.

References id, registrations, and variables.

Referenced by addVariables().

void MasterProxy::addVariables ( QVector< QPair< Oid, QSharedPointer< AbstractVariable > > >  vars)

Add several SNMP variables for serving.

This function takes multiple variables and calls agentxcpp::add_variable(const Oid&, QSharedPointer<AbstractVariable>) for each of them.

Parameters
varsThe variables to be added. Each QPair object contains an OID and the pointer to the variable; see agentxcpp::add_variable(const Oid&, QSharedPointer<AbstractVariable>) for an explanation.
Exceptions
unknown_registrationIf trying to add a variable with an id which does not reside within a registered MIB region.

Definition at line 858 of file MasterProxy.cpp.

References add_variable().

Referenced by agentxcpp::Table::addEntry().

void MasterProxy::connect ( )

Connect to the master agent.

Note
Upon creation of a MasterProxy object, the connection is automatically established. If the current state is "connected", the function does nothing.
Exceptions
disconnectedIf connecting fails.

Definition at line 84 of file MasterProxy.cpp.

References agentxcpp::UnixDomainConnector::connect(), connection, default_timeout, handle_pdu(), agentxcpp::ResponsePDU::noAgentXError, registrations, agentxcpp::UnixDomainConnector::request(), sessionID, and variables.

Referenced by MasterProxy().

QSharedPointer< UnregisterPDU > MasterProxy::create_unregister_pdu ( QSharedPointer< RegisterPDU pdu)
private

Create UnregisterPDU for undoing a registration.

This function creates an UnregisterPDU which unregisters the MIB region which was registered with the given RegisterPDU.

Parameters
pduThe RegisterPDU which was used for registration.
Returns
The created UnregisterPDU.
Exceptions
None.

Definition at line 427 of file MasterProxy.cpp.

Referenced by disconnect(), and unregister_subtree().

void MasterProxy::disconnect ( ClosePDU::reason_t  reason = ClosePDU::reasonShutdown)

Shutdown the session.

Disconnect from the master agent.

Note
Upon destruction of a MasterProxy object the session is automatically shutdown. If the session is in state "disconnected", this function does nothing.
Parameters
reasonThe shutdown reason is reported to the master agent during shutdown.
Exceptions
None.

Definition at line 144 of file MasterProxy.cpp.

References connection, create_unregister_pdu(), agentxcpp::ResponsePDU::noAgentXError, registrations, agentxcpp::UnixDomainConnector::request(), sessionID, and undo_registration().

Referenced by send_notification(), and ~MasterProxy().

void MasterProxy::do_registration ( QSharedPointer< RegisterPDU pdu)
private

Send a RegisterPDU to the master agent.

This function sends a RegisterPDU to the master agent, waits for the response and evaluates it.

Parameters
pduThe RegisterPDU to send.
Exceptions
disconnectedIf the MasterProxy is currently in state 'disconnected'.
timeout_errorIf the master agent does not respond within the timeout interval.
internal_errorIf the master received a malformed PDU. This is probably a programming error within the agentXcpp library.
master_is_unableThe master agent was unable to perform the desired register request. The reason for that is unknown.
duplicate_registrationIf the exact same subtree was already registered, either by another subagent or by this subagent.
master_is_unwillingIf the master was unwilling for some reason to make the desired registration.
parse_errorIf an unexpected response was received from the master. This is probably a programming error within the master agent. It is possible that the master actually performed the desired registration and that a retry will result in a duplicate_registration error.

Definition at line 209 of file MasterProxy.cpp.

References connection, agentxcpp::ResponsePDU::duplicateRegistration, agentxcpp::ResponsePDU::noAgentXError, agentxcpp::ResponsePDU::notOpen, agentxcpp::ResponsePDU::parseError, agentxcpp::ResponsePDU::processingError, agentxcpp::UnixDomainConnector::request(), agentxcpp::ResponsePDU::requestDenied, and agentxcpp::ResponsePDU::unsupportedContext.

Referenced by register_subtree().

quint32 agentxcpp::MasterProxy::get_sessionID ( )
inline

Get the sessionID of the session.

Get the session ID of the last established session, even if the current state is "disconnected".

Returns
The session ID of the last established session. If object was never connected to the master, 0 is returned.

Definition at line 728 of file MasterProxy.hpp.

References sessionID.

void MasterProxy::handle_cleanupsetpdu ( )
private

Handle incoming CleanupSetPDU's.

This method is called by handle_pdu(). It calls the CleanupSet handler for each variable in 'setlist'.

Definition at line 645 of file MasterProxy.cpp.

References setlist.

Referenced by handle_pdu(), and handle_testsetpdu().

void MasterProxy::handle_commitsetpdu ( QSharedPointer< ResponsePDU response,
QSharedPointer< CommitSetPDU commitset_pdu 
)
private

Handle incoming CommitSetPDU's.

This method is called by handle_pdu(). It processes the given CommitSetPDU and stores the results in the given ResponsePDU.

Parameters
responseThe pre-initialized ResponsePDU.
commitset_pduThe CommitSetPDU to be processed.

Definition at line 663 of file MasterProxy.cpp.

References agentxcpp::ResponsePDU::commitFailed, agentxcpp::ResponsePDU::noAgentXError, and setlist.

Referenced by handle_pdu().

void MasterProxy::handle_getnextpdu ( QSharedPointer< ResponsePDU response,
QSharedPointer< GetNextPDU getnext_pdu 
)
private

Handle incoming GetNextPDU's.

This method is called by handle_pdu(). It processes the given GetNextPDU and stores the results in the given ResponsePDU (i.e. it adds Varbinds to the ResponsePDU).

Parameters
responseThe pre-initialized ResponsePDU. Varbinds are added to this PDU during processing.
getnext_pduThe GetNextPDU to be processed.

Definition at line 510 of file MasterProxy.cpp.

References agentxcpp::Varbind::endOfMibView, agentxcpp::ResponsePDU::genErr, agentxcpp::Oid::include(), agentxcpp::Oid::is_null(), and variables.

Referenced by handle_pdu().

void MasterProxy::handle_getpdu ( QSharedPointer< ResponsePDU response,
QSharedPointer< GetPDU get_pdu 
)
private

Handle incoming GetPDU's.

This method is called by handle_pdu(). It processes the given GetPDU and stores the results in the given ResponsePDU (i.e. it adds varbinds to the ResponsePDU).

Parameters
responseThe pre-initialized ResponsePDU. Varbinds are added to this PDU during processing.
get_pduThe GetPDU to be processed.

Definition at line 440 of file MasterProxy.cpp.

References agentxcpp::ResponsePDU::genErr, agentxcpp::Varbind::noSuchInstance, agentxcpp::Varbind::noSuchObject, and variables.

Referenced by handle_pdu().

void MasterProxy::handle_pdu ( QSharedPointer< PDU pdu)
virtualslot

The dispatcher for incoming PDU's.

This slot is connected to UnixDomainConnector::pduArrived() and thus called for each incoming PDU (except ResponsePDU's).

This method performs the steps described in RFC 2741, 7.2.2. "Subagent Processing" (except for the steps necessary for ResponsePDU handling) and calls the methods handle_*() to handle the individual PDU types. A ResponsePDU is created here and given to the specialized methods to add their results. Finally handle_pdu() sends the response.

Definition at line 730 of file MasterProxy.cpp.

References connection, handle_cleanupsetpdu(), handle_commitsetpdu(), handle_getnextpdu(), handle_getpdu(), handle_testsetpdu(), handle_undosetpdu(), agentxcpp::ResponsePDU::noAgentXError, agentxcpp::ResponsePDU::notOpen, agentxcpp::UnixDomainConnector::send(), and sessionID.

Referenced by connect().

void MasterProxy::handle_testsetpdu ( QSharedPointer< ResponsePDU response,
QSharedPointer< TestSetPDU testset_pdu 
)
private

Handle incoming TestSetPDU's.

This method is called by handle_pdu(). It processes the given TestSetPDU and stores the results in the given ResponsePDU.

Parameters
responseThe pre-initialized ResponsePDU.
testset_pduThe TestSetPDU to be processed.

Definition at line 586 of file MasterProxy.cpp.

References handle_cleanupsetpdu(), agentxcpp::ResponsePDU::noAgentXError, agentxcpp::ResponsePDU::notWritable, setlist, and variables.

Referenced by handle_pdu().

void MasterProxy::handle_undosetpdu ( QSharedPointer< ResponsePDU response,
QSharedPointer< UndoSetPDU undoset_pdu 
)
private

Handle incoming UndoSetPDU's.

This method is called by handle_pdu(). It processes the given UndoSetPDU and stores the results in the given ResponsePDU.

Parameters
responseThe pre-initialized ResponsePDU.
undoset_pduThe UndoSetPDU to be processed.

Definition at line 691 of file MasterProxy.cpp.

References agentxcpp::ResponsePDU::noAgentXError, setlist, and agentxcpp::ResponsePDU::undoFailed.

Referenced by handle_pdu().

bool agentxcpp::MasterProxy::is_connected ( )
inline

Check whether the session is in state connected.

Returns
true if the session is connected, false otherwise.

Definition at line 670 of file MasterProxy.hpp.

References agentxcpp::UnixDomainConnector::is_connected().

bool MasterProxy::isRegistered ( Oid  id)

Check whether an OID is within the registered ranges.

This function checks whether the given OID is with an OID range which was registered before.

Parameters
idThe OID to check.
Returns
true if it is with an registered range, false otherwise.
Exceptions
None.

Definition at line 902 of file MasterProxy.cpp.

References registrations.

void agentxcpp::MasterProxy::reconnect ( )
inline

Reconnect to the master agent.

Disconnects from the master (only if currently connected), then connects again.

Exceptions
disconnectedIf connecting fails.

Definition at line 710 of file MasterProxy.hpp.

References agentxcpp::UnixDomainConnector::connect(), and agentxcpp::UnixDomainConnector::disconnect().

void MasterProxy::register_subtree ( Oid  subtree,
quint8  priority = 127,
quint8  timeout = 0 
)

Register a subtree with the master agent.

This function registers a subtree (or MIB region).

This method adds the registered subtree to registrations on success.

Parameters
subtreeThe (root of the) subtree to register.
priorityThe priority with which to register the subtree. Default is 127 according to RFC 2741, 6.2.3. "The agentx-Register-PDU".
timeoutThe timeout value for the registered subtree, in seconds. This value overrides the timeout of the session. Default value is 0 (no override) according to RFC 2741, 6.2.3. "The agentx-Register-PDU".
Exceptions
disconnectedIf the MasterProxy is currently in state 'disconnected'.
timeout_exceptionIf the master agent does not respond within the timeout interval.
master_is_unableThe master agent was unable to perform the desired register request. The reason for that is unknown.
duplicate_registrationIf the exact same subtree was already registered, either by another subagent or by this subagent.
master_is_unwillingIf the master was unwilling for some reason to make the desired registration.
parse_errorA malformed network message was found during communication with the master. This may be a programming error in the master or in the agentXcpp library. It is possible that the master actually performed the desired registration and that a retry will result in a duplicate_registration error.

Definition at line 277 of file MasterProxy.cpp.

References do_registration(), registrations, and sessionID.

void MasterProxy::remove_variable ( const Oid id)

Remove an SNMP variable so that is not longer accessible.

This removes a variable previously added using add_variable(). The variable will no longer receive SNMP requests.

If no variable is known for the given id, nothing happens.

Parameters
idThe OID of the variable to remove. This is the OID which was given to add_variable().
Exceptions
None.

Definition at line 927 of file MasterProxy.cpp.

References variables.

Referenced by removeVariables().

void MasterProxy::removeVariables ( const QVector< Oid > &  ids)

Remove several SNMP variables so that they are not longer accessible.

This function takes multiple variables and calls agentxcpp::remove_variable(const Oid&) for each of them.

Parameters
idsThe variables to be removed.
Exceptions
None.

Definition at line 933 of file MasterProxy.cpp.

References remove_variable().

Referenced by agentxcpp::Table::removeEntry().

void MasterProxy::send_notification ( const Oid snmpTrapOID,
const TimeTicksVariable sysUpTime,
const std::vector< Varbind > &  varbinds = vector<Varbind>() 
)
slot

Send a notification or trap.

This function sends a notification to the master agent, which in turn sends an SNMP notification or trap, depending on its configuration.

Each notification contains the snmpTrapOID.0 object (mandatory) and the sysUpTime.0 object (optional). The values of both objects are given as parameters.

Parameters
snmpTrapOIDThe value of snmpTrapOID.0 according to RFC 1907, which says: "The authoritative identification of the notification currently being sent." This is normally the Trap OID as specified in the corresponding MIB. However, if the notification shall be converted to an SNMPv1 trap (this conversion is done by the master agent), the snmpTrapOID.0 value must meet certain requirements. You can use generate_v1_snmpTrapOID() to construct a valid value in that case.
sysUpTimeThe value of the sysUpTime.0 object according to RFC 1907, which says: "The time (in hundreths of a second) since the network management portion of the system was last re-initialized.". You can use agentxcpp::processUpTime() to get the uptime of the current process. If the NULL pointer is given, the sysUpTime.0 will not be included in the notification, and the master agent will insert an sysUpTime.0 value (e.g. the uptime of the OS, depending on the master agent).
varbindsAdditional varbinds which are included in the notification.
Exceptions
timeout_errorFIXME
disconnectedFIXME
master_is_unableFIXME
unsupported_contextFIXME
Todo:
Document exceptions.

Definition at line 942 of file MasterProxy.cpp.

References connection, disconnect(), agentxcpp::ResponsePDU::noAgentXError, agentxcpp::ResponsePDU::notOpen, agentxcpp::ResponsePDU::parseError, agentxcpp::ResponsePDU::processingError, agentxcpp::ClosePDU::reasonProtocolError, agentxcpp::UnixDomainConnector::request(), sessionID, and agentxcpp::ResponsePDU::unsupportedContext.

Referenced by send_notification().

void agentxcpp::MasterProxy::send_notification ( const Oid snmpTrapOID,
const std::vector< Varbind > &  varbinds = vector<Varbind>() 
)
inlineslot

Writing aid: Send notification without sysUpTime.0.

This calls send_notification( const Oid&, const TimeTicksVariable*, const vector<varbind>&) with a NULL pointer for the sysUpTime.0 parameter.

For the documentation of the parameters and exceptions go to send_notification(const Oid&, TimeTicksVariable>&, const vector<varbind>&)

Definition at line 522 of file MasterProxy.hpp.

References send_notification().

void MasterProxy::undo_registration ( QSharedPointer< UnregisterPDU pdu)
private

Send a UnregisterPDU to the master agent.

This function sends an UnregisterPDU to the master agent which revokes the registration done by a RegisterPDU. Then it waits for the response and evaluates it.

Parameters
pduThe UnregisterPDU to send.
Exceptions
disconnectedIf the MasterProxy is currently in state 'disconnected'.
timeout_errorIf the master agent does not respond within the timeout interval.
internal_errorIf the master received a malformed PDU. This is probably a programming error within the agentXcpp library.
master_is_unableThe master agent was unable to perform the desired register request. The reason for that is unknown.
unknown_registrationThe MIB region is not currently registered with this parameters.
parse_errorIf an unexpected response was received from the master. This is probably a programming error within the master agent. It is possible that the master actually performed the desired registration and that a retry will result in a duplicate_registration error.

Definition at line 363 of file MasterProxy.cpp.

References connection, agentxcpp::ResponsePDU::noAgentXError, agentxcpp::ResponsePDU::notOpen, agentxcpp::ResponsePDU::parseError, agentxcpp::ResponsePDU::processingError, agentxcpp::UnixDomainConnector::request(), agentxcpp::ResponsePDU::unknownRegistration, and agentxcpp::ResponsePDU::unsupportedContext.

Referenced by disconnect(), and unregister_subtree().

void MasterProxy::unregister_subtree ( Oid  subtree,
quint8  priority = 127 
)

Unregister a subtree with the master agent.

This function unregisters a subtree (or MIB region) which has previously been registered.

This method removes the registered subtree from registrations.

Parameters
subtreeThe (root of the) subtree to unregister.
priorityThe priority with which the registration was done.
Exceptions
disconnectedIf the MasterProxy is currently in state 'disconnected'.
timeout_errorIf the master agent does not respond within the timeout interval.
master_is_unableThe master agent was unable to perform the desired unregister request. The reason for that is unknown.
unknown_registrationThe MIB region is not currently registered with this parameters.
parse_errorA malformed network message was found during communication with the master. This may be a programming error in the master or in the agentXcpp library. It is possible that the master actually unregistered the MIB region.

Definition at line 312 of file MasterProxy.cpp.

References create_unregister_pdu(), registrations, and undo_registration().

Member Data Documentation

UnixDomainConnector* agentxcpp::MasterProxy::connection
private

The connector object used for networking.

Created by constructors, destroyed by destructor.

Definition at line 218 of file MasterProxy.hpp.

Referenced by connect(), disconnect(), do_registration(), handle_pdu(), MasterProxy(), send_notification(), undo_registration(), and ~MasterProxy().

quint8 agentxcpp::MasterProxy::default_timeout
private

Default timeout of the session (in seconds).

A value of 0 indicates that there is no session-wide default.

Definition at line 239 of file MasterProxy.hpp.

Referenced by connect(), and MasterProxy().

std::string agentxcpp::MasterProxy::description
private

A string describing the subagent.

Set upon object creation. It is allowed to be emtpy.

Definition at line 232 of file MasterProxy.hpp.

Oid agentxcpp::MasterProxy::id
private

An Object Identifier that identifies the subagent. May be the null OID.

Definition at line 245 of file MasterProxy.hpp.

Referenced by add_variable().

QThread agentxcpp::MasterProxy::m_thread
private

The thread running a UnixDomainConnector.

The UnixDomainConnector object is moved into this thread after creation.

Definition at line 206 of file MasterProxy.hpp.

Referenced by MasterProxy().

std::list< QSharedPointer<RegisterPDU> > agentxcpp::MasterProxy::registrations
private

The registrations.

Every time an registration is performed, the RegisterPDU is stored in this list. This allows to automatically re-register these subtrees on reconnect.

Definition at line 254 of file MasterProxy.hpp.

Referenced by add_variable(), connect(), disconnect(), isRegistered(), register_subtree(), and unregister_subtree().

quint32 agentxcpp::MasterProxy::sessionID
private

The session ID of the current session.

If disconnected, the value is undefined.

Definition at line 225 of file MasterProxy.hpp.

Referenced by connect(), disconnect(), get_sessionID(), handle_pdu(), register_subtree(), and send_notification().

std::list< QSharedPointer<AbstractVariable> > agentxcpp::MasterProxy::setlist
private

The variables affected by the Set operation currently in progress.

The CommitSet, UndoSet and CleanupSet PDU's do not contain the affected variables but operate on the variables denominated in the preceding TestSet PDU.

These are the variables denominated in that TestSet PDU.

Definition at line 271 of file MasterProxy.hpp.

Referenced by handle_cleanupsetpdu(), handle_commitsetpdu(), handle_testsetpdu(), and handle_undosetpdu().

std::string agentxcpp::MasterProxy::socket_file
private

The path to the unix domain socket.

Definition at line 211 of file MasterProxy.hpp.

std::map< Oid, QSharedPointer<AbstractVariable> > agentxcpp::MasterProxy::variables
private

Storage for all SNMP variables known to the MasterProxy.

Definition at line 259 of file MasterProxy.hpp.

Referenced by add_variable(), connect(), handle_getnextpdu(), handle_getpdu(), handle_testsetpdu(), and remove_variable().


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