Fired when a SNMP trap packet is received.
type TTrapEvent = procedure ( Sender: TObject; RequestId: Integer; SNMPVersion: Integer; const Community: String; const User: String; SecurityLevel: Integer; const TrapOID: String; TimeStamp: Int64; const SourceAddress: String; SourcePort: Integer ) of Object;
property OnTrap: TTrapEvent read FOnTrap write FOnTrap;
The SNMPTrapMgr component should normally be used to receive traps, since it was designed and contains functionality specifically for that purpose. The SNMPMgr component can only receive traps from the agent that it is has most recently discovered with the Discover method.
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 "220.127.116.11.18.104.22.168.5", TrapOID will be a concatenation of TrapEnterprise and GenericTrap + 1. For instance a TrapOID of "22.214.171.124.126.96.36.199.5.5" has a TrapEnterprise of "188.8.131.52.184.108.40.206.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 SNMPMgr component is limited to accepting authenticated traps only for the user specified in User and Password and from the engine specified in RemoteEngineId with time parameters in RemoteEngineBoots and RemoteEngineTime (usually this is the SNMP engine discovered through the last call to Discover). If authenticated traps come from a different engine, or for a different user, they are ignored, and a BadPacket event is fired instead.
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.