C# Class SnmpSharpNet.TrapAgent

Send SNMP Trap notifications
TrapAgent class is used to hide Socket operations from users and provide an easy method to send Trap notifications. To use the class, you can use the TrapAgent class protocol specific members, recommended when you expect to send a lot of notifications, or a static helper TrapAgent.SendTrap method which will construct a new socket for each call.
Datei anzeigen Open project: griffina/SnmpSharpNet Class Usage Examples

Protected Properties

Property Type Description
_sock Socket

Public Methods

Method Description
SendTrap ( SnmpPacket packet, IpAddress peer, int port ) : void

Send SNMP Trap notification

Helper function to allow for seamless sending of SNMP notifications for all protocol versions. packet parameter should be appropriately formatted SNMP notification in SnmpV1TrapPacket, SnmpV2Packet or SnmpV3Packet class cast as SnmpPacket class. Function will determine which version of the notification is to be used by checking the type of the packet parameter and call appropriate TrapAgent member function to send it.

SendV1Trap ( IpAddress receiver, int receiverPort, string community, Oid senderSysObjectID, IpAddress senderIpAdress, Int32 genericTrap, Int32 specificTrap, UInt32 senderUpTime, VbCollection varList ) : void

Construct and send SNMP v1 Trap

SendV1Trap ( SnmpV1TrapPacket packet, IpAddress peer, int port ) : void

Send SNMP version 1 Trap notification

SendV2Trap ( IpAddress receiver, int receiverPort, string community, UInt32 senderUpTime, Oid trapObjectID, VbCollection varList ) : void

Construct and send SNMP v2 Trap

SendV2Trap ( SnmpV2Packet packet, IpAddress peer, int port ) : void

Send SNMP version 2 Trap notification

SendV3Trap ( IpAddress receiver, int receiverPort, byte engineId, Int32 senderEngineBoots, Int32 senderEngineTime, string senderUserName, UInt32 senderUpTime, Oid trapObjectID, VbCollection varList ) : void

Construct and send SNMP v3 noAuthNoPriv Trap

SendV3Trap ( IpAddress receiver, int receiverPort, byte engineId, Int32 senderEngineBoots, Int32 senderEngineTime, string senderUserName, UInt32 senderUpTime, Oid trapObjectID, VbCollection varList, AuthenticationDigests authDigest, byte authSecret ) : void

Construct and send SNMP v3 authNoPriv Trap

SendV3Trap ( IpAddress receiver, int receiverPort, byte engineId, Int32 senderEngineBoots, Int32 senderEngineTime, string senderUserName, UInt32 senderUpTime, Oid trapObjectID, VbCollection varList, AuthenticationDigests authDigest, byte authSecret, PrivacyProtocols privProtocol, byte privSecret ) : void

Construct and send SNMP v3 authPriv Trap

SendV3Trap ( SnmpV3Packet packet, IpAddress peer, int port ) : void

Send SNMP version 3 Trap notification

TrapAgent ( ) : System

Constructor.

Constructor initializes an internal Socket used to send traps. Socket is initialized by selecting a random UDP port number.

Method Details

SendTrap() public static method

Send SNMP Trap notification
Helper function to allow for seamless sending of SNMP notifications for all protocol versions. packet parameter should be appropriately formatted SNMP notification in SnmpV1TrapPacket, SnmpV2Packet or SnmpV3Packet class cast as SnmpPacket class. Function will determine which version of the notification is to be used by checking the type of the packet parameter and call appropriate TrapAgent member function to send it.
public static SendTrap ( SnmpPacket packet, IpAddress peer, int port ) : void
packet SnmpPacket SNMP trap packet
peer IpAddress Manager (receiver) IP address
port int Manager (receiver) UDP port number
return void

SendV1Trap() public method

Construct and send SNMP v1 Trap
public SendV1Trap ( IpAddress receiver, int receiverPort, string community, Oid senderSysObjectID, IpAddress senderIpAdress, Int32 genericTrap, Int32 specificTrap, UInt32 senderUpTime, VbCollection varList ) : void
receiver IpAddress Receiver IP address
receiverPort int Receiver UDP port number
community string SNMP community name
senderSysObjectID Oid Senders sysObjectID
senderIpAdress IpAddress Sender IP address
genericTrap System.Int32 Generic trap code
specificTrap System.Int32 Specific trap code
senderUpTime System.UInt32 Senders sysUpTime
varList VbCollection Variable binding list
return void

SendV1Trap() public method

