00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef header_ssl_connection
00030 #define header_ssl_connection
00031
00032 #include <prio.h>
00033 #include <certt.h>
00034 #include <keyt.h>
00035 #include <ssl.h>
00036
00037 class CL_TCPConnection;
00038 class CL_PK11PasswordHandler;
00039
00040 class CL_SSLConnection
00041 {
00043 public:
00044 CL_SSLConnection(CL_TCPConnection *connection, CL_PK11PasswordHandler *handler);
00045
00046 ~CL_SSLConnection();
00047
00049 public:
00050
00052 public:
00053
00055 private:
00056 PRFileDesc *create_prfd();
00057
00058 PRFileDesc *ssl_fd;
00059
00060 CL_TCPConnection *connection;
00061
00062 CL_PK11PasswordHandler *password_handler;
00063
00064 static SECStatus auth_certificate(void *arg, PRFileDesc *ssl_fd, PRBool check_sig, PRBool is_server);
00065
00066 static SECStatus bad_certificate(void *arg, PRFileDesc *ssl_fd);
00067
00068 static SECStatus get_client_auth_data(
00069 void *arg,
00070 PRFileDesc *fd,
00071 CERTDistNames *ca_names,
00072 CERTCertificate **ret_cert,
00073 SECKEYPrivateKey **ret_key);
00074
00075 static void handshake_completed(PRFileDesc *ssl_fd, void *arg);
00076
00077 static void prfd_dtor(PRFileDesc *fd);
00078
00079 static PRStatus prfd_close(PRFileDesc *fd);
00080
00081 static PRInt32 prfd_read(PRFileDesc *fd, void *buf, PRInt32 amount);
00082
00083 static PRInt32 prfd_write(PRFileDesc *fd, const void *buf, PRInt32 amount);
00084
00085 static PRInt32 prfd_available(PRFileDesc *fd);
00086
00087 static PRInt64 prfd_available64(PRFileDesc *fd);
00088
00089 static PRStatus prfd_fsync(PRFileDesc *fd);
00090
00091 static PRInt32 prfd_seek(PRFileDesc *fd, PRInt32 offset, PRSeekWhence whence);
00092
00093 static PRInt64 prfd_seek64(PRFileDesc *fd, PRInt64 offset, PRSeekWhence whence);
00094
00095 static PRStatus prfd_file_info(PRFileDesc *fd, PRFileInfo *info);
00096
00097 static PRStatus prfd_file_info64(PRFileDesc *fd, PRFileInfo64 *info64);
00098
00099 static PRInt32 prfd_writev(PRFileDesc *fd, const PRIOVec *iov, PRInt32 size, PRIntervalTime timeout);
00100
00101 static PRStatus prfd_connect(PRFileDesc *fd, const PRNetAddr *addr, PRIntervalTime timeout);
00102
00103 static PRFileDesc *prfd_accept(PRFileDesc *fd, PRNetAddr *addr, PRIntervalTime timeout);
00104
00105 static PRStatus prfd_bind(PRFileDesc *fd, const PRNetAddr *addr);
00106
00107 static PRStatus prfd_listen(PRFileDesc *fd, PRIntn backlog);
00108
00109 static PRStatus prfd_shutdown(PRFileDesc *fd, PRIntn how);
00110
00111 static PRInt32 prfd_recv(
00112 PRFileDesc *fd,
00113 void *buf,
00114 PRInt32 amount,
00115 PRIntn flags,
00116 PRIntervalTime timeout);
00117
00118 static PRInt32 prfd_send(
00119 PRFileDesc *fd,
00120 const void *buf,
00121 PRInt32 amount,
00122 PRIntn flags,
00123 PRIntervalTime timeout);
00124
00125 static PRInt32 prfd_recvfrom(
00126 PRFileDesc *fd,
00127 void *buf,
00128 PRInt32 amount,
00129 PRIntn flags,
00130 PRNetAddr *addr,
00131 PRIntervalTime timeout);
00132
00133 static PRInt32 prfd_sendto(
00134 PRFileDesc *fd,
00135 const void *buf,
00136 PRInt32 amount,
00137 PRIntn flags,
00138 const PRNetAddr *addr,
00139 PRIntervalTime timeout);
00140
00141 static PRInt16 prfd_poll(PRFileDesc *fd, PRInt16 in_flags, PRInt16 *out_flags);
00142
00143 static PRInt32 prfd_acceptread(
00144 PRFileDesc *listen_sock,
00145 PRFileDesc **accepted_sock,
00146 PRNetAddr **peer_addr,
00147 void *buf,
00148 PRInt32 amount,
00149 PRIntervalTime timeout);
00150
00151 static PRInt32 prfd_transmitfile(
00152 PRFileDesc *network_socket,
00153 PRFileDesc *source_file,
00154 const void *headers,
00155 PRInt32 hlen,
00156 PRTransmitFileFlags flags,
00157 PRIntervalTime timeout);
00158
00159 static PRStatus prfd_getsockname(PRFileDesc *fd, PRNetAddr *addr);
00160
00161 static PRStatus prfd_getpeername(PRFileDesc *fd, PRNetAddr *addr);
00162
00163 static PRStatus prfd_getsockopt(PRFileDesc *fd, PRSocketOptionData *data);
00164
00165 static PRStatus prfd_setsockopt(PRFileDesc *fd, const PRSocketOptionData *data);
00166
00167 static PRInt32 prfd_sendfile(
00168 PRFileDesc *network_socket,
00169 PRSendFileData *send_data,
00170 PRTransmitFileFlags flags,
00171 PRIntervalTime timeout);
00172
00173 static PRStatus prfd_connectcontinue(PRFileDesc *fd, PRInt16 out_flags);
00174
00175 static PRIntn prfd_reserved(PRFileDesc *fd);
00176
00177 static PRIOMethods methods;
00178 };
00179
00180 #endif