On Wed, 2005-04-06 at 11:29, Jim Su wrote:
> What I'm not clear is how the var_xxxtable() return each instance
> to correlate to the data previous read?
Using the 'name' parameter.
On input, this holds the OID being requested.
On return, this holds the OID of the value being returned.
I presume you've read the documentation in "AGENT.txt" ?
> How the agent correlates the array element to each instance?
Using the last entry in this 'name' array.
All of this is handled by the 'header_simple_table()' call.
So your var_xxxtable routine can start:
if ( header_simple_table( vp, name, length, exact, var_len,
write_method, MAX_ENTRIES)
!= MATCH_SUCCEEDED)
return NULL;
index = name[ length-1 ];
and 'index' will hold the index value of the row that you need.
> Yes, the table is indexed by an integer - in this case the moduleId is
> the index. However it can be any integer number set up by user.
Ah - so there can be "gaps" in the indexing, yes?
In which case it's not strictly a "simple table".
(See the description in AGENT.txt).
That doesn't matter - you can still use header_simple_table() to do
most of the work, but you'll have to do a bit more yourself.
Having called 'header_simple_table' and extracted the index (see above),
you'll then need to check whether this particular index value is valid.
If it is, then no problem - continue as before.
If it's not, then:
- for an "exact" (GET) request, the request can't be
fulfilled, so return NULL immediately.
- for an "inexact" (GETNEXT) request, you need to find the
next index value that *is* valid, and use that instead.
One way is to keep calling 'header_simple_table' and let
that do all the work. Or you could do this yourself.
You'd end up with something like:
if ( NOT_VALID( index ) ) {
if ( exact )
return NULL; /* GET request */
while ( NOT_VALID( index ) ) {
index++;
if ( index >= MAX_ENTRIES )
return NULL; /* No more rows */
}
name[length-1] = index;
}
then continue processing as before.
Dave
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users