AGENT++
4.0.3
|
#include <mib.h>
Public Member Functions | |
Mib () | |
Default Constructor. | |
Mib (const NS_SNMP OctetStr &) | |
Constructor with path where persistent MIB objects should be stored to and loaded from. | |
virtual | ~Mib () |
Destructor. | |
void | set_request_list (RequestList *) |
Set the RequestList to be used for answering request. | |
RequestList * | get_request_list () |
Gets the request list associated with all Mib instances. | |
virtual void | process_request (Request *) |
Process a request. | |
virtual int | notify (const NS_SNMP OctetStr &, const Oidx &, Vbx *, int, unsigned int=0) |
Send a notification. | |
void | set_notification_sender (NotificationSender *) |
Sets the notification sender to be used by this Mib. | |
NotificationSender * | get_notification_sender () const |
Gets the currently set NotificationSender. | |
virtual void | cleanup () |
Clean up MIB. | |
virtual MibEntry * | add (MibEntry *) |
Register a MIB object for the default context. | |
virtual MibEntry * | add (const NS_SNMP OctetStr &, MibEntry *) |
Register a MIB object within a given context. | |
virtual MibContext * | add_context (const NS_SNMP OctetStr &) |
Add a new context with a given name to the receiver. | |
virtual void | remove_context (const NS_SNMP OctetStr &) |
Remove a given context from the receiver. | |
virtual bool | add_agent_caps (const NS_SNMP OctetStr &, const Oidx &, const NS_SNMP OctetStr &) |
Add Agent Capabilities to a context. | |
virtual void | remove_agent_caps (const NS_SNMP OctetStr &, const Oidx &) |
Remove Agent Capabilities from a context. | |
virtual bool | remove (const Oidx &) |
Unregister a MIB object from the agent�s MIB. | |
virtual bool | remove (const NS_SNMP OctetStr &, const Oidx &) |
Unregister a MIB object from the agent�s MIB. | |
virtual bool | init () |
Initialize all contexts. | |
virtual void | save_all () |
Save all persistent MIB objects to disk. | |
virtual bool | save (unsigned int, const NS_SNMP OctetStr &) |
Save all persistent MIB objects in the supplied format to the supplied path. | |
virtual bool | load (unsigned int, const NS_SNMP OctetStr &) |
Load all persistent MIB objects in the supplied format from the supplied path. | |
virtual MibEntryPtr | get (const Oidx &) |
Get the MIB object with a given object id. | |
virtual MibEntryPtr | get (const NS_SNMP OctetStr &, const Oidx &) |
Get the MIB object with a given object id. | |
virtual MibGroup * | find_group_of (const NS_SNMP OctetStr &, const Oidx &) |
Find the MibGroup that contains a MibEntry with a given object ID. | |
virtual NS_SNMP OctetStr | get_persistent_objects_path () const |
Get path where persistent MIB objects are stored. | |
virtual void | set_persistent_objects_path (const NS_SNMP OctetStr *str) |
Set the path where persistent MIB objects are stored. | |
bool | is_persistency_activated () const |
Checks whether a persistent objects path has been set. | |
virtual bool | is_complex_node (const MibEntryPtr &) |
Check whether a node (a MIB object) is complex, i.e. | |
bool | is_table_node (const MibEntryPtr &e) |
Check whether a node (a MIB object) is a table. | |
bool | is_leaf_node (const MibEntryPtr &e) |
Check whether a node (a MIB object) is a leaf node. | |
void | lock_mib () |
Lock the receiver's registration. | |
void | unlock_mib () |
Release the lock on the receiver's registration. | |
virtual MibContext * | get_context (const NS_SNMP OctetStr &) |
Get a context. | |
MibContext * | get_default_context () |
Get the default context. | |
virtual int | find_next (MibContext *, const Oidx &oid, MibEntryPtr &, Request *req, const int, Oidx &nextOid) |
Find the next MIB entry which has an oid greater than the given oid. | |
virtual int | find_managing_object (MibContext *, const Oidx &, MibEntryPtr &, Request *) |
Find the MIB object (i.e., MibTable, MibLeaf, etc.) that is responsible for the managed object identified by a given oid within a given context. | |
virtual void | do_process_request (Request *) |
Internally process a request (typically within its own thread). | |
virtual void | process_set_request (Request *) |
Process a set request. | |
virtual int | process_prepare_set_request (Request *) |
Process the prepare phase of a set request. | |
virtual int | process_commit_set_request (Request *) |
Process the commit phase of a set request. | |
virtual int | process_undo_set_request (Request *) |
Process the undo phase of a set request. | |
virtual void | process_cleanup_set_request (Request *) |
Process the clean up phase of a set request. | |
virtual void | process_get_bulk_request (Request *) |
Process a get bulk request. | |
MibConfigFormat * | add_config_format (unsigned int format, MibConfigFormat *) |
Adds a config format to this Mib instance. | |
MibConfigFormat * | get_config_format (unsigned int format) |
Returns the config format for the specified format ID. | |
Public Attributes | |
RequestList * | requestList |
Pointer to the RequestList used for answering requests. | |
Static Public Attributes | |
static Mib * | instance |
Protected Member Functions | |
virtual bool | process_request (Request *, int) |
Process a subrequest. | |
virtual void | finalize (Request *) |
Finalize a request. | |
virtual void | delete_request (Request *req) |
Deletes the the supplied request. | |
Static Protected Member Functions | |
static bool | set_exception_vb (Request *, int, int) |
Set the exception status for the supplied sub-request. | |
Protected Attributes | |
OidList< MibContext > | contexts |
MibContext * | defaultContext |
NotificationSender * | notificationSender |
NS_SNMP OctetStr * | persistent_objects_path |
ThreadManager | mibLock |
Array< MibConfigFormat > | configFormats |
Mib::Mib | ( | ) |
Default Constructor.
Mib::Mib | ( | 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.
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.
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 a context.
context | a context. An empty string denotes the default context. |
sysORID | an authoritative identification of a capabilities statement with respect to various MIB modules supported by the local SNMPv2 entity acting in an agent role. |
sysORDescr | a textual description of the capabilities identified by the corresponding instance of sysORID. |
MibConfigFormat* Mib::add_config_format | ( | unsigned int | format, |
MibConfigFormat * | |||
) |
Adds a config format to this Mib instance.
If a format with the specified ID (see AGENTPP-CONFIG-MIB) is already registered, then it will be replaced and the old one will be returned. NOTE: This method is not synchronized and should therefore not be called after agent initialization.
formatID | an unsigned integer > 0 that specifies the format as defined in the AGENTPP-CONFIG-MIB or any supplemental MIB specification. |
format | the MibConfigFormat instance implementing the format. |
|
virtual |
Add a new context with a given name to the receiver.
Note: This method is synchronized using ::lock_mib(), thus you may add a context in within the agent`s mainloop in a multi-threaded enivornment, but do not use the return pointer then. The pointer to the MibContext created SHOULD ONLY be used before you enter the main loop.
contextName | the name of the new context. |
|
virtual |
Clean up MIB.
Currently, the only clean up procedure is to call the remove_unused_rows() method of each MibTable object in the MIB.
|
inlineprotectedvirtual |
Deletes the the supplied request.
This method can be overwritten by sub-classes to implement special processing before a request object is freed. This method is called at the end of the finalize method.
req | a pointer to the Request instance to delete. |
|
virtual |
Internally process a request (typically within its own thread).
req | a request. |
|
protectedvirtual |
Finalize a request.
The finalize method is called if all sub-requests have been successfully processed.
request | the request to finalize. |
|
virtual |
Find the MIB object (i.e., MibTable, MibLeaf, etc.) that is responsible for the managed object identified by a given oid within a given context.
context | the target context. |
oid | an object identifier. |
retval | changed to a pointer to the found entry or unchanged if the return value is different from SNMP_ERROR_SUCCESS. |
request | a pointer to the request that is searching. |
|
virtual |
Find the next MIB entry which has an oid greater than the given oid.
context | the target context. |
oid | the OID for which a successor OID and managing MibEntry is searched. |
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. |
subrequest | the subrequest number being processed (starting from 0) |
nextOid | returns the successor OID (if found) or a zero length OID (if not found) for objects where the successor could be determined. Otherwise, the oid will be returned unchanged. |
|
virtual |
Get the MIB object with a given object id.
key | an object identifier |
|
virtual |
Get the MIB object with a given object id.
context | an OctetStr instance specifiying the target context. |
key | an object identifier |
|
inline |
Returns the config format for the specified format ID.
formatID | the format ID. |
|
virtual |
Get a context.
context | a context. |
|
inline |
Get the default context.
|
inline |
Gets the currently set NotificationSender.
|
virtual |
Get path where persistent MIB objects are stored.
|
inline |
Gets the request list associated with all Mib instances.
|
virtual |
Initialize all contexts.
The main purpose of this method is to trigger all MIB objects to load their data from persistent storage. NOTE: If no thread pool has been assigned until calling this method a default ThreadPool will be created with the default stack size. The number of threads and the thread stack size might not match your requirements. To use your own thread pool, simply call set_thread_pool() before calling this method.
@return TRUE if initialization was successful, FALSE otherwise.
|
virtual |
Check whether a node (a MIB object) is complex, i.e.
whether the node manages more than one leaf object.
A | pointer to a node (MIB object). |
|
inline |
Check whether a node (a MIB object) is a leaf node.
entry | a pointer to a node (MIB object). |
|
inline |
Checks whether a persistent objects path has been set.
Since get_persistent_objects_path always returns a path, calling this method is the only way to determine whether a path has been explicitly unset, to disable persistent storage at all.
|
inline |
Check whether a node (a MIB object) is a table.
entry | a pointer to a node (MIB object). |
|
virtual |
Load all persistent MIB objects in the supplied format from the supplied path.
All presistent objects will be resetted.
format | the format of the persistent data. |
path | the path where the data should be stored. |
|
inline |
Lock the receiver's registration.
Thus, no adding nor removing of MIB objects can be done while the lock is active.
While processing a (sub-)request the locking scheme is as follows:
|
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 |
Process the clean up phase of a set request.
rep | - The request. |
|
virtual |
Process the commit phase of a set request.
rep | - The request. |
|
virtual |
Process a get bulk request.
rep | - The request. |
|
virtual |
Process the prepare phase of a set request.
rep | - The request. |
|
virtual |
Process a request.
If multi-threading is activated, start a thread to actually process the request.
req | - A request. |
|
protectedvirtual |
Process a subrequest.
req | A pointer to the request |
|
virtual |
Process a set request.
rep | the set request to process. |
|
virtual |
Process the undo phase of a set request.
rep | - The request. |
|
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 calldelete_requesting target::end_synch(). The target object is deleted and the MIB lock is released.
Why is this save?
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 specifying the target context. |
oid | the Oidx instance pointing to the key of the MibEntry to be removed. |
Remove Agent Capabilities from a context.
context | a context. An empty string denotes the default context. |
sysORID | an authoritative identification of a capabilities statement with respect to various MIB modules supported by the local SNMPv2 entity acting in an agent role. |
|
virtual |
Remove a given context from the receiver.
Note: This method is synchronized using ::lock_mib().
contextName | the name of the new context. |
|
virtual |
Save all persistent MIB objects in the supplied format to the supplied path.
format | the format of the persistent data. |
path | the path where the data should be stored. |
|
virtual |
Save all persistent MIB objects to disk.
|
staticprotected |
Set the exception status for the supplied sub-request.
req | a pointer to a Request. |
reqind | the index of the sub-request to be modified. |
void Mib::set_notification_sender | ( | NotificationSender * | ) |
Sets the notification sender to be used by this Mib.
By default a NotificationOriginator is used, which is created the first time the notify method is called. By setting a different notification sender before notify is called for the first time, the set NotificationSender is used instead. The set NotificationSender is deleted by the destructor of Mib or when this method is called again.
notificationSender | a pointer to a NotificationSender instance. A previously set notificationSender will be deleted. If notificationSender is set to 0, any previously set instance will be deleted and the default sender will be used when notify is called again. |
|
virtual |
Set the path where persistent MIB objects are stored.
In order to disable persistent objects, call with NULL.
str | pointer to the the path (this function calls clone() to get a clean new pointer. |
void Mib::set_request_list | ( | RequestList * | ) |
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 | a RequestList instance. |
|
inline |
Release the lock on the receiver's registration.
|
protected |
|
protected |
|
protected |
|
static |
|
protected |
|
protected |
|
protected |
RequestList* Mib::requestList |
Pointer to the RequestList used for answering requests.