Hi Robert, Been out of touch wiht this project for a while, but I'm back for more punishment. A little refresher from the thread - I'm tring to get access to the contextName within my subagent. I set up "BILL" and "TED" as contextnames in com2sec so that queries from localhost will be assigned a context of BILL and remote host A cname of TED. My subagent returns NULL when I try to print the contextname to stdout.
I'm using 5.2-pre2 - trying to get something working out of your previous suggestions. I've set up my contexts in snmpd.conf for testing as follows: rocommunity public rocommunity public1 com2sec -Cn BILL notConfigUser 127.0.0.1 public com2sec -Cn TED notConfigUser 192.168.90.155 public1 and my subagent.conf is empty (yeah, it complains abou being useless, but it works). Subagent works fine, handles are all registered etc. But, I am dogged if I know what I'm doing wrong - I wrote some testcode into my subagent's handler in an attempt to print context the request is using, it comes up as (null). Here's the snipped from one of my handles in my subagent: handle_subagenttestOut(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { printf("Context: %s\n",reginfo->contextName); printf("ASP-session-context data: %s\n\n",reqinfo->asp->session->contextName); ... Am I accessing the correct struct? I trids printing securityName as well and came up Null. It looks to me like the com2sec config in snmpd.confis not being read properly, or I am just doing something completley wrong. I should note that I am using snmpv2 snmpget's, on the 127.0.0.1 and on the 192.168.90.155 addresses and both return accurate data from my handler. On Sat, 11 Sep 2004 09:24:46 -0400, Users Robert Story <[EMAIL PROTECTED]> wrote: > On Fri, 10 Sep 2004 16:54:44 -0400 bill wrote: > BS> > If you check the recent snmpd.conf man page, the com2sec token can > BS> > specify a context, which you could easily make the same as the community > BS> > string, and thus the sub-agent would get passed the community string as > BS> > the context. > BS> > > BS> > com2sec -Cn host10-10-10-1 mynet default host10-10-10-1 > BS> > com2sec -Cn host10-10-10-2 mynet default host10-10-10-2 > BS> > > BS> This is exactly what I want to do. I understand the man page > BS> instructions, but not clear on which data structure would contain the > BS> contextName - it shows up in snmp_pdu and snmp_session - which I > BS> beleive are the same > > They aren't the same, and I would expect it would show up in the pdu. But you > shouldn't be poking around in the pdu. > > First, I haven't tried any of this, so don't quote me. But, I think you have to > register your sub-agent for each context you want to handle. So you should use > the void pointer for your handler to determine which context is in play. > > BS> Correct me if I am wrong here: Using this approach, I am forced to > BS> use V3 at the client? > > No. With V3 you can use contexts directly - it is part of the protocol. > Net-SNMP offers a mapping function to provide a context based on the community > string provided in a v1 request. > > > > -- > Robert Story; NET-SNMP Junkie <http://www.net-snmp.org/> > <irc://irc.freenode.net/#net-snmp> > Archive: <http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-users> > > You are lost in a twisty maze of little standards, all different. > ------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&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