strange persistence problem

Frank Fock Frank.Fock____t-online.de
Sat Sep 28 12:45:56 CEST 2002


Hi Dave,

Thanks for tracking this down.
The MibLeaf::set_value(unsigned long) is correct as it
is. The description of the method says that it sets the
INTEGER value of the MibLeaf. Thus, it cannot be used
to set an UNSIGNED INTEGER value.
Use MibLeaf::set_value(const SnmpSyntax&) instead.
Changing MibLeaf::set_value(unsigned long) will break
existing code, that sets index values from OIDs subindex
values. I have deprectated this method to avoid confusion
by its "unsigned long" parameter in the future.

Best regards,
Frank


Dave Mason wrote:
> Hi Frank,
> I think I tracked this down.  I use this particular object 
> programmatically (my speller doesnt seem to know how to handle that any 
> better than I do), like this:
> 
> unsigned long   seqNum = 0ul;
> while (running) {
>   do some stuff, incremement seqNum
>   wsSeqNum::instance->set_value(seqNum);
> }
> 
> If you look in mib.cpp for MibLeaf::set_value(const unsigned long l), 
> the first line is
> set_syntax(sNMP_SYNTAX_INT32);
> This apparently changes the syntax to signed integer, and it gets 
> written to persistent storage that way.  Later, I get the error below 
> when I try to read this back into an unsigned integer.  I believe this 
> should be
> set_syntax(sNMP_SYNTAX_GAUGE32);
> or something similar (UINT32).
> 
> Regards,
> Dave
> 
> Frank Fock wrote:
> 
>> Hi Dave,
>>
>> Are you sure that the syntax was Gauge32 when the object
>> has been written to disk?
>>
>> May be the syntax had been changed accidentally by calling
>> replace_value?
>>
>> The syntax is not checked when data is loaded, so if the
>> syntax of an object changes, one has to write conversion
>> routines to be able to use the old configuration files.
>>
>> Hope this helps.
>>
>> Best regards,
>> Frank
>>
>> Dave Mason wrote:
>>
>>> Hi,
>>> I have a problem where the syntax of an object appears to change 
>>> after the persistence data is read in.  Here is a code fragment from 
>>> agent.cpp.  In the MIB, wsSeqNum has SYNTAX Unsigned32, DEFVAL 0. 
>>> AgentGen Pro appears to translate this to Gauge32.
>>>
>>>    // add supported objects
>>>    init(*mib);
>>>    // add user modules
>>>    module_init(mib);
>>>
>>>    int rc;
>>>    unsigned long seqNum;
>>>    rc = wsSeqNum::instance->get_value(seqNum);
>>>    // load persitent objects from disk
>>>    mib->init();
>>>    rc = wsSeqNum::instance->get_value(seqNum);
>>>
>>> The first get_value works fine, leaving seqNum with the initial 
>>> default value of 0.  The return code rc is 0.  However, after the 
>>> mib->init(), the same get_value fails because it now thinks the 
>>> object syntax is a signed integer.  The return code is -10.  
>>> Interestingly enough, the second get_value works if I delete the 
>>> persistence data files.  Any ideas?
>>>
>>> Regards,
>>> Dave
>>>
>>>
> 
> 
> 







More information about the AGENTPP mailing list