Robert,
as you may have guessed, I've now moved on to looking at the MfD
framework again. I've noticed a couple of things that don't look
quite right, or could perhaps be useful tweaked a bit.
Firstly, the code generated by running
mib2c -c mib2c.mfd.conf {myTable}
and accepting all the defaults, isn't quite the same as that
generated by accepting the hard-coded defaults. In particular,
interactive defaults will omit the persistant storage and
dependency code, while the hard-coded settings include them.
Also, the default choice for how to gather the data should be
a basic internal container when running interactively (though
the code that was generated was actually the same as the cached
version! - now fixed). Accepting the hard-coded settings still
generate a container-cached approach.
We should probably ensure that the hard-coded and interactive
defaults match - either bringing the hard-coded settings into
line with the interactive versions (my preference), or vice versa.
The other suggestion relates to the 'object_get' routines - and in
particular to code generated for processing string- and OID-based
objects.
Currently, this code includes checks on the size of the buffer
passed in, and re-allocates memory if necessary (potentially
resulting in a memory leak, since the old memory doesn't appear
to be released). It struck me that this is effectively duplicating
the internal processing of the 'snmp_set_var_value' library routine.
Wouldn't it be clearer to tweak this 'object_get' interface slightly
to pass in the varbind structure, and generate code along the lines of:
int
myString_get(myTable_rowreq_ctx * rowreq_ctx,
netsnmp_variable_list *varbind)
{
snmp_set_value( varbind, rowreq_ctx->myString,
rowreq_ctx->myString_len);
}
(plus suitable error checking, of course).
That way all the buffer manipulation is hidden in library code,
out of the way of programmer meddling.
Comments?
Dave
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders