diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-08 21:19:09 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-09 02:38:55 -0700 |
| commit | d64f12553eb6ceb67ed6f6a5b2ceb6c061d375ba (patch) | |
| tree | f6bdac79578176f0d00528d191f862009e761eac /src/protocol/pair | |
| parent | 5f0398de8edd1ed4ddbf6455c66273a6608aad9a (diff) | |
| download | nng-d64f12553eb6ceb67ed6f6a5b2ceb6c061d375ba.tar.gz nng-d64f12553eb6ceb67ed6f6a5b2ceb6c061d375ba.tar.bz2 nng-d64f12553eb6ceb67ed6f6a5b2ceb6c061d375ba.zip | |
fixes #44 open protocol by "name" (symbol) instead number
fixes #38 Make protocols "pluggable", or at least optional
This is a breaking change, as we've done away with the central
registered list of protocols, and instead demand the user call
nng_xxx_open() where xxx is a protocol name. (We did keep a
table around in the compat framework though.)
There is a nice way for protocols to plug in via
an nni_proto_open(), where they can use a generic constructor
that they use to build a protocol specific constructor (passing
their ops vector in.)
Diffstat (limited to 'src/protocol/pair')
| -rw-r--r-- | src/protocol/pair/pair.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/protocol/pair/pair.c b/src/protocol/pair/pair.c index 55ce5aa9..59465293 100644 --- a/src/protocol/pair/pair.c +++ b/src/protocol/pair/pair.c @@ -231,6 +231,18 @@ nni_pair_send_cb(void *arg) nni_msgq_aio_get(psock->uwq, &ppipe->aio_getq); } +static void +nni_pair_sock_open(void *arg) +{ + NNI_ARG_UNUSED(arg); +} + +static void +nni_pair_sock_close(void *arg) +{ + NNI_ARG_UNUSED(arg); +} + static int nni_pair_sock_setopt(void *arg, int opt, const void *buf, size_t sz) { @@ -263,9 +275,6 @@ nni_pair_sock_getopt(void *arg, int opt, void *buf, size_t *szp) return (rv); } -// This is the global protocol structure -- our linkage to the core. -// This should be the only global non-static symbol in this file. - static nni_proto_pipe_ops nni_pair_pipe_ops = { .pipe_init = nni_pair_pipe_init, .pipe_fini = nni_pair_pipe_fini, @@ -276,15 +285,23 @@ static nni_proto_pipe_ops nni_pair_pipe_ops = { static nni_proto_sock_ops nni_pair_sock_ops = { .sock_init = nni_pair_sock_init, .sock_fini = nni_pair_sock_fini, + .sock_open = nni_pair_sock_open, + .sock_close = nni_pair_sock_close, .sock_setopt = nni_pair_sock_setopt, .sock_getopt = nni_pair_sock_getopt, }; nni_proto nni_pair_proto = { - .proto_self = NNG_PROTO_PAIR, - .proto_peer = NNG_PROTO_PAIR, - .proto_name = "pair", + .proto_version = NNI_PROTOCOL_VERSION, + .proto_self = { NNG_PROTO_PAIR_V0, "pair" }, + .proto_peer = { NNG_PROTO_PAIR_V0, "pair" }, .proto_flags = NNI_PROTO_FLAG_SNDRCV, .proto_sock_ops = &nni_pair_sock_ops, .proto_pipe_ops = &nni_pair_pipe_ops, }; + +int +nng_pair0_open(nng_socket *sidp) +{ + return (nni_proto_open(sidp, &nni_pair_proto)); +} |