Send SNMP version 1 Trap notification
public SendV1Trap ( SnmpV1TrapPacket packet, IpAddress peer, int port ) : void
packet SnmpV1TrapPacket SNMP v1 Trap packet class
peer IpAddress Manager (receiver) IP address
port int Manager (receiver) UDP port number
return void

SendV2Trap() public method

Construct and send SNMP v2 Trap
public SendV2Trap ( IpAddress receiver, int receiverPort, string community, UInt32 senderUpTime, Oid trapObjectID, VbCollection varList ) : void
receiver IpAddress Trap receiver IP address
receiverPort int Trap receiver UDP port number
community string SNMP community name
senderUpTime System.UInt32 Sender sysUpTime
trapObjectID Oid Trap ObjectID
varList VbCollection Variable binding list
return void

SendV2Trap() public method

Send SNMP version 2 Trap notification
public SendV2Trap ( SnmpV2Packet packet, IpAddress peer, int port ) : void
packet SnmpV2Packet SNMP v2 Trap packet class
peer IpAddress Manager (receiver) IP address
port int Manager (receiver) UDP port number
return void

SendV3Trap() public method

Construct and send SNMP v3 noAuthNoPriv Trap
public SendV3Trap ( IpAddress receiver, int receiverPort, byte engineId, Int32 senderEngineBoots, Int32 senderEngineTime, string senderUserName, UInt32 senderUpTime, Oid trapObjectID, VbCollection varList ) : void
receiver IpAddress Trap receiver IP address
receiverPort int Trap receiver UDP port number
engineId byte Sender SNMP engineId
senderEngineBoots Int32 Sender SNMP engine boots
senderEngineTime Int32 Sender SNMP engine time
senderUserName string Security (user) name
senderUpTime UInt32 Sender upTime
trapObjectID Oid Trap object ID
varList VbCollection Variable binding list
return void

SendV3Trap() public method

Construct and send SNMP v3 authNoPriv Trap
public SendV3Trap ( IpAddress receiver, int receiverPort, byte engineId, Int32 senderEngineBoots, Int32 senderEngineTime, string senderUserName, UInt32 senderUpTime, Oid trapObjectID, VbCollection varList, AuthenticationDigests authDigest, byte authSecret ) : void
receiver IpAddress Trap receiver IP address
receiverPort int Trap receiver UDP port number
engineId byte Sender SNMP engineId
senderEngineBoots Int32 Sender SNMP engine boots
senderEngineTime Int32 Sender SNMP engine time
senderUserName string Security (user) name
senderUpTime UInt32 Sender upTime
trapObjectID Oid Trap object ID
varList VbCollection Variable binding list
authDigest AuthenticationDigests Authentication digest. enumeration for /// available digests
authSecret byte Authentication secret
return void

SendV3Trap() public method

Construct and send SNMP v3 authPriv Trap
public SendV3Trap ( IpAddress receiver, int receiverPort, byte engineId, Int32 senderEngineBoots, Int32 senderEngineTime, string senderUserName, UInt32 senderUpTime, Oid trapObjectID, VbCollection varList, AuthenticationDigests authDigest, byte authSecret, PrivacyProtocols privProtocol, byte privSecret ) : void
receiver IpAddress Trap receiver IP address
receiverPort int Trap receiver UDP port number
engineId byte Sender SNMP engineId
senderEngineBoots Int32 Sender SNMP engine boots
senderEngineTime Int32 Sender SNMP engine time
senderUserName string Security (user) name
senderUpTime UInt32 Sender upTime
trapObjectID Oid Trap object ID
varList VbCollection Variable binding list
authDigest AuthenticationDigests Authentication digest. See enumeration for /// available digests
authSecret byte Authentication secret
privProtocol PrivacyProtocols Privacy protocol. See enumeration for /// available privacy protocols.
privSecret byte Privacy secret
return void

SendV3Trap() public method

Send SNMP version 3 Trap notification
public SendV3Trap ( SnmpV3Packet packet, IpAddress peer, int port ) : void
packet SnmpV3Packet SNMP v3 Trap packet class
peer IpAddress Manager (receiver) IP address
port int Manager (receiver) UDP port number
return void

TrapAgent() public method

Constructor.
Constructor initializes an internal Socket used to send traps. Socket is initialized by selecting a random UDP port number.
public TrapAgent ( ) : System
return System

Property Details

_sock protected_oe property

Internal Socket class
protected Socket _sock
return Socket