vlc_tls.h 2.6 KB
Newer Older
1
/*****************************************************************************
2
 * tls.c: Transport Layer Security API
3
 *****************************************************************************
4
 * Copyright (C) 2004-2007 the VideoLAN team
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
5
 * $Id$
6
 *
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
7
 * Authors: Rémi Denis-Courmont <rem # videolan.org>
8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
Antoine Cellerier's avatar
Antoine Cellerier committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 23
 *****************************************************************************/

24 25
#ifndef VLC_TLS_H
# define VLC_TLS_H
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
26

Clément Stenac's avatar
Clément Stenac committed
27
# include <vlc_network.h>
28

29
typedef struct tls_server_sys_t tls_server_sys_t;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
30 31 32

struct tls_server_t
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
33 34
    VLC_COMMON_MEMBERS

35 36
    module_t  *p_module;
    tls_server_sys_t *p_sys;
37

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
38 39
    int (*pf_add_CA) ( tls_server_t *, const char * );
    int (*pf_add_CRL) ( tls_server_t *, const char * );
40

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
41 42
    tls_session_t * (*pf_open)  ( tls_server_t * );
    void            (*pf_close) ( tls_server_t *, tls_session_t * );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
43 44
};

45 46
typedef struct tls_session_sys_t tls_session_sys_t;

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
47 48
struct tls_session_t
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
49
    VLC_COMMON_MEMBERS
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
50

51 52
    module_t  *p_module;
    tls_session_sys_t *p_sys;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
53

54
    struct virtual_socket_t sock;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
55 56
    void (*pf_set_fd) ( tls_session_t *, int );
    int  (*pf_handshake) ( tls_session_t * );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
57 58
};

59

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
60 61 62 63
tls_server_t *tls_ServerCreate (vlc_object_t *, const char *, const char *);
void tls_ServerDelete (tls_server_t *);
int tls_ServerAddCA (tls_server_t *srv, const char *path);
int tls_ServerAddCRL (tls_server_t *srv, const char *path);
64

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
65 66 67 68
tls_session_t *tls_ServerSessionPrepare (tls_server_t *);
int tls_ServerSessionHandshake (tls_session_t *, int fd);
int tls_SessionContinueHandshake (tls_session_t *);
void tls_ServerSessionClose (tls_session_t *);
69

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
70
VLC_EXPORT( tls_session_t *, tls_ClientCreate, ( vlc_object_t *, int, const char * ) );
71 72
VLC_EXPORT( void, tls_ClientDelete, ( tls_session_t * ) );

73 74
/* 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 ))
75

76
# define tls_Recv( a, b, c ) (((tls_session_t *)a)->sock.pf_recv (a, b, c ))
77

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
78
#endif