SendTrap Method

Sends an SNMP Trap.

Syntax

int SendTrap(const QString& qsRemoteHost, const QString& qsTrapOID);

Remarks

Depending upon the value of the SNMPVersion property, the packet is constructed as an SNMPv1 or SNMPv2 Trap PDU. The following configuration settings provide more control about how traps are generated: TrapPort, TrapAgentAddress, TrapCommunity, TrapEnterprise. The SysUpTime property provides the trap timestamp.

SendTrap sends an unauthenticated trap. The SendSecureTrap method is used to send authenticated SNMPv3 traps.

If any values are provided in the Objects collection, they are sent unchanged. In the case of an SNMPv2 or SNMPv3 Trap, if Objects has a count that is equal to 0, the following values are set: sysUpTime.0 equal to SysUpTime and snmpTrapOID.0 equal to TrapOID.

For SNMPv2 and SNMPv3 Traps, TrapOID must contain the full OID of the Trap. For SNMPv1, TrapOID must be a string of the form "generic.specific" where generic and specific are numeric values providing the Trap Generic Type and Specific Type.

For SNMPv1, TrapOID must be of the form "GenericTrap.SpecificTrap". These values are sent in the PDU header. TrapAgentAddress and TrapEnterprise are taken from the corresponding configuration settings.

Additionally, the following symbolic values are recognized and translated as follows:

Trap Name OID (SNMPv2 and above) SNMPv1 GenericType
coldStart 1.3.6.1.6.3.1.1.5.1 0
warmStart 1.3.6.1.6.3.1.1.5.2 1
linkDown 1.3.6.1.6.3.1.1.5.3 2
linkUp 1.3.6.1.6.3.1.1.5.4 3
authenticationFailure 1.3.6.1.6.3.1.1.5.5 4
egpNeighborLoss 1.3.6.1.6.3.1.1.5.6 5
enterpriseSpecific 1.3.6.1.6.3.1.1.5.7 6

Error Handling

This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)

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