Hi
I am working on net-snmp since past few days. I want lldpLocChassisId from
Q-BRIDGE-MIB.
I have added the mib and able to translate the OIDs.
Now I want to do get.
I did mib2c -c mib2c.scalar.conf lldpdLocalSystemData. lldpLocSystemData.c
and lldpLocSystemData.h files are generated in the folder /agent/mibgroup
I ran ./configure --with-mib-modules"lldpLocSystemData", make and sudo make
install
lldpLocSystemData.o and lldpLocSystemData.lo files are generated.
When I do snmpget -v 2c -c public localhost Q-BRIDGE-MIB::
lldpLocChassisId, I get unidentified object error.
When I run gcc lldpLocSsytemData.c -c lldpLocSystemData.o, it gives
undefined reference to functions snmp_get_do_debugging, debugmsgtoken,
debugmsg, netsnmp_create_handle_registration, netsnmp_register_scalar,
snmp_set_var_typed_value, snmp_log.
Can anyone please help me? I am attaching .c and .h files
Janki Chhatbar
M.Tech (Embedded Systems)
Nirma University
(+91) 9409239106
/*
* Note: this file originally auto-generated by mib2c using
* $
*/
#ifndef LLDPLOCALSYSTEMDATA_H
#define LLDPLOCALSYSTEMDATA_H
#ifdef __cplus
extern "C" {
#endif
config_require(Q-BRIDGE-MIB/lldpLocalSystemData)
config_add_mib(Q-BRIDGE-MIB)
#include <net-snmp/varbind_api.h>
/* function declarations */
void init_lldpLocalSystemData(void);
Netsnmp_Node_Handler handle_lldpLocChassisIdSubtype;
Netsnmp_Node_Handler handle_lldpLocChassisId;
Netsnmp_Node_Handler handle_lldpLocSysName;
Netsnmp_Node_Handler handle_lldpLocSysDesc;
Netsnmp_Node_Handler handle_lldpLocSysCapSupported;
Netsnmp_Node_Handler handle_lldpLocSysCapEnabled;
NETSNMP_IMPORT void debugmsg(const char *token, const char *format,...);
NETSNMP_IMPORT void debugmsgtoken(const char *token, const char *format,...);
#ifdef __cplusplus
}
#endif
#endif /* LLDPLOCALSYSTEMDATA_H */
/*
* Note: this file originally auto-generated by mib2c using
* $
*/
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "lldpLocalSystemData.h"
#include <net-snmp/varbind_api.h>
#include <net-snmp/library/snmp_debug.h>
static u_long chassis_id_subtype = 4;
/** Initializes the lldpLocalSystemData module */
void
init_lldpLocalSystemData(void)
{
const oid lldpLocChassisIdSubtype_oid[] = { 1,0,8802,1,1,2,1,3,1 };
const oid lldpLocChassisId_oid[] = { 1,0,8802,1,1,2,1,3,2 };
const oid lldpLocSysName_oid[] = { 1,0,8802,1,1,2,1,3,3 };
const oid lldpLocSysDesc_oid[] = { 1,0,8802,1,1,2,1,3,4 };
const oid lldpLocSysCapSupported_oid[] = { 1,0,8802,1,1,2,1,3,5 };
const oid lldpLocSysCapEnabled_oid[] = { 1,0,8802,1,1,2,1,3,6 };
// DEBUGMSGTL(("lldpLocalSystemData", "Initializing\n"));
netsnmp_register_scalar(
netsnmp_create_handler_registration("lldpLocChassisIdSubtype", handle_lldpLocChassisIdSubtype,
lldpLocChassisIdSubtype_oid, OID_LENGTH(lldpLocChassisIdSubtype_oid),
HANDLER_CAN_RONLY
));
netsnmp_register_scalar(
netsnmp_create_handler_registration("lldpLocChassisId", handle_lldpLocChassisId,
lldpLocChassisId_oid, OID_LENGTH(lldpLocChassisId_oid),
HANDLER_CAN_RONLY
));
netsnmp_register_scalar(
netsnmp_create_handler_registration("lldpLocSysName", handle_lldpLocSysName,
lldpLocSysName_oid, OID_LENGTH(lldpLocSysName_oid),
HANDLER_CAN_RONLY
));
netsnmp_register_scalar(
netsnmp_create_handler_registration("lldpLocSysDesc", handle_lldpLocSysDesc,
lldpLocSysDesc_oid, OID_LENGTH(lldpLocSysDesc_oid),
HANDLER_CAN_RONLY
));
netsnmp_register_scalar(
netsnmp_create_handler_registration("lldpLocSysCapSupported", handle_lldpLocSysCapSupported,
lldpLocSysCapSupported_oid, OID_LENGTH(lldpLocSysCapSupported_oid),
HANDLER_CAN_RONLY
));
netsnmp_register_scalar(
netsnmp_create_handler_registration("lldpLocSysCapEnabled", handle_lldpLocSysCapEnabled,
lldpLocSysCapEnabled_oid, OID_LENGTH(lldpLocSysCapEnabled_oid),
HANDLER_CAN_RONLY
));
}
int
handle_lldpLocChassisIdSubtype(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 *) &chassis_id_subtype
/* XXX: a pointer to the scalar's data */,sizeof(chassis_id_subtype)
/* XXX: the length of the data in bytes */);
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_lldpLocChassisIdSubtype\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_lldpLocChassisId(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_OCTET_STR,"12345"
/* XXX: a pointer to the scalar's data */,strlen("12345")
/* XXX: the length of the data in bytes */);
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_lldpLocChassisId\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_lldpLocSysName(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_OCTET_STR,"linuxpc"
/* XXX: a pointer to the scalar's data */,strlen("linuxpc")
/* XXX: the length of the data in bytes */);
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_lldpLocSysName\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_lldpLocSysDesc(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_OCTET_STR,"2gb"
/* XXX: a pointer to the scalar's data */,strlen("2gb")
/* XXX: the length of the data in bytes */);
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_lldpLocSysDesc\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_lldpLocSysCapSupported(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_OCTET_STR,"3"
/* XXX: a pointer to the scalar's data */,strlen("3")
/* XXX: the length of the data in bytes */);
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_lldpLocSysCapSupported\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
handle_lldpLocSysCapEnabled(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_OCTET_STR,"3"
/* XXX: a pointer to the scalar's data */,strlen("3")
/* XXX: the length of the data in bytes */);
break;
default:
/* we should never get here, so this is a really bad error */
snmp_log(LOG_ERR, "unknown mode (%d) in handle_lldpLocSysCapEnabled\n", reqinfo->mode );
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
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