Hello,

i try to initialize some entries within a table,
but every time i get only the last insrted entry from the table.
It looks like an table iterator problem. I'm sure there are two entries.

The followed request should gives the specific table entries.
 
snmptable -v 2c -c public -Cf + localhost 1.3.6.1.4.1.26958.25.3.2

I hope any can help?
If an ifTable index responible?

Norman Raedke

/*
 * struct definition and declaration
 */
static main_network_data network_data;

/* Typical data structure for a row entry */
struct moduleIDTable_entry
{
        /* Column values */
        long moduleID;

        /* Illustrate using a simple linked list */
        int valid;
        struct moduleIDTable_entry *next;
};

void
initialize_table_moduleIDTable(void)
{
    static oid moduleIDTable_oid[] = {1,3,6,1,4,1,26958,25,3,2};
    size_t moduleIDTable_oid_len   = OID_LENGTH(moduleIDTable_oid);
    netsnmp_handler_registration    *reg;
    netsnmp_iterator_info           *iinfo;
    netsnmp_table_registration_info *table_info;
    int i = 0;

    reg = netsnmp_create_handler_registration(
        "moduleIDTable",
                        moduleIDTable_handler, moduleIDTable_oid, 
moduleIDTable_oid_len,
                        HANDLER_CAN_RONLY
        );

        table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );

        iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );

         if (!reg || !table_info || !iinfo)
        {
                snmp_log(LOG_ERR, "malloc failed in 
initialize_table_moduleIDTable");
                return;
        }


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

    table_info->min_column = COLUMN_MODULEID;
    table_info->max_column = COLUMN_MODULEID;
    

    iinfo->get_first_data_point = moduleIDTable_get_first_data_point;
    iinfo->get_next_data_point  = moduleIDTable_get_next_data_point;
    iinfo->table_reginfo        = table_info;
    
    /***************************************************
         * registering the table with the master agent
         */
    netsnmp_register_table_iterator( reg, iinfo );

    /* Initialise the contents of the table here */
        for (i = 0; i < sizeof(network_data.modEntryList)
                        / sizeof(network_data.modEntryList[0]); i++)
        {
                struct moduleIDTable_entry* entry = NULL;
                if (0 == network_data.modEntryList[i])
                        break;

                snmp_log(LOG_DEBUG, "initialize_table_moduleIDTable - Found 
Module: 0x%04X\n", network_data.modEntryList[i]);
                entry = (struct moduleIDTable_entry*) 
moduleIDTable_createEntry(network_data.modEntryList[i]);

                if (entry)
                        entry->valid = true;

        }
}


/* Example iterator hook routines - using 'get_next' to do most of the work */
netsnmp_variable_list *
moduleIDTable_get_first_data_point(void **my_loop_context,
                          void **my_data_context,
                          netsnmp_variable_list *put_index_data,
                          netsnmp_iterator_info *mydata)
{
    *my_loop_context = moduleIDTable_head;
    return moduleIDTable_get_next_data_point(my_loop_context, my_data_context,
                                    put_index_data,  mydata );
}

netsnmp_variable_list *
moduleIDTable_get_next_data_point(void **my_loop_context,
                          void **my_data_context,
                          netsnmp_variable_list *put_index_data,
                          netsnmp_iterator_info *mydata)
{
    struct moduleIDTable_entry *entry = (struct moduleIDTable_entry 
*)*my_loop_context;
    netsnmp_variable_list *idx = put_index_data;

    if ( entry ) {
        *my_data_context = (void *)entry;
        *my_loop_context = (void *)entry->next;
        return put_index_data;
    } else {
        return NULL;
    }
}


-- 
Schon gehört? GMX hat einen genialen Phishing-Filter in die
Toolbar eingebaut! http://www.gmx.net/de/go/toolbar

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to