diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-01-21 22:40:10 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-02-16 19:22:27 -0800 |
| commit | 5cf750697624d4fd63cfe26921209d7c30e1a2d2 (patch) | |
| tree | bf11695e5f1ec5e400c87da0cc6ff23935a2eeff /src/supplemental/tls/tls_api.h | |
| parent | ca655b9db689ee0e655248b1a9f166b8db6cc984 (diff) | |
| download | nng-5cf750697624d4fd63cfe26921209d7c30e1a2d2.tar.gz nng-5cf750697624d4fd63cfe26921209d7c30e1a2d2.tar.bz2 nng-5cf750697624d4fd63cfe26921209d7c30e1a2d2.zip | |
fixes #872 create unified nng_stream API
This is a major change, and includes changes to use a polymorphic
stream API for all transports. There have been related bugs fixed
along the way. Additionally the man pages have changed.
The old non-polymorphic APIs are removed now. This is a breaking
change, but the old APIs were never part of any released public API.
Diffstat (limited to 'src/supplemental/tls/tls_api.h')
| -rw-r--r-- | src/supplemental/tls/tls_api.h | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/src/supplemental/tls/tls_api.h b/src/supplemental/tls/tls_api.h index 22dd68a0..4e6146b1 100644 --- a/src/supplemental/tls/tls_api.h +++ b/src/supplemental/tls/tls_api.h @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2019 Devolutions <info@devolutions.net> // @@ -12,12 +12,28 @@ #ifndef NNG_SUPPLEMENTAL_TLS_TLS_API_H #define NNG_SUPPLEMENTAL_TLS_TLS_API_H -#include <stdbool.h> - #include <nng/supplemental/tls/tls.h> -// nni_tls represents the context for a single TLS stream. -typedef struct nni_tls nni_tls; +// This nni_tls_common structure represents the "base" structure for +// an implementation to extend. One of these must be the first member +// of the implementation specific TLS stream struct. +typedef struct { + nng_stream ops; + nni_aio * aio; // system aio for connect/accept + nni_aio * uaio; // user aio for connect/accept + nng_tls_config *cfg; +} nni_tls_common; + +// The implementation supplies this function to create the TLS connection +// object. All fields will be zeroed. +extern int nni_tls_alloc(nng_stream **); +extern int nni_tls_dialer_alloc(nng_stream_dialer **, const nng_url *); +extern int nni_tls_listener_alloc(nng_stream_listener **, const nng_url *); +extern int nni_tls_checkopt(const char *, const void *, size_t, nni_type); + +// nni_tls_start is called by the common TLS dialer/listener completions +// to start the TLS stream activity. This may also do allocations, etc. +extern int nni_tls_start(nng_stream *, nng_stream *); // nni_tls_config_init creates a new TLS configuration object. // The object is created with a reference count of one. @@ -34,30 +50,4 @@ extern void nni_tls_config_fini(nng_tls_config *); // the configuration object is created with a hold on it. extern void nni_tls_config_hold(nng_tls_config *); -extern int nni_tls_init(nni_tls **, nng_tls_config *, nni_tcp_conn *); -extern void nni_tls_close(nni_tls *); -extern void nni_tls_fini(nni_tls *); -extern void nni_tls_send(nni_tls *, nng_aio *); -extern void nni_tls_recv(nni_tls *, nng_aio *); - -extern int nni_tls_setopt( - nni_tls *, const char *, const void *, size_t, nni_type); -extern int nni_tls_getopt(nni_tls *, const char *, void *, size_t *, nni_type); - -extern int nni_tls_set( - nng_tls *, const char *, const void *, size_t, nni_type); -extern int nni_tls_get(nng_tls *, const char *, void *, size_t *, nni_type); - -extern int nni_tls_dialer_setopt( - nng_tls_dialer *, const char *, const void *, size_t, nni_type); - -extern int nni_tls_dialer_getopt( - nng_tls_dialer *, const char *, void *, size_t *, nni_type); - -extern int nni_tls_listener_setopt( - nng_tls_listener *, const char *, const void *, size_t, nni_type); - -extern int nni_tls_listener_getopt( - nng_tls_listener *, const char *, void *, size_t *, nni_type); - #endif // NNG_SUPPLEMENTAL_TLS_TLS_API_H |
