Hi Dave,
How to set default row in table using provide APIs?
I just started exploring net-snmp. I created a sample mib, in which two scalar
object and a table with 3 columnar objects including index.
In created *.c & *.h using "mib2c.create-dataset.conf " option for tabular
objects and complied loading ./configure option.
Here is the code snippet, which I tried to played around to create at least one
default row. But after compilation and make I didn't see any default row is
created.
Could you please guide me.
===================================================
void
initialize_table_exampleTestIfTable(void)
{
static oid exampleTestIfTable_oid[] = {1,3,6,1,4,1,2014,15,2,2,2};
size_t exampleTestIfTable_oid_len = OID_LENGTH(exampleTestIfTable_oid);
netsnmp_table_data_set *table_set;
netsnmp_table_row *row;
u_long ind1;
int ind3;
/* create the table structure itself */
table_set = netsnmp_create_table_data_set("exampleTestIfTable");
/* comment this out or delete if you don't support creation of new rows */
table_set->allow_creation = 1;
/***************************************************
* Adding indexes
*/
DEBUGMSGTL(("initialize_table_exampleTestIfTable",
"adding indexes to table exampleTestIfTable\n"));
netsnmp_table_set_add_indexes(table_set,
ASN_UNSIGNED, /* index: unitId */
1);
DEBUGMSGTL(("initialize_table_exampleTestIfTable",
"adding column types to table exampleTestIfTable\n"));
ind1 = 1;
ind3 = 5;
netsnmp_table_set_multi_add_default_row(table_set,
COLUMN_UNITID, ASN_UNSIGNED, 0,
&ind1, sizeof(ind1),
COLUMN_UNITSYSLABEL, ASN_OCTET_STR,
1,
"Russ Mundy", strlen("Russ Mundy"),
COLUMN_UNITTYPE, ASN_INTEGER, 0,
&ind3, sizeof(ind3),
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 exampleTestIfTable_handler to "NULL" */
netsnmp_register_table_data_set(netsnmp_create_handler_registration("exampleTestIfTable",
exampleTestIfTable_handler,
exampleTestIfTable_oid,
exampleTestIfTable_oid_len,
HANDLER_CAN_RWRITE),
table_set, NULL);
/* POC - Rajnish
* create the a row for the table, and add the data
*/
// row = netsnmp_create_table_data_row();
/*
* set the index to the IETF WG name "snmpv3"
*/
// ind1 = 1;
// netsnmp_table_row_add_index(row, ASN_UNSIGNED, &ind1, sizeof(ind1));
/*
* set column 2 to be the WG chair name "Russ Mundy"
*/
// netsnmp_set_row_column(row, 2, ASN_OCTET_STR,
// "Russ Mundy", strlen("Russ Mundy"));
// netsnmp_mark_row_column_writable(row, 2, 1);
/*
* set column 3 to be the WG chair name "David Harrington"
*/
// ind3 = 5;
// netsnmp_set_row_column(row, 3, ASN_INTEGER,&ind1, sizeof(ind1));
/* POC - Rajnish End*/
=========================================================================================
I really like this tool, it's simply good. Thanks to all you guys. It would be
really nice, if you could you please help me out.
Thanks,
Rajnish
------------------------------------------------------------------------------
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders