Re: Question on Iterator model without having to setup a linked list

Dave Shield <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
2009/6/8 Ranganathan, Viji (NSN - US/Boca Raton) <[email protected]>:
>                               In this case, can I get by without
> setting up memory for the "next" pointer of the "<>head" provided by the
> template ?

The 'loop_context' field is simply some value, that can be passed
from one invocation of the 'get_next' hook routine to the next,
so that it knows how far through the list it's got.
This value is *only* every interpreted by the get_{first,next} routines,
so you can set it to whatever you like.   It doesn't have to be a memory
pointer.

With a linked-list, the obvious choice is a pointer to the data structure
itself - either the current one or (more commonly) the "next" one.
With a direct access interface, you might want to set this value to be
the actual index.
   Basically - if your 'get_next' routine is called with this value, it needs to
be able to determine the appropriate next row of the table.


>     What do I set my_data_context to ?

That's essentially similar.   It's a value that will be passed from the
get_first,next hook routines to the main MIB handler, that can then
be used to retrieve the data relating to that particular row.

Again, it's only ever interpreted by the code you provide, so you
can use whatever seems sensible.   For a linked-list implementation,
the obvious choice is the data structure itself    With a direct-access
interface, this might be the index value.  Or some hash value.  Or
anything else that seems sensible.

It doesn't have to be the same as the loop_context (though it often is).
Just some way for the main handler to get the appropriate data.

Dave

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
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.