SubAgentXMib Class Reference

#include <agentx_subagent.h>

List of all members.

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 boolean 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 boolean remove (const Oidx &)
 Unregister a MIB object from the agent's MIB.
virtual boolean remove_no_unreg (const Oidx &)
 Unregister a MIB object from the agent's MIB, but do not unregister it with the master.
virtual boolean remove (const NS_SNMP OctetStr &, const Oidx &)
 Unregister a MIB object from the agent³s MIB.
virtual boolean 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 boolean register_region (const NS_SNMP OctetStr &, const AgentXRegion &, u_int timeout, boolean, 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 void allocate_index (const NS_SNMP OctetStr &, Vbx *, int, AgentXSharedTable *t=0, u_char indexType=0)
 Allocate a set of index values.
virtual void deallocate_index (const NS_SNMP OctetStr &, Vbx *, int, AgentXSharedTable *table=0)
 Deallocate a set of index values.
virtual void index_allocated (u_int, u_int, Vbx *, int, AgentXSharedTable *)
 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 *)
 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 boolean 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.
AgentXSessionget_session ()
 Gets a pointer to the AgentXSession associated with this SubAgentXMib instance.

Static Public Member Functions

static AgentXSlaveget_agentx ()
 Get the AgentXSlave instance used for AgentX services.

Protected Member Functions

virtual AgentXSessioncreate_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)
 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.
AgentXPendingMessageget_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

AgentXSessionsession
agentx_run_status_t status
u_char priority
List< AgentXPendingMessagependingMessages
Synchronized pendingMessagesLock
QueuedThreadPool * responsePool

Static Protected Attributes

static AgentXSlaveagentx

Friends

class AgentXResponse


Constructor & Destructor Documentation

SubAgentXMib::SubAgentXMib (  ) 

Default Constructor.

SubAgentXMib::SubAgentXMib ( const NS_SNMP OctetStr &   ) 

Constructor with path where persistent MIB objects should be stored to and loaded from.

Parameters:
path the directory to store persistent objects.

virtual SubAgentXMib::~SubAgentXMib (  )  [virtual]

Destructor.


Member Function Documentation

virtual boolean SubAgentXMib::init (  )  [virtual]

Initialize the sub-agent by opening a session with the master agent and registering all MIB objects already added to the receiver.

Returns:
TRUE if connection to master could be established, FALSE otherwise.

virtual MibEntryPtr SubAgentXMib::add ( MibEntryPtr   )  [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.

Parameters:
item a pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...).
Returns:
The input pointer (if the registered object is of type MibGroup 0).

virtual MibEntryPtr SubAgentXMib::add_no_reg ( MibEntryPtr   )  [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.

Parameters:
item a pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...).
Returns:
the input pointer (if the registered object is of type MibGroup 0).

virtual MibEntry* SubAgentXMib::add ( const NS_SNMP OctetStr &  ,
MibEntry *   
) [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()

Parameters:
context an OctetStr instance specifiying the target context.
item a pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...).
Returns:
the input pointer if the MibEntry could be registered, or 0 otherwise.

