How do I add new rows to a table_data table?

Chris Smith <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
I've generated a table using mib2c.table_data.conf which works fine for
getting and setting existing rows, but segfaults when the user tries to
create a new row (because the row is null in the request info).

What is the correct way to implement this in the table handler?  At the
moment I've hacked together the following, after scouring the net-snmp
source code.  It is sort of working, but I'm not that confident about it.

[code snippet -- error handling ommitted]
    case MODE_SET_RESERVE1:
        for (request=requests; request; request=request->next) {
            table_data  = netsnmp_tdata_extract_table(request);
            table_info  = netsnmp_extract_table_info(request);
            table_row   = netsnmp_tdata_extract_row(request);
            table_entry = (struct myTable_entry *)
                              netsnmp_tdata_extract_entry(request);

            if (!table_entry) {
                table_entry = SNMP_MALLOC_TYPEDEF(struct myTable_entry);

                if (!table_row)
                    table_row = netsnmp_tdata_create_row();
                table_row->indexes =
                             snmp_clone_varbind(table_info->indexes);
                table_row->data = table_entry;
                netsnmp_tdata_add_row(table_data, table_row);
                netsnmp_insert_tdata_row(request, table_row);
[/code snippet]

I know this isn't working properly as, despite adding the new row to the
request, the code is triggered for every OID in the set request rather
than just the first.

Ideally, I don't want to create the row until I've processed all the
columns, so I can validate the data first.

Chris
-- 
Chris Smith <[email protected]>

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
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.