Mib Class Reference

#include <mib.h>

Inheritance diagram for Mib:

SimMib

List of all members.

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.
RequestListget_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.
NotificationSenderget_notification_sender () const
 Gets the currently set NotificationSender.
virtual void cleanup ()
 Clean up MIB.
virtual MibEntryadd (MibEntry *)
 Register a MIB object for the default context.
virtual MibEntryadd (const NS_SNMP OctetStr &, MibEntry *)
 Register a MIB object within a given context.
virtual MibContextadd_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 MibGroupfind_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 MibContextget_context (const NS_SNMP OctetStr &)
 Get a context.
MibContextget_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.
MibConfigFormatadd_config_format (unsigned int format, MibConfigFormat *)
 Adds a config format to this Mib instance.
MibConfigFormatget_config_format (unsigned int format)
 Returns the config format for the specified format ID.

Public Attributes

RequestListrequestList
 Pointer to the RequestList used for answering requests.

Static Public Attributes

static Mibinstance

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< MibContextcontexts
MibContextdefaultContext
NotificationSendernotificationSender
NS_SNMP OctetStr * persistent_objects_path
ThreadManager mibLock
Array< MibConfigFormatconfigFormats

Friends

class MibProxy


Constructor & Destructor Documentation

Mib::Mib (  ) 

Default Constructor.

Mib::Mib ( 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 Mib::~Mib (  )  [virtual]

Destructor.


Member Function Documentation

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.

Parameters:
requestList a RequestList instance.

RequestList* Mib::get_request_list (  )  [inline]

Gets the request list associated with all Mib instances.

Returns:
a RequestList instance.

virtual void Mib::process_request ( Request  )  [virtual]

Process a request.

If multi-threading is activated, start a thread to actually process the request.

Parameters:
req - A request.

virtual int Mib::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 if the notification could be sent successfully, otherwise an appropriate SNMP error is returned.

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.

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

Returns:
a pointer to a NotificationSender instance or 0 if it has not been set yet.

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.

virtual MibEntry* Mib::add ( MibEntry  )  [virtual]

Register a MIB object for the default context.

Note: This method is synchronized using lock_mib()

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

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

Parameters:
contextName the name of the new context.
Returns:
a pointer to the created and empty MibContext instance.

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().

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

Parameters:
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.
Returns:
TRUE if the context could be found and it contains the sysOR MIB objects, FALSE otherwise.

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

Remove Agent Capabilities from a context.

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

  • 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 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?

  • 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 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.

Returns:
TRUE if initialization was successful, FALSE otherwise.

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.

Parameters:
format the format of the persistent data.
path the path where the data should be stored.
Returns:
TRUE if data has been saved successfully, FALSE otherwise.

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.

Parameters:
format the format of the persistent data.
path the path where the data should be stored.
Returns:
TRUE if data has been saved successfully, FALSE otherwise.

virtual MibEntryPtr Mib::get ( const Oidx  )  [virtual]

Get the MIB object with a given object id.

Parameters:
key an object identifier
Returns:
a pointer to a MibEntry instance if an object with the given key could be found or 0 otherwise.

virtual MibEntryPtr Mib::get ( const NS_SNMP OctetStr &  ,
const Oidx  
) [virtual]

Get the MIB object with a given object id.

Parameters:
context an OctetStr instance specifiying the target context.
key an object identifier
Returns:
a pointer to a MibEntry instance if an object with the given key could be found or 0 otherwise.

virtual MibGroup* Mib::find_group_of ( const NS_SNMP OctetStr &  ,
const Oidx  
) [virtual]

Find the MibGroup that contains a MibEntry with a given object ID.

(NOT SYNCHRONIZED)

Parameters:
context a context identifier.
oid a object identifier.
Returns:
a pointer to the MibGroup instance that contains an instance with the given oid, or 0 otherwise.

virtual NS_SNMP OctetStr Mib::get_persistent_objects_path (  )  const [virtual]

Get path where persistent MIB objects are stored.

Returns:
The path string.

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.

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

Returns:
TRUE if persistent storage is activated.

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.

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

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

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

Release the lock on the receiver's registration.

See also:
Mib::lock_mib()

virtual MibContext* Mib::get_context ( const NS_SNMP OctetStr &   )  [virtual]

Get a context.

Parameters:
context a context.
Returns:
a pointer to a MibContext instance, or 0 if no such instance exists.

MibContext* Mib::get_default_context (  )  [inline]

Get the default context.

Returns:
a pointer to 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.

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.
subrequest the subrequest number being processed (starting from 0)
Returns:
SNMP_ERROR_SUCCESS if an entry has been found and sNMP_SYNTAX_NOSUCHOBJECT otherwise.

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.

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

virtual void Mib::do_process_request ( Request  )  [virtual]

Internally process a request (typically within its own thread).

Parameters:
req a request.

virtual void Mib::process_set_request ( Request  )  [virtual]

Process a set request.

Parameters:
rep the set request to process.

virtual int Mib::process_prepare_set_request ( Request  )  [virtual]

Process the prepare phase of a set request.

Parameters:
rep - The request.
Returns:
SNMP_ERROR_SUCCESS on success or any other SNMP error code on failure.

virtual int Mib::process_commit_set_request ( Request  )  [virtual]

Process the commit phase of a set request.

Parameters:
rep - The request.
Returns:
SNMP_ERROR_SUCCESS on success or any other SNMP error code on failure.

virtual int Mib::process_undo_set_request ( Request  )  [virtual]

Process the undo phase of a set request.

Parameters:
rep - The request.
Returns:
SNMP_ERROR_SUCCESS on success or any other SNMP error code on failure.

virtual void Mib::process_cleanup_set_request ( Request  )  [virtual]

Process the clean up phase of a set request.

Parameters:
rep - The request.

virtual void Mib::process_get_bulk_request ( Request  )  [virtual]

Process a get bulk request.

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

Parameters:
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.
Returns:
the MibConfigFormat instance that was formerly registered with the supplied formatID, or NULL if no such registration exists.

MibConfigFormat* Mib::get_config_format ( unsigned int  format  )  [inline]

Returns the config format for the specified format ID.

Parameters:
formatID the format ID.
Returns:
the MibConfigFormat instance registered for the supplied formatID, or NULL if such a format is not registered.

static boolean Mib::set_exception_vb ( Request ,
int  ,
int   
) [static, protected]

Set the exception status for the supplied sub-request.

Parameters:
req a pointer to a Request.
reqind the index of the sub-request to be modified.
Returns:
TRUE if the request can be further processed (thus it is not necessarily finished yet) or FALSE if the it has to be finished.

virtual boolean Mib::process_request ( Request ,
int   
) [protected, virtual]

Process a subrequest.

Parameters:
req A pointer to the request
Returns:
FALSE if an error occured and the whole request finished

virtual void Mib::finalize ( Request  )  [protected, virtual]

Finalize a request.

The finalize method is called if all sub-requests have been successfully processed.

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

Parameters:
req a pointer to the Request instance to delete.
Since:
3.5.23


Friends And Related Function Documentation

friend class MibProxy [friend]


Member Data Documentation

Mib* Mib::instance [static]

Pointer to the RequestList used for answering requests.

NS_SNMP OctetStr* Mib::persistent_objects_path [protected]


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

Generated on Fri May 29 22:36:54 2009 for AGENT++ by  doxygen 1.5.6