Re: Re: Re: Re: The elements of one table, their OID is discontinous.

"Jack Chen" <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <01b501c81ae7$7d1d5120$73a8a8c0@jstream>
Dear Dave:
    I am sorry, I forget to answer your question.
Is this an answer you want:

myTest.c
...
/** Initialize the myTestSecondFieldTable table by defining its contents and 
how it's structured */
void
initialize_table_myTestSecondFieldTable(void)
{
    static oid myTestSecondFieldTable_oid[] = {1,3,6,1,4,1,8072,2,6,1,3};
    netsnmp_table_registration_info *table_info;
    netsnmp_handler_registration *my_handler;
    netsnmp_iterator_info *iinfo;

    /** create the table registration information structures */
    table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
    iinfo = SNMP_MALLOC_TYPEDEF(netsnmp_iterator_info);

    my_handler = 
netsnmp_create_handler_registration("myTestSecondFieldTable",
                                             myTestSecondFieldTable_handler,
                                             myTestSecondFieldTable_oid,
                                             OID_LENGTH(myTestSecondFieldTable_oid),
                                             HANDLER_CAN_RWRITE
                                             );

    if (!my_handler || !table_info || !iinfo) {
        snmp_log(LOG_ERR, "malloc failed in 
initialize_table_myTestSecondFieldTable");
        return; /** Serious error. */
    }

    /***************************************************
     * Setting up the table's definition
     */
    netsnmp_table_helper_add_indexes(table_info,
                                  ASN_INTEGER, /** index: ifIndex */
                             0);

    /** Define the minimum and maximum accessible columns.  This
        optimizes retrival. */

    /** iterator access routines */
    iinfo->get_first_data_point = 
myTestSecondFieldTable_get_first_data_point;
    iinfo->get_next_data_point = myTestSecondFieldTable_get_next_data_point;

    /** you may wish to set these as well */
#ifdef MAYBE_USE_THESE
    iinfo->make_data_context = 
myTestSecondFieldTable_context_convert_function;
    iinfo->free_data_context = myTestSecondFieldTable_data_free;

    /** pick *only* one of these if you use them */
    iinfo->free_loop_context = myTestSecondFieldTable_loop_free;
    iinfo->free_loop_context_at_end = myTestSecondFieldTable_loop_free;
#endif

    /** tie the two structures together */
    iinfo->table_reginfo = table_info;

    /***************************************************
     * registering the table with the master agent
     */
    DEBUGMSGTL(("initialize_table_myTestSecondFieldTable",
                "Registering table myTestSecondFieldTable as a table 
iterator\n"));
    netsnmp_register_table_iterator(my_handler, iinfo);
}
...

B/R,
Jack

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.