diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-06-26 17:39:17 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-06-27 17:28:05 -0700 |
| commit | 251553b13e6bc8019914b9edd1292f97e856dd43 (patch) | |
| tree | 9193b8b4d4df86253f0a469cd96d8bb304a64c82 /src/transport/zerotier | |
| parent | 91f9061ad9289afffb0111c03a8390d0f82d7114 (diff) | |
| download | nng-251553b13e6bc8019914b9edd1292f97e856dd43.tar.gz nng-251553b13e6bc8019914b9edd1292f97e856dd43.tar.bz2 nng-251553b13e6bc8019914b9edd1292f97e856dd43.zip | |
fixes #522 Separate out the endpoint plumbing
This separates the plumbing for endpoints into distinct
dialer and listeners. Some of the transports could benefit
from further separation, but we've done some rather larger
separation e.g. for the websocket transport.
IPC would be a good one to update later, when we start looking
at exposing a more natural underlying API.
Diffstat (limited to 'src/transport/zerotier')
| -rw-r--r-- | src/transport/zerotier/zerotier.c | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/transport/zerotier/zerotier.c b/src/transport/zerotier/zerotier.c index fa8458c1..3535a248 100644 --- a/src/transport/zerotier/zerotier.c +++ b/src/transport/zerotier/zerotier.c @@ -2251,6 +2251,18 @@ zt_ep_init(void **epp, nni_url *url, nni_sock *sock, int mode) return (0); } +static int +zt_dialer_init(void **epp, nni_url *url, nni_sock *sock) +{ + return (zt_ep_init(epp, url, sock, NNI_EP_MODE_DIAL)); +} + +static int +zt_listener_init(void **epp, nni_url *url, nni_sock *sock) +{ + return (zt_ep_init(epp, url, sock, NNI_EP_MODE_LISTEN)); +} + static void zt_ep_close(void *arg) { @@ -3022,25 +3034,33 @@ static nni_tran_option zt_ep_options[] = { }, }; -static nni_tran_ep_ops zt_ep_ops = { - .ep_init = zt_ep_init, - .ep_fini = zt_ep_fini, - .ep_connect = zt_ep_connect, - .ep_bind = zt_ep_bind, - .ep_accept = zt_ep_accept, - .ep_close = zt_ep_close, - .ep_options = zt_ep_options, +static nni_tran_dialer_ops zt_dialer_ops = { + .d_init = zt_dialer_init, + .d_fini = zt_ep_fini, + .d_connect = zt_ep_connect, + .d_close = zt_ep_close, + .d_options = zt_ep_options, +}; + +static nni_tran_listener_ops zt_listener_ops = { + .l_init = zt_listener_init, + .l_fini = zt_ep_fini, + .l_bind = zt_ep_bind, + .l_accept = zt_ep_accept, + .l_close = zt_ep_close, + .l_options = zt_ep_options, }; // This is the ZeroTier transport linkage, and should be the // only global symbol in this entire file. static struct nni_tran zt_tran = { - .tran_version = NNI_TRANSPORT_VERSION, - .tran_scheme = "zt", - .tran_ep = &zt_ep_ops, - .tran_pipe = &zt_pipe_ops, - .tran_init = zt_tran_init, - .tran_fini = zt_tran_fini, + .tran_version = NNI_TRANSPORT_VERSION, + .tran_scheme = "zt", + .tran_dialer = &zt_dialer_ops, + .tran_listener = &zt_listener_ops, + .tran_pipe = &zt_pipe_ops, + .tran_init = zt_tran_init, + .tran_fini = zt_tran_fini, }; int |
