> In my sub-agent I will have a few INTEGER variables (not a table, plain
> INTERGERs) that will be GET/SET. For the moment I'm thinking about using
> netsnmp_register_int_instance() with the default integer handler.
Are these scalar MIB objects? Or individual instances (e.g. as part of
a wider table).
If they're scalar objects, then can I suggest that you consider using
'netsnmp_register_scalar()' or 'netsnmp_register_watched_scalar()'
instead. That would handle such objects rather better - in that it
would respond correctly to invalid requests as well as valid ones.
(i.e. requests for 'myObject' or 'myObject.1')
> The problem is that every INTEGER variable has a value range that must
> be checked before a SET. Does net-snmp check for the validity of INTEGER
> ranges before setting it's value?
The toolkit helpers don't, no - but you could supply your own helper
routine that could perform these checks. That would typically be the
only thing you'd need to do - the helpers would do all the rest of the
work.
So the full code for a watched writable scalar helper would be:
int
handle_myObject( .... )
{
netsnmp_request_info *request;
switch (reqinfo->mode) {
case MODE_RESERVE1:
for (request=requests; request; request=request->next) {
if ( is_not_valid( *request->requestvb->val.integer )) {
netsnmp_set_request_error( reqinfo, request,
SNMP_ERR_WRONGVALUE );
return SNMP_ERR_WRONGVALUE;
}
}
break;
}
return SNMP_ERR_NOERROR;
}
That's the appropriate way to do this - putting your helper "above" the
instance handler in the chain isn't really sensible.
Dave
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Net-snmp-coders mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders