vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Fri Dec 18 18:34:39 2015 +0200| [30d18b6a0558c2648e40cc1c4d3c91653d1c7c49] | committer: Rémi Denis-Courmont
tls: add vlc_tls_DummyCreate() > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=30d18b6a0558c2648e40cc1c4d3c91653d1c7c49 --- include/vlc_tls.h | 10 ++++++++++ src/libvlccore.sym | 1 + src/network/tls.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/include/vlc_tls.h b/include/vlc_tls.h index 4c746c4..f2a44ae 100644 --- a/include/vlc_tls.h +++ b/include/vlc_tls.h @@ -132,6 +132,16 @@ static inline int vlc_tls_SessionHandshake (vlc_tls_creds_t *crd, */ VLC_API void vlc_tls_Delete (vlc_tls_creds_t *); +/** + * Fakes a TLS session. + * + * Creates a dummy TLS session structure from a socket file descriptor. Data + * will be sent and received directly through the socket. This can be used + * either to share common code between non-TLS and TLS cases, or for testing + * purposes. + */ +VLC_API vlc_tls_t *vlc_tls_DummyCreate(vlc_object_t *obj, int fd); + /** @} */ #endif diff --git a/src/libvlccore.sym b/src/libvlccore.sym index d7971d8..a97ace1 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -431,6 +431,7 @@ vlc_tls_SessionDelete vlc_tls_Read vlc_tls_Write vlc_tls_GetLine +vlc_tls_DummyCreate ToCharset update_Check update_Delete diff --git a/src/network/tls.c b/src/network/tls.c index ebaa404..9120a27 100644 --- a/src/network/tls.c +++ b/src/network/tls.c @@ -308,3 +308,32 @@ error: free(line); return NULL; } + +static ssize_t vlc_tls_DummyReceive(vlc_tls_t *tls, void *buf, size_t len) +{ + return recv(tls->fd, buf, len, 0); +} + +static ssize_t vlc_tls_DummySend(vlc_tls_t *tls, const void *buf, size_t len) +{ + return send(tls->fd, buf, len, 0); +} + +static void vlc_tls_DummyClose(vlc_tls_t *tls) +{ + (void) tls; +} + +vlc_tls_t *vlc_tls_DummyCreate(vlc_object_t *obj, int fd) +{ + vlc_tls_t *session = malloc(sizeof (*session)); + if (unlikely(session == NULL)) + return NULL; + + session->obj = obj; + session->fd = fd; + session->recv = vlc_tls_DummyReceive; + session->send = vlc_tls_DummySend; + session->close = vlc_tls_DummyClose; + return session; +} _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
