AgentX++  2.0.5
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AgentXSharedTable Class Reference

The AgentXSharedTable class is derived from MibTable and represents a shared table between AgentX subagents. More...

#include <agentx_subagent.h>

Inheritance diagram for AgentXSharedTable:

Public Member Functions

 AgentXSharedTable (const AgentXSharedTable &)
 Copy constructor.
 
 AgentXSharedTable (const Oidx &, const index_info *, unsigned int, const Oidx *, SubAgentXMib *, const NS_SNMP OctetStr &)
 Constructor with object identifier and given index structure.
 
virtual ~AgentXSharedTable ()
 Destructor.
 
MibTableRow * add_row (const Oidx &)
 Add a row with the given index to the table.
 
void remove_row (const Oidx &)
 Remove a row with the given index from the table.
 
virtual MibTableRow * init_row (const Oidx &, Vbx *)
 Initialize a row with values.
 
virtual void new_index ()
 Request a new index from the master agent.
 
virtual void any_index ()
 Request any index from the master agent.
 
virtual bool allocate_index (const Oidx &)
 Allocate an index at the master.
 
virtual void index_allocated (const Oidx &, int, int, Vbx *vbs=0, u_int vbs_length=0)
 This method is being called, whenever an index allocation has been processed by the master and the result has been returned to the subagent.
 
Oidx get_index_from_vbs (Vbx *, u_int)
 Get an index as an object identifier from a list of index objects.
 
SubAgentXMibget_subagent_mib ()
 Get the SubAgentXMib instance for the table.
 
void set_timeout (unsigned int t)
 Set the timeout value characteristics for this group of MIB objects.
 
unsigned int get_timeout ()
 Get the timeout (in seconds) for this MIB group.
 
virtual void clear ()
 Removes all rows from this table.
 
virtual void reinit ()
 Reallocates any indexes and reregisters any rows of this table.
 
void set_index_strategy (agentx_index_strategy is)
 Sets the index allocation strategy to be used by this shared table.
 
agentx_index_strategy get_index_strategy ()
 Gets the current index allocation strategy.
 

Protected Member Functions

void get_index_value (NS_SNMP SmiUINT32, const Oidx &, Vbx &vb)
 
Vbx * create_index_vbs (const Oidx &)
 

Protected Attributes

NS_SNMP OctetStr myContext
 
Oidx * indexOIDs
 
SubAgentXMibbackReference
 
unsigned int timeout
 
agentx_index_strategy indexStrategy
 

Detailed Description

The AgentXSharedTable class is derived from MibTable and represents a shared table between AgentX subagents.

The AgentXSharedTable only registers table rows instead of a whole table. Thus, other subagents may also register rows within the same conceptual table.

Do not add rows to this table before the SubAgentXMib::init() method has been called, because allocating an index or adding (registering) a row requires AgentX communication with the master agent.

Before adding a row by using the add_row method, the index of the new row should be allocated by allocate_index. A row with a new or any index may be added by calling new_index or any_index, respectively. The row_added method should be overriden, in order to set the values of the new row. The row_added method is called whenever a new row has been successfully registered with the master.

Author
Frank Fock
Version
1.4.11

Constructor & Destructor Documentation

AgentXSharedTable::AgentXSharedTable ( const AgentXSharedTable )

Copy constructor.

AgentXSharedTable::AgentXSharedTable ( const Oidx &  ,
const index_info *  ,
unsigned  int,
const Oidx *  ,
SubAgentXMib ,
const NS_SNMP OctetStr &   
)

Constructor with object identifier and given index structure.

In AGENT++ the structure of a table's index is given by an array of integer values. Each element represents an object of the index. A value of -1 represents a implied variable length string or oid. A value of 0 a variable length string or oid index object. A value greater than 0 determines the length of the index object meassured in subidentifiers.

Parameters
othe object identifier of the table, which has to be the oid of the the SMI table entry object (table.1).
indexan integer array. The length of the array corresponds to the number of objects in the INDEX clause.
sizethe size of the above index array.
indexOIDsan array of size "size" with the OIDs of the index objects.
backReferencea pointer to a SubAgentXMib instance.
contextthe context the shared table belongs to. An empty string denotes the default context.
virtual AgentXSharedTable::~AgentXSharedTable ( )
virtual

Destructor.

Member Function Documentation

MibTableRow* AgentXSharedTable::add_row ( const Oidx &  )

Add a row with the given index to the table.

by cloning the generator row and setting the oids accordingly. Unlike MibTable the row_added is only called when the registration of the row at the master was successful. The call of MibTable::row_added is synchronized with the table. This is different to MibTable::row_added which is not synchronized by AGENT++.

Parameters
indthe index of the new row.
Returns
a pointer to the added row.
virtual bool AgentXSharedTable::allocate_index ( const Oidx &  )
virtual

Allocate an index at the master.

The index value is checked before it is send to the master. If the index is invalid for this table, FALSE will be returned and no index allocation will take place. If the index is valid, then an allocation request will be send to the master. If the request has been successfully processed, then index_allocated will be called with error status set to AGENTX_OK, otherwise the error status will be set to AGENTX_INDEX_ALREADY_ALLOCATED or AGENTX_INDEX_NONE_AVAILABLE and the error index value will be set to the subindex that failed.

