AGENT++  4.0.3
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MibProxy Class Reference

The MibProxy class represents a sub-tree within an agents MIB whose nodes and their values are proxied (forwarded) from another SNMPv1/v2c agent. More...

#include <mib_proxy.h>

Inheritance diagram for MibProxy:
MibEntry ThreadManager Synchronized

Public Member Functions

 MibProxy ()
 Default constructor.
 
 MibProxy (const MibProxy &other)
 Copy constructor.
 
 MibProxy (const Oidx &, mib_access, const NS_SNMP UdpAddress &)
 Simple proxy registration.
 
 MibProxy (const Oidx &, mib_access, const Oidx &, const NS_SNMP UdpAddress &)
 Proxy registration with oid translation.
 
virtual ~MibProxy ()
 Destructor.
 
virtual mib_type type () const
 Return type of the MIB entry.
 
virtual MibEntryclone ()
 Clone.
 
virtual OidxPtr max_key ()
 Return the immediate successor of the greatest object identifier within the receiver's scope.
 
virtual Oidx find_succ (const Oidx &, Request *r=0)
 Find the successor of the given OID in the proxied MIB view and cache its value for a possibly following get_next_request call.
 
virtual bool is_empty ()
 Check whether the reciever node contains any instance of a managed object.
 
virtual void get_request (Request *, int)
 Let the receiver process a SNMP GET subrequest.
 
virtual int commit_set_request (Request *, int)
 Let the receiver commit a SNMP SET subrequest.
 
virtual int prepare_set_request (Request *, int &)
 Let the receiver prepare a SNMP SET subrequest.
 
virtual void get_next_request (Request *, int)
 Let the receiver process a SNMP GETNEXT subrequest.
 
void set_community (access_types a, const NS_SNMP OctetStr &c)
 Set the READ and WRITE community for outgoing requests, respectively.
 
- Public Member Functions inherited from MibEntry
 MibEntry ()
 Default constructor.
 
 MibEntry (const Oidx &, mib_access)
 Construct a MibEntry instance with a given object identifier and maximum access rights.
 
 MibEntry (const MibEntry &)
 Copy constructor.
 
virtual ~MibEntry ()
 Destructor.
 
virtual int undo_set_request (Request *, int &)
 Clean up resources used for performing (or undoing) set requests.
 
virtual void cleanup_set_request (Request *, int &)
 Set the receiver's value and backup its old value for a later undo.
 
virtual void load_from_file (const char *)
 Load the value(s) of the receiver node from a file.
 
virtual void save_to_file (const char *)
 Save the value(s) of the receiver node to a file.
 
virtual bool serialize (char *&, int &)
 Serialize the value of the receiver.
 
virtual bool deserialize (char *, int &)
 Read the value of the receiver from a byte stream.
 
virtual void notify_change (const Oidx &, mib_change)
 Notify all registered nodes of changes to an object managed by the receiver node.
 
virtual void register_for_notifications (MibEntry *)
 Register an MibEntry object to receive notifications about changes of the receiver node.
 
virtual void add_change_notification (MibEntry *e)
 Wrapper function for register_for_notifications.
 
virtual void change_notification (const Oidx &, mib_change)
 Receive a notification about changes to a managed object.
 
OidxPtr key ()
 Return a pointer to the key (object identifier) of the receiver.
 
virtual mib_access get_access ()
 Return the maximum access rights for the managed object represented by the receiver node.
 
virtual bool is_volatile ()
 Check whether the entry is volatile or not.
 
virtual void reset ()
 Resets (clears) the content of this entry.
 
int operator< (const MibEntry &) const
 
int operator> (const MibEntry &) const
 
int operator== (const MibEntry &) const
 
int operator< (const Oidx &) const
 
int operator> (const Oidx &) const
 
int operator<= (const Oidx &) const
 
int operator>= (const Oidx &) const
 
int operator== (const Oidx &) const
 
- Public Member Functions inherited from ThreadManager
 ThreadManager ()
 Default constructor.
 
virtual ~ThreadManager ()
 Destructor.
 
void start_synch ()
 Start synchronized execution.
 
void end_synch ()
 End synchronized execution.
 
- Public Member Functions inherited from Synchronized
 Synchronized ()
 
 ~Synchronized ()
 
void wait ()
 Causes current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
 
bool wait (unsigned long timeout)
 Causes current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a specified amount of time has elapsed.
 
void notify ()
 Wakes up a single thread that is waiting on this object's monitor.
 
void notify_all ()
 Wakes up all threads that are waiting on this object's monitor.
 
bool lock ()
 Enter a critical section.
 
TryLockResult trylock ()
 Try to enter a critical section.
 
bool unlock ()
 Leave a critical section.
 

Protected Member Functions

virtual Oidx translate (const Oidx &)
 
virtual Oidx backward_translate (const Oidx &)
 
void determineDefaultRange (const Oidx &)
 
- Protected Member Functions inherited from MibEntry
void set_oid (const Oidx &)
 Set the object identifier of the receiver node.
 

Protected Attributes

NS_SNMP UdpAddress source
 
Oidx translation
 
bool translating
 
NS_SNMP OctetStr community [WRITING+1]
 
Oidx range
 
Vbx lastNext
 
int lastNextStatus
 
- Protected Attributes inherited from MibEntry
Oidx oid
 
mib_access access
 
List< MibEntrynotifies
 

Additional Inherited Members

- Public Types inherited from Synchronized
enum  TryLockResult { LOCKED = 1, BUSY = 0, OWNED = -1 }
 
- Static Public Member Functions inherited from ThreadManager
static void start_global_synch ()
 Start global synchronized execution.
 
