Here is a snippet of the code that I'm using... And this works perfectly
when the context name is set to "".

###############################################   
Void SnmpInit()
{
// Close syslog if it's already open by the application
   // SNMP library will reopen it
   //
   closelog();
   snmp_enable_syslog_ident(logInfo.GetSyslogIdent(),
                                  logInfo.GetSyslogFacility());
   break;

   // Make us an agentx client
   //
   netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_ROLE, 1);
   netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
NETSNMP_DS_AGENT_X_SOCKET, "127.0.0.1:7005");

   // Ask net-snmp to NOT use SIGALRM for it's alarm functionality
   //
   netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
                          NETSNMP_DS_LIB_ALARM_DONT_USE_SIG, 1);

   init_agent("slSnmp");

   // Initialize all modules 
  netsnmp_handler_registration *reg;

  reg = netsnmp_create_handler_registration("slsActiveSession",
handle_slsActiveSession,   slsActiveSession_oid,
OID_LENGTH(slsActiveSession_oid),HANDLER_CAN_RONLY);

    /* Set the context name */
    reg->contextName = strdup("host:9999");

  netsnmp_register_scalar(reg);

   init_snmp("slSnmp");

......
....
// Do all handling as given in example_demon.c
......
}

int
handle_slsActiveSession(netsnmp_mib_handler *pDmyHandler,
                          netsnmp_handler_registration *pDmyRegInfo,
                          netsnmp_agent_request_info   *reqinfo,
                          netsnmp_request_info         *requests)
{
    int data;
    u_char *pData;

    pDmyHandler = 0; /* To avoid warnings */
    pDmyRegInfo = 0; /* To avoid warnings */

    /* We are never called for a GETNEXT if it's registered as a
       "instance", as it's "magically" handled for us.  */

    /* a instance handler also only hands us one request at a time, so
       we don't need to loop over a list of requests; we'll only get
one. */

    switch(reqinfo->mode) {

        case MODE_GET:
               data = slSnmp_slsActiveSession_Get();
               pData = (u_char *)(&data);
               snmp_set_var_typed_value(requests->requestvb,
ASN_COUNTER,
                                        pData, sizeof(int));
            break;


        default:
            /* we should never get here, so this is a really bad error
*/
            snmp_log(LOG_ERR, "unknown mode (%d) in
handle_slsActiveSession\n", reqinfo->mode );
            return SNMP_ERR_GENERR;
    }

    return SNMP_ERR_NOERROR;
}

########################################################################

-----Original Message-----
From: Robert Story [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 15, 2005 10:41 AM
To: Riju Kallivalappil
Cc: [email protected]
Subject: Re: Managing multiple instances of a MIB

On Fri, 11 Feb 2005 16:56:17 -0800 Riju wrote:
RK>  Do SNMP v3 contexts work with agentx in 5.2.1? 

Yes, they should.

RK> I've been trying to get this work for the past few days. I was
trying with
RK> 5.2 initially. Didn't work. So, I tried upgrading to 5.2.1. Still
doesn't
RK> work. When I turn on the debug level logs I can see that the master
agent
RK> forwards the request to the correct subagent. But, the context
information
RK> doesn't seem to reach the subagent. And subagent returns " No Such
Object
RK> available on this agent at this OID" error.
RK> 
RK> (This setup works fine when I do not use a context or use the
context "")

How are you registering the sub-agent module?

>From the log you sent:

RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug]
handler:calling:
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug] main
handler
RK> bulk_to_ next
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug]
handler:calling:
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug] calling
handler
RK> bulk_ to_next for mode GET
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug]
handler:calling:
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug] calling
handler
RK> null for mode GET
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug]
helper:null: 
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug] Got
request
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug]
helper:null: 
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug]   oid:
RK> Feb 11 16:23:09 viper GDC[16818]: [ID 702911 local0.debug]
RK> iso.3.6.1.4.1.114313. 1.2.2.1.0

This seems to indicate that the nul handler is being called, eg your
hander
isn't being called.

-- 
Robert Story; NET-SNMP Junkie
Support: <http://www.net-snmp.org/> <irc://irc.freenode.net/#net-snmp>
Archive:
<http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-coders>

You are lost in a twisty maze of little standards, all different. 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to