Hi Dave, I think I understand the big picture now, but still a few details:
1. where do you populate treecache for a SET request? Is it "netsnmp_add_varbind_to_cache"? And is it the place that you combine all varbinds having the same handler into one "requests" (looping through via requests->next)? This func is not very easy to understand. 2. As I mentioned, I'm actually using 4.x style (but with a net-snmp 5.1 agent). So for each sub-oid in a table, I have a write_method defined. Basically in get_xxTable(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method), I assign *write_method=my_write_method for each sub-oid. So for my case, do I still have varbinds combined (whenever possible)? For a SET pdu like: set my_table.a=1, my_table.b=2, my_table.c=3 How many times will netsnmp_call_handlers() be called? 3. Since I'm not using 5.x handler API, do you consider "my_write_method" as a handler? (I guess probably not, since I don't call handler registration func), but then how is my_write_method called in 5.x agent? Thanks a lot, Yong Chen -----Original Message----- From: Dave Shield [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 07, 2005 1:26 AM To: Yong Chen (yongche) Cc: [email protected] Subject: Re: Question about netsnmp_call_handlers() function in snmp_agent.c 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_idv37&alloc_id865&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
