On 02/01/2008, Xuan Pan <[EMAIL PROTECTED]> wrote:
> 2. I am using table_iterator to implement it by referencing the example
> code of vacm_context.c. Am I choosing the right handler?
It's impossible to answer that question.
The iterator helper is a perfectly reasonable choice for
implementing a table (though perhaps not the most efficient).
If it does what you need, then use it.
If not, then try one of the others.
See the FAQ entry
What's the difference between the various mib2c configuration files?
http://www.net-snmp.org/wiki/index.php/FAQ:Coding_07
for a brief description of the various options.
My personal preference is for 'mib2c.table_data.conf',
but other developers have different preferences.
> 3. The sample code has three components:
> + an init function which get called when receiving requests.
No - the init function is used to register the table when the agent first
starts up. This is how the agent knows where to send requests for
this table.
> + two functions getFirstContext and getNextConext that can be assigned to
> hooks
These are use to select the appropriate row for a given request.
When the agent receives a request for an OID in the table, it starts by
calling the getFirstContext hook routine , followed by the getNextContext
hook routine (repeatedly). Your code should walk through the various
rows of the table (in whatever order is most convenient), reporting on
the various index values.
The iterator helper can then use this information to select the appropriate
row for this request.
> + a handler function
This is the bit that actually handles the request.
It's given the row chosen by the getFirst/NextContext routines,
and should extract (or update) the appropriate column value.
> The question is how should I insert my code to tell which row is being
> read or updated (GET or SET).
That's handled by the iterator helper.
> I think there should be an indexing mechanism or something,
> but I couldn't find it in the vacm_context example.
That's the role of the getFirstContext/getNextContext routines.
In particular, the statement:
snmp_set_var_value(put_data, context_ptr->context_name,
strlen(context_ptr->context_name));
which returns the index value for each row (i.e. the context name)
Dave
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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