aboutsummaryrefslogtreecommitdiff
path: root/src/core/protocol.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-06-12 20:05:34 -0700
committerGarrett D'Amore <garrett@damore.org>2018-06-13 18:01:52 -0700
commitda2aac4a6eb10af88e3938068e24c58aea1832b1 (patch)
treefb0676be5426ed1510945b7e7fe3d09eb45333a7 /src/core/protocol.h
parent61ffae5e3649897776c26799ccaaa35d578ba816 (diff)
downloadnng-da2aac4a6eb10af88e3938068e24c58aea1832b1.tar.gz
nng-da2aac4a6eb10af88e3938068e24c58aea1832b1.tar.bz2
nng-da2aac4a6eb10af88e3938068e24c58aea1832b1.zip
fixes #540 nni_ep_opttype serves no purpose
fixes #538 setopt should have an explicit chkopt routine fixes #537 Internal TCP API needs better name separation fixes #524 Option types should be "typed" This is a rework of the option management code, to make it both clearer and to prepare for further work to break up endpoints. This reduces a certain amount of dead or redundant code, and actually saves cycles when setting options, as some loops were not terminated that should have been.
Diffstat (limited to 'src/core/protocol.h')
-rw-r--r--src/core/protocol.h25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/core/protocol.h b/src/core/protocol.h
index 9c3b4d33..12ca7e71 100644
--- a/src/core/protocol.h
+++ b/src/core/protocol.h
@@ -21,6 +21,13 @@
// As a consequence, most of the concurrency in nng exists in the protocol
// implementations.
+struct nni_proto_option {
+ const char *o_name;
+ int o_type;
+ int (*o_get)(void *, void *, size_t *, nni_opt_type);
+ int (*o_set)(void *, const void *, size_t, nni_opt_type);
+};
+
// nni_proto_pipe contains protocol-specific per-pipe operations.
struct nni_proto_pipe_ops {
// pipe_init creates the protocol-specific per pipe data structure.
@@ -50,13 +57,6 @@ struct nni_proto_pipe_ops {
void (*pipe_stop)(void *);
};
-struct nni_proto_ctx_option {
- const char *co_name;
- int co_type;
- int (*co_getopt)(void *, void *, size_t *, int);
- int (*co_setopt)(void *, const void *, size_t, int);
-};
-
struct nni_proto_ctx_ops {
// ctx_init creates a new context. The second argument is the
// protocol specific socket structure.
@@ -80,14 +80,7 @@ struct nni_proto_ctx_ops {
void (*ctx_drain)(void *, nni_aio *);
// ctx_options array.
- nni_proto_ctx_option *ctx_options;
-};
-
-struct nni_proto_sock_option {
- const char *pso_name;
- int pso_type;
- int (*pso_getopt)(void *, void *, size_t *, int);
- int (*pso_setopt)(void *, const void *, size_t, int);
+ nni_proto_option *ctx_options;
};
struct nni_proto_sock_ops {
@@ -130,7 +123,7 @@ struct nni_proto_sock_ops {
void (*sock_drain)(void *, nni_aio *);
// Options. Must not be NULL. Final entry should have NULL name.
- nni_proto_sock_option *sock_options;
+ nni_proto_option *sock_options;
};
typedef struct nni_proto_id {