IPWorks SNMP 2020 .NET Edition

Questions / Feedback?

Trap Event

Fired when a SNMP trap packet is received.

Syntax

public event OnTrapHandler OnTrap;

public delegate void OnTrapHandler(object sender, SnmptcptrapmgrTrapEventArgs e);

public class SnmptcptrapmgrTrapEventArgs : EventArgs {
  public int RequestId { get; }
  public int SNMPVersion { get; }
  public string Community { get; }
  public string User { get; }
  public int SecurityLevel { get; }
  public string TrapOID { get; }
  public long TimeStamp { get; }
  public string AgentAddress { get; }
  public string SourceAddress { get; }
  public int SourcePort { get; }
}
Public Event OnTrap As OnTrapHandler

Public Delegate Sub OnTrapHandler(sender As Object, e As SnmptcptrapmgrTrapEventArgs)

Public Class SnmptcptrapmgrTrapEventArgs Inherits EventArgs
  Public ReadOnly Property RequestId As Integer
  Public ReadOnly Property SNMPVersion As Integer
  Public ReadOnly Property Community As String
  Public ReadOnly Property User As String
  Public ReadOnly Property SecurityLevel As Integer
  Public ReadOnly Property TrapOID As String
  Public ReadOnly Property TimeStamp As Long
  Public ReadOnly Property AgentAddress As String
  Public ReadOnly Property SourceAddress As String
  Public ReadOnly Property SourcePort As Integer
End Class

Remarks

The TrapOID and TimeStamp parameters contain the Trap OID and TimeStamp. In the case of an SNMPv1 trap, there are two possible scenarios:

First, if the enterprise of the trap is "1.3.6.1.6.3.1.1.5", TrapOID will be a concatenation of TrapEnterprise and GenericTrap + 1. For instance a TrapOID of "1.3.6.1.6.3.1.1.5.5" has a TrapEnterprise of "1.3.6.1.6.3.1.1.5" and a GenericTrap of "4".

Second, In all other cases TrapOID will be a concatenation of the values for TrapEnterprise, GenericTrap, and SpecificTrap, separated by '.'.

For SNMPv2 and above, they are read from the variable-value list (if available).

For SNMPv3, the User parameter shows the user that was supplied with the packet. This parameter MUST be used together with the SecurityLevel parameter which shows the level of security in the message.

The SecurityLevel parameter shows whether the request has been authenticated. If SecurityLevel is 0, the request has NOT been authenticated (i.e. the packet signature has not been verified). For an authenticated, non encrypted request, SecurityLevel is 1. For an authenticated and encrypted request, SecurityLevel is 2.

The list of variables in the SNMP packet, including optional values and types, is provided through the Objects collection. Each object is of type SNMPObject. This type describes the Oid, ObjectType, and Value of each SNMP object. These variables must be copied to another location before the event has completed executing, or they may be overridden by other events.

The SourceAddress and SourcePort parameters show the address and port of the sender as reported by the TCP/IP stack.

Some parameters are only applicable depending on the SNMPVersion value. The table below shows which parameters are applicable to which SNMP versions.

SNMPv1 SNMPv2 SNMPv3
AgentAddress X
Community X X
RequestId X X
SecurityLevel X
User X
SNMPVersion X X X
SourceAddress X X X
SourcePort X X X
TimeStamp X X X
TrapOID X X X

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks SNMP 2020 .NET Edition - Version 20.0 [Build 8202]