Re: How to implement tables

This is a discussion on Re: How to implement tables within the SNMP Users forums, part of the Networking and Network Related category; On 02/01/2008, Xuan Pan <xuan@kth.se> wrote: > 2. I am using table_iterator to implement ...


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

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-03-2008
Dave Shield
 
Posts: n/a
Default Re: How to implement tables

On 02/01/2008, Xuan Pan <xuan@kth.se> 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
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/...net-snmp-users
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 05:39 AM.


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