Update: I gave up on Convert::ASN1, and switched down to Convert::BER. The structure of SNMP traps is relatively straightforward, and I was able to cobble a BER parser together quite quickly - borrowing a bit from Mon:SNMP to get started.

If anyone someday supersearches for this, and attempts the same, I suggest reading this bug report before beginning, as it outlines some essentially required modifications. In particular, if you actually want to get the values sent (update: by values, I mean the VarBindList values), you need to attempt to decode them...

my $ret; for my $type ( qw{ STRING BOOLEAN INTEGER REAL } ) { return $ret if defined( $ber->decode( $type => \$ret )); } return $ber->buffer();

...though, of course, the encoding type is normally based on the identifying OID, so if you have a list of all the OIDs you might receive and their types, you can be more efficient about it. It also seems to me that BER is rich enough that you should be able to probe for the type of the next token, but I haven't found an obvious method for this yet.


In reply to Re: Getting Convert::ASN1 to parse SNMP traps by fishbot_v2
in thread Getting Convert::ASN1 to parse SNMP traps by fishbot_v2

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.