小弟目前在cyclone v 架設 snmp
在測試snmpset時一直發生以下錯誤:
Error in packet.
Reason: noAccess
Failed object: Test-MIB::GetTime.0
上網查了之後覺得是權限問題,所以修改了snmpd.conf 如下
應該要能寫入了但仍然不行
附上程式碼:
#include
#include
#include
#include "Test.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/** Initializes the Test module */
void
init_Test(void)
{
const oid GetTime_oid[] = { 1, 3, 6, 1, 4, 1, 16535, 1, 1 };
DEBUGMSGTL(("Test", "Initializing\n"));
netsnmp_register_scalar(netsnmp_create_handler_registration
("GetTime", handle_GetTime, GetTime_oid,
OID_LENGTH(GetTime_oid), HANDLER_CAN_RONLY));
}
int
handle_GetTime(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{ int ret;
int id = 219;
switch (reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,(u_char *) &id
/* XXX: a pointer to the scalar's data */
, sizeof(id)
/*
* XXX: the length of the data in bytes
*/ );
break;
case MODE_SET_RESERVE1:
ret = netsnmp_check_vb_type(requests->requestvb, ASN_OCTET_STR);
if ( ret != SNMP_ERR_NOERROR ) {
netsnmp_set_request_error(reqinfo, requests, ret );
}
break;
case MODE_SET_FREE:
/* XXX: free resources allocated in RESERVE1 and/or
RESERVE2. Something failed somewhere, and the states
below won't be called. */
break;
case MODE_SET_ACTION:
id = *requests->requestvb->val.integer;
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR, "unknown mode (%d) in handle_GetTime\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
...麻煩各位幫我看一下了…萬分感謝~