static void end_global_synch ()
 End global synchronized execution.
 

Detailed Description

The MibProxy class represents a sub-tree within an agents MIB whose nodes and their values are proxied (forwarded) from another SNMPv1/v2c agent.

The following figure displays a possible scenario:

   +--------------+        +----------+       +-----------+
   |    Manager   |        | AGENT++  |       | Any v1 or |
   |              |--------| MibProxy |-------| v2c agent |
   | v1/v2c or v3 |        |          |       |           |
   +--------------+        +----------+       +-----------+

SNMP v3 support for MibProxy can be easily added by sub-classing.

Author
Frank Fock
Version
3.02

Constructor & Destructor Documentation

MibProxy::MibProxy ( )

Default constructor.

MibProxy::MibProxy ( const MibProxy other)

Copy constructor.

Parameters
otheranother MibProxy instance
MibProxy::MibProxy ( const Oidx ,
mib_access  ,
const NS_SNMP UdpAddress &   
)

Simple proxy registration.

Parameters
rootthe oid of the root of the proxied MIB portion
accessthe max-access for the whole sub-tree
sourcethe UDP address of the SNMP agent to whom requests for oids within this MibProxy sub-tree should be redirected
MibProxy::MibProxy ( const Oidx ,
mib_access  ,
const Oidx ,
const NS_SNMP UdpAddress &   
)

Proxy registration with oid translation.

Parameters
rootthe oid of the root of the proxied MIB portion
accessthe max-access for the whole sub-tree
translated_rootroot will be replaced by translated_root for requests sent out to the remote agent (for example if root="1.3.6.1.3" and translated_root="1.3.6.1.2" all oids of mgmt of the remote agent would become experimental objects of the proxy agent
sourcethe UDP address of the SNMP agent to whom requests for oids within this MibProxy sub-tree should be redirected
virtual MibProxy::~MibProxy ( )
inlinevirtual

Destructor.

Member Function Documentation

virtual Oidx MibProxy::backward_translate ( const Oidx )
protectedvirtual
virtual MibEntry* MibProxy::clone ( )
inlinevirtual

Clone.

Returns
a pointer to a clone of the receiver

Reimplemented from MibEntry.

virtual int MibProxy::commit_set_request ( Request ,
int   
)
virtual

Let the receiver commit a SNMP SET subrequest.

Parameters
req- A pointer to the whole SNMP SET request.
ind- The index of the subrequest to be processed.
Returns
SNMP_ERROR_SUCCESS on success and SNMP_ERROR_COMITFAIL on failure.

Reimplemented from MibEntry.

void MibProxy::determineDefaultRange ( const Oidx )
protected
virtual Oidx MibProxy::find_succ ( const Oidx ,
Request r = 0 
)
virtual

Find the successor of the given OID in the proxied MIB view and cache its value for a possibly following get_next_request call.

Parameters
idan oid less or equal than max_key()
requesta pointer to the Request instance for in whose context the find_next is issued.
Returns
an oid greater than id or an empty oid (zero length) if an successor could not be determined or would be greater than max_key()

Reimplemented from MibEntry.

virtual void MibProxy::get_next_request ( Request ,
int   
)
virtual

Let the receiver process a SNMP GETNEXT subrequest.

The OID of the subrequest identified by the given index is already set to the next OID found. In other words, the OID of the current subrequest is different from the OID in the original request. So the implementation of this method does not need to search the appropriate "next" OID.

Parameters
req- A pointer to the whole SNMP GETNEXT request.
ind- The index of the subrequest to be processed.

Reimplemented from MibEntry.

virtual void MibProxy::get_request ( Request ,
int   
)
virtual

Let the receiver process a SNMP GET subrequest.

Parameters
req- A pointer to the whole SNMP GET request.
ind- The index of the subrequest to be processed.

Reimplemented from MibEntry.

virtual bool MibProxy::is_empty ( )
inlinevirtual

Check whether the reciever node contains any instance of a managed object.

Returns
TRUE if the node currently manages an instance.

Reimplemented from MibEntry.

virtual OidxPtr MibProxy::max_key ( )
virtual

Return the immediate successor of the greatest object identifier within the receiver's scope.

Returns
a pointer to the non including upper bound of the receiver's scope

Reimplemented from MibEntry.

virtual int MibProxy::prepare_set_request ( Request ,
int &   
)
virtual

Let the receiver prepare a SNMP SET subrequest.

Parameters
req- A pointer to the whole SNMP SET request.
ind- The index of the subrequest to be processed.
Returns
SNMP_ERROR_SUCCESS on success and SNMP_ERROR_WRONG_VALUE, SNMP_ERROR_WRONG_TYPE, or SNMP_ERROR_NOT_WRITEABLE on failure.

Reimplemented from MibEntry.

void MibProxy::set_community ( access_types  a,
const NS_SNMP OctetStr &  c 
)
inline

Set the READ and WRITE community for outgoing requests, respectively.

Parameters
access_typethe access type associated with the community - currently only READING and WRITING are supported
communitythe community to be used for the specified access type
virtual Oidx MibProxy::translate ( const Oidx )
protectedvirtual
virtual mib_type MibProxy::type ( ) const
inlinevirtual

Return type of the MIB entry.

Returns
AGENTPP_PROXY

Reimplemented from MibEntry.

Member Data Documentation

NS_SNMP OctetStr MibProxy::community[WRITING+1]
protected
Vbx MibProxy::lastNext
protected
int MibProxy::lastNextStatus
protected
Oidx MibProxy::range
protected
NS_SNMP UdpAddress MibProxy::source
protected
bool MibProxy::translating
protected
Oidx MibProxy::translation
protected

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