hi ..
i am a fresher, both to netsnmp as well as this
mailing list.
the problem i face is as follows:
i am trying to write a handler for a scalar of type
OCTET STRING. i created the template code from the mib
compiler as follows:
mib2c -c scalar.conf netSnmpfilename
then i made changes as suggested by the comments at
the appropriate places in the handler to handle
GET/SET requests.i compiled this with the
example-demon given on the netsnmp site.
THE PROBLEM:
-------------
when i try to do an snmpset on the above scalar it is
giving me the following error:
Error in packet.
Reason: resourceUnavailable (This is likely a
out-of-memory failure within the agent)
Failed object: NET-SNMP-MIB::netSnmp.2.5.2.0
Can anyone please tell me where i have gone wrong???
also to the best of my knowledge, unlike for scalar
inetgers, there are no pre-written handlers for string
scalars. in case there are any please let me know
where i can find them.
the handler code i have written is as follows:
***********************************
int
handle_netSnmpfilename(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
char *it = (char *) handler->myvoid;
char *it_save;
switch (reqinfo->mode)
{
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb,
ASN_OCTET_STR,
(u_char *) it
, sizeof(it));
break;
case MODE_SET_RESERVE1:
if (requests->requestvb->type != ASN_OCTET_STR
)
{
netsnmp_set_request_error(reqinfo,
requests,SNMP_ERR_WRONGTYPE);
}
break;
case MODE_SET_RESERVE2:
memdup((u_char**)&it_save,(u_char*)it,sizeof(it))));
if ( it_save == NULL )
{
netsnmp_set_request_error(reqinfo,
requests,SNMP_ERR_RESOURCEUNAVAILABLE);
return SNMP_ERR_NOERROR;
}
netsnmp_request_add_list_data(requests,
netsnmp_create_data_list(INSTANCE_HANDLER_NAME,
it_save,free));
break;
case MODE_SET_ACTION:
DEBUGMSGTL(("testhandler", "updated u_char %s ->
%s\n", *it,
*(requests->requestvb->val.string)));
*it = *(requests->requestvb->val.string);
break;
case MODE_SET_UNDO:
it = ((char *) netsnmp_request_get_list_data
(requests,INSTANCE_HANDLER_NAME));
break;
case MODE_SET_COMMIT:
break;
case MODE_SET_FREE:
break;
}
return SNMP_ERR_NOERROR;
}
*******************************
regards,
Sharath
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
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