Re: Strange error in test program...

This is a discussion on Re: Strange error in test program... within the SNMP Coders forums, part of the Networking and Network Related category; On 08/04/2008, Kris van Rens <krisvanrens.list@gmail.com> wrote: > size_t if_oid_len = MAX_OID_LEN; > read_objid(&...


Go Back   Usenet Forums > Networking and Network Related > SNMP Coders

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008
Dave Shield
 
Posts: n/a
Default Re: Strange error in test program...

On 08/04/2008, Kris van Rens <krisvanrens.list@gmail.com> wrote:
> size_t if_oid_len = MAX_OID_LEN;
> read_objid("IF-MIB::ifNumber.0", if_oid, &if_oid_len);


Remember that this sets the value of 'if_oid_len' to be the actual
length of the OID for 'ifNumber.0' (i.e. 10)


> for (i = 0; i < num_if; i++) {
> sprintf(oid_str, "IF-MIB::ifPhysAddress.%d", i+1);


if_oid_len still has the value 10, so there isn't room in the
'if_oid' buffer to hold the OID for the ifPhysAddress instances.
(Well, actually there is, but 'read_objid()' thinks there isn't).

Try resetting if_oid_len to be MAX_OID_LEN before each
call to read_objid()'

> read_objid(oid_str, if_oid, &if_oid_len);
> snmp_add_null_var(req, if_oid, if_oid_len);
> }




You are also assuming that ifTable entries will always be
in a strict consecutive sequence (starting from 1). That's
probably true for most simple systems, but it's not guaranteed.
It is perfectly valid to have 3 interfaces, with indexes 2, 3
and 27, for example.

You might want to look at using a sequence of GETNEXT requests,
or (if your agent supports SNMPv2c or SNMPv3), a GETBULK
request, which would do the same thing but in one go.

Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Register now and save $200. Hurry, offer ends at 11:59 p.m.,
Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757...un.com/javaone
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:54 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0