On 17/01/2008, Devvrat Tripathi <[EMAIL PROTECTED]> wrote: > I would like to get the responses for these pdu's from different snmp agents > located at some other place depending on the context supplied with the pdu. > Now the problem is that i do not know these contexts before hand and also > that the number of unique contexts can be huge and that is why i require > dynamic forwarding of these pdu's to other machines.
OK - that makes things much clearer. The main problem you've got is that the Net-SNMP agent is designed using an assumption of static contexts. The registration of which OIDs are supported actually takes the form of multiple parallel registration trees - a separate one for each context. Handling requests for "any" context is going to stretch the behaviour of the agent somewhat. > One thing which i thought i could do was actually changing the code for the > callback function handle_snmp_packet in the snmp source code ( for the > default agent). The simplest approach is probably to insert code into the routine netsnmp_agent_check_parse() (see 'agent/snmp_agent.c'). This is called after the request has been received and parsed, but before it is processed. Within this routine, you could extract the context of the request, and register your handler for that context. Then when the processing returns to the main agent, it will pick up this new context, and pass the request on to your handler. That would also avoid the clashes with the standard MIB modules, since these would only be registered in the default context. > What i would like to have instead is maybe a subagent which > receives the pdu before the main agent gets to parse it That's not how subagents work. The SNMP/AgentX model is that the main agent receives the requests, and delegates them to the appropriate subagent(s). But everything passes through the main agent first. You could perhaps replace the Net-SNMP agent altogether, and provide your own application which passes requests on to the appropriate agent for handling. This is more a "proxy" approach rather than "subagents". But if you were going to use the Net-SNMP agent as the basis for this initial filtering, then you'd still run into the same problems regarding context registration. I suspect your best bet is to follow the dynamic-registration approach outlined above. Note that all this assumes that you are using SNMPv3. A community-based approach would be somewhat trickier. Dave ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
