vlc_tls.h 2.61 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

27 28 29 30 31
/**
 * \file
 * This file defines Transport Layer Security API (TLS) in vlc
 */

Clément Stenac's avatar
Clément Stenac committed
32
# include <vlc_network.h>
33

34
typedef struct tls_server_sys_t tls_server_sys_t;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
35 36 37

struct tls_server_t
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
38 39
    VLC_COMMON_MEMBERS

40 41
    module_t  *p_module;
    tls_server_sys_t *p_sys;
42

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
43 44
    int (*pf_add_CA) ( tls_server_t *, const char * );
    int (*pf_add_CRL) ( tls_server_t *, const char * );
45

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
46 47
    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
48 49
};

50 51
typedef struct tls_session_sys_t tls_session_sys_t;

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
52 53
struct tls_session_t
{
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
54
    VLC_COMMON_MEMBERS
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
55

56 57
    module_t  *p_module;
    tls_session_sys_t *p_sys;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
58

59
    struct virtual_socket_t sock;
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
60 61
    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
62 63
};

64

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
65 66 67 68
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);
69

70 71 72
tls_session_t *tls_ServerSessionCreate (tls_server_t *, int fd);
int tls_ServerSessionHandshake (tls_session_t *);
void tls_ServerSessionDelete (tls_session_t *);
73

74 75
VLC_API tls_session_t * tls_ClientCreate( vlc_object_t *, int, const char * );
VLC_API void tls_ClientDelete( tls_session_t * );
76

77 78
/* 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 ))
79

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

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