I did much more research on agentx subagents and context through the
mail archives.
Wow, there is a lot to sift through. 
I found out my major problems, namely, that I needed to register my subagent
in the proper context.  I did not find any examples, but based on descriptions,
I needed to set the "contextName" member of struct
"netsnmp_handler_registration".
That makes sense - so I _think_ I got that part right, but could use
some validation.




-----------------
mysubagent.c
-----------------
...
        netsnmp_handler_registration rinfo;
        rinfo.contextName="BILL";
  static oid maxiRfOut_oid[] = { 1,3,6,1,4,1,143279,1000,1,1,3 };
  
  DEBUGMSGTL(("sack", "Initializing\n"));
    netsnmp_register_scalar(
        netsnmp_create_handler_registration("subagentTEST", handle_subagentTEST,
                               subagentTEST, OID_LENGTH(subagentTEST),
                               HANDLER_CAN_RONLY
        ));
...
--------------------


The other thing wrong was my VACM config in snmpd.conf - boy was I
missing a lot.
I beleive this correctly set up to map community name "BILL" to context "BILL"
I'm not sure I need the "xyz" view - I got errors about "no subtree
for context "BILL", so I
thought I'd messa round with that.  Not sure what that error is
referring to - I'm guessing
it could not find a (registered) subagent to answer the request -
which means my method
abof for registering the agent in the proper context is wrong.


------------
snmpd.conf
------------
...
com2sec -Cn BILL notConfigUser 127.0.0.1  BILL

group   notConfigGroup v1            notConfigUser
group   notConfigGroup v2c           notConfigUser

view    systemview     included      system
view    xyz     included                                1.3.6.1.4.1.143279.1000.1

#       group           context         sec.model sec.level prefix read   write        
 notif
access notConfigGroup   BILL    any     noauth  exact xyz none  none
...
-----------------


Things arent working, not crashing, just not working when I try to use
contexts.
Here is a snipped form debug output:

-------------
snmpd.log
-------------
...
trace: init_agent_snmp_session(): snmp_agent.c, 1257:
verbose:asp: asp 0x80deba0 reqinfo 0x80d2bc8 created
trace: snmp_call_callbacks(): callback.c, 205:
callback: START calling callbacks for maj=1 min=5
trace: snmp_call_callbacks(): callback.c, 219:
callback: calling a callback for maj=1 min=5
trace: vacm_in_view(): mibgroup/mibII/vacm_conf.c, 708:
mibII/vacm_vars: vacm_in_view: ver=0, community=BILL
trace: netsnmp_udp_getSecName(): snmpUDPDomain.c, 928:
netsnmp_udp_getSecName: resolve <"BILL", 0x0100007f>
trace: netsnmp_udp_getSecName(): snmpUDPDomain.c, 933:
netsnmp_udp_getSecName: compare <"BILL", 0x0100007f/0xffffffff>... SUCCESS
trace: netsnmp_subtree_find_first(): agent_registry.c, 156:
subtree: looking for subtree for context: "BILL"
trace: netsnmp_subtree_find_first(): agent_registry.c, 165:
subtree: didn't find a subtree for context: "BILL"
trace: vacm_in_view(): mibgroup/mibII/vacm_conf.c, 831:
mibII/vacm_vars: vacm_in_view: no such ctxt "BILL"
trace: snmp_call_callbacks(): callback.c, 231:
callback: END calling callbacks for maj=1 min=5 (1 called)
...
---------------

I think the snmpd.conf vacm config is correct based on the log message:
 "netsnmp_udp_getSecName: compare <"BILL", 0x0100007f/0xffffffff>... SUCCESS"

Any suggestions on where to proceed from here,  or a link to an
example of registering
a subagent using a context? 
(I should note, I am attempting to do this with AgentX, but should be
ok with 5.2-pre2. )




On Fri, 5 Nov 2004 10:15:02 -0500, bill smith <[EMAIL PROTECTED]> wrote:
> 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

Reply via email to