Sending GENERR back in GET Request

"JORDI LOPEZ" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
I'm writing a simple AgentX sub-agent to handle two scalars called defaultBackGroundColor and dmsColorScheme. When accesing defaultBackGroundColor I have to return its value or a genErr depending on the value of dmsColorScheme. I'm forced by specification to use SNMP v1.
 
Here is the code I use to register both scalars
 
reg = netsnmp_create_handler_registration ( "defaultBackGroundColor", handle_defaultBackGroundColor,
                                            defaultBackGroundColor_oid, OID_LENGTH(defaultBackGroundColor_oid),
                                            HANDLER_CAN_RWRITE);
netsnmp_register_scalar( reg );
 
reg  = netsnmp_create_handler_registration ( "dmsColorScheme", NULL,
                                             dmsColorScheme_oid, OID_LENGTH(dmsColorScheme_oid),
                                             HANDLER_CAN_RONLY);
winfo = netsnmp_create_watcher_info ( &dmsColorScheme, sizeof(long),
                                      ASN_INTEGER, WATCHER_FIXED_SIZE);
netsnmp_register_watched_scalar ( reg, winfo );
 
And the handler for defaultBackGroundColor
 
int handle_defaultBackgroundColor ( netsnmp_mib_handler          *handler,
                                    netsnmp_handler_registration *reginfo,
                                    netsnmp_agent_request_info   *reqinfo,
                                    netsnmp_request_info         *requests )
{
    int ret;
 
    switch ( reqinfo->mode )
    {
        case MODE_GET:
            
            if ( dmsColorScheme != CS_colorClassic )
                netsnmp_set_request_error ( reqinfo, requests, SNMP_ERR_GENERR );
            else
                snmp_set_var_typed_value ( requests->requestvb, ASN_INTEGER,
                                           (u_char *) &defaultBackgroundColor, sizeof(long) ); 
            break;
 
        case MODE_SET_RESERVE1:
            if ( dmsColorScheme != CS_colorClassic )
                netsnmp_set_request_error ( reqinfo, requests, SNMP_ERR_GENERR );
            else
            {    
                if ( ( ret = netsnmp_check_vb_int_range ( requests->requestvb, DMSCLASSICCOLOR_MIN, DMSCLASSICCOLOR_MAX ) ) )
                {
                    DEBUGMSGTL ( ( "ntcip", "defaultBackgroundColor Bad value\n" ) );
                    netsnmp_set_request_error ( reqinfo, requests, ret );
                }
            }
            break;
 
        case MODE_ACTION:
            defaultBackgroundColor = *requests->requestvb->val.integer;
            break;
        case MODE_SET_RESERVE2:
        case MODE_SET_COMMIT:
        case MODE_SET_UNDO
            break;
        
        default:
            return SNMP_ERR_GENERR;

    }
 
    return SNMP_ERR_NOERROR;
}
                                                  
The subagent is working fine except for a small problem. If I set dmsColorScheme to a value that forces dmsBackGroundColor to return a GENERR error, in a SET request I get a GENERR error but, in a GET request, I get a NOSUCHNAME error. I'm using snmpset and snmpget to make the tests.
 
The funny thing is that if I issue the same commands using SNMP v2c I get GENERR on both GET and SET requests, and if I run my agent as a master agent I get GENERR also on both requests even using SNMP v1.
 
The net-snmp version is 5.4.1 and the OS is an Ubuntu Jaunty
 
any ideas on what am I missing here?
 
Jordi López

______________________________________________________________________
IMAGO GROUP www.imagoscreens.com
This email has been scanned by the MessageLabs Email Security System.
 
______________________________________________________________________

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.