video_filter: erase: use C99 loop declarations
[vlc.git] / include / vlc_tls.h
blobd66809887921b08742b6ade0ba5ed13644ee0432
1 /*****************************************************************************
2 * vlc_tls.h: Transport Layer Security API
3 *****************************************************************************
4 * Copyright (C) 2004-2011 RĂ©mi Denis-Courmont
5 * Copyright (C) 2005-2006 VLC authors and VideoLAN
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * 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 vlc_tls_t;
33 typedef struct vlc_tls_creds vlc_tls_creds_t;
35 /** TLS session */
36 struct vlc_tls
38 VLC_COMMON_MEMBERS
40 void *sys;
41 int fd;
43 struct virtual_socket_t sock;
46 VLC_API vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *, int fd,
47 const char *host, const char *service,
48 const char *const *alpn, char **alp);
49 vlc_tls_t *vlc_tls_SessionCreate (vlc_tls_creds_t *, int fd, const char *host,
50 const char *const *alpn);
51 int vlc_tls_SessionHandshake (vlc_tls_t *, const char *host, const char *serv,
52 char ** /*restrict*/ alp);
53 VLC_API void vlc_tls_SessionDelete (vlc_tls_t *);
55 VLC_API int vlc_tls_Read(vlc_tls_t *, void *buf, size_t len, bool waitall);
56 VLC_API char *vlc_tls_GetLine(vlc_tls_t *);
57 VLC_API int vlc_tls_Write(vlc_tls_t *, const void *buf, size_t len);
59 # define tls_Recv(a,b,c) vlc_tls_Read(a,b,c,false)
60 # define tls_Send(a,b,c) vlc_tls_Write(a,b,c)
62 /** TLS credentials (certificate, private and trust settings) */
63 struct vlc_tls_creds
65 VLC_COMMON_MEMBERS
67 module_t *module;
68 void *sys;
70 int (*open) (vlc_tls_creds_t *, vlc_tls_t *, int fd, const char *host,
71 const char *const *alpn);
72 int (*handshake) (vlc_tls_t *, const char *host, const char *service,
73 char ** /*restrict*/ alp);
74 void (*close) (vlc_tls_t *);
77 VLC_API vlc_tls_creds_t *vlc_tls_ClientCreate (vlc_object_t *);
78 vlc_tls_creds_t *vlc_tls_ServerCreate (vlc_object_t *,
79 const char *cert, const char *key);
80 VLC_API void vlc_tls_Delete (vlc_tls_creds_t *);
82 #endif