]> git.sesse.net Git - vlc/blobdiff - include/vlc_tls.h
Implement net_* virtualization with TLS module
[vlc] / include / vlc_tls.h
index b7b130cce14c72a13f4516ce667f9c99495d545e..3f2b8521a078162a44b360cbfcfcfb322ca079e4 100644 (file)
@@ -24,6 +24,8 @@
 #ifndef _VLC_TLS_H
 # define _VLC_TLS_H
 
+# include "network.h"
+
 struct tls_t
 {
     VLC_COMMON_MEMBERS
@@ -33,6 +35,7 @@ struct tls_t
     void *p_sys;
 
     tls_server_t * (*pf_server_create) ( tls_t *, const char *, const char * );
+    tls_session_t * (*pf_client_create) ( tls_t *, const char * );
 };
 
 struct tls_server_t
@@ -55,10 +58,9 @@ struct tls_session_t
 
     void *p_sys;
 
+    struct virtual_socket_t sock;
     tls_session_t * (*pf_handshake) ( tls_session_t *, int );
     void (*pf_close) ( tls_session_t * );
-    int (*pf_send) ( tls_session_t *, const char *, int );
-    int (*pf_recv) ( tls_session_t *, char *, int );
 };
 
 
@@ -95,12 +97,18 @@ VLC_EXPORT( void, tls_ServerDelete, ( tls_server_t * ) );
 
 # define tls_ServerSessionPrepare( a ) (((tls_server_t *)a)->pf_session_prepare (a))
 
+# define __tls_ClientCreate( a, b ) (((tls_t *)a)->pf_client_create (a, b ))
+VLC_EXPORT( tls_session_t *, tls_ClientCreate, ( vlc_object_t *, const char * ) );
+VLC_EXPORT( void, tls_ClientDelete, ( tls_session_t * ) );
+
 # define tls_SessionHandshake( a, b ) (((tls_session_t *)a)->pf_handshake (a, b))
 
 # define tls_SessionClose( a ) (((tls_session_t *)a)->pf_close (a))
+# define __tls_ClientDelete( a ) tls_SessionClose( a )
 
-# define tls_Send( a, b, c ) (((tls_session_t *)a)->pf_send (a, b, c ))
+/* NOTE: It is assumed that a->sock.p_sys = a */
+# define tls_Send( a, b, c ) (((tls_session_t *)a)->sock.pf_send (a, b, c ))
 
-# define tls_Recv( a, b, c ) (((tls_session_t *)a)->pf_recv (a, b, c ))
+# define tls_Recv( a, b, c ) (((tls_session_t *)a)->sock.pf_recv (a, b, c ))
 
 #endif