AgentX++
2.0.5
|
#include <agentx_subagent.h>
Public Member Functions | |
SubAgentXMib () | |
Default Constructor. | |
SubAgentXMib (const NS_SNMP OctetStr &) | |
Constructor with path where persistent MIB objects should be stored to and loaded from. | |
virtual | ~SubAgentXMib () |
Destructor. | |
virtual bool | init () |
Initialize the sub-agent by opening a session with the master agent and registering all MIB objects already added to the receiver. | |
virtual MibEntryPtr | add (MibEntryPtr) |
Register a MIB object for the agent's MIB. | |
virtual MibEntryPtr | add_no_reg (MibEntryPtr) |
Register a MIB object for the agent's MIB. | |
virtual MibEntry * | add (const NS_SNMP OctetStr &, MibEntry *) |
Register a MIB object within a given context. | |
virtual MibEntry * | register_entry (const NS_SNMP OctetStr &, MibEntry *, u_int) |
Register a MIB object within a given context at the master. | |
virtual MibEntry * | add_no_reg (const NS_SNMP OctetStr &, MibEntry *) |
Register a MIB object within a given context. | |
virtual bool | remove (const Oidx &) |
Unregister a MIB object from the agent's MIB. | |
virtual bool | remove_no_unreg (const Oidx &) |
Unregister a MIB object from the agent's MIB, but do not unregister it with the master. | |
virtual bool | remove (const NS_SNMP OctetStr &, const Oidx &) |
Unregister a MIB object from the agent³s MIB. | |
virtual bool | remove_no_unreg (const NS_SNMP OctetStr &, const Oidx &) |
Unregister a MIB object from the given context, but do not unregister it with the master. | |
virtual int | open_session () |
Open session. | |
virtual void | reconnect () |
(Re)Connect with the master. | |
void | set_default_priority (const u_char p) |
Set the default priority for registrations by this sub-agent. | |
void | set_request_list (AgentXRequestList *) |
Set the RequestList to be used for answering request. | |
virtual int | notify (const NS_SNMP OctetStr &, const Oidx &, Vbx *, int, unsigned int=0) |
Send a notification. | |
virtual unsigned long | ping_master () |
Send a ping PDU to the master agent to monitor the master agent's ability to receive and send AgentX PDUs over their AgentX session. | |
virtual void | ping_received (const AgentXPdu &) |
This method is called when this subagent received a PING response from its master. | |
virtual bool | register_region (const NS_SNMP OctetStr &, const AgentXRegion &, u_int timeout, bool, AgentXSharedTable *t=0) |
Register a region at the master agent. | |
virtual void | registration_failed (const AgentXRegion &, int, AgentXSharedTable *) |
Registration failed. | |
virtual void | registration_success (const AgentXRegion &, AgentXSharedTable *) |
Registration success. | |
virtual u_int | allocate_index (const NS_SNMP OctetStr &, Vbx *, int, AgentXSharedTable *t=0, u_char indexType=0, Oidx *rowIndex=0) |
Allocate a set of index values. | |
virtual u_int | deallocate_index (const NS_SNMP OctetStr &, Vbx *, int, AgentXSharedTable *table=0, Oidx *rowIndex=0) |
Deallocate a set of index values. | |
virtual void | index_allocated (u_int, u_int, Vbx *, int, AgentXSharedTable *, u_int, Oidx *) |
This method is being called, whenever an index allocation has been processed by the master and the result has been returned to the subagent. | |
virtual void | index_deallocated (u_int, u_int, Vbx *, int, AgentXSharedTable *, u_int, Oidx *) |
This method is being called, whenever an index deallocation has been processed by the master and the result has been returned to the subagent. | |
virtual bool | add_agent_caps (const NS_SNMP OctetStr &, const Oidx &, const NS_SNMP OctetStr &) |
Add agent capabilities to the sysORTable of the master. | |
virtual void | remove_agent_caps (const NS_SNMP OctetStr &, const Oidx &) |
Add agent capabilities to the sysORTable of the master. | |
AgentXSession * | get_session () |
Gets a pointer to the AgentXSession associated with this SubAgentXMib instance. | |
AgentXIndexDB * | get_index_registry () |
Gets a pointer to the index registry associated with this subagent. | |
Static Public Member Functions | |
static AgentXSlave * | get_agentx () |
Get the AgentXSlave instance used for AgentX services. | |
Protected Member Functions | |
virtual AgentXSession * | create_session () |
Create a session that will be used for this Mib instance. | |
virtual void | not_connected () |
This method is called when an attempt has been made to send an AgentX message to the master agent. | |
virtual int | find_next (MibContext *, const Oidx &, MibEntryPtr &, Request *req, const int, Oidx &nextOid) |
Find the next MIB entry which has an oid greater than the given oid. | |
virtual void | do_process_request (Request *) |
Process an AgentX request. | |
virtual void | process_response (AgentXRequest *) |
Process an AgentX response. | |
virtual void | synchronize_uptime (u_int) |
Synchronize local sysUpTime with the given time. | |
void | remove_pending_messages (MibEntry *) |
Remove pending messages for a MibEntry instance. | |
AgentXPendingMessage * | get_pending_message (u_int) |
virtual void | init_response_pool () |
Create and initialize response pool and queue. | |
virtual void | delete_request (Request *req) |
Deletes the supplied request unless it is a TestSet or CommitSet PDU. | |
Protected Attributes | |
AgentXSession * | session |
agentx_run_status_t | status |
u_char | priority |
AgentXIndexDB * | indexRegistry |
List< AgentXPendingMessage > | pendingMessages |
Synchronized | pendingMessagesLock |
QueuedThreadPool * | responsePool |
Static Protected Attributes | |
static AgentXSlave * | agentx |
Friends | |
class | AgentXResponse |
SubAgentXMib::SubAgentXMib | ( | ) |
Default Constructor.
SubAgentXMib::SubAgentXMib | ( | const NS_SNMP OctetStr & | ) |
Constructor with path where persistent MIB objects should be stored to and loaded from.
path | the directory to store persistent objects. |
|
virtual |
Destructor.
|
virtual |
Register a MIB object for the agent's MIB.
If the subagent's connection to the master is established, then the object will be immediately registered at the master.
item | a pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...). |
|
virtual |
Register a MIB object within a given context.
If the given context is a new context, it will be added to the list of known contexts. If the subagent's connection to the master is established, then the object will be immediately registered at the master.
Note: This method is synchronized using ::lock_mib()
context | an OctetStr instance specifiying the target context. |
item | a pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...). |
|
virtual |
Add agent capabilities to the sysORTable of the master.
context | a context. Use "" for the default context. |
id | an object identifier containing the value of an invocation of the AGENT-CAPABILITIES macro, which the master agent exports as a value of sysORID for the indicated context. |
descr | an OctetStr containing a DisplayString to be used as the value of sysORDescr corresponding to the sysORID value above. |
|
virtual |
Register a MIB object for the agent's MIB.
If the subagent's connection to the master is established, then the object will not be registered at the master, otherwise it will be registered through the reconnect method.
item | a pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...). |
|
virtual |
Register a MIB object within a given context.
If the given context is a new context, it will be added to the list of known contexts. If the subagent's connection to the master is established, then the object will not be registered at the master, otherwise it will be registered through the reconnect method.
Note: This method is synchronized using ::lock_mib()
context | an OctetStr instance specifiying the target context. |
item | a pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...). |
|
virtual |
Allocate a set of index values.
context | a context. "" denotes the default context. |
indexValues | an array of Vbx instances. The oid portion denotes the oid of the specified index object and the value portion denotes the value of that index object. |
size | the size of the above array. |
reference | a pointer to an AgentXSharedTable instance association with this index allocation. Default for this parameter is 0. |
indexType | the type of index to be allocated. Possible values are: 0 - index values are given by indexValues AGENTX_NEW_INDEX - allocate unique new index values AGENTX_ANY_INDEX - allocate any new index values |
rowIndex | the (optional) row index for which index values are allocated. Because index values can be allocated for one or more sub-indexes of a row index, the rowIndex value is not necessarily equal to the indexValues. The rowIndex will be deleted when the corresponding AgentX packet is deleted (or if the AgentX request could not be sent). Thus, the caller does not need to delete this pointer nor may the caller use it after the call anymore! |
|
protectedvirtual |
Create a session that will be used for this Mib instance.
Override this method to create your own session object, i.e., with a non-default timeout value.
|
virtual |
Deallocate a set of index values.
context | a context. "" denotes the default context. |
indexValues | an array of Vbx instances. The oid portion denotes the oid of the specified index object and the value portion denotes the value of that index object. |
size | the size of the above array. |
reference | a pointer to an AgentXSharedTable instance association with this index allocation. Default for this parameter is 0. |
rowIndex | the (optional) row index for which index values are allocated. Because index values can be allocated for one or more sub-indexes of a row index, the rowIndex value is not necessarily equal to the indexValues. The rowIndex will be deleted when the corresponding AgentX packet is deleted (or if the AgentX request could not be sent). Thus, the caller does not need to delete this pointer nor may the caller use it after the call anymore! |
|
protectedvirtual |
Deletes the supplied request unless it is a TestSet or CommitSet PDU.
req | the Request to delete. |
|
protectedvirtual |
Process an AgentX request.
req | a request. |
|
protectedvirtual |
Find the next MIB entry which has an oid greater than the given oid.
(Respects AgentX search ranges)
context | the target context. |
oid | an object identifier. |
entry | will be changed to a pointer to the found entry or remain unchanged if the return value is different from SNMP_ERROR_SUCCESS. |
request | a pointer to the Request instance for in whose context the find_next is issued. |
nextOid | returns the identified successor OID for complex entries. For mib entries where the next OID cannot be determined, the value will remain unchanged. |
|
inlinestatic |
Get the AgentXSlave instance used for AgentX services.
|
inline |
Gets a pointer to the index registry associated with this subagent.
The index registry records index registrations to avoid duplicate registrations for some index allocation strategies.
|
protected |
|
inline |
Gets a pointer to the AgentXSession associated with this SubAgentXMib instance.
|
virtual |
This method is being called, whenever an index allocation has been processed by the master and the result has been returned to the subagent.
error | an AgentX error code if the index allocation failed, or 0 if it has been completed successfully. |
errorIndex | if error is not 0, errorIndex points to the index object within the index that actually failed (starting from 1). |
vbs | an array of index objects. |
size | the size of the above array. |
sharedTable | a pointer to an AgentXSharedTable instance that initiated the index allocation. If the index allocation was not initiated by an AgentXSharedTable instance this pointer will be 0. |
packetID | the packet ID of the AgentX request that send the allocation PDU. This value can be used to associate any objects with the (asynchronous) index allocation request. |
rowIndex | the row index originally provided to the allocation request. |
|
inlinevirtual |
This method is being called, whenever an index deallocation has been processed by the master and the result has been returned to the subagent.
error | an AgentX error code if the index deallocation failed, or 0 if it has been completed successfully. |
errorIndex | if error is not 0, errorIndex points to the index object within the index that actually failed (starting from 1). |
vbs | an array of index objects. |
size | the size of the above array. |
sharedTable | a pointer to an AgentXSharedTable instance that initiated the index deallocation. If the index deallocation was not initiated by an AgentXSharedTable instance this pointer will be 0. |
packetID | the packet ID of the AgentX request that send the allocation PDU. This value can be used to associate any objects with the (asynchronous) index allocation request. |
rowIndex | the row index originally provided to the allocation request. |
|
virtual |
Initialize the sub-agent by opening a session with the master agent and registering all MIB objects already added to the receiver.
|
protectedvirtual |
Create and initialize response pool and queue.
|
protectedvirtual |
This method is called when an attempt has been made to send an AgentX message to the master agent.
The default implementation logs a warning message only.
|
virtual |
Send a notification.
context | the context originating the notification ("" for the default context). |
trapoid | the oid of the notification. |
vbs | an array of variable bindings. |
size | the size of the above variable binding array. |
timestamp | an optional timestamp. |
|
virtual |
Open session.
|
virtual |
|
virtual |
This method is called when this subagent received a PING response from its master.
pdu | the AgentX PDU containing the response for the ping. |
|
protectedvirtual |
Process an AgentX response.
req | a request. |
|
virtual |
(Re)Connect with the master.
Allocates regions for the objects of this Mib instance and also allocates indexes and rows of shared tables.
|
virtual |
Register a MIB object within a given context at the master.
If the given context is a new context, it will be added to the list of known contexts. Note that the subagent's connection to the master must be established before this method is called, otherwise this method will return 0.
Note: This method is synchronized using ::lock_mib()
context | an OctetStr instance specifiying the target context. |
item | a pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...). |
timeout | the entry's (region's) timeout value. |
|
virtual |
Register a region at the master agent.
context | the context. |
region | an AgentXRegion instance. |
timeout | the regions timeout value or 0 for using the sessions timeout value. |
mode | if TRUE the region is registered at the master, if FALSE the region is deregistered. |
reference | a pointer to an AgentXSharedTable instance that initiates the registration. If the registration attempt is initiated by any other MIB object instance, then this paramter should be set to 0 or omitted. |
|
inlinevirtual |
Registration failed.
This method is called when a registration attempt failed.
region | the region. |
errorStatus | the error status of the attempt. |
reference | a pointer to the AgentXSharedTable instance that initiated the registration. This parameter is 0 for other registrations. |
|
virtual |
Registration success.
This method is called when a registration attempt succeeded.
region | the region. |
reference | a pointer to the AgentXSharedTable instance that initiated the registration. This parameter is 0 for other registrations. |
|
virtual |
Unregister a MIB object from the agent's MIB.
This method now (>3.3) works for MibGroups, too.
Note: This method is synchronized. It first acquires ::mib_lock(), then searches for the target MIB object and then acquires target::start_synch(). Then it RELEASES the MIB object lock by calling target::end_synch(). The target object is deleted and the MIB lock is released.
Why is this save?
oid | the Oidx instance pointing to the key of the MibEntry to be removed. |
|
virtual |
Unregister a MIB object from the agent³s MIB.
This method now (>3.3) works for MibGroups, too.
Note: This method is synchronized. It first acquires ::mib_lock(), then searches for the target MIB object and then acquires target::start_synch(). Then it RELEASES the MIB object lock by calling target::end_synch(). The target object is deleted and the MIB lock is released.
Why is this save?
context | an OctetStr instance specifiying the target context. |
oid | the Oidx instance pointing to the key of the MibEntry to be removed. |
|
virtual |
Add agent capabilities to the sysORTable of the master.
context | a context. Use "" for the default context. |
id | an object identifier containing the value of sysORID that should be no longer exported. |
|
virtual |
Unregister a MIB object from the agent's MIB, but do not unregister it with the master.
Use this method when the object to be removed has been registred by add_no_reg().
oid | the Oidx instance pointing to the key of the MibEntry to be removed. |
|
virtual |
Unregister a MIB object from the given context, but do not unregister it with the master.
Use this method when the object to be removed has been registred by add_no_reg().
context | an OctetStr instance specifiying the target context. |
oid | the Oidx instance pointing to the key of the MibEntry to be removed. |
|
protected |
Remove pending messages for a MibEntry instance.
entry | a pointer to a MibEntry instance. |
|
inline |
Set the default priority for registrations by this sub-agent.
priority | a value between 0 and 255 (default is 127). |
void SubAgentXMib::set_request_list | ( | AgentXRequestList * | ) |
Set the RequestList to be used for answering request.
Note: The request list is NOT deleted by the receiver's destructor. This should be done outside class Mib.
requestList | an AgentXRequestList instance with its agentx protocol service set. (If the agentx protocol service is not set, this will end program execution) |
|
protectedvirtual |
Synchronize local sysUpTime with the given time.
time | the 1/100 seconds since the master system started. |
|
friend |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |