debian/tmp/usr/include/conexus-0.5/conexus/nspr_socket.h

00001 /***************************************************************************
00002 *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003 *   rvinyard@cs.nmsu.edu                                                  *
00004 *                                                                         *
00005 *   This program is free software; you can redistribute it and/or modify  *
00006 *   it under the terms of the GNU Lesser General Public License as        *
00007 *   published by the Free Software Foundation version 2.1.                *
00008 *                                                                         *
00009 *   This program is distributed in the hope that it will be useful,       *
00010 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012 *   GNU General Public License for more details.                          *
00013 *                                                                         *
00014 *   You should have received a copy of the GNU Lesser General Public      *
00015 *   License along with this library; if not, write to the                 *
00016 *   Free Software Foundation, Inc.,                                       *
00017 *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018 ***************************************************************************/
00019 #ifndef CONEXUSNSPRSOCKET_H
00020 #define CONEXUSNSPRSOCKET_H
00021 
00022 #include <sys/types.h>
00023 
00024 #include <iostream>
00025 
00026 #include <utility>
00027 
00028 #include <conexus/nspr_filedescriptor.h>
00029 #include <conexus/ipv4_address.h>
00030 #include <conexus/except.h>
00031 
00032 #include <pk11func.h>
00033 #include <secitem.h>
00034 #include <ssl.h>
00035 #include <certt.h>
00036 #include <nss.h>
00037 #include <secder.h>
00038 #include <key.h>
00039 #include <sslproto.h>
00040 
00045 namespace Conexus
00046 {
00047 
00048   namespace NSPR
00049   {
00050 
00063     class Socket: public FileDescriptor
00064     {
00065       public:
00066 
00070         Socket( ) throw ();
00071 
00072         virtual ~Socket() throw ();
00073 
00078         virtual void close( bool force = false ) throw ( close_exception );
00079 
00085         virtual void bind() throw ( bind_exception );
00086 
00094         virtual void bind( Conexus::Address& a ) throw ( bind_exception );
00095 
00101         virtual void connect() throw ( connect_exception );
00102 
00110         virtual void connect( Address& a ) throw ( connect_exception );
00111 
00119         virtual void listen( int backlog = 0 );
00120 
00121 //         virtual Data::pointer read( size_t s = 0 ) throw ( read_exception );
00122 
00123 //         virtual ssize_t write( const void* data, size_t size, IOMethod block = BLOCK ) throw ( write_exception );
00124         virtual ssize_t writeto( Address& a, const void* data, size_t size ) throw ( write_exception );
00125 
00126 
00127         virtual void set_option( PRSocketOptionData& option );
00128 
00129         virtual void change_state( long states ) throw ( state_exception );
00130 
00131         sigc::signal<void> signal_bound();
00132 
00133         sigc::signal<void> signal_connected();
00134 
00135         sigc::signal<void> signal_listening();
00136 
00137         bool is_bound();
00138 
00139         bool is_connected();
00140 
00141         bool is_listening();
00142 
00143         bool is_accepted();
00144 
00145         void enable_ssl(bool as_server);
00146 
00147         void set_ssl_url(const std::string& url);
00148 
00149         std::string ssl_get_url();
00150 
00151         void ssl_force_handshake();
00152 
00153         void ssl_rehandshake( bool flush_cache );
00154 
00155         void ssl_reset_handshake();
00156 
00157         void ssl_invalidate_session();
00158 
00159         int ssl_input_available();
00160 
00167         int ssl_security_status();
00168 
00169         std::string ssl_cipher();
00170 
00171         int ssl_session_key_size();
00172 
00173         int ssl_secret_key_size();
00174 
00175         std::string ssl_issuer();
00176 
00177         std::string ssl_subject();
00178 
00179         virtual Conexus::IPv4::Address& local_interface();
00180 
00181         virtual Conexus::IPv4::Address& remote_address();
00182 
00183         virtual void set_remote_address(Conexus::IPv4::Address addr);
00184 
00185         virtual void unset_remote_address();
00186 
00187         virtual void set_local_interface(Conexus::IPv4::Address addr);
00188 
00189         virtual const std::string& object_type()
00190         {
00191           static std::string s( "Conexus::NSPR::Socket" );
00192           return s;
00193         }
00194 
00195       protected:
00196         Conexus::IPv4::Address m_local_interface;
00197         Conexus::IPv4::Address m_remote_address;
00198         bool m_ssl_enabled;
00199         bool m_ssl_server;
00200 
00201 //         virtual void read_thread_main();
00202 
00203         virtual void set_state_closed();
00204         virtual void set_state_bound();
00205         virtual void set_state_connected();
00206         virtual void set_state_listening();
00207 
00208         sigc::signal<void> m_signal_bound;
00209         sigc::signal<void> m_signal_connected;
00210         sigc::signal<void> m_signal_listening;
00211 
00212         char * on_ssl_pkcs11_password(PK11SlotInfo *info, PRBool retry);
00213 
00214         virtual SECStatus on_ssl_certificate_authenticate(PRBool checksig, PRBool isServer);
00215 
00216         virtual SECStatus on_ssl_bad_certificate();
00217 
00218         virtual SECStatus on_ssl_handshake();
00219 
00220         virtual SECStatus on_ssl_client_authenticate( struct CERTDistNamesStr *caNames,
00221             struct CERTCertificateStr **pRetCert,
00222             struct SECKEYPrivateKeyStr **pRetKey);
00223 
00224       private:
00225         static char * SSL_SetPKCS11PinArg_proxy(PK11SlotInfo *info, PRBool retry, void *arg);
00226 
00227         static SECStatus SSL_AuthCertificateHook_proxy(void *arg, PRFileDesc *socket,
00228                                     PRBool checksig, PRBool isServer);
00229 
00230         static SECStatus SSL_BadCertHook_proxy(void *arg, PRFileDesc *socket);
00231 
00232         static SECStatus SSL_HandshakeCallback_proxy(PRFileDesc *socket, void *arg);
00233 
00234         static SECStatus SSL_GetClientAuthDataHook_proxy(void *arg, PRFileDesc *socket,
00235                                       struct CERTDistNamesStr *caNames,
00236                                       struct CERTCertificateStr **pRetCert,
00237                                       struct SECKEYPrivateKeyStr **pRetKey);
00238 
00239     };
00240 
00241   }
00242 }
00243 
00244 #endif

Generated on Tue Mar 13 19:54:48 2007 by  doxygen 1.5.1