[vlc-commits] gnutls: use custom receive callback
Rémi Denis-Courmont
git at videolan.org
Wed Jan 13 21:49:50 CET 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jan 13 00:17:31 2016 +0200| [48f2d395b5f252f771bb330818d755799dd71285] | committer: Rémi Denis-Courmont
gnutls: use custom receive callback
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=48f2d395b5f252f771bb330818d755799dd71285
---
modules/misc/gnutls.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/modules/misc/gnutls.c b/modules/misc/gnutls.c
index 34c1be9..2d76be0 100644
--- a/modules/misc/gnutls.c
+++ b/modules/misc/gnutls.c
@@ -130,8 +130,24 @@ static int gnutls_Error(vlc_tls_t *tls, int val)
return -1;
}
-static ssize_t vlc_gnutls_writev (gnutls_transport_ptr_t ptr,
- const giovec_t *giov, int iovcnt)
+static ssize_t vlc_gnutls_read(gnutls_transport_ptr_t ptr, void *buf,
+ size_t length)
+{
+ int fd = (intptr_t)ptr;
+ struct iovec iov = {
+ .iov_base = buf,
+ .iov_len = length,
+ };
+ struct msghdr msg = {
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ };
+
+ return recvmsg(fd, &msg, 0);
+}
+
+static ssize_t vlc_gnutls_writev(gnutls_transport_ptr_t ptr,
+ const giovec_t *giov, int iovcnt)
{
if (unlikely((unsigned)iovcnt > IOV_MAX))
{
@@ -297,8 +313,9 @@ static int gnutls_SessionOpen(vlc_tls_creds_t *creds, vlc_tls_t *tls, int type,
free (protv);
}
- gnutls_transport_set_int (session, fd);
- gnutls_transport_set_vec_push_function (session, vlc_gnutls_writev);
+ gnutls_transport_set_ptr(session, (void *)(intptr_t)fd);
+ gnutls_transport_set_vec_push_function(session, vlc_gnutls_writev);
+ gnutls_transport_set_pull_function(session, vlc_gnutls_read);
tls->sys = session;
tls->get_fd = gnutls_GetFD;
tls->readv = gnutls_Recv;
More information about the vlc-commits
mailing list