not sure how to initialize table_data
Kathy McLeod <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <OFCDFF3104.9D55F9E7-ON862576E9.0070F7A7-862576EA.00566BD2@us.ibm.com> |
Hi -
I took your advice and ran mib2c -c mib2c.table_data.conf
LLDP-MIB::lldpPortConfigTable. The generated .h has this:
/*
* column number definitions for table lldpPortConfigTable
*/
#define COLUMN_LLDPPORTCONFIGPORTNUM 1
#define COLUMN_LLDPPORTCONFIGADMINSTATUS 2
#define COLUMN_LLDPPORTCONFIGNOTIFICATIONENABLE 3
#define COLUMN_LLDPPORTCONFIGTLVSTXENABLE 4
Note that the MIB defines the port number as the index, in the range of 1
to 4096.
My internal table that holds the data is this:
#define PORT_TAB_MAX_ENTRIES 4
typedef struct port_tab_entry_s {
long port_tab_portnum;
long port_tab_status;
long port_tab_notify;
char port_tab_tlvs;
} port_tab_entry_t;
extern port_tab_entry_t tempTable[PORT_TAB_MAX_ENTRIES];
Here is my code to copy my data to the table_data (for now I am testing
with fake data):
/*
* Initialise the contents of the table here
*/
for(i=0; i<4; i++)
{
tempTable[i].port_tab_portnum = i+1;
tempTable[i].port_tab_status = (i+1) % 5; /* 1 thru 4 */
tempTable[i].port_tab_notify = i % 2; /* true or false */
tempTable[i].port_tab_tlvs = BIT0 | i;
lldpPortConfigTable_createEntry(table_data, i);
}
snmptable works:
snmptable -v 2c -c private localhost LLDP-MIB::lldpPortConfigTableSNMP
table: LLDP-MIB::lldpPortConfigTable
lldpPortConfigAdminStatus lldpPortConfigNotificationEnable
lldpPortConfigTLVsTxEnable
txOnly 0
"00 "
rxOnly true
"01 "
txAndRx 0
"02 "
disabled true
"03 "
However when I do a get, the row numbers are from 0-3 (apparently) and the
top row is inaccessible (even though my port numbers (index) go from 1 -
4).
snmpget -v 2c -c private localhost LLDP-MIB::lldpPortConfigTable.1.2.1
LLDP-MIB::lldpPortConfigAdminStatus.1 = INTEGER: rxOnly(2)
When I change to lldpPortConfigTable_createEntry(table_data, i+1);
I get complete garbage:
snmptable -v 2c -c private localhost LLDP-MIB::lldpPortConfigTableSNMP
table: LLDP-MIB::lldpPortConfigTable
lldpPortConfigAdminStatus lldpPortConfigNotificationEnable
lldpPortConfigTLVsTxEnable
0 0
"00 "
0 0
"00 "
0 0
"00 "
1128482560 539579726
"32 "
I wasn't sure what
netsnmp_table_helper_add_indexes(table_info, ASN_INTEGER, /* index:
lldpPortConfigPortNum */
0);
does, so I changed the 0 to a 1. Then snmptable works ok, but I was not
able to get anything from any of the columns.
Help. Thanks.
Kathy McLeod
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users