aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/defs.h2
-rw-r--r--src/core/dialer.c4
-rw-r--r--src/core/listener.c4
-rw-r--r--src/core/options.h23
-rw-r--r--src/core/pipe.c2
-rw-r--r--src/core/protocol.h13
-rw-r--r--src/core/socket.c164
-rw-r--r--src/core/transport.c8
-rw-r--r--src/core/transport.h30
9 files changed, 113 insertions, 137 deletions
diff --git a/src/core/defs.h b/src/core/defs.h
index 3a3f23ff..5c06cf53 100644
--- a/src/core/defs.h
+++ b/src/core/defs.h
@@ -47,12 +47,10 @@ typedef struct nni_listener nni_listener;
typedef struct nni_pipe nni_pipe;
typedef struct nni_tran nni_tran;
-typedef struct nni_tran_option nni_tran_option;
typedef struct nni_tran_dialer_ops nni_tran_dialer_ops;
typedef struct nni_tran_listener_ops nni_tran_listener_ops;
typedef struct nni_tran_pipe_ops nni_tran_pipe_ops;
-typedef struct nni_proto_option nni_proto_option;
typedef struct nni_proto_ctx_ops nni_proto_ctx_ops;
typedef struct nni_proto_sock_ops nni_proto_sock_ops;
typedef struct nni_proto_pipe_ops nni_proto_pipe_ops;
diff --git a/src/core/dialer.c b/src/core/dialer.c
index 11faed7c..a74f30f0 100644
--- a/src/core/dialer.c
+++ b/src/core/dialer.c
@@ -389,7 +389,7 @@ int
nni_dialer_setopt(nni_dialer *d, const char *name, const void *val, size_t sz,
nni_opt_type t)
{
- nni_tran_option *o;
+ nni_option *o;
if (strcmp(name, NNG_OPT_URL) == 0) {
return (NNG_EREADONLY);
@@ -430,7 +430,7 @@ int
nni_dialer_getopt(
nni_dialer *d, const char *name, void *valp, size_t *szp, nni_opt_type t)
{
- nni_tran_option *o;
+ nni_option *o;
if (strcmp(name, NNG_OPT_RECONNMAXT) == 0) {
int rv;
diff --git a/src/core/listener.c b/src/core/listener.c
index 135478de..84f8cafd 100644
--- a/src/core/listener.c
+++ b/src/core/listener.c
@@ -364,7 +364,7 @@ int
nni_listener_setopt(nni_listener *l, const char *name, const void *val,
size_t sz, nni_opt_type t)
{
- nni_tran_option *o;
+ nni_option *o;
if (strcmp(name, NNG_OPT_URL) == 0) {
return (NNG_EREADONLY);
@@ -388,7 +388,7 @@ int
nni_listener_getopt(
nni_listener *l, const char *name, void *valp, size_t *szp, nni_opt_type t)
{
- nni_tran_option *o;
+ nni_option *o;
for (o = l->l_ops.l_options; o && o->o_name; o++) {
if (strcmp(o->o_name, name) != 0) {
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
diff --git a/src/core/pipe.c b/src/core/pipe.c
index d04c8b28..9357cee4 100644
--- a/src/core/pipe.c
+++ b/src/core/pipe.c
@@ -289,7 +289,7 @@ int
nni_pipe_getopt(
nni_pipe *p, const char *name, void *val, size_t *szp, nni_opt_type t)
{
- nni_tran_option *o;
+ nni_option *o;
for (o = p->p_tran_ops.p_options; o && o->o_name; o++) {
if (strcmp(o->o_name, name) != 0) {
diff --git a/src/core/protocol.h b/src/core/protocol.h
index 12ca7e71..f164ee45 100644
--- a/src/core/protocol.h
+++ b/src/core/protocol.h
@@ -11,6 +11,8 @@
#ifndef CORE_PROTOCOL_H
#define CORE_PROTOCOL_H
+#include "core/options.h"
+
// Protocol implementation details. Protocols must implement the
// interfaces in this file. Note that implementing new protocols is
// not necessarily intended to be a trivial task. The protocol developer
@@ -21,13 +23,6 @@
// 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.
@@ -80,7 +75,7 @@ struct nni_proto_ctx_ops {
void (*ctx_drain)(void *, nni_aio *);
// ctx_options array.
- nni_proto_option *ctx_options;
+ nni_option *ctx_options;
};
struct nni_proto_sock_ops {
@@ -123,7 +118,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_option *sock_options;
+ nni_option *sock_options;
};
typedef struct nni_proto_id {
diff --git a/src/core/socket.c b/src/core/socket.c
index 22fa5c07..888200ef 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -33,13 +33,6 @@ struct nni_ctx {
nng_duration c_rcvtimeo;
};
-typedef struct sock_option {
- const char * o_name;
- nni_opt_type o_type;
- int (*o_get)(nni_sock *, void *, size_t *, nni_opt_type);
- int (*o_set)(nni_sock *, const void *, size_t, nni_opt_type);
-} sock_option;
-
typedef struct nni_sockopt {
nni_list_node node;
char * name;
@@ -120,22 +113,24 @@ static void nni_ctx_destroy(nni_ctx *);
static void dialer_shutdown_locked(nni_dialer *);
static void listener_shutdown_locked(nni_listener *);
+#define SOCK(s) ((nni_sock *) (s))
+
static int
-sock_get_fd(nni_sock *s, int flag, int *fdp)
+sock_get_fd(void *s, int flag, int *fdp)
{
int rv;
nni_pollable *p;
- if ((flag & nni_sock_flags(s)) == 0) {
+ if ((flag & nni_sock_flags(SOCK(s))) == 0) {
return (NNG_ENOTSUP);
}
switch (flag) {
case NNI_PROTO_FLAG_SND:
- rv = nni_msgq_get_sendable(s->s_uwq, &p);
+ rv = nni_msgq_get_sendable(SOCK(s)->s_uwq, &p);
break;
case NNI_PROTO_FLAG_RCV:
- rv = nni_msgq_get_recvable(s->s_urq, &p);
+ rv = nni_msgq_get_recvable(SOCK(s)->s_urq, &p);
break;
default:
rv = NNG_EINVAL;
@@ -150,62 +145,62 @@ sock_get_fd(nni_sock *s, int flag, int *fdp)
}
static int
-sock_get_sendfd(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_sendfd(void *s, void *buf, size_t *szp, nni_opt_type t)
{
int fd;
int rv;
- if ((rv = sock_get_fd(s, NNI_PROTO_FLAG_SND, &fd)) != 0) {
+ if ((rv = sock_get_fd(SOCK(s), NNI_PROTO_FLAG_SND, &fd)) != 0) {
return (rv);
}
return (nni_copyout_int(fd, buf, szp, t));
}
static int
-sock_get_recvfd(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_recvfd(void *s, void *buf, size_t *szp, nni_opt_type t)
{
int fd;
int rv;
- if ((rv = sock_get_fd(s, NNI_PROTO_FLAG_RCV, &fd)) != 0) {
+ if ((rv = sock_get_fd(SOCK(s), NNI_PROTO_FLAG_RCV, &fd)) != 0) {
return (rv);
}
return (nni_copyout_int(fd, buf, szp, t));
}
static int
-sock_get_raw(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_raw(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- bool raw = ((nni_sock_flags(s) & NNI_PROTO_FLAG_RAW) != 0);
+ bool raw = ((nni_sock_flags(SOCK(s)) & NNI_PROTO_FLAG_RAW) != 0);
return (nni_copyout_bool(raw, buf, szp, t));
}
static int
-sock_set_recvtimeo(nni_sock *s, const void *buf, size_t sz, nni_opt_type t)
+sock_set_recvtimeo(void *s, const void *buf, size_t sz, nni_opt_type t)
{
- return (nni_copyin_ms(&s->s_rcvtimeo, buf, sz, t));
+ return (nni_copyin_ms(&SOCK(s)->s_rcvtimeo, buf, sz, t));
}
static int
-sock_get_recvtimeo(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_recvtimeo(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- return (nni_copyout_ms(s->s_rcvtimeo, buf, szp, t));
+ return (nni_copyout_ms(SOCK(s)->s_rcvtimeo, buf, szp, t));
}
static int
-sock_set_sendtimeo(nni_sock *s, const void *buf, size_t sz, nni_opt_type t)
+sock_set_sendtimeo(void *s, const void *buf, size_t sz, nni_opt_type t)
{
- return (nni_copyin_ms(&s->s_sndtimeo, buf, sz, t));
+ return (nni_copyin_ms(&SOCK(s)->s_sndtimeo, buf, sz, t));
}
static int
-sock_get_sendtimeo(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_sendtimeo(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- return (nni_copyout_ms(s->s_sndtimeo, buf, szp, t));
+ return (nni_copyout_ms(SOCK(s)->s_sndtimeo, buf, szp, t));
}
static int
-sock_set_recvbuf(nni_sock *s, const void *buf, size_t sz, nni_opt_type t)
+sock_set_recvbuf(void *s, const void *buf, size_t sz, nni_opt_type t)
{
int len;
int rv;
@@ -213,19 +208,19 @@ sock_set_recvbuf(nni_sock *s, const void *buf, size_t sz, nni_opt_type t)
if ((rv = nni_copyin_int(&len, buf, sz, 0, 8192, t)) != 0) {
return (rv);
}
- return (nni_msgq_resize(s->s_urq, len));
+ return (nni_msgq_resize(SOCK(s)->s_urq, len));
}
static int
-sock_get_recvbuf(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_recvbuf(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- int len = nni_msgq_cap(s->s_urq);
+ int len = nni_msgq_cap(SOCK(s)->s_urq);
return (nni_copyout_int(len, buf, szp, t));
}
static int
-sock_set_sendbuf(nni_sock *s, const void *buf, size_t sz, nni_opt_type t)
+sock_set_sendbuf(void *s, const void *buf, size_t sz, nni_opt_type t)
{
int len;
int rv;
@@ -233,117 +228,106 @@ sock_set_sendbuf(nni_sock *s, const void *buf, size_t sz, nni_opt_type t)
if ((rv = nni_copyin_int(&len, buf, sz, 0, 8192, t)) != 0) {
return (rv);
}
- return (nni_msgq_resize(s->s_uwq, len));
+ return (nni_msgq_resize(SOCK(s)->s_uwq, len));
}
static int
-sock_get_sendbuf(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_sendbuf(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- int len = nni_msgq_cap(s->s_uwq);
+ int len = nni_msgq_cap(SOCK(s)->s_uwq);
return (nni_copyout_int(len, buf, szp, t));
}
static int
-sock_get_sockname(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_sockname(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- return (nni_copyout_str(s->s_name, buf, szp, t));
+ return (nni_copyout_str(SOCK(s)->s_name, buf, szp, t));
}
static int
-sock_set_sockname(nni_sock *s, const void *buf, size_t sz, nni_opt_type t)
+sock_set_sockname(void *s, const void *buf, size_t sz, nni_opt_type t)
{
- return (nni_copyin_str(s->s_name, buf, sizeof(s->s_name), sz, t));
+ return (nni_copyin_str(
+ SOCK(s)->s_name, buf, sizeof(SOCK(s)->s_name), sz, t));
}
static int
-sock_get_proto(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_proto(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- return (nni_copyout_int(nni_sock_proto_id(s), buf, szp, t));
+ return (nni_copyout_int(nni_sock_proto_id(SOCK(s)), buf, szp, t));
}
static int
-sock_get_peer(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_peer(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- return (nni_copyout_int(nni_sock_peer_id(s), buf, szp, t));
+ return (nni_copyout_int(nni_sock_peer_id(SOCK(s)), buf, szp, t));
}
static int
-sock_get_protoname(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_protoname(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- return (nni_copyout_str(nni_sock_proto_name(s), buf, szp, t));
+ return (nni_copyout_str(nni_sock_proto_name(SOCK(s)), buf, szp, t));
}
static int
-sock_get_peername(nni_sock *s, void *buf, size_t *szp, nni_opt_type t)
+sock_get_peername(void *s, void *buf, size_t *szp, nni_opt_type t)
{
- return (nni_copyout_str(nni_sock_peer_name(s), buf, szp, t));
+ return (nni_copyout_str(nni_sock_peer_name(SOCK(s)), buf, szp, t));
}
-static const sock_option sock_options[] = {
+static const nni_option sock_options[] = {
{
.o_name = NNG_OPT_RECVTIMEO,
- .o_type = NNI_TYPE_DURATION,
.o_get = sock_get_recvtimeo,
.o_set = sock_set_recvtimeo,
},
{
.o_name = NNG_OPT_SENDTIMEO,
- .o_type = NNI_TYPE_DURATION,
.o_get = sock_get_sendtimeo,
.o_set = sock_set_sendtimeo,
},
{
.o_name = NNG_OPT_RECVFD,
- .o_type = NNI_TYPE_INT32,
.o_get = sock_get_recvfd,
},
{
.o_name = NNG_OPT_SENDFD,
- .o_type = NNI_TYPE_INT32,
.o_get = sock_get_sendfd,
},
{
.o_name = NNG_OPT_RECVBUF,
- .o_type = NNI_TYPE_INT32,
.o_get = sock_get_recvbuf,
.o_set = sock_set_recvbuf,
},
{
.o_name = NNG_OPT_SENDBUF,
- .o_type = NNI_TYPE_INT32,
.o_get = sock_get_sendbuf,
.o_set = sock_set_sendbuf,
},
{
.o_name = NNG_OPT_SOCKNAME,
- .o_type = NNI_TYPE_STRING,
.o_get = sock_get_sockname,
.o_set = sock_set_sockname,
},
{
.o_name = NNG_OPT_RAW,
- .o_type = NNI_TYPE_BOOL,
.o_get = sock_get_raw,
},
{
.o_name = NNG_OPT_PROTO,
- .o_type = NNI_TYPE_INT32,
.o_get = sock_get_proto,
},
{
.o_name = NNG_OPT_PEER,
- .o_type = NNI_TYPE_INT32,
.o_get = sock_get_peer,
},
{
.o_name = NNG_OPT_PROTONAME,
- .o_type = NNI_TYPE_STRING,
.o_get = sock_get_protoname,
},
{
.o_name = NNG_OPT_PEERNAME,
- .o_type = NNI_TYPE_STRING,
.o_get = sock_get_peername,
},
// terminate list
@@ -975,13 +959,12 @@ int
nni_sock_setopt(
nni_sock *s, const char *name, const void *v, size_t sz, nni_opt_type t)
{
- int rv = NNG_ENOTSUP;
- nni_dialer * d;
- nni_listener * l;
- nni_sockopt * optv;
- nni_sockopt * oldv = NULL;
- const sock_option * sso;
- const nni_proto_option *pso;
+ int rv = NNG_ENOTSUP;
+ nni_dialer * d;
+ nni_listener * l;
+ nni_sockopt * optv;
+ nni_sockopt * oldv = NULL;
+ const nni_option *opt;
nni_mtx_lock(&s->s_mx);
if (s->s_closing) {
@@ -992,29 +975,29 @@ nni_sock_setopt(
// Protocol options. The protocol can override options that
// the socket framework would otherwise supply, like buffer
// sizes.
- for (pso = s->s_sock_ops.sock_options; pso->o_name != NULL; pso++) {
- if (strcmp(pso->o_name, name) != 0) {
+ for (opt = s->s_sock_ops.sock_options; opt->o_name != NULL; opt++) {
+ if (strcmp(opt->o_name, name) != 0) {
continue;
}
- if (pso->o_set == NULL) {
+ if (opt->o_set == NULL) {
nni_mtx_unlock(&s->s_mx);
return (NNG_EREADONLY);
}
- rv = pso->o_set(s->s_data, v, sz, t);
+ rv = opt->o_set(s->s_data, v, sz, t);
nni_mtx_unlock(&s->s_mx);
return (rv);
}
// Some options do not go down to transports. Handle them directly.
- for (sso = sock_options; sso->o_name != NULL; sso++) {
- if (strcmp(sso->o_name, name) != 0) {
+ for (opt = sock_options; opt->o_name != NULL; opt++) {
+ if (strcmp(opt->o_name, name) != 0) {
continue;
}
- if (sso->o_set == NULL) {
+ if (opt->o_set == NULL) {
nni_mtx_unlock(&s->s_mx);
return (NNG_EREADONLY);
}
- rv = sso->o_set(s, v, sz, t);
+ rv = opt->o_set(s, v, sz, t);
nni_mtx_unlock(&s->s_mx);
return (rv);
}
@@ -1122,10 +1105,9 @@ int
nni_sock_getopt(
nni_sock *s, const char *name, void *val, size_t *szp, nni_opt_type t)
{
- int rv = NNG_ENOTSUP;
- nni_sockopt * sopt;
- const sock_option * sso;
- const nni_proto_option *pso;
+ int rv = NNG_ENOTSUP;
+ nni_sockopt * sopt;
+ const nni_option *opt;
nni_mtx_lock(&s->s_mx);
if (s->s_closing) {
@@ -1136,29 +1118,29 @@ nni_sock_getopt(
// Protocol specific options. The protocol can override
// options like the send buffer or notification descriptors
// this way.
- for (pso = s->s_sock_ops.sock_options; pso->o_name != NULL; pso++) {
- if (strcmp(name, pso->o_name) != 0) {
+ for (opt = s->s_sock_ops.sock_options; opt->o_name != NULL; opt++) {
+ if (strcmp(name, opt->o_name) != 0) {
continue;
}
- if (pso->o_get == NULL) {
+ if (opt->o_get == NULL) {
nni_mtx_unlock(&s->s_mx);
return (NNG_EWRITEONLY);
}
- rv = pso->o_get(s->s_data, val, szp, t);
+ rv = opt->o_get(s->s_data, val, szp, t);
nni_mtx_unlock(&s->s_mx);
return (rv);
}
// Socket generic options.
- for (sso = sock_options; sso->o_name != NULL; sso++) {
- if (strcmp(name, sso->o_name) != 0) {
+ for (opt = sock_options; opt->o_name != NULL; opt++) {
+ if (strcmp(name, opt->o_name) != 0) {
continue;
}
- if (sso->o_get == NULL) {
+ if (opt->o_get == NULL) {
nni_mtx_unlock(&s->s_mx);
return (NNG_EWRITEONLY);
}
- rv = sso->o_get(s, val, szp, t);
+ rv = opt->o_get(s, val, szp, t);
nni_mtx_unlock(&s->s_mx);
return (rv);
}
@@ -1372,9 +1354,9 @@ int
nni_ctx_getopt(
nni_ctx *ctx, const char *opt, void *v, size_t *szp, nni_opt_type t)
{
- nni_sock * sock = ctx->c_sock;
- nni_proto_option *o;
- int rv = NNG_ENOTSUP;
+ nni_sock * sock = ctx->c_sock;
+ nni_option *o;
+ int rv = NNG_ENOTSUP;
nni_mtx_lock(&sock->s_mx);
if (strcmp(opt, NNG_OPT_RECVTIMEO) == 0) {
@@ -1402,9 +1384,9 @@ int
nni_ctx_setopt(
nni_ctx *ctx, const char *opt, const void *v, size_t sz, nni_opt_type t)
{
- nni_sock * sock = ctx->c_sock;
- nni_proto_option *o;
- int rv = NNG_ENOTSUP;
+ nni_sock * sock = ctx->c_sock;
+ nni_option *o;
+ int rv = NNG_ENOTSUP;
nni_mtx_lock(&sock->s_mx);
if (strcmp(opt, NNG_OPT_RECVTIMEO) == 0) {
diff --git a/src/core/transport.c b/src/core/transport.c
index e27c349e..185ab779 100644
--- a/src/core/transport.c
+++ b/src/core/transport.c
@@ -120,7 +120,7 @@ nni_tran_chkopt(const char *name, const void *v, size_t sz, int typ)
NNI_LIST_FOREACH (&nni_tran_list, t) {
const nni_tran_dialer_ops * dops;
const nni_tran_listener_ops *lops;
- const nni_tran_option * o;
+ const nni_option * o;
// Generally we look for endpoint options. We check both
// dialers and listeners.
@@ -133,9 +133,8 @@ nni_tran_chkopt(const char *name, const void *v, size_t sz, int typ)
nni_mtx_unlock(&nni_tran_lk);
return (NNG_EREADONLY);
}
-
- rv = (o->o_chk != NULL) ? o->o_chk(v, sz, typ) : 0;
nni_mtx_unlock(&nni_tran_lk);
+ rv = o->o_set(NULL, v, sz, typ);
return (rv);
}
lops = t->t_tran.tran_listener;
@@ -147,9 +146,8 @@ nni_tran_chkopt(const char *name, const void *v, size_t sz, int typ)
nni_mtx_unlock(&nni_tran_lk);
return (NNG_EREADONLY);
}
-
- rv = (o->o_chk != NULL) ? o->o_chk(v, sz, typ) : 0;
nni_mtx_unlock(&nni_tran_lk);
+ rv = o->o_set(NULL, v, sz, typ);
return (rv);
}
}
diff --git a/src/core/transport.h b/src/core/transport.h
index 8e5bba48..1736f8ea 100644
--- a/src/core/transport.h
+++ b/src/core/transport.h
@@ -11,6 +11,8 @@
#ifndef CORE_TRANSPORT_H
#define CORE_TRANSPORT_H
+#include "core/options.h"
+
// We quite intentionally use a signature where the upper word is nonzero,
// which ensures that if we get garbage we will reject it. This is more
// likely to mismatch than all zero bytes would. The actual version is
@@ -27,28 +29,6 @@
#define NNI_TRANSPORT_V5 0x54520005
#define NNI_TRANSPORT_VERSION NNI_TRANSPORT_V5
-// Option handlers.
-struct nni_tran_option {
- // o_name is the name of the option.
- const char *o_name;
-
- // o_type is the type of the option.
- nni_opt_type o_type;
-
- // o_get retrieves the value of the option. The first argument is the
- // dialer, listener, or pipe where the request is being made.
- int (*o_get)(void *, void *, size_t *, nni_opt_type);
-
- // o_set sets the value of the option. The first argument is the
- // dialer, listener, or pipe where the request is being made.
- int (*o_set)(void *, const void *, size_t, nni_opt_type);
-
- // o_chk checks to see if the proposed value is legal -- this is
- // checks only the type, size, and generic range validation. This
- // function can be called before any transport objects are created.
- int (*o_chk)(const void *, size_t, nni_opt_type);
-};
-
// Endpoint operations are called by the socket in a
// protocol-independent fashion. The socket makes individual calls,
// which are expected to block if appropriate (except for destroy), or
@@ -81,7 +61,7 @@ struct nni_tran_dialer_ops {
// d_options is an array of dialer options. The final
// element must have a NULL name. If this member is NULL, then
// no dialer specific options are available.
- nni_tran_option *d_options;
+ nni_option *d_options;
};
struct nni_tran_listener_ops {
@@ -111,7 +91,7 @@ struct nni_tran_listener_ops {
// l_options is an array of listener options. The final
// element must have a NULL name. If this member is NULL, then
// no dialer specific options are available.
- nni_tran_option *l_options;
+ nni_option *l_options;
};
// Pipe operations are entry points called by the socket. These may be
@@ -160,7 +140,7 @@ struct nni_tran_pipe_ops {
// p_options is an array of pipe options. The final element
// must have a NULL name. If this member is NULL, then no
// transport specific options are available.
- nni_tran_option *p_options;
+ nni_option *p_options;
};
// Transport implementation details. Transports must implement the