Hi all,
I have run mib2c and obtained my .c and .h files. I have one single RW scalar
variable named "id". I I have completed the MODE_GET case by giving the pointor
and lenght of "id". The problem is that i don't know how to complete the
MODE_SET_ACTION, all i want is to affect an integer value to my scalar object
"id".
Please help, I'm totally begineer. Thanks a lot.
here is the C code given by mib2c:
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "leadTechDesign.h"
/*
* Then, we declare the variables we want to be accessed with their default
values
*/
static int id = 1
void
init_leadTechDesign(void)
{
/*
* the OIDs we want to register our scalars at
*/
static oid id_oid[] = { 1, 3, 6, 1, 4, 1, 31900, 1, 2, 1 };
/*
* a debugging statement
*/
DEBUGMSGTL(("leadTechDesign", "Initializing\n"));
netsnmp_register_scalar(netsnmp_create_handler_registration
("id", handle_id, id_oid, OID_LENGTH(id_oid),
}
int
handle_id(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
int ret;
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
*/ );
DEBUGMSGTL(("LTD-MIB", "id current value : %d\n", id));
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:
ret = netsnmp_check_vb_type(requests->requestvb, ASN_INTEGER);
if (ret != SNMP_ERR_NOERROR) {
netsnmp_set_request_error(reqinfo, requests, ret);
}
break;
case MODE_SET_RESERVE2:
if ( /* XXX if malloc, or whatever, failed: */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_RESOURCEUNAVAILABLE);
}
break;
case MODE_SET_FREE:
break;
case MODE_SET_ACTION:
/* * XXX: perform the value change here */
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests, /* some error */
);
}
break;
case MODE_SET_COMMIT:
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_COMMITFAILED);
}
break;
case MODE_SET_UNDO:
if ( /* XXX: error? */ ) {
netsnmp_set_request_error(reqinfo, requests,
SNMP_ERR_UNDOFAILED);
}
break;
default:
snmp_log(LOG_ERR, "unknown mode (%d) in handle_id\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users