Re: netSnmpHostsTable*.*

Dave Shield <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
On Mon, 2006-03-13 at 14:26 +0100, hjubal wrote:
> Hi, I'm studying 'netSnmpHoststTable' code located in
> agent in examples.
> 
> If the request is GET

First thing - the processing is basically the same for
both GET and GETNEXT requests.  In both cases, the
iterator will work through the get_{first,next}_dp loop
to locate the appropriate row of the table.

>  then it is called 'netSnmpHostsTable_get_first_data_point'

once

>  and then 'netSnmpHostsTable_get_next_data_point'.

several times (one for each row of the table).


> This builds 'my_loop_context'.

Which keeps track of the current stage within this loop.

> Then it will be called 'netSnmpHostsTable_create_data_context'
> to convert 'my_loop_context' into 'my_data_context'.

Which provides a means of referring to a particular row
*outside* the context of the loop.


> In the end 'get_*' functions use 'my_data_context' to return
> data for the requested column.
> 
> Is it correct?

Correct.


> So, why is necessary to build 'my_loop_context' and convert it to
> 'my_data_context' instead of directly build 'my_data_context'?

It's not always necessary to do this, no.  In many cases, the
same value can serve for both purposes - keeping track of the
current point in the list, and identifying the data for a
particular row.
   In many cases, but not always.   Sometimes it's necessary
(or useful) to have different values for these two.

For example, suppose you represented the table as an array
of pointers to the per-row data structures.   Looping through
the list just requires a simple integer index (loop_context)
into this array.  But the main handler might as well be passed
the actual pointer directly (data_context).

Note that in this case, the data_context value cannot be used
as the loop_context as well, since there's no way to determine
the "next" row.  Looping through the array requires the integer
index.


Does that help explain it at all?

Dave


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.