Commit 551ad114 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix and simplify client-side API

(failed to release allocated data in some error cases)
parent d68b6075
......@@ -98,13 +98,12 @@ 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( tls_session_t *, tls_ClientCreate, ( vlc_object_t *, const char *, int ) );
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 )
/* 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 ))
......
......@@ -78,7 +78,7 @@ tls_ServerCreate( vlc_object_t *p_this, const char *psz_cert,
/*****************************************************************************
* tls_ServerDelete:
*****************************************************************************
* Releases data allocated with tls_ServerCreate
* Releases data allocated with tls_ServerCreate.
*****************************************************************************/
void
tls_ServerDelete( tls_server_t *p_server )
......@@ -96,11 +96,11 @@ tls_ServerDelete( tls_server_t *p_server )
/*****************************************************************************
* tls_ClientCreate:
*****************************************************************************
* Allocates a client's TLS credentials.
* Allocates a client's TLS credentials and shakes hands through the network.
* Returns NULL on error.
*****************************************************************************/
tls_session_t *
tls_ClientCreate( vlc_object_t *p_this, const char *psz_ca )
tls_ClientCreate( vlc_object_t *p_this, const char *psz_ca, int fd )
{
tls_t *p_tls;
tls_session_t *p_session;
......@@ -114,8 +114,14 @@ tls_ClientCreate( vlc_object_t *p_this, const char *psz_ca )
p_session = __tls_ClientCreate( p_tls, psz_ca );
if( p_session != NULL )
{
msg_Dbg( p_this, "TLS/SSL provider initialized" );
return p_session;
p_session = tls_SessionHandshake( p_session, fd );
if( p_session != NULL )
{
msg_Dbg( p_this, "TLS/SSL provider initialized" );
return p_session;
}
else
msg_Err( p_this, "TLS/SSL session handshake error" );
}
else
msg_Err( p_this, "TLS/SSL provider error" );
......@@ -133,14 +139,14 @@ tls_ClientCreate( vlc_object_t *p_this, const char *psz_ca )
/*****************************************************************************
* tls_ClientDelete:
*****************************************************************************
* Releases data allocated with tls_ClientCreate
* Releases data allocated with tls_ClientCreate.
*****************************************************************************/
void
tls_ClientDelete( tls_session_t *p_session )
{
tls_t *p_tls = p_session->p_tls;
__tls_ClientDelete( p_session );
tls_SessionClose( p_session );
module_Unneed( p_tls, p_tls->p_module );
vlc_object_detach( p_tls );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment