aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2019-01-05 16:09:10 -0800
committerGarrett D'Amore <garrett@damore.org>2019-01-06 12:12:27 -0800
commit68c6310ee83078d6ad6af0c9ccddef11b8f8b7c2 (patch)
treed03175dddb1142a5ac9fedf4a8643f27648db53e /include
parentf76f536742c7d0766244ff4b8d388586100384d5 (diff)
downloadnng-68c6310ee83078d6ad6af0c9ccddef11b8f8b7c2.tar.gz
nng-68c6310ee83078d6ad6af0c9ccddef11b8f8b7c2.tar.bz2
nng-68c6310ee83078d6ad6af0c9ccddef11b8f8b7c2.zip
fixes #847 Define public TLS API
Diffstat (limited to 'include')
-rw-r--r--include/nng/supplemental/tls/tls.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/include/nng/supplemental/tls/tls.h b/include/nng/supplemental/tls/tls.h
index 5983f3b6..ee80b45b 100644
--- a/include/nng/supplemental/tls/tls.h
+++ b/include/nng/supplemental/tls/tls.h
@@ -105,6 +105,74 @@ NNG_DECL int nng_tls_config_ca_file(nng_tls_config *, const char *);
NNG_DECL int nng_tls_config_cert_key_file(
nng_tls_config *, const char *, const char *);
+// The rest of the definitions in this file rely upon having support for the
+// TLS supplemental API enabled. If you don't have this configured in your
+// library, then your programs will not link.
+
+// nng_tls represents a TLS connection over TCP.
+typedef struct nng_tls_s nng_tls;
+
+// nng_tls_dialer is a dialer that creates TLS connections (nng_tls objects)
+// by establishing outgoing connections.
+typedef struct nng_tls_dialer_s nng_tls_dialer;
+
+// nng_tls_listener is a listener that creates TLS connections (nng_tls
+// objects) by accepting incoming connections.
+typedef struct nng_tls_listener_s nng_tls_listener;
+
+// nng_tls_close closes a TLS connection, without releasing the underlying
+// resources. Use nng_tls_free to release the resources.
+NNG_DECL void nng_tls_close(nng_tls *);
+
+// nng_tls_free frees a TLS connection, and will implicity also close the
+// connection if not already done so.
+NNG_DECL void nng_tls_free(nng_tls *);
+
+NNG_DECL void nng_tls_send(nng_tls *, nng_aio *);
+NNG_DECL void nng_tls_recv(nng_tls *, nng_aio *);
+
+NNG_DECL int nng_tls_getopt(nng_tls *, const char *, void *, size_t *);
+
+// nng_tls_dialer_alloc allocates a dialer that creates TLS connections
+// (nng_tls structures) by connecting to remote servers.
+NNG_DECL int nng_tls_dialer_alloc(nng_tls_dialer **);
+
+// nng_tls_dialer_close closes the dialer, but does not free it's resources.
+NNG_DECL void nng_tls_dialer_close(nng_tls_dialer *);
+
+// nng_tls_dialer_free frees the dialer, implicitly closing it as well.
+NNG_DECL void nng_tls_dialer_free(nng_tls_dialer *);
+
+// nng_tls_dialer_dial attempts to create a new connection (nng_tls object)
+// by dialing to the remote server specified in the aio. Note that the
+// TLS connection may be returned before the TLS handshake is complete.
+// The remote server will only be verified if a server name has been configured
+// with the NNG_OPT_TLS_SERVER_NAME option (using nng_tls_dialer_setopt).
+NNG_DECL void nng_tls_dialer_dial(
+ nng_tls_dialer *, const nng_sockaddr *, nng_aio *);
+
+// nng_tls_dialer_getopt returns options from the dialer.
+NNG_DECL int nng_tls_dialer_getopt(
+ nng_tls_dialer *, const char *, void *, size_t *);
+
+// nng_tls_dialer_setopt sets options on the dialer. Options may include
+// NNG_OPT_TLS_CONFIG, as well as various other NNG_OPT_TLS_ options and
+// the TCP options that are valid for TCP dialers as well.
+NNG_DECL int nng_tls_dialer_setopt(
+ nng_tls_dialer *, const char *, const void *, size_t);
+
+NNG_DECL int nng_tls_listener_alloc(nng_tls_listener **);
+NNG_DECL void nng_tls_listener_close(nng_tls_listener *);
+NNG_DECL void nng_tls_listener_free(nng_tls_listener *);
+NNG_DECL int nng_tls_listener_listen(nng_tls_listener *, nng_sockaddr *);
+NNG_DECL void nng_tls_listener_accept(nng_tls_listener *, nng_aio *);
+
+NNG_DECL int nng_tls_listener_getopt(
+ nng_tls_listener *, const char *, void *, size_t *);
+
+NNG_DECL int nng_tls_listener_setopt(
+ nng_tls_listener *, const char *, const void *, size_t);
+
#ifdef __cplusplus
}
#endif