I'm working slowly towards my new mib module, but I've hit a frustrating
snag.
I'm basically using code straight out of mib2c.iterator.conf. I'm
writing a module that returns a table of data from the kernel. I can
compile it fine, but it ignores requests!
Here's a snippet of the code. Again, straight out of mib2c..
-----------------8<---------------------
...
void initialize_table_ipfInTable(void)
{
const oid ipfInTable_oid[] = {1,3,6,1,4,1,8072,9999,9999,247,1};
const size_t ipfInTable_oid_len = OID_LENGTH(ipfInTable_oid);
netsnmp_handler_registration *reg;
netsnmp_iterator_info *iinfo;
netsnmp_table_registration_info *table_info;
DEBUGMSGTL(("ipfTable:init", "initializing table ipfInTable\n"));
reg = netsnmp_create_handler_registration(
"ipfInTable", ipfTable_handler,
ipfInTable_oid, ipfInTable_oid_len,
HANDLER_CAN_RONLY
);
table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
netsnmp_table_helper_add_indexes(table_info,
ASN_INTEGER, /* index: ipfInIndex */
0);
table_info->min_column = COLUMN_IPFRULE;
table_info->max_column = COLUMN_IPFBYTES;
iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
iinfo->get_first_data_point = ipfInTable_get_first_data_point;
iinfo->get_next_data_point = ipfInTable_get_next_data_point;
iinfo->table_reginfo = table_info;
netsnmp_register_table_iterator( reg, iinfo );
p_ipfInTable = SNMP_MALLOC_TYPEDEF(struct ipfTable_entry);
p_ipfInTable->ipfRule_len = 1024;
p_ipfInTable->ipfRule = malloc(sizeof(char) * 1024);
}
...
netsnmp_variable_list *
ipfInTable_get_first_data_point(void **my_loop_context,
void **my_data_context,
netsnmp_variable_list *put_index_data,
netsnmp_iterator_info *mydata)
{
DEBUGMSGTL(("ipfTable", "get_first_data_point ipfInTable\n"));
// Here is a call to a common func that handles multiple tables
ipfTable_get_first_data_point(in_state, p_ipfInTable,
my_loop_context, my_data_context,
put_index_data, mydata);
}
...
----------------->8---------------------
Okay so lets run a test instance and check it out...
snmp get on "1.3.6.1.4.1.8072.9999.9999.247.1"
and on "1.3.6.1.4.1.8072.9999.9999.247.1.1"
snmpd -f -Lo -d -DipfTable udp:192.168.1.1:9999
-----------------stdout---------------------
registered debug token ipfTable, 1
ipfTable:init: initializing table ipfInTable
ipfTable:init: initializing table ipfOutTable
ipfTable: initialization complete
Warning: no access control information configured.
(Config search path:
/usr/pkg/etc/snmp:/usr/pkg/share/snmp:/usr/pkg/lib/snmp:/root/.snmp)
It's unlikely this agent can serve any useful purpose in this state.
Run "snmpconf -g basic_setup" to help you configure the snmpd.conf
file for this agent.
[init_smux] bind failed: Address already in use
NET-SNMP version 5.6.1.1
Received 49 byte packet from UDP: [192.168.1.20]:49905->[0.0.0.0]:0
0000: 30 2F 02 01 00 04 06 70 75 62 6C 69 63 A0 22 02 0/.....public.".
0016: 04 23 DC FC C9 02 01 00 02 01 00 30 14 30 12 06 .#.........0.0..
0032: 0E 2B 06 01 04 01 BF 08 CE 0F CE 0F 81 77 01 05 .+...........w..
0048: 00 .
Connection from UDP: [192.168.1.20]:49905->[0.0.0.0]:0
Received SNMP packet(s) from UDP: [192.168.1.20]:49905->[0.0.0.0]:0
GET message
-- IPF-IPNAT-MIB::ipfInTable
Received 50 byte packet from UDP: [192.168.1.20]:53455->[0.0.0.0]:0
0000: 30 30 02 01 00 04 06 70 75 62 6C 69 63 A0 23 02 00.....public.#.
0016: 04 23 DC FC CD 02 01 00 02 01 00 30 15 30 13 06 .#.........0.0..
0032: 0F 2B 06 01 04 01 BF 08 CE 0F CE 0F 81 77 01 01 .+...........w..
0048: 05 00 ..
Connection from UDP: [192.168.1.20]:53455->[0.0.0.0]:0
Received SNMP packet(s) from UDP: [192.168.1.20]:53455->[0.0.0.0]:0
GET message
-- IPF-IPNAT-MIB::ipfInEntry
-----------------stdout---------------------
snmpd just sits there and the mib browser eventually times out.
Notice that I never see "ipfTable: get_first_data_point ipfInTable" or
any other debug message, other than the init messages. I have them
splattered all over the code, including in the handler function. I get
nada.
Please, tell my what I'm doing wrong!!
thanks for any help,
-d
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders