I like to display the OID as string. So instead of integer I have chosen some
char* as the key
initialize_table_messageTable(void) {
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER,
ASN_OCTET_STR,
ASN_INTEGER,
ASN_INTEGER,
ASN_INTEGER, 0);
}
but while doing snmpwalk I am not getting them as String
snmpwalk -v2c -c public -Oa localhost:11161 1.3.6.1.4.1.11456
ABC-MIB::messageType.0.3.65.70.77.98374.98374.4 = STRING: AFM
--OID has been displayed as 65.70.77 which is basically AFM
Where I expect to display as ABC-MIB::messageType.0.3.AFM.98374.98374.4 =
STRING: AFM
how can I achive this ?
/*
* Note: this file originally auto-generated by mib2c using
* : mib2c.iterate.conf 19302 2010-08-13 12:19:42Z dts12 $
*/
#include net-snmp/net-snmp-config.h
#include net-snmp/net-snmp-includes.h
#include net-snmp/agent/net-snmp-agent-includes.h
#include abcModule.h
#define STRMAX 256
static void update_stats( unsigned int, void* );
/** Initializes the abcModule module */
void
init_abcModule(void)
{
/* here we initialize all the tables we're planning on supporting */
initialize_table_messageTable();
initialize_table_msgVMTable();
}
/** Initialize the messageTable table by defining its contents and how it's structured */
void
initialize_table_messageTable(void)
{
const oid messageTable_oid[] = {1,3,6,1,4,1,11456,3,3};
const size_t messageTable_oid_len = OID_LENGTH(messageTable_oid);
netsnmp_handler_registration*reg;
netsnmp_iterator_info *iinfo;
netsnmp_table_registration_info *table_info;
DEBUGMSGTL((abcModule:init, initializing table messageTable\n));
reg = netsnmp_create_handler_registration(
messageTable, messageTable_handler,
messageTable_oid, messageTable_oid_len,
HANDLER_CAN_RONLY
);
table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER,
ASN_OCTET_STR,
ASN_INTEGER,
ASN_INTEGER,
ASN_INTEGER, 0);
table_info-min_column = COLUMN_MESSAGETYPE;
table_info-max_column = COLUMN_CURRENTMSGID;
iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
iinfo-get_first_data_point = messageTable_get_first_data_point;
iinfo-get_next_data_point = messageTable_get_next_data_point;
iinfo-table_reginfo= table_info;
netsnmp_register_table_iterator( reg, iinfo );
snmp_alarm_register( 5, SA_REPEAT , update_stats, NULL );
/* Initialise the contents of the table here */
}
/* Typical data structure for a row entry */
struct msgVMTable_entry {
/* Index values */
long messageIndex;
long msgVMIndex;
/* Column values */
char msgVMName[10];
long msgVMId;
/* Illustrate using a simple linked list */
int valid;
struct msgVMTable_entry *next;
};
/* Typical data structure for a row entry */
struct messageTable_entry {
/* Index values */
long messageIndex;
/* Column values */
char messageType[10];
long sentMsgCount;
long errorMsgCount;
long currentMsgID;
/* Illustrate using a simple linked list */
int valid;
struct messageTable_entry *next;
//struct msgVMTable_entry *msgVMTable_head;
};
struct messageTable_entry *messageTable_head; //top level Table
struct msgVMTable_entry *msgVMTable_head; // vm table is repeated for each row of messageTable
/* create a new row in the (unsorted) table */
struct messageTable_entry *
messageTable_createEntry(
long messageIndex
) {
struct messageTable_entry *entry;
entry = SNMP_MALLOC_TYPEDEF(struct messageTable_entry);
if (!entry)
return NULL;
entry-messageIndex = messageIndex;
entry-next = messageTable_head;
messageTable_head = entry;
return entry;
}
void
messageTable_removeEntry( struct messageTable_entry *entry ) {
struct messageTable_entry *ptr, *prev;
if (!entry)
return;
for ( ptr = messageTable_head, prev = NULL;
ptr != NULL;
prev = ptr, ptr = ptr-next ) {
if ( ptr == entry )
break;
}
if ( !ptr )
return;
if ( prev == NULL )
messageTable_head = ptr-next;
else
prev-next = ptr-next;
SNMP_FREE( entry );
}
/* Example iterator hook routines - using 'get_next' to do most of the work */
netsnmp_variable_list *
messageTable_get_first_data_point(void