-----Original Message-----
From: dave.shield@googlemail.com [mailto:dave.shield@googlemail.com] On
Behalf Of Dave Shield
Sent: Thursday, March 01, 2007 12:25 PM
To: Adam Bell
Cc: net-snmp-coders@lists.sourceforge.net
Subject: Re: mib2c generated code and GET_NEXT

On 01/03/07, Adam Bell wrote:
> 2. Using mib2c -c mib2c.table.conf :

The Net-SNMP project does not include a mib2c template
called "mib2c.table.conf". Do you mean "table_data"?

**** Yes

> What is missing are the get first and next support routines
> found under the next two options. (for GET_NEXT operations)

The table_data framework holds the rows of the table within
the helper itself. That means that the table_data helper handler
knows which rows are valid, so can determine the appropriate
row for a given request automatically. There's no need to call
user-provided code for this.

The helper will automatically turn a GETNEXT request into
the appropriate GET request. All of this is handled transparently.

**** Hmm, Was I was debugging a simple table, the MODE_GETNEXT was the
**** value of reqinfo->mode, so I did not see it translated to MODE_GET.
**** (See below)

> Question 1: Can I simply lift the first and next routines from the other 2
> mib2c runs and use them in the table style code?

The iterate and iterate_access frameworks work with an "external"
(i.e. user-provided) table. The get_{first,next} hook routines are
used to step through this in whatever way seems easiest.
The "internal-data" frameworks (table_data, container) hold the
table within the helper, so don't need these hook routines at all.
They are also likely to be more efficient, since they can go
directly to the relevant row data structure.

> MFD seems to have done
> away with the huge switch statement in the generated code.

Sort of - it's still there, but hidden away in one of the files
that you wouldn't normally need to look at.

> Question 2: The code comments around the table and iterate styles have
> MODE_GET: and state these handle GET_NEXT and GET_BULK when
> in fact they do not.

Yes - they do.

The helper routine decides which row of the table is relevant for
a given request. This uses either the internal knowledge about
the valid rows of the table, or the information provided by the
get_{first,next} loop respectively.

But in either case, the main handler routine is called with the data
structure the row that it needs to work with. The GETNEXT request
is converted into a GET request automatically. This is a deliberate
design decision.

Try debugging one of the existing MIB modules that use one of
these helpers. You'll see that both GETNEXT and GET requests
get turned into GET requests before they reach the MIB-specific
handler routine. But things work as expected.

**** I see it now in helpers/table_data.c - it hinges on finding the next
**** valid row and it may (actually it is the case) be I did not setup the
**** table with the indecies
**** properly so that a proper row could be found, hence GETNEXT did not
**** translate to GET and the table get failed.
**** Great info, my tables are external so the other options look like what
**** I need

**** Thanks - Adam


The information contained in this electronic mail transmission may be privileged and confidential, and therefore, protected from disclosure. If you have received this communication in error, please notify us immediately by replying to this message and deleting it from your computer without copying or disclosing it.

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
Net-snmp-coders mailing list