Looking at the example in the tutorial,
http://www.net-snmp.org/dev/agent/scalar__int_8c-example.html
I wrote the test at the end of this email.
My problem is that my handler apparently gets called after the default
handler, so if I want to manipulate the string that the agent will
return, my manipulation happens after the default handler returns the
value.
How can I prevent this?
Thanks,
- Jordi G. H.
//************** code begins here *************
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
/* default value */
static int jordi_int = 6969;
int
jordi_handler(
netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
switch(reqinfo ->mode){
case MODE_GET:
jordi_int = 42;
break;
default:
break;
}
return SNMP_ERR_NOERROR;
}
void
init_scalar_int(void)
{
oid my_registration_oid[] = { 1, 3, 6, 1, 4, 1, 8072, 2, 1, 1, 0 };
netsnmp_register_read_only_int_instance("my example int variable",
my_registration_oid,
OID_LENGTH(my_registration_oid),
&jordi_int, &jordi_handler);
}
/*
Sample output:
jo...@clio:~/snmp$ snmpget localhost netSnmpExampleInteger.0
NET-SNMP-EXAMPLES-MIB::netSnmpExampleInteger.0 = INTEGER: 6969
jo...@clio:~/snmp$ snmpget localhost netSnmpExampleInteger.0
NET-SNMP-EXAMPLES-MIB::netSnmpExampleInteger.0 = INTEGER: 42
Want 42 to always be the answer, not 6969.
*/
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
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