Re: snmpget problem
"Artem Fedko" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Here is it! Sorry I forgot to attach it to previous mail ;) Artem On 12/19/06, Dave Shield <[email protected]> wrote: > On 19/12/06, Artem Fedko <[email protected]> wrote: > > > How have you implemented this object? > > > > I've implemented it in next way: > > > > 1) create MIB file and put it in /usr/local/share/snmp/mibs > > 2) use mib2c -c mib2c.scalar.conf ART-MIB::arttest > > > OK - so you're using the scalar template. > What does the 'arttest.c' file look like? > > Dave > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ 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
arttest.c
(application/octet-stream, 3.4 KB)
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf,v 1.8 2004/10/14 12:57:34 dts12 Exp $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "arttest.h"
unsigned long ret_value = 1;
/** Initializes the arttest module */
void
init_arttest(void)
{
static oid arttest_oid[] = { 1,3,6,1,2,1,99,1 };
DEBUGMSGTL(("arttest", "Initializing\n"));
netsnmp_register_scalar(
netsnmp_create_handler_registration("arttest", handle_arttest,
arttest_oid, OID_LENGTH(arttest_oid),
HANDLER_CAN_RWRITE
));
}
int
handle_arttest(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
/* We are never called for a GETNEXT if it's registered as a
"instance", as it's "magically" handled for us. */
/* a instance handler also only hands us one request at a time, so
we don't need to loop over a list of requests; we'll only get one. */
switch(reqinfo->mode) {
case MODE_GET:
snmp_set_var_typed_value(requests->requestvb, ASN_UNSIGNED, (u_char *)&ret_value, sizeof(ret_value));
break;
/*
* SET REQUEST
*
* multiple states in the transaction. See:
* http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
*/
case MODE_SET_RESERVE1:
if (requests->requestvb->type != ASN_UINTEGER) {
netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGVALUE);
}
break;
case MODE_SET_RESERVE2:
/* XXX malloc "undo" storage buffer */
// if (/* XXX if malloc, or whatever, failed: */) {
// netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_RESOURCEUNAVAILABLE);
// }
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:
ret_value=requests->requestvb->val.integer;
// if (/* XXX: error? */) {
// netsnmp_set_request_error(reqinfo, requests, /* some error */);
// }
break;
case MODE_SET_COMMIT:
/* XXX: delete temporary storage */
//if (/* XXX: error? */) {
// /* try _really_really_ hard to never get to this point */
// netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_COMMITFAILED);
//}
break;
case MODE_SET_UNDO:
/* XXX: UNDO and return to previous value for the object */
//if (/* XXX: error? */) {
/* try _really_really_ hard to never get to this point */
// netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_UNDOFAILED);
//}
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_arttest\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}