[AGENT++] Handling result of missing object?

Jochen Katz katz at agentpp.com
Mon Jan 24 23:15:05 CET 2011


Hi,

> * An snmp manager based on snmp++ queries some oid from some snmp
>   agent, say 1.3.6.1.2.1.2.2.1.8.10101 (column 8, row 10101 in
>   some table).  In case it matters:  In the same request other
>   oids in the same table and totally unrelated oids.
> 
> * The row with 1.3.6.1.2.1.2.2.1.8.10101 does not exist, and in
>   the response, the agent properly says "no such object".
> 
> * The async response is received by the manager.  Later on the
>   code calls pdu.get_vb(vb, ...) for the missing object which returns
>   TRUE.

yes, this is ok, as the Vb exists.

> * vb.get_value() does not return SNMP_CLASS_INVALID (I actually
>   did not check that ..._SUCCESS is returned, but in the source I
>   see that if it's not ...INVALID, it must be ...SUCCESS).
>   The actual value returned is some random value from an earlier
>   request into that table.

You've hit a bug: The snmp++ Pdu parser reuses the previous Vb object.
In case of exceptions (nosuchobject, nosuchinstance,...) it uses
Vb::set_exception_status(), which does not free the value of the vb. So
the get_value() functions return the old value. The patch below fixes this.

Index: include/snmp_pp/vb.h
===================================================================
--- include/snmp_pp/vb.h        (Revision 1952)
+++ include/snmp_pp/vb.h        (Arbeitskopie)
@@ -367,7 +367,7 @@
    * @param status - the new SNMPv2 exception status.
    */
   void set_exception_status(const SmiUINT32 status)
-    { exception_status = status; };
+    { free_vb(); exception_status = status; };

   /**
    * Get the exception status.

> How do I detect that the response did not contain a value at all?

With Vb::get_exception_status() or get_syntax().

Regards,
  Jochen



More information about the AGENTPP mailing list