summaryrefslogtreecommitdiff
path: root/lib/libtls/tls.h
diff options
context:
space:
mode:
authorBrent Cook <bcook@cvs.openbsd.org>2016-09-04 12:26:44 +0000
committerBrent Cook <bcook@cvs.openbsd.org>2016-09-04 12:26:44 +0000
commita2005718008f8821c63824729b44deb5b983c8ef (patch)
treeb1057a3dfb108c600b04386116addd858f8fccb7 /lib/libtls/tls.h
parentb7c49ff4fa84db1a85dff35590381a345191fc53 (diff)
Add callback-based interface to libtls.
This allows working with buffers and callback functions instead of directly on sockets or file descriptors. Original patch from Tobias Pape <tobias_at_netshed.de>. ok beck@
Diffstat (limited to 'lib/libtls/tls.h')
-rw-r--r--lib/libtls/tls.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libtls/tls.h b/lib/libtls/tls.h
index 107614c759f..e4dd31775a9 100644
--- a/lib/libtls/tls.h
+++ b/lib/libtls/tls.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tls.h,v 1.35 2016/08/22 14:58:26 jsing Exp $ */
+/* $OpenBSD: tls.h,v 1.36 2016/09/04 12:26:43 bcook Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
*
@@ -44,6 +44,11 @@ extern "C" {
struct tls;
struct tls_config;
+typedef ssize_t (*tls_read_cb)(void *_ctx, void *_buf, size_t _buflen,
+ void *_cb_arg);
+typedef ssize_t (*tls_write_cb)(void *_ctx, const void *_buf,
+ size_t _buflen, void *_cb_arg);
+
int tls_init(void);
const char *tls_config_error(struct tls_config *_config);
@@ -102,12 +107,16 @@ void tls_free(struct tls *_ctx);
int tls_accept_fds(struct tls *_ctx, struct tls **_cctx, int _fd_read,
int _fd_write);
int tls_accept_socket(struct tls *_ctx, struct tls **_cctx, int _socket);
+int tls_accept_cbs(struct tls *_ctx, struct tls **_cctx,
+ tls_read_cb _read_cb, tls_write_cb _write_cb, void *_cb_arg);
int tls_connect(struct tls *_ctx, const char *_host, const char *_port);
int tls_connect_fds(struct tls *_ctx, int _fd_read, int _fd_write,
const char *_servername);
int tls_connect_servername(struct tls *_ctx, const char *_host,
const char *_port, const char *_servername);
int tls_connect_socket(struct tls *_ctx, int _s, const char *_servername);
+int tls_connect_cbs(struct tls *_ctx, tls_read_cb _read_cb,
+ tls_write_cb _write_cb, void *_cb_arg, const char *_servername);
int tls_handshake(struct tls *_ctx);
ssize_t tls_read(struct tls *_ctx, void *_buf, size_t _buflen);
ssize_t tls_write(struct tls *_ctx, const void *_buf, size_t _buflen);