Hi,
I wrote some linesin bug section a few hours ago and I have
still the same problem:
Initial Comment:
Hi,
I'am working with linux suse with net-snmp 5.4.
I write a mib, I put it in the enterprises.
I use mib2c tool. All is ok, I have one .c and one .h
file. No errors.
I compile the agent using ./configure -with-mib-
modules="name of node"
All is all right, no errors in compilation.
then the make and make install -> no problems.
But I can not access to my mib.
snmpget -> no such objet available on this agent at
this OID
snmpwalk enterprise: I can not see the MIB that I add
in the agent.
That is for me a very strange problem that I can not
solve. So please help me if you have an idea ?
Best regards,
Thomas
I join you the 3 files: mib asn1, .c and .h
Is there something wrong in those ?
If I work with an other mib module that I want to add in the
enterprises node, I have the same problem:
When I make a snmpwalk:
ENSEIRB-MIB:enseirb=No such object available on this agent at
this OID
If I make a snmpget I have the same answer.
If I try to set a value with a value that on feet in the MIB
(2 and values are between 0 and 1)-> then system tells me that
value 2 is out of range.
So my mib is in the agent but I can not read value ?
Please help me
Thomas
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf,v 1.1 2002/06/19 18:50:13 hardaker Exp $
*/
#ifndef ENSEIRB_H
#define ENSEIRB_H
/*
* function declarations
*/
void init_enseirb(void);
Netsnmp_Node_Handler do_led0;
Netsnmp_Node_Handler do_led1;
Netsnmp_Node_Handler do_led2;
Netsnmp_Node_Handler do_led3;
Netsnmp_Node_Handler do_led4;
Netsnmp_Node_Handler do_led5;
Netsnmp_Node_Handler do_led6;
Netsnmp_Node_Handler do_led7;
#endif /* ENSEIRB_H */
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.scalar.conf,v 1.1 2002/06/19 18:50:13 hardaker 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 "enseirb.h"
#include <stdlib.h>
#include <unistd.h>
#include <asm/io.h>
#define lp_base 0x378
#define OFF 0
#define ON 1
static int led0 = OFF;
static int led1 = OFF;
static int led2 = OFF;
static int led3 = OFF;
static int led4 = OFF;
static int led5 = OFF;
static int led6 = OFF;
static int led7 = OFF;
static char lpdata;
/** Initialzies the enseirb module */
void
init_enseirb(void)
{
static oid led0_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 1, 0 };
static oid led1_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 2, 0 };
static oid led2_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 3, 0 };
static oid led3_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 4, 0 };
static oid led4_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 5, 0 };
static oid led5_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 6, 0 };
static oid led6_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 7, 0 };
static oid led7_oid[] = { 1, 3, 6, 1, 4, 1, 9362, 1, 8, 0 };
DEBUGMSGTL(("enseirb", "Initializing\n"));
netsnmp_register_instance(
netsnmp_create_handler_registration
("led0",
do_led0, led0_oid, OID_LENGTH(led0_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_instance(netsnmp_create_handler_registration
("led1",
do_led1, led1_oid, OID_LENGTH(led1_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_instance(netsnmp_create_handler_registration
("led2",
do_led2, led2_oid, OID_LENGTH(led2_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_instance(netsnmp_create_handler_registration
("led3",
do_led3, led3_oid, OID_LENGTH(led3_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_instance(netsnmp_create_handler_registration
("led4",
do_led4, led4_oid, OID_LENGTH(led4_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_instance(netsnmp_create_handler_registration
("led5",
do_led5, led5_oid, OID_LENGTH(led5_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_instance(netsnmp_create_handler_registration
("led6",
do_led6, led6_oid, OID_LENGTH(led6_oid),
HANDLER_CAN_RWRITE));
netsnmp_register_instance(netsnmp_create_handler_registration
("led7",
do_led7, led7_oid, OID_LENGTH(led7_oid),
HANDLER_CAN_RWRITE));
// Acces port parallele
ioperm(lp_base, 1, 1);
// On eteint les 8 leds
lpdata = 0;
outb(lpdata, lp_base);
}
int
do_led0(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
char tmp;
/*
* 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 *) &led0,
sizeof(led0));
DEBUGMSGTL(("enseirb", "led0 current value : %d\n", led0));
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:
break;
case MODE_SET_RESERVE2:
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:
/*
* XXX: perform the value change here
*/
lpdata = inb(lp_base);
tmp = *(requests->requestvb->val.integer);
if((tmp == 0) && (led0 == 1))
send_easy_trap(SNMP_TRAP_ENTERPRISESPECIFIC, 100);
// send_easy_trap(10, 10);
led0 = tmp;
DEBUGMSGTL(("enseirb", "led0 set now to %d\n", led0));
tmp = led0 << 0;
if(tmp)
lpdata = lpdata | tmp;
else {
tmp = 1 << 0;
lpdata = lpdata & (~tmp);
}
outb(lpdata, lp_base);
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
break;
default:
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
do_led1(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
char tmp;
/*
* 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 *) &led1,
sizeof(led1));
DEBUGMSGTL(("enseirb", "led0 current value : %d\n", led1));
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:
break;
case MODE_SET_RESERVE2:
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:
/*
* XXX: perform the value change here
*/
lpdata = inb(lp_base);
led1 = *(requests->requestvb->val.integer);
DEBUGMSGTL(("enseirb", "led1 set now to %d\n", led1));
tmp = led1 << 1;
if(tmp)
lpdata = lpdata | tmp;
else {
tmp = 1 << 1;
lpdata = lpdata & (~tmp);
}
outb(lpdata, lp_base);
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
break;
default:
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
do_led2(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
char tmp;
/*
* 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 *) &led2,
sizeof(led2));
DEBUGMSGTL(("enseirb", "led2 current value : %d\n", led2));
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:
break;
case MODE_SET_RESERVE2:
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:
/*
* XXX: perform the value change here
*/
lpdata = inb(lp_base);
led2 = *(requests->requestvb->val.integer);
DEBUGMSGTL(("enseirb", "led2 set now to %d\n", led2));
tmp = led2 << 2;
if(tmp)
lpdata = lpdata | tmp;
else {
tmp = 1 << 2;
lpdata = lpdata & (~tmp);
}
outb(lpdata, lp_base);
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
break;
default:
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
do_led3(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
char tmp;
/*
* 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 *) &led3,
sizeof(led3));
DEBUGMSGTL(("enseirb", "led3 current value : %d\n", led3));
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:
break;
case MODE_SET_RESERVE2:
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:
/*
* XXX: perform the value change here
*/
lpdata = inb(lp_base);
led3 = *(requests->requestvb->val.integer);
DEBUGMSGTL(("enseirb", "led3 set now to %d\n", led3));
tmp = led3 << 3;
if(tmp)
lpdata = lpdata | tmp;
else {
tmp = 1 << 3;
lpdata = lpdata & (~tmp);
}
outb(lpdata, lp_base);
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
break;
default:
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
do_led4(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
char tmp;
/*
* 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 *) &led4,
sizeof(led4));
DEBUGMSGTL(("enseirb", "led4 current value : %d\n", led4));
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:
break;
case MODE_SET_RESERVE2:
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:
/*
* XXX: perform the value change here
*/
lpdata = inb(lp_base);
led4 = *(requests->requestvb->val.integer);
DEBUGMSGTL(("enseirb", "led4 set now to %d\n", led4));
tmp = led4 << 4;
if(tmp)
lpdata = lpdata | tmp;
else {
tmp = 1 << 4;
lpdata = lpdata & (~tmp);
}
outb(lpdata, lp_base);
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
break;
default:
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
do_led5(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
char tmp;
/*
* 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 *) &led5,
sizeof(led5));
DEBUGMSGTL(("enseirb", "led5 current value : %d\n", led5));
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:
break;
case MODE_SET_RESERVE2:
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:
/*
* XXX: perform the value change here
*/
lpdata = inb(lp_base);
led5 = *(requests->requestvb->val.integer);
DEBUGMSGTL(("enseirb", "led5 set now to %d\n", led5));
tmp = led5 << 5;
if(tmp)
lpdata = lpdata | tmp;
else {
tmp = 1 << 5;
lpdata = lpdata & (~tmp);
}
outb(lpdata, lp_base);
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
break;
default:
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
do_led6(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
char tmp;
/*
* 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 *) &led6,
sizeof(led6));
DEBUGMSGTL(("enseirb", "led6 current value : %d\n", led6));
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:
break;
case MODE_SET_RESERVE2:
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:
/*
* XXX: perform the value change here
*/
lpdata = inb(lp_base);
led6 = *(requests->requestvb->val.integer);
DEBUGMSGTL(("enseirb", "led6 set now to %d\n", led6));
tmp = led6 << 6;
if(tmp)
lpdata = lpdata | tmp;
else {
tmp = 1 << 6;
lpdata = lpdata & (~tmp);
}
outb(lpdata, lp_base);
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
break;
default:
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
int
do_led7(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
char tmp;
/*
* 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 *) &led7,
sizeof(led7));
DEBUGMSGTL(("enseirb", "led7 current value : %d\n", led7));
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:
break;
case MODE_SET_RESERVE2:
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:
/*
* XXX: perform the value change here
*/
lpdata = inb(lp_base);
led7 = *(requests->requestvb->val.integer);
DEBUGMSGTL(("enseirb", "led7 set now to %d\n", led7));
tmp = led7 << 7;
if(tmp)
lpdata = lpdata | tmp;
else {
tmp = 1 << 7;
lpdata = lpdata & (~tmp);
}
outb(lpdata, lp_base);
break;
case MODE_SET_COMMIT:
/*
* XXX: delete temporary storage
*/
break;
case MODE_SET_UNDO:
/*
* XXX: UNDO and return to previous value for the object
*/
break;
default:
/*
* we should never get here, so this is a really bad error
*/
return SNMP_ERR_GENERR;
}
return SNMP_ERR_NOERROR;
}
ENSEIRB-MIB DEFINITIONS ::= BEGIN
-- MIB of the ENSEIRB School of electrical Engineering
IMPORTS
enterprises FROM SNMPv2-SMI,
MODULE-IDENTITY FROM SNMPv2-SMI
MODULE-COMPLIANCE, OBJECT-GROUP FROM SNMPv2-CONF;
--
-- A brief description and update information about this mib.
--
enseirb MODULE-IDENTITY
LAST-UPDATED "0104010000Z" -- 01 Apr 2001, midnight
ORGANIZATION "ENSEIRB"
CONTACT-INFO "
Author: Patrice Kadionik
ENSEIRB, School of Electrical Engineering
postal: PO Box 99
33402 TALENCE CEDEX
FRANCE
email: [EMAIL PROTECTED]
phone: +33-5-56-84-65-00
"
DESCRIPTION "MIB for remote control by SNMP
"
::= { enterprises 9362 }
leds OBJECT IDENTIFIER ::= { enseirb 1 }
reserved OBJECT IDENTIFIER ::= { enseirb 2 }
-- Define the sections of the mib them selves:
--
-- 8 LEDs connected to the PC parallel port
--
--
-- LED 0 connected to the PC parallel port
--
led0 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Led 0 connected to bit 0 of the PC parallel port."
DEFVAL { 0 }
::= { leds 1 }
--
-- LED 1 connected to the PC parallel port
--
led1 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Led 1 connected to bit 1 of the PC parallel port."
DEFVAL { 0 }
::= { leds 2 }
--
-- LED 2 connected to the PC parallel port
--
led2 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Led 2 connected to bit 2 of the PC parallel port."
DEFVAL { 0 }
::= { leds 3 }
--
-- LED 3 connected to the PC parallel port
--
led3 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Led 3 connected to bit 3 of the PC parallel port."
DEFVAL { 0 }
::= { leds 4 }
--
-- LED 4 connected to the PC parallel port
--
led4 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Led 4 connected to bit 4 of the PC parallel port."
DEFVAL { 0 }
::= { leds 5 }
--
-- LED 5 connected to the PC parallel port
--
led5 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Led 5 connected to bit 5 of the PC parallel port."
DEFVAL { 0 }
::= { leds 6 }
--
-- LED 6 connected to the PC parallel port
--
led6 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Led 6 connected to bit 6 of the PC parallel port."
DEFVAL { 0 }
::= { leds 7 }
--
-- LED 7 connected to the PC parallel port
--
led7 OBJECT-TYPE
SYNTAX Integer32 (0..1)
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Led 7 connected to bit 7 of the PC parallel port."
DEFVAL { 0 }
::= { leds 8 }
END