Re: Question about netsnmp_call_handlers() function in snmp_agent.c

Dave Shield <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
On Tue, 2005-12-06 at 16:58 -0800, Yong Chen (yongche) wrote:
> I've a question regarding netsnmp_call_handlers(),
> if I have a SET pdu as following:
> 
>    set a=1, b=2, c=3
> 
> Is netsnmp_call_handlers() called once for all 3 varbinds,
> or it is called three times, each for one varbind?

That depends on what 'a', 'b' and 'c' are.

If all three OIDs refer to the same area of the overall
MIB tree (i.e. fall within the same registration), then
netsnmp_call_handlers will be invoked once.

If all three OIDs refer to different areas, then
netsnmp_call_handlers will be invoked three times.



> Based on the code in handle_var_requests():
> 
>     for (i=0; i<=asp->treecache_num; i++)
>     {
>         ...
>         netsnmp_call_handlers();
>         ...
>     }
> 
> I tend to think netsnmp_call_handlers() is called 3 times

Understandable - but not quite true.
The code that sets up 'asp->treecache' will group
related varbinds together, so that they're handled
via a single call to 'netsnmp_call_handlers'



> Also is there any place I can find description regarding
> asp->treecache[]?

    <net-snmp/agent/snmp_agent.h>

>  What is it for?

    It holds the list of the varbinds relating to a
particular MIB handler.

>  What is asp->treecache_num?

    The number of different MIB handlers that will
need to be called.


Think of this like a postal sorting office.

It would be very inefficient for a postman to be
given each letter separately, go and deliver it,
and then come back for the next letter (which might
well be intended for the very same house).

Instead, the incoming letters are sorted into
"rounds", and each postman will be given *all* the
letters relevant to their particular round.

The UCD agent used the first model - handling each
varbind separately.  The Net-SNMP agent uses the
second model - grouping related varbinds together
into a single "round" (MIB handler).

Each "treecache" entry corresponds to a particular
MIB handler, and may contain one or more varbinds.

Does that help?

Dave


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
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.