Hi,

I am writing code to get and set values for our internal 
vendor-defined MIB.
When I set a string value using SNMPSET, the following 
problem occurs:
- if the string is longer than the previously set value, 
SNMPSET works fine;
- if the string is shorter than the previously set value, 
the rest of the "string buffer" retains the characters 
from the previous SNMPSET operation.

For example:
===========================================================
[EMAIL PROTECTED] net-snmp-5.3.1]$ snmpset -v2c -c private 
localhost IPCompanion-MIB::pmibLband22K.0 = "OFF"
IPCompanion-MIB::pmibLband22K.0 = STRING: "OFF"

[EMAIL PROTECTED] net-snmp-5.3.1]$ snmpset -v2c -c private 
localhost IPCompanion-MIB::pmibLbandPolar.0 = "VERTICAL"
IPCompanion-MIB::pmibLbandPolar.0 = STRING: "VERTICAL"

[EMAIL PROTECTED] net-snmp-5.3.1]$ snmpset -v2c -c private 
localhost IPCompanion-MIB::pmibLband22K.0 = "ON"
Error in packet.
Reason: noCreation (That table does not support row 
creation or that object can not ever be created)
Failed object: IPCompanion-MIB::pmibLband22K.0
===========================================================

The last error is due to the fact that the previous value 
in
requests->requestvb->val.string is not getting cleared, as 
can be seen from the log file (see the second pmibLband22K 
value -- should be "ON"):

pmibLband22K: string_value: OFF
pmibLbandPolar: string_value: VERTICAL
pmibLband22K: string_value: ONRTICAL

The code to handle get, set, etc are defined in a file 
generated by MFD. I am attaching a sample function from 
the file, that handles the get/set for pmibLbandPolar:
===========================================================
int
handle_pmibLbandPolar(netsnmp_mib_handler *handler,
                       netsnmp_handler_registration 
*reginfo,
                       netsnmp_agent_request_info 
*reqinfo,
                       netsnmp_request_info *requests)
{
     int             ret;
     static char     szbuf_tmp_decode[128];
     int             nbytes_decoded;
     static char     szbuf_tmp[128];
     u_char          *polar_string;

     switch (reqinfo->mode) {

     case MODE_GET:
       dboper_decode( szbuf_tmp_decode, sizeof( 
szbuf_tmp_decode ),
                      &nbytes_decoded,
                      DBPARAM_LBAND_POLARIZATION,
                      &gst_db_engine, 0 );
       snmp_set_var_typed_value(requests->requestvb, 
ASN_OCTET_STR,
                                (u_char 
*)szbuf_tmp_decode,
                                nbytes_decoded);

       break;

     case MODE_SET_RESERVE1:
       break;

     case MODE_SET_RESERVE2:
       break;

     case MODE_SET_FREE:
       break;

     case MODE_SET_ACTION:
       snmp_log(LOG_ERR, "pmibLbandPolar: string_value: 
%s\n", requests->requestvb->val.string);

       polar_string = requests->requestvb->val.string;

       ret = dboper_proc_usr_input( szbuf_tmp, 
sizeof(szbuf_tmp),
                                    DBPARAM_LBAND_POLARIZATION,
                                    &gst_db_engine, 0,
                                    polar_string );
       save_params(&gst_db_engine);

       if ( ret < 0 )
         netsnmp_set_request_error(reqinfo, requests, 
SNMP_ERR_NOCREATION);

       break;

     case MODE_SET_COMMIT:
       break;

     case MODE_SET_UNDO:
       break;

     default:
       snmp_log(LOG_ERR, "unknown mode (%d) in 
handle_pmibLbandPolar\n",
                reqinfo->mode);
       return SNMP_ERR_GENERR;
     }
     return SNMP_ERR_NOERROR;
}
===========================================================

Any advice on how to resolve this problem would be greatly 
appreciated. Going through the mail archives, I noticed 
that a similar bug was reported by Ritu Singla (?) way 
back in 2002, but I did not come across any satisfactory 
resolution to that.

Thanks in advance,
Ayan

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to