On Mon, May 28, 2018 at 07:56:08AM +0000, Anders Selhammer wrote:
> The idea was to have all different MIBs in separate files. Then it is easy to
> get a view on
> which MIBs that are implemented and which code is MIB specific and which one
> is
> general for the snmp and pmc.
Sounds reasonable. This background information need to go into the
commit message so the reviewers know what the plan is.
> >> +long longObject = 0;
> >> +size_t long_size = sizeof(long);
> > This won't scale to many objects of different types.
>
> No, but this was just an example. The idea was to have a number of globals of
> different
> types, which can be used for temp storage for the snmp requests.
But temp storage belongs on the stack.
> There is no h-file for snmpd.c. I can off course add that but no other
> utility program
> file has one.
You can also put the prototype into the mib.h file.
> >> + longObject = mtd->val;
> > Better to pass in a pointer to a data structure that holds the
> > result. Then you can avoid the global.
>
> Since the data type is different for the different objects, we picked this
> alternative
> for the first draft. It is also possible with a void pointer and then cast to
> the preferred
> type. Or are you talking about a struct holding all types of possible return
> values?
A union of all types might make sense.
> >> +static int handle_tempMibObject(netsnmp_mib_handler *handler,
> > Avoid camelCase please.
>
> Yes, mib2c used this way. The code will be replaced when whole MIB is
> implemented.
...
> The code was generated from mib2c. I will update with errorhandling and
> without
> the nested calls.
I am not familiar with libsnmp, but if the mib2c tool generates useful
code, then we should use it directly. The code generation should take
place under the control of the makefile.
> >> +void init_ptpbaseMib(struct ptp_message* (*cb)(char *command))
> >> +{
> >> + pmc_cb = cb;
> > Really don't see the point of this callback. Do you expect to pass in
> > different values of 'cb' ?
>
> Then, I can either add a h-file or include by external, what do you prefer?
Header file, please.
Thanks,
Richard
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel