For historic reasons, the project we are working on is stuck using a 
very old version of net-snmp (5.1.2). However, looking at the more 
recent code, it looks like the problem I am seeing exists there too.

We recently made the transition from 32 bits to 64 bits, and I find that 
under 64 bits, I can no longer snmpwalk our MIBs. I get lots of this in 
the log when I try:

snmpd err  send response: Error building ASN.1 representation (build int 
size 4: s/b 8)

Looking at our code, I see that for rows in the MIB that are of type 
INTEGER, we appropriately define fields in structs of type int. Then, 
when we process an snmpget, we construct the variable with code like this:

[in some .h file]

int fred;

[actual code]

          snmp_set_var_typed_value(var, ASN_INTEGER,
                                                      (u_char *) &fred, 
sizeof(fred));

But later, deep in the net-snmp code, at the top of the routine 
asn_build_int(), we fail this sanity test:

     if (intsize != sizeof(long)) {
         _asn_size_err(errpre, intsize, sizeof(long));
         return NULL;
     }

Now unless I am misunderstanding something, (and I hope I am) the 
intsize here is the sizeof(fred) I passed into snmp_set_var_typed_value, 
and in both 32 bit and 64 bit environments, that's 4 bytes (i.e. 
sizeof(int)). But while under 32 bits, sizeof(long) is also 4, under 64 
bits, sizeof(long) is 8 bytes. So under 64 bits, the sanity test in 
asn_build_int() will always fail, and I see the error messages in my log 
and my snmpwalk times out.

INTEGER is 4 bytes, now and forever, right? The ASN.1 protocol doesn't 
change just because the underlying machine architecture changes. So 
surely I should use a (4 byte) int in my internal structs to hold values 
that are declared as INTEGER in the MIB files. But the code seems to 
insist that I use longs, and pass them into snmp_set_var_typed_value() 
as such. Is this so? If so, why? Please tell me I'm missing something 
basic here. We have lots of incumbent structs with the INTEGERs defined 
to be ints, not longs.

-John Gregg


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to