From d3bd35ab49ad74528fd9e34cce9016d74dd91943 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 28 Dec 2018 21:07:58 -0800 Subject: fixes #831 Unify option structures, o_type is unused --- src/core/options.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/core/options.h') diff --git a/src/core/options.h b/src/core/options.h index ac64f9e3..f0ab9811 100644 --- a/src/core/options.h +++ b/src/core/options.h @@ -51,4 +51,27 @@ extern int nni_copyout_u64(uint64_t, void *, size_t *, nni_opt_type); // then it passes through a pointer, created by nni_strdup(). extern int nni_copyout_str(const char *, void *, size_t *, nni_opt_type); +// nni_option is used for socket, protocol, transport, and similar options. +// Note that only for transports, the o_set member may be called with a NULL +// instance parameter, in which case the request should only validate the +// argument and do nothing further. +typedef struct nni_option_s nni_option; +struct nni_option_s { + // o_name is the name of the option. + const char *o_name; + + // o_get is used to retrieve the value of the option. The + // size supplied will limit how much data is copied. Regardless, + // the actual size of the object that would have been copied + // is supplied by the function in the size. If the object did + // not fit, then NNG_EINVAL is returned. + int (*o_get)(void *, void *, size_t *, nni_opt_type); + + // o_set is used to set the value of the option. For transport + // endpoints only, the instance parameter (first argument) may be + // NULL, in which case only a generic validation of the parameters + // is performed. (This is used when setting socket options before + int (*o_set)(void *, const void *, size_t, nni_opt_type); +}; + #endif // CORE_OPTIONS_H -- cgit v1.2.3-70-g09d2