Hi All,
i am new to net-snmp and assigned a task of writting MIB module for embedded
device.
so i started with implementing/Adding a single scalar variable to Agent. (on a
intel based PC)
my MIB file and skeleton file(output of mib2c -c mob2c.scalar.conf) are
attached here.
m struck at how to populate .c file.
help will b appreciated
MahesH
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf 17337 2009-01-01 14:28:29Z magfr $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "MyVar.h"
/** Initializes the MyVar module */
void
init_MyVar(void)
{
const oid MyVar_oid[] = { 1, 3, 6, 1, 3, 1, 1 };
DEBUGMSGTL(("MyVar", "Initializing\n"));
netsnmp_register_scalar(netsnmp_create_handler_registration
("MyVar", handle_MyVar, MyVar_oid,
OID_LENGTH(MyVar_oid), HANDLER_CAN_RONLY));
}
int
handle_MyVar(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_INTEGER,
(u_char *)
/* XXX: a pointer to the scalar's data */
reqinfo->agent_data->data
,
/*
* XXX: the length of the data in bytes
*/
1
);
break;
default:
/*
* we should never get here, so this is a really bad error
*/
snmp_log(LOG_ERR, "unknown mode (%d) in handle_MyVar\n",
reqinfo->mode);
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
MY-MIB DEFINITIONS ::= BEGIN
IMPORTS
experimental, Integer32, MODULE-IDENTITY
FROM SNMPv2-SMI;
MyMIB MODULE-IDENTITY
::= { experimental 1 }
MyVar OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION "testvariable"
DEFVAL { 10 }
::= { MyMIB 1 }
END
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
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