It is my first time that I post something as I tend to try solving a problem without bothering other people. However I have spent 2 days Googling on this issue and I just can't fix it. I hope that a Perl GOD out there can do justice and help me out :-)

I have a simple script that receives SNMP trap messages on port 162 (UDP).

It works fine except for one thing: decoding the varbinds of the SNMP trap message. The message are sent from a CISCO firewall and commercial packages are able to decode the trap without any problems. SNMP packages are SNMPv1

The part of the trap that includes the varbinds has following HEX value:
3014060e2b06010401090929010203010200040232303013060e2b0601040109092901 +0203010300020105301d060e2b06010401090929010203010400040b5379736c6f672 +05472 617030818c060e2b06010401090929010203010500047a3130363032333a2044656e79 +2069636d7020737263206f7574736964653a3231362e3139362e36342e31323420647 +37420696e73 6964653a3230382e3130392e39302e323120287479706520382c20636f646520302920 +6279206163636573732d67726f757020226f7574736964655f6163636573735f696e2 +23016060e2b 06010401090929010203010600430473c36bf8


The code works fine for a simple trap message generated by trapgen but it seems that when there are multiple oid's then it just no longer does the job.

Here is the code
use BER; use SNMP_session; my $session = SNMPv1_Session->open_trap_session (); while (my ($trap, $sender, $sender_port) = $session->receive_trap ()) { &print_trap($session,$trap,$sender,$sender_port,$counter); } sub print_trap { my ($this, $trap, $sender, $sender_port, $counter) = @_; my $error=0; my ($community, $ent, $agent, $gen, $spec, $dt, $error, @bindings +) = $this->decode_trap_request ($trap); foreach my $encoded_pair (@bindings) { my ($oid, $value) = decode_by_template ($encoded_pair, "%O%@") +; print "returned pair: $oid -> $value\n"; } }

In reply to SNMP Trap Decoding issue by ikkeniet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.