Hi All,
I was testing the snmpset with the example file scalar_int.c that
comes with the net-snmp. I extended it to test set but it is failing
every time giving following error in the mib-browser.
THIS IS THE RESPONSE FOR THE SET REQUEST
Request Failed: Get Response PDU received from 127.0.0.1
Error Indication in response: A not writable error occured.
Errindex: 1
Is anything am i doing wrong.
OUTPUT OF THE BELOW PROGRAM is
Default value is 42
DEFAULT value is 2
***********INSIDE setFunc*********
inside MODE_SET_RESERVE1
***********INSIDE setFunc*********
inside MODE_SET_FREE
BELOW IS THE EXAMPLE CODE WHICH I TRIED.
THE REGISTRATION METHOD
netsnmp_register_int_instance("my example int variable",
my_registration_oid,
OID_LENGTH(my_registration_oid),
&example1, setFunc);
DEBUGMSGTL(("example_scalar_int",
"Done initalizing example scalar int\n"));
}
HANDLER FUNCTION
int setFunc(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
printf("***********INSIDE setFunc*********\n");
int *pexample = NULL;
switch(reqinfo->mode)
{
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
(u_char *)&example1
,sizeof(int)
);
break;
case MODE_SET_RESERVE1:
printf( "inside MODE_SET_RESERVE1\n");
if ( requests->requestvb->type != ASN_INTEGER ) {
printf( "wrong type\n");
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_WRONGTYPE
);
return SNMP_ERR_WRONGTYPE;
}
if ( (*(requests->requestvb->val.integer) > 1 ) ||
(*(requests->requestvb->val.integer) < 0))
{
printf( "wrong value\n");
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_WRONGVALUE
);
return SNMP_ERR_WRONGVALUE;
}
break;
case MODE_SET_RESERVE2:
printf( "inside MODE_SET_RESERVE2\n");
/*
* XXX malloc "undo" storage buffer
*/
memdup((u_char **)&pexample, (u_char *)&example1,
sizeof(example1));
if ( pexample == NULL ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_RESOURCEUNAVAILABLE);
return SNMP_ERR_NOERROR;
}
break;
case MODE_SET_FREE:
printf( "inside MODE_SET_FREE \n");
break;
case MODE_SET_ACTION:
printf( "Inside MODE_SET_ACTION\n");
example1 = *(requests->requestvb->val.integer);
break;
case MODE_SET_COMMIT:
printf( "Inside MODE_SET_COMMIT\n");
break;
case MODE_SET_UNDO:
printf("Inside MODE_SET_UNDO\n");
break;
default:
printf( "inside default\n");
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
/*if (handler->next && handler->next->access_method)
return netsnmp_call_next_handler(handler, reginfo, reqinfo,
requests);*/
return SNMP_ERR_NOERROR;
}
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
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