virtual MibEntry* SubAgentXMib::register_entry ( const NS_SNMP OctetStr &  ,
MibEntry *  ,
u_int   
) [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()

Parameters:
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.
Returns:
the input pointer if the MibEntry could be registered, or 0 otherwise.

virtual MibEntry* SubAgentXMib::add_no_reg ( const NS_SNMP OctetStr &  ,
MibEntry *   
) [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()

Parameters:
context an OctetStr instance specifiying the target context.
item a pointer to a MibEntry object (i.e., MibLeaf, MibTable, MibGroup, ...).
Returns:
the input pointer if the MibEntry could be registered, or 0 otherwise.

virtual boolean SubAgentXMib::remove ( const Oidx &   )  [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?

  • we hold the lock for the MIB (lock_mib())
  • before a request can lock a MibEntry object it must get the MIB lock
  • so if we get the MibEntry lock here no other request can be currently using this object
  • even if we release the lock, because we hold the MIB lock

Parameters:
oid the Oidx instance pointing to the key of the MibEntry to be removed.
Returns:
TRUE if the entry could be removed, FALSE otherwise

virtual boolean SubAgentXMib::remove_no_unreg ( const Oidx &   )  [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().

Parameters:
oid the Oidx instance pointing to the key of the MibEntry to be removed.
Returns:
TRUE if the entry could be removed, FALSE otherwise

virtual boolean SubAgentXMib::remove ( const NS_SNMP OctetStr &  ,
const Oidx &   
) [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?

  • we hold the lock for the MIB (lock_mib())
  • before a request can lock a MibEntry object it must get the MIB lock
  • so if we get the MibEntry lock here no other request can be currently using this object
  • even if we release the lock, because we hold the MIB lock

Parameters:
context an OctetStr instance specifiying the target context.
oid the Oidx instance pointing to the key of the MibEntry to be removed.
Returns:
TRUE if the entry could be removed, FALSE otherwise

virtual boolean SubAgentXMib::remove_no_unreg ( const NS_SNMP OctetStr &  ,
const Oidx &   
) [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().

Parameters:
context an OctetStr instance specifiying the target context.
oid the Oidx instance pointing to the key of the MibEntry to be removed.
Returns:
TRUE if the entry could be removed, FALSE otherwise

virtual int SubAgentXMib::open_session (  )  [virtual]

Open session.

virtual void SubAgentXMib::reconnect (  )  [virtual]

(Re)Connect with the master.

Allocates regions for the objects of this Mib instance and also allocates indexes and rows of shared tables.

void SubAgentXMib::set_default_priority ( const u_char  p  )  [inline]

Set the default priority for registrations by this sub-agent.

Parameters:
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.

Parameters:
requestList an AgentXRequestList instance with its agentx protocol service set. (If the agentx protocol service is not set, this will end program execution)

virtual int SubAgentXMib::notify ( const NS_SNMP OctetStr &  ,
const Oidx &  ,
Vbx *  ,
int  ,
unsigned  int = 0 
) [virtual]

Send a notification.

Parameters:
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.
Returns:
SNMP_ERROR_SUCCESS.

static AgentXSlave* SubAgentXMib::get_agentx (  )  [inline, static]

Get the AgentXSlave instance used for AgentX services.

Returns:
an AgentXSlave instance.

virtual unsigned long SubAgentXMib::ping_master (  )  [virtual]

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.

Returns:
a transaction id to match ping requests to responses later.

virtual void SubAgentXMib::ping_received ( const AgentXPdu  )  [virtual]

This method is called when this subagent received a PING response from its master.

Parameters:
pdu the AgentX PDU containing the response for the ping.

virtual boolean SubAgentXMib::register_region ( const NS_SNMP OctetStr &  ,
const AgentXRegion ,
u_int  timeout,
boolean  ,
AgentXSharedTable t = 0 
) [virtual]

Register a region at the master agent.

Parameters:
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.
Returns:
TRUE if the registration message has been successfully sent, FALSE otherwise.

virtual void SubAgentXMib::registration_failed ( const AgentXRegion ,
int  ,
AgentXSharedTable  
) [inline, virtual]

Registration failed.

This method is called when a registration attempt failed.

Parameters:
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 void SubAgentXMib::registration_success ( const AgentXRegion ,
AgentXSharedTable  
) [virtual]

Registration success.

This method is called when a registration attempt succeeded.

Parameters:
region the region.
reference a pointer to the AgentXSharedTable instance that initiated the registration. This parameter is 0 for other registrations.

virtual void SubAgentXMib::allocate_index ( const NS_SNMP OctetStr &  ,
Vbx *  ,
int  ,
AgentXSharedTable t = 0,
u_char  indexType = 0 
) [virtual]

Allocate a set of index values.

Parameters:
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

virtual void SubAgentXMib::deallocate_index ( const NS_SNMP OctetStr &  ,
Vbx *  ,
int  ,
AgentXSharedTable table = 0 
) [virtual]

Deallocate a set of index values.

Parameters:
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.

virtual void SubAgentXMib::index_allocated ( u_int  ,
u_int  ,
Vbx *  ,
int  ,
AgentXSharedTable  
) [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.

Parameters:
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.

virtual void SubAgentXMib::index_deallocated ( u_int  ,
u_int  ,
Vbx *  ,
int  ,
AgentXSharedTable  
) [inline, virtual]

This method is being called, whenever an index deallocation has been processed by the master and the result has been returned to the subagent.

Parameters:
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.

virtual boolean SubAgentXMib::add_agent_caps ( const NS_SNMP OctetStr &  ,
const Oidx &  ,
const NS_SNMP OctetStr &   
) [virtual]

Add agent capabilities to the sysORTable of the master.

Parameters:
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.
Returns:
TRUE if the context could be found.

virtual void SubAgentXMib::remove_agent_caps ( const NS_SNMP OctetStr &  ,
const Oidx &   
) [virtual]

Add agent capabilities to the sysORTable of the master.

Parameters:
context a context. Use "" for the default context.
id an object identifier containing the value of sysORID that should be no longer exported.

AgentXSession* SubAgentXMib::get_session (  )  [inline]

Gets a pointer to the AgentXSession associated with this SubAgentXMib instance.

Returns:
a pointer to an AgentXSession instance. The content of the session should not be modified. In addition, the memory allocated for the session object may be invalidated when the session is closed.

virtual AgentXSession* SubAgentXMib::create_session (  )  [protected, virtual]

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.

Returns:
a pointer to an AgentXSession instance. It will be deleted by SubAgentXMib when session is closed.

virtual void SubAgentXMib::not_connected (  )  [protected, virtual]

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 int SubAgentXMib::find_next ( MibContext *  ,
const Oidx &  ,
MibEntryPtr &  ,
Request *  req,
const   int 
) [protected, virtual]

Find the next MIB entry which has an oid greater than the given oid.

(Respects AgentX search ranges)

Parameters:
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.
Returns:
SNMP_ERROR_SUCCESS if an entry has been found and sNMP_SYNTAX_NOSUCHOBJECT otherwise.

virtual void SubAgentXMib::do_process_request ( Request *   )  [protected, virtual]

Process an AgentX request.

Parameters:
req a request.

virtual void SubAgentXMib::process_response ( AgentXRequest  )  [protected, virtual]

Process an AgentX response.

Parameters:
req a request.

virtual void SubAgentXMib::synchronize_uptime ( u_int   )  [protected, virtual]

Synchronize local sysUpTime with the given time.

Parameters:
time the 1/100 seconds since the master system started.

void SubAgentXMib::remove_pending_messages ( MibEntry *   )  [protected]

Remove pending messages for a MibEntry instance.

Parameters:
entry a pointer to a MibEntry instance.

AgentXPendingMessage* SubAgentXMib::get_pending_message ( u_int   )  [protected]

virtual void SubAgentXMib::init_response_pool (  )  [protected, virtual]

Create and initialize response pool and queue.

virtual void SubAgentXMib::delete_request ( Request *  req  )  [protected, virtual]

Deletes the supplied request unless it is a TestSet or CommitSet PDU.

Parameters:
req the Request to delete.
Since:
1.4.12


Friends And Related Function Documentation

friend class AgentXResponse [friend]


Member Data Documentation

AgentXSlave* SubAgentXMib::agentx [static, protected]

u_char SubAgentXMib::priority [protected]

Synchronized SubAgentXMib::pendingMessagesLock [protected]

QueuedThreadPool* SubAgentXMib::responsePool [protected]


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

Generated on Tue May 26 23:32:16 2009 for AgentX++ by  doxygen 1.5.6