Hi to all,
I am new to net-snmp and I have a problem accessing the data of a table.
I have already noticed the previous discussion indexed "table problems",
but I followed the rule init_FILENAME and I still have problem.
I ran mib2c.create-dataset.conf on my MIB file. The .c and .h files are
attached to the mail. I tried to follow the example given in data_set.c
The table in the MIB is of the form
intracomTable OBJECT-TYPE
SYNTAX SEQUENCE OF IntracomTableEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION ""
::= { F5000grt 2 }
intracomTableEntry OBJECT-TYPE
SYNTAX IntracomTableContent
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION ""
INDEX { intracomTableId }
::= { intracomTable 1 }
IntracomTableEntry ::= SEQUENCE {
intracomTableId OCTET STRING,
intracomTableContent1 OCTET STRING,
intracomTableContent2 OCTET STRING
}
intracomTableId OBJECT-TYPE
SYNTAX OCTET STRING ( SIZE (1..32))
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION ""
::= { intracomTableEntry 1 }
intracomTableContent1 OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-create
STATUS current
DESCRIPTION ""
::= { intracomTableEntry 2 }
intracomTableContent2 OBJECT-TYPE
SYNTAX OCTET STRING
MAX-ACCESS read-create
STATUS current
DESCRIPTION ""
::= { intracomTableEntry 3 }
the snmptranslate works fine.
I have no problem at compilation, but as soon as I start the snmp
daemon, I can see all the debugging related to intracomTable.
However, the snmwalk does not work properly.
Giving snmpwalk -v2c -c public localhost intracomTable returns
INTRACOM-F5000-VOIPV1-MIB::intracomTable = No Such Object available on
this agent at this OID
I will appreciate any idea/help, because I am stucked.
Thank you in advance,
Pavlos
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.create-dataset.conf,v 5.4 2004/02/02 19:06:53 rstory 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 "intracomTable.h"
/** Initialize the intracomTable table by defining its contents and how it's structured */
void
initialize_table_intracomTable(void)
{
static oid intracomTable_oid[] = { 1, 3, 6, 1, 4, 1, 1807, 1, 2 };
size_t intracomTable_oid_len = OID_LENGTH(intracomTable_oid);
netsnmp_table_data_set *table_set;
netsnmp_table_row *row;
int r;
/*
* create the table structure itself
*/
table_set = netsnmp_create_table_data_set("intracomTable");
/*
* comment this out or delete if you don't support creation of new rows
*/
table_set->allow_creation = 1;
/***************************************************
* Adding indexes
*/
DEBUGMSGTL(("initialize_table_intracomTable",
"adding indexes to table intracomTable\n"));
netsnmp_table_dataset_add_index(table_set, ASN_OCTET_STR);
DEBUGMSGTL(("initialize_table_intracomTable",
"adding column types to table intracomTable\n"));
netsnmp_table_set_multi_add_default_row(table_set,
COLUMN_INTRACOMTABLEID,
ASN_OCTET_STR, 0, NULL, 0,
COLUMN_INTRACOMTABLECONTENT1,
ASN_OCTET_STR, 1, NULL, 0,
COLUMN_INTRACOMTABLECONTENT2,
ASN_OCTET_STR, 1, NULL, 0, 0);
/*
* registering the table with the master agent
*/
/*
* note: if you don't need a subhandler to deal with any aspects
* of the request, change intracomTable_handler to "NULL"
*/
netsnmp_register_table_data_set(netsnmp_create_handler_registration
("intracomTable",
intracomTable_handler,
intracomTable_oid,
intracomTable_oid_len,
HANDLER_CAN_RWRITE), table_set, NULL);
row = netsnmp_create_table_data_row();
if (row == NULL)
DEBUGMSGTL(("initialize_table_intracomTable",
"ERROR 1\n"));
netsnmp_table_row_add_index(row, ASN_OCTET_STR, "f5000", strlen("f5000"));
r = netsnmp_set_row_column(row, 2, ASN_OCTET_STR, "ppar", strlen("ppar"));
if (r != SNMPERR_SUCCESS)
DEBUGMSGTL(("initialize_table_intracomTable",
"ERROR 2\n"));
r = netsnmp_mark_row_column_writable(row, 2, 1);
if (r != SNMPERR_SUCCESS)
DEBUGMSGTL(("initialize_table_intracomTable",
"ERROR 3\n"));
r = netsnmp_set_row_column(row, 3, ASN_OCTET_STR, "ptzi", strlen("ptzi"));
if (r != SNMPERR_SUCCESS)
DEBUGMSGTL(("initialize_table_intracomTable",
"ERROR 4\n"));
r = netsnmp_mark_row_column_writable(row, 3, 1);
if (r != SNMPERR_SUCCESS)
DEBUGMSGTL(("initialize_table_intracomTable",
"ERROR 5\n"));
netsnmp_table_dataset_add_row(table_set, row);
netsnmp_register_auto_data_table(table_set, NULL);
}
/** Initializes the intracomTable module */
void
init_intracomTable(void)
{
DEBUGMSGTL(("initialize_table_intracomTable",
"1!!!\n"));
/*
* here we initialize all the tables we're planning on supporting
*/
initialize_table_intracomTable();
}
/** handles requests for the intracomTable table, if anything else needs to be done */
int
intracomTable_handler(netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests)
{
DEBUGMSGTL(("initialize_table_intracomTable",
"2!!!\n"));
/*
* perform anything here that you need to do. The requests have
* already been processed by the master table_dataset handler, but
* this gives you chance to act on the request in some other way
* if need be.
*/
return SNMP_ERR_NOERROR;
}
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.create-dataset.conf,v 5.4 2004/02/02 19:06:53 rstory Exp $
*/
#ifndef INTRACOMTABLE_H
#define INTRACOMTABLE_H
/*
* function declarations
*/
void init_intracomTable(void);
void initialize_table_intracomTable(void);
Netsnmp_Node_Handler intracomTable_handler;
/*
* column number definitions for table intracomTable
*/
#define COLUMN_INTRACOMTABLEID 1
#define COLUMN_INTRACOMTABLECONTENT1 2
#define COLUMN_INTRACOMTABLECONTENT2 3
#endif /* INTRACOMTABLE_H */