From da2aac4a6eb10af88e3938068e24c58aea1832b1 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 12 Jun 2018 20:05:34 -0700 Subject: 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. --- src/core/protocol.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'src/core/protocol.h') 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 { -- cgit v1.2.3-70-g09d2