#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 boolean | 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 boolean | remove (const Oidx &) |
Unregister a MIB object from the agentūs MIB. | |
virtual boolean | remove (const NS_SNMP OctetStr &, const Oidx &) |
Unregister a MIB object from the agentūs MIB. | |
virtual boolean | init () |
Initialize all contexts. | |
virtual void | save_all () |
Save all persistent MIB objects to disk. | |
virtual boolean | save (unsigned int, const NS_SNMP OctetStr &) |
Save all persistent MIB objects in the supplied format to the supplied path. | |
virtual boolean | 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. | |
boolean | is_persistency_activated () const |
Checks whether a persistent objects path has been set. | |
virtual boolean | is_complex_node (const MibEntryPtr &) |
Check whether a node (a MIB object) is complex, i.e. | |
boolean | is_table_node (const MibEntryPtr &e) |
Check whether a node (a MIB object) is a table. | |
boolean | 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 &, MibEntryPtr &, Request *req, const int) |
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. | |
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 boolean | 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 boolean | 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 |
Friends | |
class | MibProxy |
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 Mib::~Mib | ( | ) | [virtual] |
Destructor.
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. |
RequestList* Mib::get_request_list | ( | ) | [inline] |
virtual void Mib::process_request | ( | Request * | ) | [virtual] |
Process a request.
If multi-threading is activated, start a thread to actually process the request.
req | - A request. |
virtual int Mib::notify | ( | const NS_SNMP OctetStr & | , | |
const Oidx & | , | |||
Vbx * | , | |||
int | , | |||
unsigned | int = 0 | |||
) | [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. |
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. |
NotificationSender* Mib::get_notification_sender | ( | ) | const [inline] |
Gets the currently set NotificationSender.
virtual void Mib::cleanup | ( | ) | [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.
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 MibContext* Mib::add_context | ( | const NS_SNMP OctetStr & | ) | [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 void Mib::remove_context | ( | const NS_SNMP OctetStr & | ) | [virtual] |
Remove a given context from the receiver.
Note: This method is synchronized using lock_mib().
contextName | the name of the new context. |
virtual boolean Mib::add_agent_caps | ( | const NS_SNMP OctetStr & | , | |
const Oidx & | , | |||
const NS_SNMP OctetStr & | ||||
) | [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. |
virtual void Mib::remove_agent_caps | ( | const NS_SNMP OctetStr & | , | |
const Oidx & | ||||
) | [virtual] |
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 boolean Mib::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?
virtual boolean Mib::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?
context | an OctetStr instance specifiying the target context. | |
oid | the Oidx instance pointing to the key of the MibEntry to be removed. |
virtual boolean Mib::init | ( | ) | [virtual] |
Initialize all contexts.
The main purpose of this method is to trigger all MIB objects to load their data from persistent storage.
virtual void Mib::save_all | ( | ) | [virtual] |
Save all persistent MIB objects to disk.
virtual boolean Mib::save | ( | unsigned | int, | |
const NS_SNMP OctetStr & | ||||
) | [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 boolean Mib::load | ( | unsigned | int, | |
const NS_SNMP OctetStr & | ||||
) | [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. |
virtual MibEntryPtr Mib::get | ( | const Oidx & | ) | [virtual] |
Get the MIB object with a given object id.
key | an object identifier |
virtual MibEntryPtr Mib::get | ( | const NS_SNMP OctetStr & | , | |
const Oidx & | ||||
) | [virtual] |
Get the MIB object with a given object id.
context | an OctetStr instance specifiying the target context. | |
key | an object identifier |
virtual NS_SNMP OctetStr Mib::get_persistent_objects_path | ( | ) | const [virtual] |
Get path where persistent MIB objects are stored.
virtual void Mib::set_persistent_objects_path | ( | const NS_SNMP OctetStr * | str | ) | [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. |
boolean Mib::is_persistency_activated | ( | ) | const [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.
virtual boolean Mib::is_complex_node | ( | const MibEntryPtr & | ) | [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). |
boolean Mib::is_table_node | ( | const MibEntryPtr & | e | ) | [inline] |
Check whether a node (a MIB object) is a table.
entry | a pointer to a node (MIB object). |
boolean Mib::is_leaf_node | ( | const MibEntryPtr & | e | ) | [inline] |
Check whether a node (a MIB object) is a leaf node.
entry | a pointer to a node (MIB object). |
void Mib::lock_mib | ( | ) |
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: 1. This MIB lock is acquired. 2. The MIB object is identified, which is responsible for processing the sub-request. 3. The MIB objects lock (MibEntry::start_synch()) is acquired. 4. The MIB lock is released. 5. The sub-request is propagated to the MIB object. 6. When finished, the MIB objects lock is released.
void Mib::unlock_mib | ( | ) |
virtual MibContext* Mib::get_context | ( | const NS_SNMP OctetStr & | ) | [virtual] |
Get a context.
context | a context. |
MibContext* Mib::get_default_context | ( | ) | [inline] |
Get the default context.
virtual int Mib::find_next | ( | MibContext * | , | |
const Oidx & | , | |||
MibEntryPtr & | , | |||
Request * | req, | |||
const | int | |||
) | [virtual] |
Find the next MIB entry which has an oid greater than the given oid.
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. | |
subrequest | the subrequest number being processed (starting from 0) |
virtual int Mib::find_managing_object | ( | MibContext * | , | |
const Oidx & | , | |||
MibEntryPtr & | , | |||
Request * | ||||
) | [virtual] |
Find the MIB object (i.e., MibTable, MibLeaf, etc.
) that is responsible for the managed object indentified 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 void Mib::do_process_request | ( | Request * | ) | [virtual] |
Internally process a request (typically within its own thread).
req | a request. |
virtual void Mib::process_set_request | ( | Request * | ) | [virtual] |
Process a set request.
rep | the set request to process. |
virtual int Mib::process_prepare_set_request | ( | Request * | ) | [virtual] |
Process the prepare phase of a set request.
rep | - The request. |
virtual int Mib::process_commit_set_request | ( | Request * | ) | [virtual] |
Process the commit phase of a set request.
rep | - The request. |
virtual int Mib::process_undo_set_request | ( | Request * | ) | [virtual] |
Process the undo phase of a set request.
rep | - The request. |
virtual void Mib::process_cleanup_set_request | ( | Request * | ) | [virtual] |
Process the clean up phase of a set request.
rep | - The request. |
virtual void Mib::process_get_bulk_request | ( | Request * | ) | [virtual] |
Process a get bulk request.
rep | - The request. |
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. |
MibConfigFormat* Mib::get_config_format | ( | unsigned int | format | ) | [inline] |
Returns the config format for the specified format ID.
formatID | the format ID. |
static boolean Mib::set_exception_vb | ( | Request * | , | |
int | , | |||
int | ||||
) | [static, protected] |
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. |
virtual boolean Mib::process_request | ( | Request * | , | |
int | ||||
) | [protected, virtual] |
Process a subrequest.
req | A pointer to the request |
virtual void Mib::finalize | ( | Request * | ) | [protected, virtual] |
Finalize a request.
The finalize method is called if all sub-requests have been successfully processed.
request | the request to finalize. |
virtual void Mib::delete_request | ( | Request * | req | ) | [inline, protected, virtual] |
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. |
friend class MibProxy [friend] |
Mib* Mib::instance [static] |
Pointer to the RequestList used for answering requests.
OidList<MibContext> Mib::contexts [protected] |
MibContext* Mib::defaultContext [protected] |
NotificationSender* Mib::notificationSender [protected] |
NS_SNMP OctetStr* Mib::persistent_objects_path [protected] |
ThreadManager Mib::mibLock [protected] |
Array<MibConfigFormat> Mib::configFormats [protected] |