Re: Re: How agent acts upon receiving a request???
"Dave Shield" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
On 25/04/07, Reza Salehi <[email protected]> wrote: > I am using > netsnmp_register_int_instant(..,..,..,..My_handler) I presume you mean 'netsnmp_register_int_instance()' The basic idea of this particular helper is that you're telling the agent: "Here's an integer variable. Watch it, and whenever you're asked for this MIB object, return the current value of this watched variable buffer." So by default, the agent will return the value from this buffer. You don't need to do anything else. But before it returns this value, it will call your handler (if any), to allow you to tweak the value being returned. Note that the varbind has already been set up with the value from your watched variable, so you need to update the *varbind* - not (just) the variable buffer itself. Normally, this buffer would be updated automatically as part of the normal operation of the subsystem. It's not really intended to be updated from the handler itself - that rather negates the point of having a watched buffer in the first place. One final question - are you implementing a scalar object, or an instance within a table? If this is a scalar MIB object, then you should probably consider using "netsnmp_register_scalar()', and supply the value in the handler, in the usual manner. The difference is in the handling of "invalid instances" (e.g. myObject.1). ns_register_scalar() will return the correct error - ns_register_int_instance() gets this wrong when used for a scalar object. > My_handler(....,....,netsnmp_agent_request_info *reqinfo,.......) > then > case( reqinfo->mode) . > is this the right way? I have no idea whether this is right or not. You haven't given any indication of what you are actually doing in the handler. "case( reqinfo->mode )" is too vague to be useful. Dave ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ 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