Re: Retrieving table from external data (row identification?)
"Victor Palacio" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Jul 3, 2008 at 11:13 AM, Dave Shield <[email protected]> wrote: > 2008/7/3 Victor Palacio <[email protected]>: > > > > I'm trying to use table iterator from code skeleton generated with > > mib2c.iterate.conf. > > > > When I use snmptable on the agent, get_first_data_point function is > > executed every time one column is consulted, so I suppose I must load > > data for consulted row in data context. > > > > The problem is... How can I identify which row (index) is consulted > > You don't - that's the job of the iterator helper. > > You provide the get_{first,next}_data_point functions, which > walk through the table in whatever order is most convenient. > > The iterator helper will identify the row(s) which are required for > the current request. It then calls your handler routine, passing > the data structure for that row, as suppied via the 'data_context' > parameter of the two get_{first,next} routines. > > > Dave > -- Thanks for your answer, Dave... but I still have problems with this. My problem is that all rows are using the last data context, so I get same information for all rows, although then number of rows is correct. In _get_first_data_point, I ... 1)Create Loop and Data context, 2)set number of rows in loop context and, 3)call get_next_data_point In get_next_data_point, I assume that I can use same data_context. Perhaps must I allocate new data context in get_next_data_point? Regards, CODE: myTable_get_next_data_point(void **my_loop_context, void **my_data_context, netsnmp_variable_list *put_index_data, netsnmp_iterator_info *mydata) { netsnmp_variable_list *vptr; my_loop_info *loopctx = *my_loop_context; my_data_info *datactx = *my_data_context; if (!loopctx){ return NULL; } while (iter < loopctx->MAX_ROWS){ iter++; /* OBTAIN VALUES A and B FOR ITER */ //... datactx->index = iter; datactx->A = A; datactx->B = B; vptr = put_index_data; snmp_set_var_value(vptr, (u_char *) & datactx->index, sizeof(datactx->index)); *my_loop_context = loopctx; *my_data_context = datactx; return put_index_data; } /* we're out of data */ *my_loop_context = NULL; return NULL; } ******************** Victor M. Palacio ******************** ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ 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