Hi,

I tried out with Net-SNMP version 5.2.1.

With this version using netsnmp_register_scalar_group () and setting
SNMP_NOSUCHOBJECT error for the var-bind is stopping the SNMP walk at
the manager.

I have attached the file that I used for testing with this mail.

Thanks
Sridhar

On Thu, 7 Apr 2005 14:48:31 -0400, "Robert Story" <[EMAIL PROTECTED]>
said:
> On Tue, 05 Apr 2005 10:09:36 +0530 Sridhar wrote:
> SS> I am using Net-SNMP version 5.0.9.
> SS> 
> SS> The attached file ifNumber_orig.c is the code that that generated by
> SS> tool-kit and handler function is modified to retrieve the value of
> SS> ifNumber from the back-end. With this file, if retrieving the value
> from
> SS> the back-end fails then agent is not returning the next
> lexographically
> SS> available object in the tree. At the manager end a SNMP walk stops
> with
> SS> the error
> SS> 
> SS> IF-MIB::ifNumber.0 = No Such Object available on this agent at this
> OID
> SS> 
> SS> I modified the above file further. After handler registration, I
> SS> registered scalar variable using API 'netsnmp_register_scalar_group'.
> I
> SS> tried this API by looking at the 'mibII/icmp.c' file. With this code
> SS> (ifNumber_modif.c) I am able to  walk the whole tree, irrespective of
> SS> get_ifNumber () API return status.
> SS> 
> SS> Please share your thoughts on this.
> 
> Looks like you found a bug. Can you reproduce this with a 5.2.1?
> 
> -- 
> NOTE: messages sent directly to me, instead of the lists, will be deleted
>       unless they are requests for paid consulting services.
> 
> 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-users>
> 
> You are lost in a twisty maze of little standards, all different. 
/*
 * Note: this file originally auto-generated by mib2c using
 *        : mib2c.scalar.conf,v 1.8 2004/10/14 12:57:34 dts12 Exp $
 */

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "ifNumber.h"

/** Initializes the ifNumber module */
void
init_ifNumber(void)
{
    static oid ifNumber_oid[] = { 1,3,6,1,2,1,2 };

    netsnmp_handler_registration *reginfo;

    DEBUGMSGTL(("ifNumber", "Initializing\n"));

    reginfo = netsnmp_create_handler_registration("ifNumber", handle_ifNumber,
                               ifNumber_oid, OID_LENGTH(ifNumber_oid),
                               HANDLER_CAN_RONLY);

    netsnmp_register_scalar_group (reginfo, 1, 1);
}

int
handle_ifNumber(netsnmp_mib_handler *handler,
                          netsnmp_handler_registration *reginfo,
                          netsnmp_agent_request_info   *reqinfo,
                          netsnmp_request_info         *requests)
{
    /* 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. */

    static int if_count;
    
    switch(reqinfo->mode) {

        case MODE_GET:

            /*
            if (get_ifNumber (&if_count) == SUCCESS)
            {
                snmp_set_var_typed_value (requests->requestvb, ASN_INTEGER,
                                     (u_char *) &if_count, sizeof (int));
            }
            else
            */
            {
                netsnmp_set_request_error (reqinfo,
                                           requests,
                                           SNMP_NOSUCHOBJECT);
            }
            break;


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

    return SNMP_ERR_NOERROR;
}

Reply via email to