Hello Helper,

 

When I am coding with incoming SNMP traps from SNMP agent which uses net-snmp SNMP package, I met a problem.  What I want to do is printing out all the bindings for incoming SNMP traps from the agent side, just like the information logged in snmptrap.log if I use âsnmptrapd âo snmptrap.logâ command.  Basically, an application is written for my purpose and keeps listening on port 162 on my local PC, I want to catch the incoming SNMP traps from the SNMP agent and print the information out. 

 

The problem Iâve met is that after I capture the UPD datagram (not care about the UPD overhead) and keep it in a Char array in C++.  But when I try to print it, the result is not ASCII code.  Instead, they are human un-readable text.  Please see samples as below:

 

What I expected to print out from the Trap just as on the trap log file:

 

  "2004-09-09T10:42:54.571-05:00"        SNMPv2-SMI::enterprises.5517.4.1.1.7.0 =

 STRING: "A device has been manually removed by an operator."   SNMPv2-SMI::ente

rprises.5517.4.1.1.8.0 = INTEGER: 1     SNMPv2-SMI::enterprises.5517.4.1.1.9.0 =

 INTEGER: 1     SNMPv2-SMI::enterprises.5517.4.1.1.15.0 = INTEGER: 37

192.168.122.142 [192.168.122.142]: Trap SNMPv2-MIB::sysUpTime.0 = Timeticks: (63

80824) 17:43:28.24, SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.551

7.4.1.2.12.4, SNMPv2-SMI::enterprises.5517.4.1.1.1.0 = STRING: "192.168.122.142"

, SNMPv2-SMI::enterprises.5517.4.1.1.18.0 = STRING: "SystemManagerA", SNMPv2-SMI

::enterprises.5517.4.1.1.2.0 = INTEGER: 50, SNMPv2-SMI::enterprises.5517.4.1.1.3

.0 = STRING: "T1DS1-12-15-27", SNMPv2-SMI::enterprises.5517.4.1.1.4.0 = INTEGER:

 3, SNMPv2-SMI::enterprises.5517.4.1.1.16.0 = STRING: "OUT_OF_SERVICE", SNMPv2-S

MI::enterprises.5517.4.1.1.17.0 = STRING: "SystemManagerA", SNMPv2-SMI::enterpri

ses.5517.4.1.1.5.0 = "", SNMPv2-SMI::enterprises.5517.4.1.1.6.0 = STRING: "2004-

09-09T10:42:54.571-05:00", SNMPv2-SMI::enterprises.5517.4.1.1.7.0 = STRING: "A d

evice has been manually removed by an operator.", SNMPv2-SMI::enterprises.5517.4

.1.1.8.0 = INTEGER: 1, SNMPv2-SMI::enterprises.5517.4.1.1.9.0 = INTEGER: 1, SNMP

v2-SMI::enterprises.5517.4.1.1.15.0 = INTEGER: 37

 

What I have got:

 

âââââ0âââ+ââââÂ

 

I guess it must be some encoding format between bindings in the UDP datagram.  Would you tell me that what could be for this case?  And how I can decode them if there is such encoding method? 

 

Thanks very much,

 

William

 

 

 

Reply via email to