aboutsummaryrefslogtreecommitdiff
path: root/src/core/options.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-11-15 17:47:54 -0800
committerGarrett D'Amore <garrett@damore.org>2020-11-15 17:47:54 -0800
commit249932f3a208260f6b9c99d778b22d51cfabe87b (patch)
tree4fd4826127e9c225d5232c39d4ae1db89b539689 /src/core/options.h
parenteb328da56c3fc7167b536dcb206df0abb0f4a9b9 (diff)
downloadnng-249932f3a208260f6b9c99d778b22d51cfabe87b.tar.gz
nng-249932f3a208260f6b9c99d778b22d51cfabe87b.tar.bz2
nng-249932f3a208260f6b9c99d778b22d51cfabe87b.zip
fixes #1071 tran_chkopt can be cleaned up
This is a sweeping cleanup of the transport logic around options, and also harmonizes the names used when setting or getting options. Additionally, legacy methods are now moved into a separate file and can be elided via CMake or a preprocessor define. Fundamentally, the ability to set to transport options via the socket is deprecated; there are numerous problems with this and my earlier approaches to deal with this have been somewhat misguided. Further these approaches will not work with future protocol work that is planned (were some options need to be negotiated with peers at the time of connection establishment.) Documentation has been updated to reflect this. The test suites still make rather broad use of the older APIs, and will be converted later.
Diffstat (limited to 'src/core/options.h')
-rw-r--r--src/core/options.h180
1 files changed, 0 insertions, 180 deletions
diff --git a/src/core/options.h b/src/core/options.h
index 41d10365..9c5d4817 100644
--- a/src/core/options.h
+++ b/src/core/options.h
@@ -74,191 +74,11 @@ struct nni_option_s {
int (*o_set)(void *, const void *, size_t, nni_type);
};
-typedef struct nni_chkoption_s nni_chkoption;
-struct nni_chkoption_s {
- const char *o_name;
- // o_check can be NULL for read-only options
- int (*o_check)(const void *, size_t, nni_type);
-};
-
// nni_getopt and nni_setopt are helper functions to implement options
// based on arrays of nni_option structures.
extern int nni_getopt(
const nni_option *, const char *, void *, void *, size_t *, nni_type);
extern int nni_setopt(
const nni_option *, const char *, void *, const void *, size_t, nni_type);
-extern int nni_chkopt(
- const nni_chkoption *, const char *, const void *, size_t, nni_type);
-
-//
-// This next block sets up to define the various typed option functions.
-// To make it easier to cover them all at once, we use macros.
-//
-
-#define NNI_DEFGET(base, pointer) \
- int nng_##base##_get( \
- nng_##base pointer s, const char *nm, void *vp, size_t *szp) \
- { \
- return (nni_##base##_getx(s, nm, vp, szp, NNI_TYPE_OPAQUE)); \
- }
-
-#define NNI_DEFTYPEDGET(base, suffix, pointer, type, nnitype) \
- int nng_##base##_get_##suffix( \
- nng_##base pointer s, const char *nm, type *vp) \
- { \
- size_t sz = sizeof(*vp); \
- return (nni_##base##_getx(s, nm, vp, &sz, nnitype)); \
- }
-
-#define NNI_DEFGETALL(base) \
- NNI_DEFGET(base, ) \
- NNI_DEFTYPEDGET(base, int, , int, NNI_TYPE_INT32) \
- NNI_DEFTYPEDGET(base, bool, , bool, NNI_TYPE_BOOL) \
- NNI_DEFTYPEDGET(base, size, , size_t, NNI_TYPE_SIZE) \
- NNI_DEFTYPEDGET(base, uint64, , uint64_t, NNI_TYPE_UINT64) \
- NNI_DEFTYPEDGET(base, string, , char *, NNI_TYPE_STRING) \
- NNI_DEFTYPEDGET(base, ptr, , void *, NNI_TYPE_POINTER) \
- NNI_DEFTYPEDGET(base, ms, , nng_duration, NNI_TYPE_DURATION) \
- NNI_DEFTYPEDGET(base, addr, , nng_sockaddr, NNI_TYPE_SOCKADDR)
-
-#define NNI_DEFGETALL_PTR(base) \
- NNI_DEFGET(base, *) \
- NNI_DEFTYPEDGET(base, int, *, int, NNI_TYPE_INT32) \
- NNI_DEFTYPEDGET(base, bool, *, bool, NNI_TYPE_BOOL) \
- NNI_DEFTYPEDGET(base, size, *, size_t, NNI_TYPE_SIZE) \
- NNI_DEFTYPEDGET(base, uint64, *, uint64_t, NNI_TYPE_UINT64) \
- NNI_DEFTYPEDGET(base, string, *, char *, NNI_TYPE_STRING) \
- NNI_DEFTYPEDGET(base, ptr, *, void *, NNI_TYPE_POINTER) \
- NNI_DEFTYPEDGET(base, ms, *, nng_duration, NNI_TYPE_DURATION) \
- NNI_DEFTYPEDGET(base, addr, *, nng_sockaddr, NNI_TYPE_SOCKADDR)
-
-#define NNI_DEFSET(base, pointer) \
- int nng_##base##_set( \
- nng_##base pointer s, const char *nm, const void *vp, size_t sz) \
- { \
- return (nni_##base##_setx(s, nm, vp, sz, NNI_TYPE_OPAQUE)); \
- }
-
-#define NNI_DEFTYPEDSETEX(base, suffix, pointer, type, len, nnitype) \
- int nng_##base##_set_##suffix( \
- nng_##base pointer s, const char *nm, type v) \
- { \
- return (nni_##base##_setx(s, nm, &v, len, nnitype)); \
- }
-
-#define NNI_DEFTYPEDSET(base, suffix, pointer, type, nnitype) \
- int nng_##base##_set_##suffix( \
- nng_##base pointer s, const char *nm, type v) \
- { \
- return (nni_##base##_setx(s, nm, &v, sizeof(v), nnitype)); \
- }
-
-#define NNI_DEFSTRINGSET(base, pointer) \
- int nng_##base##_set_string( \
- nng_##base pointer s, const char *nm, const char *v) \
- { \
- return (nni_##base##_setx(s, nm, v, \
- v != NULL ? strlen(v) + 1 : 0, NNI_TYPE_STRING)); \
- }
-
-#define NNI_DEFSOCKADDRSET(base, pointer) \
- int nng_##base##_set_addr( \
- nng_##base pointer s, const char *nm, const nng_sockaddr *v) \
- { \
- return (nni_##base##_setx( \
- s, nm, v, sizeof(*v), NNI_TYPE_SOCKADDR)); \
- }
-
-#define NNI_DEFSETALL(base) \
- NNI_DEFSET(base, ) \
- NNI_DEFTYPEDSET(base, int, , int, NNI_TYPE_INT32) \
- NNI_DEFTYPEDSET(base, bool, , bool, NNI_TYPE_BOOL) \
- NNI_DEFTYPEDSET(base, size, , size_t, NNI_TYPE_SIZE) \
- NNI_DEFTYPEDSET(base, uint64, , uint64_t, NNI_TYPE_UINT64) \
- NNI_DEFTYPEDSET(base, ms, , nng_duration, NNI_TYPE_DURATION) \
- NNI_DEFTYPEDSET(base, ptr, , void *, NNI_TYPE_POINTER) \
- NNI_DEFSTRINGSET(base, ) \
- NNI_DEFSOCKADDRSET(base, )
-
-#define NNI_DEFSETALL_PTR(base) \
- NNI_DEFSET(base, *) \
- NNI_DEFTYPEDSET(base, int, *, int, NNI_TYPE_INT32) \
- NNI_DEFTYPEDSET(base, bool, *, bool, NNI_TYPE_BOOL) \
- NNI_DEFTYPEDSET(base, size, *, size_t, NNI_TYPE_SIZE) \
- NNI_DEFTYPEDSET(base, uint64, *, uint64_t, NNI_TYPE_UINT64) \
- NNI_DEFTYPEDSET(base, ms, *, nng_duration, NNI_TYPE_DURATION) \
- NNI_DEFTYPEDSET(base, ptr, *, void *, NNI_TYPE_POINTER) \
- NNI_DEFSTRINGSET(base, *) \
- NNI_DEFSOCKADDRSET(base, *)
-
-#define NNI_LEGACY_DEFGET(base) \
- int nng_##base##_getopt( \
- nng_##base s, const char *nm, void *vp, size_t *szp) \
- { \
- return (nng_##base##_get(s, nm, vp, szp)); \
- }
-
-#define NNI_LEGACY_DEFTYPEDGET(base, suffix, type) \
- int nng_##base##_getopt_##suffix( \
- nng_##base s, const char *nm, type *vp) \
- { \
- return (nng_##base##_get_##suffix(s, nm, vp)); \
- }
-
-#define NNI_LEGACY_DEFSOCKADDRGET(base) \
- int nng_##base##_getopt_sockaddr( \
- nng_##base s, const char *nm, nng_sockaddr *vp) \
- { \
- return (nng_##base##_get_addr(s, nm, vp)); \
- }
-
-#define NNI_LEGACY_DEFGETALL(base) \
- NNI_LEGACY_DEFGET(base) \
- NNI_LEGACY_DEFTYPEDGET(base, int, int) \
- NNI_LEGACY_DEFTYPEDGET(base, bool, bool) \
- NNI_LEGACY_DEFTYPEDGET(base, size, size_t) \
- NNI_LEGACY_DEFTYPEDGET(base, uint64, uint64_t) \
- NNI_LEGACY_DEFTYPEDGET(base, string, char *) \
- NNI_LEGACY_DEFTYPEDGET(base, ptr, void *) \
- NNI_LEGACY_DEFTYPEDGET(base, ms, nng_duration) \
- NNI_LEGACY_DEFSOCKADDRGET(base)
-
-#define NNI_LEGACY_DEFSET(base) \
- int nng_##base##_setopt( \
- nng_##base s, const char *nm, const void *vp, size_t sz) \
- { \
- return (nng_##base##_set(s, nm, vp, sz)); \
- }
-
-#define NNI_LEGACY_DEFTYPEDSET(base, suffix, type) \
- int nng_##base##_setopt_##suffix(nng_##base s, const char *nm, type v) \
- { \
- return (nng_##base##_set_##suffix(s, nm, v)); \
- }
-
-#define NNI_LEGACY_DEFSTRINGSET(base) \
- int nng_##base##_setopt_string( \
- nng_##base s, const char *nm, const char *v) \
- { \
- return (nng_##base##_set_string(s, nm, v)); \
- }
-
-#define NNI_LEGACY_DEFSOCKADDRSET(base) \
- int nng_##base##_setopt_sockaddr( \
- nng_##base s, const char *nm, const nng_sockaddr *v) \
- { \
- return (nng_##base##_set_addr(s, nm, v)); \
- }
-
-#define NNI_LEGACY_DEFSETALL(base) \
- NNI_LEGACY_DEFSET(base) \
- NNI_LEGACY_DEFTYPEDSET(base, int, int) \
- NNI_LEGACY_DEFTYPEDSET(base, bool, bool) \
- NNI_LEGACY_DEFTYPEDSET(base, size, size_t) \
- NNI_LEGACY_DEFTYPEDSET(base, uint64, uint64_t) \
- NNI_LEGACY_DEFTYPEDSET(base, ms, nng_duration) \
- NNI_LEGACY_DEFTYPEDSET(base, ptr, void*) \
- NNI_LEGACY_DEFSTRINGSET(base) \
- NNI_LEGACY_DEFSOCKADDRSET(base)
#endif // CORE_OPTIONS_H