On Sun, 2005-05-01 at 09:43, ericyosho wrote: > first,initial our table in the init_... function,and > register it correctly.
Right. > then we usually form a linked list whose node is just > an entry in our table. That's not the *only* way to represent the table, but it's certainly a valid approach. > when we get a request,for example ,GET,we just update > the linked list with data running out of the agent and > return the correct value. You wouldn't normally *update* the linked list. The iterator hook routines will *search* this list for the appropriate entry, and then the handler routine will return the relevant column value from it. > my first question is about these two pointers > **my_loop & **my_data. > do they point to one node of the linked list ,or > something to do with our own data. The linked list would normally be referring to your data. I'm not sure why you're drawing a distinction between them. > what are they used for. The 'loop_context' parameter provides a way to step from one row of the table to the next. This could be a pointer to an entry in the linked list, an index value pointing into an array, or anything else you might care to use. The important thing is that the 'get_next' hook routine can take this value, and use it to identify the next row in the table. (It should also update this value, ready for the next time round). The 'data_context' parameter provides a way to retrieve the data for a particular row. It's often the same value as the 'loop_context' (an entry of the linked list, or an index into an array), but it doesn't have to be. Just as long as the handler can retrieve the necessary column values for that particular row. > my second question, in the definition of my table > structure,there is a 'int valid'.is it reserved for > customer use or has something to do with the API > process. It's used by the default mib2c iterator template output as part of the RowStatus handling for creating new rows, or deleting existing ones. In particular, it's used when handling a failed SET request, in order to tell whether to delete the current row or not. > in another word,can i just omit it if i don't want to > use it. If you're not using the RowStatus column to create or delete rows, then it's irrelevant and can safely be omitted. If you *are* using RowStatus, but have replaced the default template handling with code of your own, then again you can simply omit it. But if you're using the template code generated by the mib2c iterator config, and your table includes a RowStatus column, then this field *is* used. > we add a new entry as the head of our linked list if > needed.but then probably, we will get a linked > list,not corresponding to the OID index order. That's fine. The iterator helper was designed specifically for this type of problem. It does *not* assume that the list is held in the correct order, and will search through the whole thing for every request. That's partly why it's not the most efficient helper in the agent toolkit! Dave ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20 _______________________________________________ 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