Parameters
indexan object identifier representing the whole index of a new row.
virtual void AgentXSharedTable::any_index ( )
virtual

Request any index from the master agent.

This requests an index that must not be currently allocated to any other subagent. If a new index is available it is returned by calling the callback method index_allocated.

virtual void AgentXSharedTable::clear ( )
virtual

Removes all rows from this table.

Vbx* AgentXSharedTable::create_index_vbs ( const Oidx &  )
protected
Oidx AgentXSharedTable::get_index_from_vbs ( Vbx *  ,
u_int   
)

Get an index as an object identifier from a list of index objects.

Parameters
vbsan array of variable bindings. Each variable binding represents an index object of this table. The order of the vbs must be the same as in the table's INDEX clause.
sizethe size of the above array.
Returns
an object identifier representing an index of this table.
agentx_index_strategy AgentXSharedTable::get_index_strategy ( )
inline

Gets the current index allocation strategy.

See set_index_strategy(agentx_index_strategy).

Returns
the index allocation strategy as defined by the agentx_index_strategy enum.
Since
4.0.2
void AgentXSharedTable::get_index_value ( NS_SNMP  SmiUINT32,
const Oidx &  ,
Vbx &  vb 
)
protected
SubAgentXMib* AgentXSharedTable::get_subagent_mib ( )
inline

Get the SubAgentXMib instance for the table.

Returns
a pointer to a SubAgentXMib instance.
unsigned int AgentXSharedTable::get_timeout ( )
inline

Get the timeout (in seconds) for this MIB group.

Returns
a timeout value in seconds or 0 if default timeout should be used.
Since
3.5
virtual void AgentXSharedTable::index_allocated ( const Oidx &  ,
int  ,
int  ,
Vbx *  vbs = 0,
u_int  vbs_length = 0 
)
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
indexthe row index of the row for which the index allocation succeeded.
erroran AgentX error code if the index allocation failed, or 0 if it has been completed successfully.
errorIndexif error is not 0, errorIndex points to the index object within the index that actually failed (starting from 1).
vbsthe variable bindings array of the AgentX index allocation response PDU which reflect the actually allocated (or failed) sub-index values.
vbs_lengththe length of the vbs array.
virtual MibTableRow* AgentXSharedTable::init_row ( const Oidx &  ,
Vbx *   
)
virtual

Initialize a row with values.

This method is typically called when a row is loaded from persistent storage. In contrast to the corresponding method of MibTable, this method allocates the index at the master agent.

Parameters
indexthe index of the row.
vbsa pointer to an array of variable bindings that provides initial values for all columns in the newly created row. The size of the array must be the same as the size of the row.
Returns
a pointer to the added row or 0 if the index is not valid.
virtual void AgentXSharedTable::new_index ( )
virtual

Request a new index from the master agent.

This requests an index that must not have been allocated (even if sub- sequently released) to any subagent since the last re- initialization of the master agent. If a new index is available it is returned by calling the callback method index_allocated.

virtual void AgentXSharedTable::reinit ( )
virtual

Reallocates any indexes and reregisters any rows of this table.

Using the currently configured index allocation strategy.

void AgentXSharedTable::remove_row ( const Oidx &  )

Remove a row with the given index from the table.

Before row_delete is called, the row will be unregistered at the master.

Parameters
indthe index of the row.
void AgentXSharedTable::set_index_strategy ( agentx_index_strategy  is)
inline

Sets the index allocation strategy to be used by this shared table.

For most use cases the agentx_index_strategy#firstSubIndexOnly strategy is recommended. With that strategy, only the first sub-index value will be allocated at the master agent if it has not yet been allocated by this table support (for any table). Unless you need to allocated sub-indexes by a multi-sub-index table, because there does not exists a shared table for the same session with that sub-index as first sub-index value, you should always use the agentx_index_strategy#firstSubIndexOnly or agentx_index_strategy#anyNonAllocatedSubIndex. The agentx_index_strategy#anyNonAllocatedSubIndex should be used for a master and dependent table combination where the dependent table(s) extend the index of the master table by additional sub-indexes.

Parameters
isthe new index allocation/deallocation strategy.
Since
4.0.2
void AgentXSharedTable::set_timeout ( unsigned int  t)
inline

Set the timeout value characteristics for this group of MIB objects.

Within AGENT++ this value is currently not used, but AgentX++ is using this value to set the region timeout when registering a subagent. Future implementations may also use this value for setting region (or subtree) timeouts.

Parameters
timeouta timeout value in seconds. 0 sets the systems default timeout.
Since
3.5

Member Data Documentation

SubAgentXMib* AgentXSharedTable::backReference
protected
Oidx* AgentXSharedTable::indexOIDs
protected
agentx_index_strategy AgentXSharedTable::indexStrategy
protected
NS_SNMP OctetStr AgentXSharedTable::myContext
protected
unsigned int AgentXSharedTable::timeout
protected

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