vlc_tls.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_tls.h: Transport Layer Security API
00003  *****************************************************************************
00004  * Copyright (C) 2004-2011 Rémi Denis-Courmont
00005  * Copyright (C) 2005-2006 VLC authors and VideoLAN
00006  *
00007  * This program is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by
00009  * the Free Software Foundation; either version 2.1 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this program; if not, write to the Free Software Foundation,
00019  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00020  *****************************************************************************/
00021 
00022 #ifndef VLC_TLS_H
00023 # define VLC_TLS_H
00024 
00025 /**
00026  * \file
00027  * This file defines Transport Layer Security API (TLS) in vlc
00028  */
00029 
00030 # include <vlc_network.h>
00031 
00032 typedef struct vlc_tls_sys vlc_tls_sys_t;
00033 
00034 typedef struct vlc_tls
00035 {
00036     VLC_COMMON_MEMBERS
00037 
00038     union {
00039         module_t *module; /**< Plugin handle (client) */
00040         void    (*close) (struct vlc_tls *); /**< Close callback (server) */
00041     } u;
00042     vlc_tls_sys_t *sys;
00043 
00044     struct virtual_socket_t sock;
00045     int  (*handshake) (struct vlc_tls *);
00046 } vlc_tls_t;
00047 
00048 VLC_API vlc_tls_t *vlc_tls_ClientCreate (vlc_object_t *, int fd,
00049                                          const char *hostname);
00050 VLC_API void vlc_tls_ClientDelete (vlc_tls_t *);
00051 
00052 /* NOTE: It is assumed that a->sock.p_sys = a */
00053 # define tls_Send( a, b, c ) (((vlc_tls_t *)a)->sock.pf_send (a, b, c))
00054 
00055 # define tls_Recv( a, b, c ) (((vlc_tls_t *)a)->sock.pf_recv (a, b, c))
00056 
00057 
00058 typedef struct vlc_tls_creds_sys vlc_tls_creds_sys_t;
00059 
00060 /** TLS (server-side) credentials */
00061 typedef struct vlc_tls_creds
00062 {
00063     VLC_COMMON_MEMBERS
00064 
00065     module_t  *module;
00066     vlc_tls_creds_sys_t *sys;
00067 
00068     int (*add_CA) (struct vlc_tls_creds *, const char *path);
00069     int (*add_CRL) (struct vlc_tls_creds *, const char *path);
00070 
00071     vlc_tls_t *(*open) (struct vlc_tls_creds *, int fd);
00072 } vlc_tls_creds_t;
00073 
00074 vlc_tls_creds_t *vlc_tls_ServerCreate (vlc_object_t *,
00075                                        const char *cert, const char *key);
00076 void vlc_tls_ServerDelete (vlc_tls_creds_t *);
00077 int vlc_tls_ServerAddCA (vlc_tls_creds_t *srv, const char *path);
00078 int vlc_tls_ServerAddCRL (vlc_tls_creds_t *srv, const char *path);
00079 
00080 vlc_tls_t *vlc_tls_ServerSessionCreate (vlc_tls_creds_t *, int fd);
00081 int vlc_tls_ServerSessionHandshake (vlc_tls_t *);
00082 void vlc_tls_ServerSessionDelete (vlc_tls_t *);
00083 
00084 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines