On Thu, 21 Sep 2006 09:43:24 +0100 Dave wrote:
DS> What the handler needs is "some way" of retrieving the data for a
DS> particular row.
DS> This is the role of 'my_data_context'. The details of "some way" are
DS> up to you.
DS>
DS> The most common approach is to have this variable point directly to
DS> the full contents of the row (e.g. as an entry within a linked list),
DS> but that's not the only way to handle this. You could equally well
DS> pass a database lookup key, or the index into some global array, or a
DS> kernel memory address.
DS> If you're concerned about the underlying table data changing
DS> underneath your feet, then one possibillity might be to load a copy of
DS> the table into the agent, and work with that copy instead.
Well, since Dave didn't remember the details either, I went and poked about.
It seems that the agent does track the data context as it finds the best
match. Usually it just keeps the pointer, but if you are worried about that
pointer vanishing, then you can allocate data. Based on looking at the code,
it looks like you need to specify a function for the make_data_context
function pointer. The prototype for the function is:
typedef void *(Netsnmp_Make_Data_Context) (void *loop_context,
struct netsnmp_iterator_info_s *);
So, after each get_next_data_point, if the most recent OID returned is the
best match, the make_data_context will be called with the same loop_context,
allowing you to allocate memory to store the data. The free_context callback
function will be used to free the allocated memory when the agent is done with
it.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders