AGENT++  4.0.3
Classes | Public Member Functions | Protected Member Functions | List of all members
NotificationOriginator Class Reference

The NotificationOriginator provides services to send traps and notifications by using the SNMP-TARGET-MIB and the SNMP-NOTIFICATION-MIB. More...

#include <notification_originator.h>

Inheritance diagram for NotificationOriginator:
NotificationSender

Classes

class  NotificationOriginatorParams
 

Public Member Functions

 NotificationOriginator ()
 Constructs a notification originator instance.
 
virtual ~NotificationOriginator ()
 Destructor.
 
void generate (Vbx *, int, const Oidx &, const Oidx &, const NS_SNMP OctetStr &)
 Generate a notification message.
 
void generate (Vbx *, int, const Oidx &, unsigned int, const NS_SNMP OctetStr &)
 Generate a notification message.
 
virtual int notify (const NS_SNMP OctetStr &, const Oidx &, Vbx *, int, unsigned int=0)
 Send a notification.
 
virtual bool add_v1_trap_destination (const NS_SNMP UdpAddress &addr, const NS_SNMP OctetStr &name, const NS_SNMP OctetStr &tag, const NS_SNMP OctetStr &community)
 Make all necessary entries in snmpTargetAddressTable, snmpTargetParamsTable, and snmpNotifyTable for the given v1, v2 or v3 trap destination.
 
virtual bool add_v2_trap_destination (const NS_SNMP UdpAddress &addr, const NS_SNMP OctetStr &name, const NS_SNMP OctetStr &tag, const NS_SNMP OctetStr &community)
 
virtual bool add_v3_trap_destination (const NS_SNMP UdpAddress &addr, const NS_SNMP OctetStr &name, const NS_SNMP OctetStr &tag, const NS_SNMP OctetStr &secName, const int secLevel)
 
- Public Member Functions inherited from NotificationSender
 NotificationSender ()
 Default constructor.
 
virtual ~NotificationSender ()
 Destructor.
 

Protected Member Functions

int generate (Vbx *, int, const Oidx &, unsigned int, const Oidx &, const NS_SNMP OctetStr &)
 Generate a notification message.
 
bool check_access (ListCursor< MibTableRow > &cur, NotificationOriginatorParams &nop)
 Check notification access for a management target.
 
int send_notify (ListCursor< MibTableRow > &cur, NotificationOriginatorParams &nop, int notify)
 Send a notification to a valid target.
 

Detailed Description

The NotificationOriginator provides services to send traps and notifications by using the SNMP-TARGET-MIB and the SNMP-NOTIFICATION-MIB.

NotificationOriginator is typically used outside the main loop of an agent's request handling.

Author
Frank Fock
Version
3.5.10

Constructor & Destructor Documentation

NotificationOriginator::NotificationOriginator ( )

Constructs a notification originator instance.

virtual NotificationOriginator::~NotificationOriginator ( )
virtual

Destructor.

Member Function Documentation

virtual bool NotificationOriginator::add_v1_trap_destination ( const NS_SNMP UdpAddress &  addr,
const NS_SNMP OctetStr &  name,
const NS_SNMP OctetStr &  tag,
const NS_SNMP OctetStr &  community 
)
virtual

Make all necessary entries in snmpTargetAddressTable, snmpTargetParamsTable, and snmpNotifyTable for the given v1, v2 or v3 trap destination.

Parameters
addran UDP target address.
nameunique name for the entries.
tagunique tag for the entries.
community/ secName community / security name to use when sending traps.
secLevelsecurity level to use when sending v3 traps
Returns
TRUE if the operation has been successful, FALSE otherwise.
virtual bool NotificationOriginator::add_v2_trap_destination ( const NS_SNMP UdpAddress &  addr,
const NS_SNMP OctetStr &  name,
const NS_SNMP OctetStr &  tag,
const NS_SNMP OctetStr &  community 
)
virtual
virtual bool NotificationOriginator::add_v3_trap_destination ( const NS_SNMP UdpAddress &  addr,
const NS_SNMP OctetStr &  name,
const NS_SNMP OctetStr &  tag,
const NS_SNMP OctetStr &  secName,
const int  secLevel 
)
virtual
bool NotificationOriginator::check_access ( ListCursor< MibTableRow > &  cur,
NotificationOriginatorParams nop 
)
protected

Check notification access for a management target.

Call this to validate access before sending the notificaiton. The NotificationOriginatorParams parameter must have the vbs, size, id, and contextName parameters filled in. Upon a TRUE return, the securityName, securityModel, securityLevel, mpModel, and target parameters will be filled in. If TRUE is returned, the caller is responsible to delete the target object in the NotificationOriginatorParams object (after sending the notification).

Parameters
curthe selected entry in the snmpTargetAddrTable
nopthe notification originator parameters
Returns
TRUE if access is okay, FALSE otherwise
void NotificationOriginator::generate ( Vbx ,
int  ,
const Oidx ,
const Oidx ,
const NS_SNMP OctetStr &   
)

Generate a notification message.

Parameters
vbsan array of variable bindings - the payload of the notification.
sizethe size of the above array.
idthe trap oid which identifies the notification.
enterprisethe enterprise oid. For v2,v3 and enterprise specific v1 traps this parameter should be "" (empty OID).
contextNamethe context in which the trap occured.
void NotificationOriginator::generate ( Vbx ,
int  ,
const Oidx ,
unsigned  int,
const NS_SNMP OctetStr &   
)

Generate a notification message.

Parameters
vbsan array of variable bindings - the payload of the notification.
sizethe size of the above array.
idthe trap oid which identifies the notification.
sysUpTimethe timestamp to be used
contextNamethe context in which the trap occured.
int NotificationOriginator::generate ( Vbx ,
int  ,
const Oidx ,
unsigned  int,
const Oidx ,
const NS_SNMP OctetStr &   
)
protected

Generate a notification message.

Parameters
vbsan array of variable bindings - the payload of the notification.
sizethe size of the above array.
idthe trap oid which identifies the notification.
sysUpTimethe timestamp to be used
enterprisethe enterprise oid. For v2,v3 and enterprise specific v1 traps this parameter should be "" (empty OID).
contextNamethe context in which the trap occured.
virtual int NotificationOriginator::notify ( const NS_SNMP OctetStr &  ,
const Oidx ,
Vbx ,
int  ,
unsigned  int = 0 
)
virtual

Send a notification.

This implements the NotificationSender interface.

Parameters
contextthe context originating the notification ("" for the default context).
trapoidthe oid of the notification.
vbsan array of variable bindings.
sizethe size of the above variable binding array.
timestampan optional timestamp.
Returns
SNMP_ERROR_SUCCESS if the notification could be sent successfully, otherwise an appropriate SNMP error is returned.

Implements NotificationSender.

int NotificationOriginator::send_notify ( ListCursor< MibTableRow > &  cur,
NotificationOriginatorParams nop,
int  notify 
)
protected

Send a notification to a valid target.

Call this only after validating access by calling the check_access method first. The NotificationOriginatorParams parameter must have the vbs, size, id, timestamp, enterprise, contextName, securityName, securityLevel, mpModel, and target parameters filled in.

Parameters
curthe selected entry in the snmpTargetAddrTable
nopthe notification originator parameters
notifyspecifies the notification type (trap or inform)
Returns
The result from calling SnmpRequestV3::send or SnmpRequest::process_trap

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