aboutsummaryrefslogtreecommitdiffstats
path: root/src/libtls/tls_socket.h
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-01-10 16:20:06 +0100
committerMartin Willi <martin@revosec.ch>2013-01-15 17:43:05 +0100
commitee90c78998911aea33fbf64e38f164902559e593 (patch)
tree73db0cf6156b692de30cc8ec637d17f861c3815b /src/libtls/tls_socket.h
parent47af9848a215e3094ccdf53de773dedd8d384b7a (diff)
downloadstrongswan-ee90c78998911aea33fbf64e38f164902559e593.tar.bz2
strongswan-ee90c78998911aea33fbf64e38f164902559e593.tar.xz
Use a more POSIXy tls_socket interface with more flexibility.
If an unsufficient read buffer is provided, application data gets cached for subsequent read() calls.
Diffstat (limited to 'src/libtls/tls_socket.h')
-rw-r--r--src/libtls/tls_socket.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/libtls/tls_socket.h b/src/libtls/tls_socket.h
index edd05fd29..4ddddc19e 100644
--- a/src/libtls/tls_socket.h
+++ b/src/libtls/tls_socket.h
@@ -35,24 +35,27 @@ typedef struct tls_socket_t tls_socket_t;
struct tls_socket_t {
/**
- * Read data from secured socket, return allocated chunk.
+ * Read data from secured socket.
*
* This call is blocking, you may use select() on the underlying socket to
- * wait for data. If the there was non-application data available, the
- * read function can return an empty chunk.
+ * wait for data. If "block" is FALSE and no application data is available,
+ * the function returns -1 and sets errno to EWOULDBLOCK.
*
- * @param data pointer to allocate received data
- * @return TRUE if data received successfully
+ * @param buf buffer to write received data to
+ * @param len size of buffer
+ * @param block TRUE to block this call, FALSE to fail if it would block
+ * @return number of bytes read, 0 on EOF, -1 on error
*/
- bool (*read)(tls_socket_t *this, chunk_t *data);
+ ssize_t (*read)(tls_socket_t *this, void *buf, size_t len, bool block);
/**
- * Write a chunk of data over the secured socket.
+ * Write data over the secured socket.
*
- * @param data data to send
- * @return TRUE if data sent successfully
+ * @param buf data to send
+ * @param len number of bytes to write from buf
+ * @return number of bytes written, -1 on error
*/
- bool (*write)(tls_socket_t *this, chunk_t data);
+ ssize_t (*write)(tls_socket_t *this, void *buf, size_t len);
/**
* Read/write plain data from file descriptor.