Re: Questions in _access function
Dave Shield <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 2005-11-11 at 14:30 +0800, Earnest Pan wrote:
> What is the following variable used to do?
>
> *my_loop_context
> *my_data_context
> put_index_data
The get_{first,next}_data_point routines will loop
through the rows of a table - one row at a time.
So there needs to be some way of keeping track of
the "current row".
That's the role of the two context variables.
You should set these to indicate which is the current
row in some way or other.
Exactly how you do this is up to you - typically
this will either be a pointer to an entry in a
linked list, or an index into an array structure.
The 'loop_context' is used to pass the current row
from one invocation of the get_{first,next} routine
to the next. The 'data_context' is used to pass
the current row to the main handler routine.
The simplest approach is probably to use the same
value for both, though there are situations when
it makes sense to treat them differently.
The 'put_index_data' is a varbind list, which you
need to set up with the list of index values.
If the table is indexed by a single object, then
this will be a single varbind. If the table is
indexed by two MIB objects, then there will be two
varbinds in the list, and so on.
Just use 'snmp_set_var_value' to set the appropriate
index values, and then return 'put_index_data' as
the result of the routine. If there are no more
rows, then return NULL (so that the helper knows
that it's reached the end of the table).
Dave
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
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