Dave,

Thank you for the reply. I got the trap OID from the second varbind as
you said and my code is working very well now.

Don


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Dave Shield
Sent: Tuesday, May 15, 2007 2:24 AM
To: Tu, Don
Cc: [email protected]
Subject: Re: Help to get trap name from PDU

On 14/05/07, Tu, Don <[EMAIL PROTECTED]> wrote:
> I am writing a call back function to selectively forward traps based 
> on the name (or OID) of the trap in the PDU.

You mean like the snmptrapd.conf "forward" directive does?


>                                                         I need to 
> check the trap name inside the PDU against a given list of trap names.

> Is there a function call I can use to extract the name or OID of the
trap from the trap PDU?

If this is an SNMPv1 trap, then you'll need to look at the two integer
trap fields (generic and specific), and possibly the enterprise field
(an OID).

If this is an SNMPv2 notification (i.e. SNMPv2c or SNMPv3), then the
trap OID is the second varbind of the varbind list.

The Net-SNMP snmptrapd application handles this by converting SNMPv1
traps into the equivalent SNMPv2 form, and always works with the
snmpTrapOID.0 varbind.   This is then used to decide what to do with
that particular trap (logging it, passing it to a script for processing,
or forwarding it to another system).

Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to