I'm trying to send SNMPv2c trap by modifying the TrapSend.dpr sample project 
which I downloaded from http://synapse.ararat.cz/files/contrib/Trap.zip.  
Will be grateful for any pointers.  :)
Rgds,Joshua

This is the original function SendTrap 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 in http://en.it-usenet.org/thread/14303/3313/, I 
tried to modify to the following but it didn't 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;  -> enterprise oid is added to variable 
binding in v2c    SNMP.Trap.Community := Community;  //  SNMP.Trap.GenTrap := 
Generic;   -> generic not required?  //  SNMP.Trap.SpecTrap := Specific;  -> 
specifi not required?   // SNMP.Trap.TimeTicks := Seconds;   -> timeticks added 
to variable binding  
   SNMP.Trap.Version := SNMP_V2C;  //newly added   SNMP.Trap.PDUType := 
PDUTrapV2;   //newly added
   // SNMP.Trap.MIBAdd(MIBName,MIBValue,MIBType);    
SNMP.Trap.MIBAdd('.1.3.6.1.2.1.1.3.0','10',ASN1_INT);    //timetick?    
SNMP.Trap.MIBAdd('.1.3.6.1.6.3.1.1.4.1.0','.1.3.6.1.6.3.1.1.5.1',ASN1_OBJID);   
// SNMP_TRAP_OID value set to "coldStartt    Result := SNMP.Send;  finally    
SNMP.Free;  end;end;

Wireshark returned the following error:
No.     Time           Source                Destination           Protocol 
Length Info 174322 4365.937784000 192.168.0.125         192.168.0.10          
SNMP     120    snmpV2-trap
Frame 174322: 120 bytes on wire (960 bits), 120 bytes captured (960 bits) on 
interface 0Ethernet 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: 52464 (52464), 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            BER Error: Wrong field in sequence  
expected class:UNIVERSAL(0) tag:2(INTEGER) but found class:APPLICATION(1) tag:0 
           error-index: 0            BER Error: Wrong field in sequence  
expected class:UNIVERSAL(0) tag:16(SEQUENCE) but found class:UNIVERSAL(0) tag:2 
           BER Error: This field lies beyond the end of the known sequence 
definition.            BER Error: This field lies beyond the end of the known 
sequence definition.


                                          
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to