Developing a table mib module failes. 
A simple scalar module (macdTest) is working, so basic set up seems to be well.
For the table module 'gatewayTable' seems to be incomplete. 
Even it can be compiled and the library loaded nothing happens (/etc/snmp/snmpd.conf: 
line 146: Warning: missing an data value)

My questions:
- What is wrong/missing with the code?
- Is there an uptodate and complete example?
- How can I add a row to the table. I do not see code inside the module to do this.

Many thanks for any hint.


My environment:
Using netsnmp  5.1.2 packages from  debian testing (sarge) with dlmod functionality.
The initial source for the mibs is generated using:
> macdTest.c, macdTest.h
>   - template generated using 'mib2c  -c mib2c.scalar.conf macdTest'
> 
> gatewayTable.h, gatewayTable.c
>   - template generated using 'mib2c -c mib2c.create-dataset.conf gatewayTable'


# --- /etc/snmp/snmpd.conf ---
[...]
dlmod macdTest /home/reiner/macd/all-all/root/lib/linux/libsnmpd-macdTest.so
dlmod gatewayTable /home/reiner/macd/all-all/root/lib/linux/libsnmpd-gatewayTable.so
add_row gatewayTable 1 1 "TrendGateway" "reiner" 
"queue/macd/Gateway:TrendServer:trdv01" 1234 0 "Stopped" 0 0 0 0 0 0 0 0


# --- /var/log/snmp ---
> 2004-10-12 11:20:24 Received TERM or STOP signal...  shutting down...
> 2004-10-12 11:20:25 dlmod: Module macdTest unloaded
> 2004-10-12 11:20:25 dlmod: Module gatewayTable unloaded
> dlmod: register mib
> dlmod: dlmod_path: /usr/lib/snmp/dlmod
> 2004-10-12 11:20:27 dlmod: dlmod_create_module
> 2004-10-12 11:20:27 dlmod: dlmod_load_module macdTest: 
> /home/reiner/macd/all-all/root/lib/linux/libsnmpd-macdTest.so
> 2004-10-12 11:20:27 macdTest: Initializing
> 2004-10-12 11:20:27 dlmod: dlmod_create_module
> 2004-10-12 11:20:27 dlmod: dlmod_load_module gatewayTable: 
> /home/reiner/macd/all-all/root/lib/linux/libsnmpd-gatewayTable.so
> 2004-10-12 11:20:27 /etc/snmp/snmpd.conf: line 146: Warning: missing an data value


> # --- gatewayTable.c
> /*
>  * Note: this file originally auto-generated by mib2c using
>  *        : mib2c.create-dataset.conf,v 5.3 2002/12/05 00:29:45 hardaker 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 "gatewayTable.h"
> 
> /** Initialize the gatewayTable table by defining its contents and how it's 
> structured */
> void
> initialize_table_gatewayTable(void)
> {
>     static oid gatewayTable_oid[] = {1,3,6,1,4,1,25111,1,2};
>     size_t gatewayTable_oid_len = OID_LENGTH(gatewayTable_oid);
>     netsnmp_table_data_set *table_set;
>     netsnmp_table_row *row;
>     
>     /* create the table structure itself */
>     table_set = netsnmp_create_table_data_set("gatewayTable");
>     
>     /* comment this out or delete if you don't support creation of new rows */
>     table_set->allow_creation = 1;
>     
>     /***************************************************
>      * Adding indexes
>      */
>     DEBUGMSGTL(("initialize_table_gatewayTable",
>                 "adding indexes to table gatewayTable\n"));
>     netsnmp_table_set_add_indexes(table_set,
>                                   ASN_INTEGER );
>     
>     DEBUGMSGTL(("initialize_table_gatewayTable",
>                 "adding column types to table gatewayTable\n"));   
>     netsnmp_table_set_multi_add_default_row
>         ( table_set,
>           COLUMN_GATEWAYINDEX, ASN_INTEGER, 1,
>           0, sizeof( int ),
>           COLUMN_PROGRAMNAME, ASN_OCTET_STR, 1,
>           "", sizeof( "" ),
>           COLUMN_USERNAME, ASN_OCTET_STR, 1,
>           "", sizeof( "" ),
>           COLUMN_GATEWAYADDRESS, ASN_OCTET_STR /* XXX */, 1,
>           "", sizeof( "" ),
>           COLUMN_PROCESSID, ASN_INTEGER, 1,
>           NULL, 0,
>           COLUMN_PROCESSUPTIME, ASN_COUNTER /* XXX */ , 1,
>           NULL, 0,
>           COLUMN_PROCESSSTATUS, ASN_OCTET_STR, 1,
>           "", sizeof( "" ),
>           COLUMN_MESSAGESFROMXCONNECT, ASN_COUNTER, 1,
>           0, sizeof( int ),
>           COLUMN_MESSAGESTOXCONNECT, ASN_COUNTER, 1,
>           0, sizeof( int ),
>           COLUMN_MESSAGESFROMEXTERIEUR, ASN_COUNTER, 1,
>           0, sizeof( int ),
>           COLUMN_MESSAGESTOEXTERIEUR, ASN_COUNTER, 1,
>           0, sizeof( int ),
>           COLUMN_BACKLOGTOXCONNECT, ASN_GAUGE, 1,
>           0, sizeof( int ),
>           COLUMN_BACKLOGTOEXTERIEUR, ASN_GAUGE, 1,
>           0, sizeof( int ),
>           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 gatewayTable_handler to "NULL" */
>     netsnmp_register_table_data_set
>         ( netsnmp_create_handler_registration
>           ( "gatewayTable",
>             NULL /* gatewayTable_handler */,
>             gatewayTable_oid,
>             gatewayTable_oid_len,
>             HANDLER_CAN_RWRITE ),
>           table_set,
>           NULL );
> 
> 
>     /* sample row */
>     // row = netsnmp_create_table_data_row();
>     // netsnmp_table_row_add_index(row, ASN_INTEGER, 1, sizeof( int ) );
>     // netsnmp_table_dataset_add_row(table_set, row);
> 
>     netsnmp_register_auto_data_table(table_set, NULL);
> }
> 
> 
> 
> /** Initializes the gatewayTable module */
> void
> init_gatewayTable(void)
> {
>     
>     /* here we initialize all the tables we're planning on supporting */
>     initialize_table_gatewayTable();
> }
> 
> /** handles requests for the gatewayTable table, if anything else needs to be done */
> int
> gatewayTable_handler(
>                      netsnmp_mib_handler               *handler,
>                      netsnmp_handler_registration      *reginfo,
>                      netsnmp_agent_request_info        *reqinfo,
>                      netsnmp_request_info              *requests) {
>     /* 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;
> }
> 

- Reiner


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
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

Reply via email to