Compat: relicense vasprintf, strlcpy and localtime_r to LGPL
[vlc.git] / include / vlc_tls.h
blob9889d24f243d9c1a8da02487ed06a6d74b9db9ea
1 /*****************************************************************************
2 * vlc_tls.h: Transport Layer Security API
3 *****************************************************************************
4 * Copyright (C) 2004-2011 RĂ©mi Denis-Courmont
5 * Copyright (C) 2005-2006 the VideoLAN team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20 *****************************************************************************/
22 #ifndef VLC_TLS_H
23 # define VLC_TLS_H
25 /**
26 * \file
27 * This file defines Transport Layer Security API (TLS) in vlc
30 # include <vlc_network.h>
32 typedef struct vlc_tls_sys vlc_tls_sys_t;
34 typedef struct vlc_tls
36 VLC_COMMON_MEMBERS
38 union {
39 module_t *module; /**< Plugin handle (client) */
40 void (*close) (struct vlc_tls *); /**< Close callback (server) */
41 } u;
42 vlc_tls_sys_t *sys;
44 struct virtual_socket_t sock;
45 int (*handshake) (struct vlc_tls *);
46 } vlc_tls_t;
48 VLC_API vlc_tls_t *vlc_tls_ClientCreate (vlc_object_t *, int fd,
49 const char *hostname);
50 VLC_API void vlc_tls_ClientDelete (vlc_tls_t *);
52 /* NOTE: It is assumed that a->sock.p_sys = a */
53 # define tls_Send( a, b, c ) (((vlc_tls_t *)a)->sock.pf_send (a, b, c))
55 # define tls_Recv( a, b, c ) (((vlc_tls_t *)a)->sock.pf_recv (a, b, c))
58 typedef struct vlc_tls_creds_sys vlc_tls_creds_sys_t;
60 /** TLS (server-side) credentials */
61 typedef struct vlc_tls_creds
63 VLC_COMMON_MEMBERS
65 module_t *module;
66 vlc_tls_creds_sys_t *sys;
68 int (*add_CA) (struct vlc_tls_creds *, const char *path);
69 int (*add_CRL) (struct vlc_tls_creds *, const char *path);
71 vlc_tls_t *(*open) (struct vlc_tls_creds *, int fd);
72 } vlc_tls_creds_t;
74 vlc_tls_creds_t *vlc_tls_ServerCreate (vlc_object_t *,
75 const char *cert, const char *key);
76 void vlc_tls_ServerDelete (vlc_tls_creds_t *);
77 int vlc_tls_ServerAddCA (vlc_tls_creds_t *srv, const char *path);
78 int vlc_tls_ServerAddCRL (vlc_tls_creds_t *srv, const char *path);
80 vlc_tls_t *vlc_tls_ServerSessionCreate (vlc_tls_creds_t *, int fd);
81 int vlc_tls_ServerSessionHandshake (vlc_tls_t *);
82 void vlc_tls_ServerSessionDelete (vlc_tls_t *);
84 #endif