aboutsummaryrefslogtreecommitdiff
path: root/src/core/options.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-12-28 21:07:58 -0800
committerGarrett D'Amore <garrett@damore.org>2018-12-29 14:22:06 -0800
commitd3bd35ab49ad74528fd9e34cce9016d74dd91943 (patch)
tree596459970f49a340f5e292f7bdb4060f4ea2be81 /src/core/options.h
parent02e90dd4f29037e43f28e3bd1e912d4092011d23 (diff)
downloadnng-d3bd35ab49ad74528fd9e34cce9016d74dd91943.tar.gz
nng-d3bd35ab49ad74528fd9e34cce9016d74dd91943.tar.bz2
nng-d3bd35ab49ad74528fd9e34cce9016d74dd91943.zip
fixes #831 Unify option structures, o_type is unused
Diffstat (limited to 'src/core/options.h')
-rw-r--r--src/core/options.h23
1 files changed, 23 insertions, 0 deletions
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