Thanks Robert.
"Item created successfully. (Artifact 3495075)"

On 2/27/12 1:35 PM, Robert Story wrote:
> JL>  On 2/24/12 10:59 AM, Joe Lorenz wrote:
> JL>  >  $ snmpset -v 2c -c private dut
> JL>  >  NET-SNMP-TUTORIAL-MIB::nstAgentSubagentObject.0 i 5 Error in packet.
> JL>  >  Reason: wrongLength (The set value has an illegal length from what the
> JL>  >  agent expects)
> JL>  >  Failed object: NET-SNMP-TUTORIAL-MIB::nstAgentSubagentObject.0
> JL>  >
> JL>  >  This is on an x86_64 environment where sizeof(int) = 4 and 
> sizeof(long)
> JL>  >  = 8. What I'm noticing is that netsnmp_register_int_instance() calls
> JL>  >  netsnmp_create_watcher_info() with sizeof(int). But I also see
> JL>  >  snmp_set_var_typed_integer() call snmp_set_var_value() with
> JL>  >  sizeof(long), which seems possibly inconsistent.
> JL>  >
> JL>  >  The snmp_set_var_value() appears to have conditionals for differences
> JL>  >  between size of int and long. So I'm not sure why this doesn't Just
> JL>  >  Work.
>
> Because when snmp_set_var_value is called to create the internal structure to
> hold the incoming value, is saves a length of 8 for ANY integer, regardless of
> the actual incoming size.
>
> JL>  >  I think I will attempt to change netsnmp_register_int_instance() and 
> see
> JL>  >  what happens.
>
> a better idea would be to change the subagent to use
> netsnmp_register_long_instance.
>
> JL>  >  If anyone has insight on this, I'm all ears.
>
> It's a bug. The integer instance handler should properly deal with the fact
> that the variable structure uses a long, and properly convert it down to a
> integer.  Can you submit a bug report?
>
> On Fri,
> JL>  >  24 Feb 2012 11:32:13 -0500 Joe wrote:
> JL>  I changed netsnmp_register_int() to use sizeof(long) instead of
> JL>  sizeof(int), and now sets are working.
> JL>
> JL>  Now how do I know I'm not causing any regressions with such a change? :-/
>
> You are. Essentially, you are telling the code it's ok to write up to 8 bytes,
> when the pointer passed in for storage is pointing to only 4 bytes of storage.
>
>

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to