ssl_connection.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2005 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00029 #pragma once
00030 
00033 
00034 #include <prio.h>
00035 #include <certt.h>
00036 #include <keyt.h>
00037 #include <ssl.h>
00038 
00039 class CL_TCPConnection;
00040 class CL_PK11PasswordHandler;
00041 
00045 class CL_SSLConnection
00046 {
00049 
00050 public:
00051 
00056         CL_SSLConnection(CL_TCPConnection *connection, CL_PK11PasswordHandler *handler);
00057 
00058         ~CL_SSLConnection();
00059 
00063 
00064 public:
00065 
00069 
00070 public:
00071 
00075 
00076 private:
00077 
00081         PRFileDesc *create_prfd();
00082 
00083         PRFileDesc *ssl_fd;
00084 
00085         CL_TCPConnection *connection;
00086 
00087         CL_PK11PasswordHandler *password_handler;
00088 
00097         static SECStatus auth_certificate(void *arg, PRFileDesc *ssl_fd, PRBool check_sig, PRBool is_server);
00098 
00105         static SECStatus bad_certificate(void *arg, PRFileDesc *ssl_fd);
00106 
00107         static SECStatus get_client_auth_data(
00108                 void *arg,
00109                 PRFileDesc *fd,
00110                 CERTDistNames *ca_names,
00111                 CERTCertificate **ret_cert,
00112                 SECKEYPrivateKey **ret_key);
00113 
00118         static void handshake_completed(PRFileDesc *ssl_fd, void *arg);
00119 
00123         static void prfd_dtor(PRFileDesc *fd);
00124 
00130         static PRStatus prfd_close(PRFileDesc *fd);
00131 
00139         static PRInt32 prfd_read(PRFileDesc *fd, void *buf, PRInt32 amount);
00140 
00148         static PRInt32 prfd_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
00149 
00155         static PRInt32 prfd_available(PRFileDesc *fd);
00156 
00162         static PRInt64 prfd_available64(PRFileDesc *fd);
00163 
00169         static PRStatus prfd_fsync(PRFileDesc *fd);
00170 
00178         static PRInt32 prfd_seek(PRFileDesc *fd, PRInt32 offset, PRSeekWhence whence);
00179 
00187         static PRInt64 prfd_seek64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence);
00188 
00195         static PRStatus prfd_file_info(PRFileDesc *fd, PRFileInfo *info);
00196 
00203         static PRStatus prfd_file_info64(PRFileDesc *fd, PRFileInfo64 *info64);
00204 
00213         static PRInt32 prfd_writev(PRFileDesc *fd, const PRIOVec *iov, PRInt32 size, PRIntervalTime timeout);
00214 
00222         static PRStatus prfd_connect(PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout);
00223 
00231         static PRFileDesc *prfd_accept(PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout);
00232 
00239         static PRStatus prfd_bind(PRFileDesc *fd, const PRNetAddr *addr);
00240 
00247         static PRStatus prfd_listen(PRFileDesc *fd, PRIntn backlog);
00248 
00255         static PRStatus prfd_shutdown(PRFileDesc *fd, /*PRShutdownHow*/ PRIntn how);
00256 
00257         static PRInt32 prfd_recv(
00258                 PRFileDesc *fd,
00259                 void *buf,
00260                 PRInt32 amount,
00261                 PRIntn flags,
00262                 PRIntervalTime timeout);
00263 
00264         static PRInt32 prfd_send(
00265                 PRFileDesc *fd,
00266                 const void *buf,
00267                 PRInt32 amount,
00268                 PRIntn flags,
00269                 PRIntervalTime timeout);
00270 
00271         static PRInt32 prfd_recvfrom(
00272                 PRFileDesc *fd,
00273                 void *buf,
00274                 PRInt32 amount,
00275                 PRIntn flags,
00276                 PRNetAddr *addr,
00277                 PRIntervalTime timeout);
00278 
00279         static PRInt32 prfd_sendto(
00280                 PRFileDesc *fd,
00281                 const void *buf,
00282                 PRInt32 amount,
00283                 PRIntn flags,
00284                 const PRNetAddr *addr,
00285                 PRIntervalTime timeout);
00286 
00294         static PRInt16 prfd_poll(PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags);
00295 
00296         static PRInt32 prfd_acceptread(
00297                 PRFileDesc *listen_sock,
00298                 PRFileDesc **accepted_sock,
00299                 PRNetAddr **peer_addr,
00300                 void *buf,
00301                 PRInt32 amount,
00302                 PRIntervalTime timeout);
00303 
00304         static PRInt32 prfd_transmitfile(
00305                 PRFileDesc *network_socket,
00306                 PRFileDesc *source_file,
00307                 const void *headers,
00308                 PRInt32 hlen,
00309                 PRTransmitFileFlags flags,
00310                 PRIntervalTime timeout);
00311 
00318         static PRStatus prfd_getsockname(PRFileDesc *fd, PRNetAddr *addr);
00319 
00326         static PRStatus prfd_getpeername(PRFileDesc *fd, PRNetAddr *addr);
00327 
00334         static PRStatus prfd_getsockopt(PRFileDesc *fd, PRSocketOptionData *data);
00335 
00342         static PRStatus prfd_setsockopt(PRFileDesc *fd, const PRSocketOptionData *data);
00343 
00344         static PRInt32 prfd_sendfile(
00345                 PRFileDesc *network_socket,
00346                 PRSendFileData *send_data,
00347                 PRTransmitFileFlags flags,
00348                 PRIntervalTime timeout);
00349 
00356         static PRStatus prfd_connectcontinue(PRFileDesc *fd, PRInt16 out_flags);
00357 
00363         static PRIntn prfd_reserved(PRFileDesc *fd);
00364 
00365         static PRIOMethods methods;
00367 };
00368 

Generated on Thu Dec 3 02:39:32 2009 for ClanLib by  doxygen 1.4.6