AgentX++
2.0.5
|
The AgentXSharedTable class is derived from MibTable and represents a shared table between AgentX subagents. More...
#include <agentx_subagent.h>
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. | |
SubAgentXMib * | get_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 |
SubAgentXMib * | backReference |
unsigned int | timeout |
agentx_index_strategy | indexStrategy |
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.
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.
o | the object identifier of the table, which has to be the oid of the the SMI table entry object (table.1). |
index | an integer array. The length of the array corresponds to the number of objects in the INDEX clause. |
size | the size of the above index array. |
indexOIDs | an array of size "size" with the OIDs of the index objects. |
backReference | a pointer to a SubAgentXMib instance. |
context | the context the shared table belongs to. An empty string denotes the default context. |
|
virtual |
Destructor.
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++.
ind | the index of the new row. |
|
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.
index | an object identifier representing the whole index of a new row. |
|
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 |
Removes all rows from this table.
|
protected |
Oidx AgentXSharedTable::get_index_from_vbs | ( | Vbx * | , |
u_int | |||
) |
Get an index as an object identifier from a list of index objects.
vbs | an 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. |
size | the size of the above array. |
|
inline |
Gets the current index allocation strategy.
See set_index_strategy(agentx_index_strategy).
|
protected |
|
inline |
Get the SubAgentXMib instance for the table.
|
inline |
Get the timeout (in seconds) for this MIB group.
|
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.
index | the row index of the row for which the index allocation succeeded. |
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 | the variable bindings array of the AgentX index allocation response PDU which reflect the actually allocated (or failed) sub-index values. |
vbs_length | the length of the vbs array. |
|
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.
index | the index of the row. |
vbs | a 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. |
|
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 |
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.
ind | the index of the row. |
|
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.
is | the new index allocation/deallocation strategy. |
|
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.
timeout | a timeout value in seconds. 0 sets the systems default timeout. |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |