Thanks M/F,
I tried your suggested code but it won't compile...
netsnmp_init_watcher_info6รข was not declared in this scope
I am using net-snmp 5.4.2.1
Thanks
Prakash
The problems I see are:
* You are telling the agent that you are returning a buffer of 256
bytes but you are only initializing about ten of those bytes,
the rest you are leaving unspecified.
* Further, it looks as if you are initializing it with a local
variable in a function, if that is the case then it is expected
that the result contains utter garbage as it is whatever happens
to be at the stack when the handler is called.
I would probably write your code like
--- abc.c ---
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
static char abcName[256] = "ABC Default value";
static const oid abcName_oid[] = {1,3,6,1,4,1,3286,13,5,1,1,3,0};
static netsnmp_watcher_info winfo;
static netsnmp_handler_registration *reg = NULL;
void
init_abc(void)
{
netsnmp_init_watcher_info6(
&winfo, abcName, 0, ASN_OCTET_STR,
WATCHER_MAX_SIZE|WATCHER_SIZE_STRLEN, sizeof(abcName), NULL);
reg = netsnmp_create_handler_registration(
"abcName", NULL, abcName_oid, OID_LENGTH(abcName_oid),
HANDLER_CAN_RWRITE);
if (!reg)
snmp_log(LOG_ERR, "Failed to create registration for abcName");
else if(netsnmp_register_watched_instance(reg, &winfo) < 0)
snmp_log(LOG_ERR, "Failed to register watched abcName");
}
--- EOF ---
/MF
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders