Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vlc_tls.h

00001 /*****************************************************************************
00002  * tls.c
00003  *****************************************************************************
00004  * Copyright (C) 2004-2005 the VideoLAN team
00005  * $Id: vlc_tls.h 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Remi Denis-Courmont <rem # videolan.org>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef _VLC_TLS_H
00025 # define _VLC_TLS_H
00026 
00027 # include "network.h"
00028 
00029 struct tls_t
00030 {
00031     VLC_COMMON_MEMBERS
00032 
00033     /* Module properties */
00034     module_t  *p_module;
00035     void *p_sys;
00036 
00037     tls_server_t * (*pf_server_create) ( tls_t *, const char *,
00038                                          const char * );
00039     tls_session_t * (*pf_client_create) ( tls_t * );
00040 };
00041 
00042 struct tls_server_t
00043 {
00044     VLC_COMMON_MEMBERS
00045 
00046     void *p_sys;
00047 
00048     void (*pf_delete) ( tls_server_t * );
00049     
00050     int (*pf_add_CA) ( tls_server_t *, const char * );
00051     int (*pf_add_CRL) ( tls_server_t *, const char * );
00052     
00053     tls_session_t * (*pf_session_prepare) ( tls_server_t * );
00054 };
00055 
00056 struct tls_session_t
00057 {
00058     VLC_COMMON_MEMBERS
00059 
00060     void *p_sys;
00061 
00062     struct virtual_socket_t sock;
00063     int (*pf_handshake) ( tls_session_t *, int, const char * );
00064     int (*pf_handshake2) ( tls_session_t * );
00065     void (*pf_close) ( tls_session_t * );
00066 };
00067 
00068 
00069 /*****************************************************************************
00070  * tls_ServerCreate:
00071  *****************************************************************************
00072  * Allocates a whole server's TLS credentials.
00073  * Returns NULL on error.
00074  *****************************************************************************/
00075 VLC_EXPORT( tls_server_t *, tls_ServerCreate, ( vlc_object_t *, const char *, const char * ) );
00076 
00077 /*****************************************************************************
00078  * tls_ServerAddCA:
00079  *****************************************************************************
00080  * Adds one or more certificate authorities.
00081  * Returns -1 on error, 0 on success.
00082  *****************************************************************************/
00083 # define tls_ServerAddCA( a, b ) (((tls_server_t *)a)->pf_add_CA (a, b))
00084 
00085 
00086 /*****************************************************************************
00087  * tls_ServerAddCRL:
00088  *****************************************************************************
00089  * Adds a certificates revocation list to be sent to TLS clients.
00090  * Returns -1 on error, 0 on success.
00091  *****************************************************************************/
00092 # define tls_ServerAddCRL( a, b ) (((tls_server_t *)a)->pf_add_CRL (a, b))
00093 
00094 
00095 VLC_EXPORT( void, tls_ServerDelete, ( tls_server_t * ) );
00096 
00097 
00098 # define tls_ServerSessionPrepare( a ) (((tls_server_t *)a)->pf_session_prepare (a))
00099 # define tls_ServerSessionHandshake( a, b ) (((tls_session_t *)a)->pf_handshake (a, b, NULL))
00100 # define tls_ServerSessionClose( a ) (((tls_session_t *)a)->pf_close (a))
00101 
00102 VLC_EXPORT( tls_session_t *, tls_ClientCreate, ( vlc_object_t *, int, const char * ) );
00103 VLC_EXPORT( void, tls_ClientDelete, ( tls_session_t * ) );
00104 
00105 # define tls_ClientSessionHandshake( a, b, c ) (((tls_session_t *)a)->pf_handshake (a, b, c))
00106 
00107 # define tls_SessionContinueHandshake( a ) (((tls_session_t *)a)->pf_handshake2 (a))
00108 
00109 
00110 /* NOTE: It is assumed that a->sock.p_sys = a */
00111 # define tls_Send( a, b, c ) (((tls_session_t *)a)->sock.pf_send (a, b, c ))
00112 
00113 # define tls_Recv( a, b, c ) (((tls_session_t *)a)->sock.pf_recv (a, b, c ))
00114 
00115 #endif

Generated on Tue Dec 20 10:14:19 2005 for vlc-0.8.4a by  doxygen 1.4.2