How to send SNMP v2 trap using Ararat Synapse?

I tried to modify the TrapSend.dpr sample project, which I downloaded from http://synapse.ararat.cz/files/contrib/Trap.zip to send SNMP v2 traps without success. Note. I can successfully send SNMP v1 traps using a sample.

This is the original SendTrap function in SNMPTrap.pas:

function SendTrap(Dest, Source, Enterprise, Community: string; Generic, Specific, Seconds: integer; MIBName, MIBValue: string; MIBtype:integer): integer; var SNMP: TTrapSNMP; begin SNMP := TTrapSNMP.Create; try SNMP.SNMPHost := Dest; SNMP.Trap.TrapHost := Source; SNMP.Trap.Enterprise := Enterprise; SNMP.Trap.Community := Community; SNMP.Trap.GenTrap := Generic; SNMP.Trap.SpecTrap := Specific; SNMP.Trap.TimeTicks := Seconds; SNMP.Trap.MIBAdd(MIBName,MIBValue,MIBType); Result := SNMP.Send; finally SNMP.Free; end; end; 

After reading the example at http://en.it-usenet.org/thread/14303/3313/ , I changed SNMPTrap.pas to the following to send a generic SNMP v2 binding, but it did not work:

 function SendTrap(Dest, Source, Enterprise, Community: string; Generic, Specific, Seconds: integer; MIBName, MIBValue: string; MIBtype:integer): integer; var SNMP: TTrapSNMP; begin SNMP := TTrapSNMP.Create; try SNMP.SNMPHost := Dest; // SNMP.Trap.TrapHost := Source; // SNMP.Trap.Enterprise := Enterprise; SNMP.Trap.Community := Community; // SNMP.Trap.GenTrap := Generic; // SNMP.Trap.SpecTrap := Specific; // SNMP.Trap.TimeTicks := Seconds; SNMP.Trap.Version := SNMP_V2C; SNMP.Trap.PDUType := PDUTrapV2; // SNMP.Trap.MIBAdd(MIBName,MIBValue,MIBType); SNMP.Trap.MIBAdd('1.3.6.1.2.1.1.3.0','0',ASN1_TIMETICKS); SNMP.Trap.MIBAdd('1.3.6.1.6.3.1.1.4.1.0','1.3.6.1.6.3.1.1.5.3',ASN1_OBJID); Result := SNMP.Send; finally SNMP.Free; end; end; 

Wireshark returned the following error:

 No. Time Source Destination Protocol Length Info 50494 2016.821366000 192.168.0.125 192.168.0.10 SNMP 117 snmpV2-trap Frame 50494: 117 bytes on wire (936 bits), 117 bytes captured (936 bits) on interface 0 Ethernet II, Src: IntelCor_0b:d9:b8 (00:24:d7:0b:d9:b8), Dst: Hewlett-_48:5c:54 (00:23:7d:48:5c:54) Internet Protocol Version 4, Src: 192.168.0.125 (192.168.0.125), Dst: 192.168.0.10 (192.168.0.10) User Datagram Protocol, Src Port: 63309 (63309), Dst Port: snmptrap (162) Simple Network Management Protocol version: v2c (1) community: public data: snmpV2-trap (7) snmpV2-trap BER Error: Wrong field in sequence expected class:UNIVERSAL(0) tag:2(INTEGER) but found class:UNIVERSAL(0) tag:6 [Expert Info (Warn/Malformed): BER Error: Wrong field in sequence] [Message: BER Error: Wrong field in sequence] [Severity level: Warn] [Group: Malformed] BER Error: Wrong field in sequence expected class:UNIVERSAL(0) tag:2(INTEGER) but found class:APPLICATION(1) tag:0 [Expert Info (Warn/Malformed): BER Error: Wrong field in sequence] [Message: BER Error: Wrong field in sequence] [Severity level: Warn] [Group: Malformed] error-index: 0 BER Error: Wrong field in sequence expected class:UNIVERSAL(0) tag:16(SEQUENCE) but found class:UNIVERSAL(0) tag:2 [Expert Info (Warn/Malformed): BER Error: Wrong field in sequence] [Message: BER Error: Wrong field in sequence] [Severity level: Warn] [Group: Malformed] BER Error: This field lies beyond the end of the known sequence definition. [Expert Info (Warn/Malformed): BER Error: Unknown field in Sequence] [Message: BER Error: Unknown field in Sequence] [Severity level: Warn] [Group: Malformed] BER Error: This field lies beyond the end of the known sequence definition. [Expert Info (Warn/Malformed): BER Error: Unknown field in Sequence] [Message: BER Error: Unknown field in Sequence] [Severity level: Warn] [Group: Malformed] 

For comparison, I turned on a properly configured SNMP SNMP trap (which I sent using the sender / sender).

 No. Time Source Destination Protocol Length Info 54 7.697996000 192.168.0.125 192.168.0.10 SNMP 111 snmpV2-trap SNMPv2-MIB::sysUpTime.0 SNMPv2-MIB::snmpTrapOID.0 Frame 54: 111 bytes on wire (888 bits), 111 bytes captured (888 bits) on interface 0 Ethernet II, Src: IntelCor_0b:d9:b8 (00:24:d7:0b:d9:b8), Dst: Hewlett-_48:5c:54 (00:23:7d:48:5c:54) Internet Protocol Version 4, Src: 192.168.0.125 (192.168.0.125), Dst: 192.168.0.10 (192.168.0.10) User Datagram Protocol, Src Port: 53423 (53423), Dst Port: snmptrap (162) Simple Network Management Protocol version: v2c (1) community: public data: snmpV2-trap (7) snmpV2-trap request-id: 75820535 error-status: noError (0) error-index: 0 variable-bindings: 2 items SNMPv2-MIB::sysUpTime.0 (1.3.6.1.2.1.1.3.0): 0 Object Name: 1.3.6.1.2.1.1.3.0 (SNMPv2-MIB::sysUpTime.0) Value (Timeticks): 0 SNMPv2-MIB::snmpTrapOID.0 (1.3.6.1.6.3.1.1.4.1.0): 1.3.6.1.6.3.1.1.5.3 (IF-MIB::linkDown) Object Name: 1.3.6.1.6.3.1.1.4.1.0 (SNMPv2-MIB::snmpTrapOID.0) Value (OID): 1.3.6.1.6.3.1.1.5.3 (IF-MIB::linkDown) 
+6
source share

Source: https://habr.com/ru/post/956932/


All Articles