diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-09-25 12:49:10 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-09-27 14:38:12 -0700 |
| commit | 64db0f085be0c9efc6dca8d9e72d3e5a47cb792e (patch) | |
| tree | 475520498d8ebe9e47e9785d8f9d209c87582400 /src/core/protocol.h | |
| parent | 86a96e5bf1b207a8b1aa925e1d9f73ce834505b8 (diff) | |
| download | nng-64db0f085be0c9efc6dca8d9e72d3e5a47cb792e.tar.gz nng-64db0f085be0c9efc6dca8d9e72d3e5a47cb792e.tar.bz2 nng-64db0f085be0c9efc6dca8d9e72d3e5a47cb792e.zip | |
Refactor option handling APIs.
This makes the APIs use string keys, and largely eliminates the use of
integer option IDs altogether. The underlying registration for options
is also now a bit richer, letting protcols and transports declare the
actual options they use, rather than calling down into each entry point
carte blanche and relying on ENOTSUP.
This code may not be as fast as the integers was, but it is more intuitive,
easier to extend, and is not on any hot code paths. (If you're diddling
options on a hot code path you're doing something wrong.)
Diffstat (limited to 'src/core/protocol.h')
| -rw-r--r-- | src/core/protocol.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/protocol.h b/src/core/protocol.h index 9416b2bf..0c0d93ce 100644 --- a/src/core/protocol.h +++ b/src/core/protocol.h @@ -47,6 +47,12 @@ struct nni_proto_pipe_ops { void (*pipe_stop)(void *); }; +struct nni_proto_sock_option { + const char *pso_name; + int (*pso_getopt)(void *, void *, size_t *); + int (*pso_setopt)(void *, const void *, size_t); +}; + struct nni_proto_sock_ops { // sock_init creates the protocol instance, which will be stored on // the socket. This is run without the sock lock held, and allocates @@ -68,10 +74,6 @@ struct nni_proto_sock_ops { // it can signal the socket worker threads to exit. void (*sock_close)(void *); - // Option manipulation. These may be NULL. - int (*sock_setopt)(void *, int, const void *, size_t); - int (*sock_getopt)(void *, int, void *, size_t *); - // Receive filter. This may be NULL, but if it isn't, then // messages coming into the system are routed here just before being // delivered to the application. To drop the message, the prtocol @@ -81,6 +83,9 @@ struct nni_proto_sock_ops { // Send filter. This may be NULL, but if it isn't, then messages // here are filtered just after they come from the application. nni_msg *(*sock_sfilter)(void *, nni_msg *); + + // Options. Must not be NULL. Final entry should have NULL name. + nni_proto_sock_option *sock_options; }; typedef struct nni_proto_id { |
