
Remco van de Meent writes:
Remco> Suppose you try to create a subagent using the output from Remco> "smidump -f netsnmp".
Remco> In the header file you get definitions like
[...]
Remco> Now take a look a the switch statement that takes care of Remco> returned the correct value to the master agent (switch based on Remco> vp's magic number). It looks like this:
[...]
Remco> However, what the master agent is actually expecting is a Remco> pointer to the value, not a pointer to the pointer to the Remco> value. Looks nice in those snmpwalk outputs, such memory Remco> addresses :-)
Remco> Is this a problem with libsmi or am I overlooking something?
It is a problem with the netsnmp output driver. If you grab the latest version from CVS, you will notice that the generated API has already changed. I expect even more changes to this output driver in the future to make it really useful.
Remco> On a sidenote, what I am supposed to use *_clientData and __foo Remco> in the example above for?
The __foo's and the pointers are gone in the current version (but they might come back ;-). The original idea was to always use pointers to the data so that NULL pointers can be used to identify non-existing objects (holes in tables). I am using this approach on the manager side in the stools stub code and it works fine. On the agent side, you frequently want to have the required storage available without doing malloc's. So the idea in the version you are looking at was to provide some private __foo's which you can point to and which you to not have to allocate.
The _clientData is a field which can hold a pointer and allows you to bind your private data structure to a compiler generated data structure.
Note that we now have a student who is going to improve the netsnmp code generator. So changes will be likely - but things will also get much better designed and tested.
/js