vlc_tls_sys_t *sys;
struct virtual_socket_t sock;
- int (*handshake) (vlc_tls_t *, const char *host, const char *service);
};
VLC_API vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *, int fd,
vlc_tls_creds_sys_t *sys;
int (*open) (vlc_tls_creds_t *, vlc_tls_t *, int fd, const char *host);
- void (*close) (vlc_tls_creds_t *, vlc_tls_t *);
+ int (*handshake) (vlc_tls_t *, const char *host, const char *service);
+ void (*close) (vlc_tls_t *);
};
VLC_API vlc_tls_creds_t *vlc_tls_ClientCreate (vlc_object_t *);
* Terminates TLS session and releases session data.
* You still have to close the socket yourself.
*/
-static void gnutls_SessionClose (vlc_tls_creds_t *crd, vlc_tls_t *session)
+static void gnutls_SessionClose (vlc_tls_t *session)
{
vlc_tls_sys_t *sys = session->sys;
gnutls_deinit (sys->session);
free (sys);
- (void) crd;
}
session->sock.p_sys = session;
session->sock.pf_send = gnutls_Send;
session->sock.pf_recv = gnutls_Recv;
- if (type == GNUTLS_SERVER)
- session->handshake = gnutls_ContinueHandshake;
- else
- session->handshake = gnutls_HandshakeAndValidate;
sys->handshaked = false;
int val = gnutls_init (&sys->session, type);
return VLC_SUCCESS;
error:
- gnutls_SessionClose (crd, session);
+ gnutls_SessionClose (session);
return VLC_EGENERIC;
}
if (unlikely(sys == NULL))
goto error;
- crd->sys = sys;
- crd->open = gnutls_ServerSessionOpen;
- crd->close = gnutls_SessionClose;
-
/* Sets server's credentials */
val = gnutls_certificate_allocate_credentials (&sys->x509_cred);
if (val != 0)
gnutls_strerror (val));
}
+ crd->sys = sys;
+ crd->open = gnutls_ServerSessionOpen;
+ crd->handshake = gnutls_ContinueHandshake;
+ crd->close = gnutls_SessionClose;
+
return VLC_SUCCESS;
error:
if (unlikely(sys == NULL))
goto error;
- crd->sys = sys;
- crd->open = gnutls_ClientSessionOpen;
- crd->close = gnutls_SessionClose;
-
int val = gnutls_certificate_allocate_credentials (&sys->x509_cred);
if (val != 0)
{
gnutls_certificate_set_verify_flags (sys->x509_cred,
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT);
+ crd->sys = sys;
+ crd->open = gnutls_ClientSessionOpen;
+ crd->handshake = gnutls_HandshakeAndValidate;
+ crd->close = gnutls_SessionClose;
+
return VLC_SUCCESS;
error:
free (sys);
return NULL;
}
-void vlc_tls_SessionDelete (vlc_tls_t *session)
+int vlc_tls_SessionHandshake (vlc_tls_t *session, const char *host,
+ const char *service)
{
vlc_tls_creds_t *crd = (vlc_tls_creds_t *)(session->p_parent);
- crd->close (crd, session);
- vlc_object_release (session);
+ return crd->handshake (session, host, service);
}
-int vlc_tls_SessionHandshake (vlc_tls_t *session, const char *host,
- const char *service)
+void vlc_tls_SessionDelete (vlc_tls_t *session)
{
- return session->handshake (session, host, service);
+ vlc_tls_creds_t *crd = (vlc_tls_creds_t *)(session->p_parent);
+
+ crd->close (session);
+ vlc_object_release (session);
}
/**