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
Dave, thank you for your answer, 'netsnmp_register_watched_scalar()' did the job.
One more thing, is there a way to make net-snmp read my MIB module and then use the library to find out what are de DEFAULT values and allowable range of the INTEGER scalars defined in the MIB module (so I don't have to hardcode the allowable range of values and the DEFAULT value in my application)?
Also, what would you suggest to use for DisplayString variables (I did not find any netsnmp_register_string() or something like it)?
Regards, -- Ivens Porto OSE - Open Systems Engineering http://www.ose.com.br Phone: (55) 34 - 3214-5995 Fax: (55) 34 - 3214-5994 Cel: (55) 34 - 8816-9942
------------------------------------------------------- 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
