On Tue, 2005-10-18 at 08:30 -0300, Jordan Janeiro Lopes da Silva wrote: > why the agent calls the get_{first,next} of the result table if the > command snmptable was explicity for the control table?
Remember that there's no such low-level SNMP request as "snmptable". Fundamentally, the only requests are GET and GETNEXT. Remember too that the "snmptable" command doesn't know what row indexes are valid in the table. So all it can do is issue a "GETNEXT" request on the table objects, to retrieve the first row of the table. Now look at things from the agent's point of view - it's received a GETNEXT request for "the next value following this OID" (which happens to be one of the column objects). Not "the next value in the same table" you'll notice - it is expected to return "the next value" (regardless of where this occurs). So the agent starts with the OID it received, and calls the control table handler - as being the most likely source of a suitable value. When that returns nothing, it moves on to the next registered handler (presumably the result table handler). If that returns nothing, it will move on to the *next* registered handler, and so on and so on - until it either gets a value it can use, or runs out of handler to ask ('endOfMibView'). Note that exactly the same thing happens at the end of a non-empty control table. "snmptable" will receive what happens to be the last row of this table, but won't realise this. So it will issue another GETNEXT request, to retrieve "the next row". The agent will call the control table handler, which will return nothing (since there are no more rows left). So the agent will again move on to the next registered handler - the results table. Assuming that there *are* now some results, this handler will return a suitable value, which will be passed back by the agent. "snmptable" will receive this value, notice that it's not part of the control table, and hence know that it's finished. So it can simply discard this value, display any remaining results, and exit. But snmptable doesn't know when it should stop until it's gone too far. The agent doesn't know that it should stop either - it just provides what it's asked for, the "next value". Does that make sense? Dave ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders