diff options
Diffstat (limited to 'ace/SSL')
-rw-r--r-- | ace/SSL/SSL_Context.cpp | 245 | ||||
-rw-r--r-- | ace/SSL/SSL_Context.h | 188 | ||||
-rw-r--r-- | ace/SSL/SSL_Context.i | 87 | ||||
-rw-r--r-- | ace/SSL/SSL_Context.inl | 87 | ||||
-rw-r--r-- | ace/SSL/SSL_Export.h | 36 | ||||
-rw-r--r-- | ace/SSL/SSL_SOCK_Acceptor.cpp | 258 | ||||
-rw-r--r-- | ace/SSL/SSL_SOCK_Acceptor.h | 156 | ||||
-rw-r--r-- | ace/SSL/SSL_SOCK_Acceptor.i | 113 | ||||
-rw-r--r-- | ace/SSL/SSL_SOCK_Connector.cpp | 318 | ||||
-rw-r--r-- | ace/SSL/SSL_SOCK_Connector.h | 195 | ||||
-rw-r--r-- | ace/SSL/SSL_SOCK_Connector.i | 33 | ||||
-rw-r--r-- | ace/SSL/SSL_SOCK_Stream.cpp | 546 | ||||
-rw-r--r-- | ace/SSL/SSL_SOCK_Stream.h | 263 | ||||
-rw-r--r-- | ace/SSL/SSL_SOCK_Stream.i | 238 | ||||
-rw-r--r-- | ace/SSL/sslconf.h | 37 |
15 files changed, 0 insertions, 2800 deletions
diff --git a/ace/SSL/SSL_Context.cpp b/ace/SSL/SSL_Context.cpp deleted file mode 100644 index 6c45b938c69..00000000000 --- a/ace/SSL/SSL_Context.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// SSL_Context.cpp -// -// = AUTHOR -// Chris Zimman -// Carlos O'Ryan <coryan@cs.wustl.edu> -// Ossama Othman <othman@cs.wustl.edu> -// -// ============================================================================ - -#if defined (ACE_HAS_SSL) - -#include "SSL_Context.h" -#include "sslconf.h" - -#if !defined(__ACE_INLINE__) -#include "SSL_Context.i" -#endif /* __ACE_INLINE__ */ - -#include "ace/Synch.h" -#include "ace/Object_Manager.h" - -#include <openssl/x509.h> -#include <openssl/err.h> - -int ACE_SSL_Context::library_init_count_ = 0; - -ACE_SSL_Context::ACE_SSL_Context () - : context_ (0), - mode_ (-1), - default_verify_mode_ (SSL_VERIFY_NONE) -{ - ACE_SSL_Context::ssl_library_init (); -} - -ACE_SSL_Context::~ACE_SSL_Context () -{ - if (this->context_) - { - ::SSL_CTX_free(this->context_); - this->context_ = 0; - } - ACE_SSL_Context::ssl_library_fini (); -} - -void -ACE_SSL_Context::ssl_library_init () -{ - ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, - ace_ssl_mon, - *ACE_Static_Object_Lock::instance ())); - - if (ACE_SSL_Context::library_init_count_ == 0) - { - ::SSL_library_init (); - ::SSL_load_error_strings (); - ::SSLeay_add_ssl_algorithms (); - } - ACE_SSL_Context::library_init_count_++; -} - -void -ACE_SSL_Context::ssl_library_fini () -{ - ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, - ace_ssl_mon, - *ACE_Static_Object_Lock::instance ())); - - ACE_SSL_Context::library_init_count_--; - if (ACE_SSL_Context::library_init_count_ == 0) - { - // @@ What should we do here??? - } -} - -int -ACE_SSL_Context::set_mode (int mode) -{ - if (this->context_ != 0) - return -1; - - SSL_METHOD *method = 0; - - switch (mode) - { - case ACE_SSL_Context::SSLv2_client: - method = ::SSLv2_client_method (); - break; - case ACE_SSL_Context::SSLv2_server: - method = ::SSLv2_server_method (); - break; - case ACE_SSL_Context::SSLv2: - method = ::SSLv2_method (); - break; - case ACE_SSL_Context::SSLv3_client: - method = ::SSLv3_client_method (); - break; - case ACE_SSL_Context::SSLv3_server: - method = ::SSLv3_server_method (); - break; - case ACE_SSL_Context::SSLv3: - method = ::SSLv3_method (); - break; - case ACE_SSL_Context::SSLv23_client: - method = ::SSLv23_client_method (); - break; - case ACE_SSL_Context::SSLv23_server: - method = ::SSLv23_server_method (); - break; - case ACE_SSL_Context::SSLv23: - method = ::SSLv23_method (); - break; - case ACE_SSL_Context::TLSv1_client: - method = ::TLSv1_client_method (); - break; - case ACE_SSL_Context::TLSv1_server: - method = ::TLSv1_server_method (); - break; - case ACE_SSL_Context::TLSv1: - method = ::TLSv1_method (); - break; - default: - method = ::SSLv3_method (); - break; - } - - this->context_ = ::SSL_CTX_new (method); - if (this->context_ == 0) - { - ::ERR_print_errors_fp (stderr); - return -1; - } - - this->mode_ = mode; - - const char *cert_file = ACE_OS::getenv (ACE_SSL_CERT_FILE_ENV); - if (cert_file == 0) - cert_file = ACE_DEFAULT_SSL_CERT_FILE; - const char *cert_dir = ACE_OS::getenv (ACE_SSL_CERT_DIR_ENV); - if (cert_dir == 0) - cert_dir = ACE_DEFAULT_SSL_CERT_DIR; - - ::SSL_CTX_load_verify_locations (this->context_, - cert_file, - cert_dir); - ::ERR_print_errors_fp (stderr); - - if (this->certificate_.type () != -1 - && ::SSL_CTX_use_certificate_file (this->context_, - this->certificate_.file_name (), - this->certificate_.type ()) <= 0) - { - // ERR_print_errors_fp (stderr); - return -1; - } - if (this->private_key_.type () != -1 - && SSL_CTX_use_PrivateKey_file (this->context_, - this->private_key_.file_name (), - this->private_key_.type ()) <= 0) - { - // ERR_print_errors_fp (stderr); - return -1; - } - - if (!::SSL_CTX_check_private_key (this->context_)) - { - // ACE_ERROR ((LM_ERROR, "Mismatch in key/certificate\n")); - return -1; - } - return 0; -} - -int -ACE_SSL_Context::get_mode (void) const -{ - return this->mode_; -} - -int -ACE_SSL_Context::private_key (const char *file_name, - int type) -{ - if (this->private_key_.type () != -1) - return 0; - - this->private_key_ = ACE_SSL_Data_File (file_name, type); - - if (this->context_ == 0) - return 0; - - int status = - ::SSL_CTX_use_PrivateKey_file (this->context_, - this->private_key_.file_name (), - this->private_key_.type ()); - return status; -} - -int -ACE_SSL_Context::verify_private_key (void) -{ - this->check_context (); - - return ::SSL_CTX_check_private_key (this->context_); -} - -int -ACE_SSL_Context::certificate (const char *file_name, - int type) -{ - if (this->certificate_.type () != -1) - return 0; - - this->certificate_ = ACE_SSL_Data_File (file_name, type); - - if (this->context_ == 0) - return 0; - - int status = - ::SSL_CTX_use_certificate_file (this->context_, - this->certificate_.file_name (), - this->certificate_.type ()); - return status; -} - -// **************************************************************** - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class ACE_Singleton<ACE_SSL_Context,ACE_SYNCH_MUTEX>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate ACE_Singleton<ACE_SSL_Context,ACE_SYNCH_MUTEX> - -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/SSL_Context.h b/ace/SSL/SSL_Context.h deleted file mode 100644 index 7aaeb6bf54e..00000000000 --- a/ace/SSL/SSL_Context.h +++ /dev/null @@ -1,188 +0,0 @@ -// -*- C++ -*- -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// SSL_Context.h -// -// = AUTHOR -// Carlos O'Ryan <coryan@cs.wustl.edu> -// -// ============================================================================ - -#ifndef ACE_SSL_CONTEXT_H -#define ACE_SSL_CONTEXT_H - -#include "ace/SString.h" - -#if defined (ACE_HAS_SSL) - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "ace/Singleton.h" -#include "ace/Synch.h" - -#include <openssl/ssl.h> - -#include "SSL_Export.h" - -class ACE_SSL_Export ACE_SSL_Data_File -{ -public: - ACE_SSL_Data_File (); - // Default constructor - - ACE_SSL_Data_File (const char *file_name, - int type = SSL_FILETYPE_PEM); - // Contructor from a file name and the file type. - - // Default dtor, cpy ctor and operator= - - const char *file_name (void) const; - // The file name - - int type (void) const; - // The type - -private: - ACE_CString file_name_; - // The file name - - int type_; - // The type, used by the SSL library to parse the file contents. -}; - -// **************************************************************** - -class ACE_SSL_Export ACE_SSL_Context -{ - // = TITLE - // A wrapper for the ACE_SSL_Context class. - // - // = DESCRIPTION - // This class provides a wrapper for the SSL_CTX data structure. - // Since most applications have a single SSL_CTX structure, this - // class can be used as a singleton. - -public: - - enum { - INVALID_METHOD = -1, - SSLv2_client = 1, - SSLv2_server, - SSLv2, - SSLv3_client, - SSLv3_server, - SSLv3, - SSLv23_client, - SSLv23_server, - SSLv23, - TLSv1_client, - TLSv1_server, - TLSv1 - }; - - ACE_SSL_Context (); - // Constructor - - ~ACE_SSL_Context (void); - // Destructor - - static ACE_SSL_Context *instance (void); - // The Singleton context, the SSL components use the singleton if - // nothing else is available. - - int set_mode (int mode = ACE_SSL_Context::SSLv3); - // Set the CTX mode. The mode can be set only once, afterwards the - // function has no effect and returns -1. - // Once the mode is set the underlying SSL_CTX is initialized and - // the class can be used. - // If the mode is not set, the the class automatically initializes - // itself to the default mode. - - int get_mode (void) const; - // @@ John, you need to document each function or at least each - // group of functions. Also remember to follow the ACE guidelines, - // this includes: - // - a space between the function name and the '(' starting its - // argument list. - // - a single space after the return value - // - Using const where appropriate - // - // You may not like the style (i don't) but it is more important - // that we all use the same than keeping each one of us happy. - - SSL_CTX *context (void); - // Get the SSL context - - int private_key_type (void) const; - const char *private_key_file_name (void) const; - // Get the file name and file format used for the private key - - int private_key (const char *file_name, - int type = SSL_FILETYPE_PEM); - // Set the private key file. - - int verify_private_key (void); - // Verify if the private key is valid - - int certificate_type (void) const; - const char *certificate_file_name (void) const; - // Get the file name and file format used for the certificate file - - int certificate (const char *file_name, - int type = SSL_FILETYPE_PEM); - // Set the certificate file. - - void default_verify_mode (int mode); - int default_verify_mode (void) const; - // Set and query the default verify mode for this context, it is - // inherited by all the ACE_SSL objects created using the context. - // It can be overriden on a per-ACE_SSL object. - -private: - void check_context (void); - // Verify if the context has been initialized or not. - - void ssl_library_init (); - void ssl_library_fini (); - // @@ More to document - -private: - // @@ Carlos, I protected this variable with an ACE_GUARD, just like - // what we do for the orb_init_count_ variable in - // tao/ORB.cpp. The code isn't pretty but it should suffice - // until the SSL context is stored in a Singleton. - // -Ossama - - SSL_CTX *context_; - // The SSL_CTX structure - - int mode_; - // Cache the mode so we can answer fast - - ACE_SSL_Data_File private_key_; - ACE_SSL_Data_File certificate_; - // The private key and certificate file - - int default_verify_mode_; - // The default verify mode. - - static int library_init_count_; - // @@ This should also be done with a singleton, otherwise it is not - // thread safe and/or portable to some weird platforms... -}; - -#if defined(__ACE_INLINE__) -#include "SSL_Context.i" -#endif /* __ACE_INLINE__ */ - -#endif /* ACE_HAS_SSL */ - -#endif /* ACE_SSL_CONTEXT_H */ diff --git a/ace/SSL/SSL_Context.i b/ace/SSL/SSL_Context.i deleted file mode 100644 index 02a0f7efddb..00000000000 --- a/ace/SSL/SSL_Context.i +++ /dev/null @@ -1,87 +0,0 @@ -// -// $Id$ -// - -ACE_INLINE -ACE_SSL_Data_File::ACE_SSL_Data_File (void) - : type_ (-1) -{ -} - -ACE_INLINE -ACE_SSL_Data_File::ACE_SSL_Data_File (const char *file_name, - int type) - : file_name_ (file_name), - type_ (type) -{ -} - -ACE_INLINE const char* -ACE_SSL_Data_File::file_name (void) const -{ - return this->file_name_.c_str (); -} - -ACE_INLINE int -ACE_SSL_Data_File::type (void) const -{ - return this->type_; -} - -// **************************************************************** - -ACE_INLINE ACE_SSL_Context* -ACE_SSL_Context::instance (void) -{ - return ACE_Singleton<ACE_SSL_Context,ACE_SYNCH_MUTEX>::instance (); -} - -ACE_INLINE void -ACE_SSL_Context::check_context () -{ - if (this->context_ == 0) - this->set_mode (); -} - -ACE_INLINE SSL_CTX * -ACE_SSL_Context::context (void) -{ - this->check_context (); - return this->context_; -} - -ACE_INLINE int -ACE_SSL_Context::private_key_type (void) const -{ - return this->private_key_.type (); -} - -ACE_INLINE const char* -ACE_SSL_Context::private_key_file_name (void) const -{ - return this->private_key_.file_name (); -} - -ACE_INLINE int -ACE_SSL_Context::certificate_type (void) const -{ - return this->certificate_.type (); -} - -ACE_INLINE const char* -ACE_SSL_Context::certificate_file_name (void) const -{ - return this->certificate_.file_name (); -} - -ACE_INLINE void -ACE_SSL_Context::default_verify_mode (int mode) -{ - this->default_verify_mode_ = mode; -} - -ACE_INLINE int -ACE_SSL_Context::default_verify_mode (void) const -{ - return this->default_verify_mode_; -} diff --git a/ace/SSL/SSL_Context.inl b/ace/SSL/SSL_Context.inl deleted file mode 100644 index 02a0f7efddb..00000000000 --- a/ace/SSL/SSL_Context.inl +++ /dev/null @@ -1,87 +0,0 @@ -// -// $Id$ -// - -ACE_INLINE -ACE_SSL_Data_File::ACE_SSL_Data_File (void) - : type_ (-1) -{ -} - -ACE_INLINE -ACE_SSL_Data_File::ACE_SSL_Data_File (const char *file_name, - int type) - : file_name_ (file_name), - type_ (type) -{ -} - -ACE_INLINE const char* -ACE_SSL_Data_File::file_name (void) const -{ - return this->file_name_.c_str (); -} - -ACE_INLINE int -ACE_SSL_Data_File::type (void) const -{ - return this->type_; -} - -// **************************************************************** - -ACE_INLINE ACE_SSL_Context* -ACE_SSL_Context::instance (void) -{ - return ACE_Singleton<ACE_SSL_Context,ACE_SYNCH_MUTEX>::instance (); -} - -ACE_INLINE void -ACE_SSL_Context::check_context () -{ - if (this->context_ == 0) - this->set_mode (); -} - -ACE_INLINE SSL_CTX * -ACE_SSL_Context::context (void) -{ - this->check_context (); - return this->context_; -} - -ACE_INLINE int -ACE_SSL_Context::private_key_type (void) const -{ - return this->private_key_.type (); -} - -ACE_INLINE const char* -ACE_SSL_Context::private_key_file_name (void) const -{ - return this->private_key_.file_name (); -} - -ACE_INLINE int -ACE_SSL_Context::certificate_type (void) const -{ - return this->certificate_.type (); -} - -ACE_INLINE const char* -ACE_SSL_Context::certificate_file_name (void) const -{ - return this->certificate_.file_name (); -} - -ACE_INLINE void -ACE_SSL_Context::default_verify_mode (int mode) -{ - this->default_verify_mode_ = mode; -} - -ACE_INLINE int -ACE_SSL_Context::default_verify_mode (void) const -{ - return this->default_verify_mode_; -} diff --git a/ace/SSL/SSL_Export.h b/ace/SSL/SSL_Export.h deleted file mode 100644 index 4c42722d80b..00000000000 --- a/ace/SSL/SSL_Export.h +++ /dev/null @@ -1,36 +0,0 @@ -// -*- C++ -*- -// $Id$ -// Definition for Win32 Export directives. -// This file is generated automatically by -// ${ACE_ROOT}/GenExportH.BAT -// ------------------------------ -#ifndef ACE_SSL_EXPORT_H -#define ACE_SSL_EXPORT_H - -#include "ace/OS.h" - -#if !defined (ACE_SSL_HAS_DLL) -#define ACE_SSL_HAS_DLL 1 -#endif /* ! ACE_SSL_HAS_DLL */ - -#if defined (ACE_SSL_HAS_DLL) -# if (ACE_SSL_HAS_DLL == 1) -# if defined (ACE_SSL_BUILD_DLL) -# define ACE_SSL_Export ACE_Proper_Export_Flag -# define ACE_SSL_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) -# else -# define ACE_SSL_Export ACE_Proper_Import_Flag -# define ACE_SSL_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) -# endif /* ACE_SSL_BUILD_DLL */ -# else -# define ACE_SSL_Export -# define ACE_SSL_SINGLETON_DECLARATION(T) -# endif /* ! ACE_SSL_HAS_DLL == 1 */ -#else -# define ACE_SSL_Export -# define ACE_SSL_SINGLETON_DECLARATION(T) -#endif /* ACE_SSL_HAS_DLL */ - -#endif /* ACE_SSL_EXPORT_H */ - -// End of auto generated file. diff --git a/ace/SSL/SSL_SOCK_Acceptor.cpp b/ace/SSL/SSL_SOCK_Acceptor.cpp deleted file mode 100644 index b77ca714554..00000000000 --- a/ace/SSL/SSL_SOCK_Acceptor.cpp +++ /dev/null @@ -1,258 +0,0 @@ -// -// $Id$ -// - -#define ACE_BUILD_DLL - -#include "SSL_SOCK_Acceptor.h" -#include "SSL.h" - -#include "ace/Synch.h" - -#if defined (ACE_HAS_SSL) - -ACE_ALLOC_HOOK_DEFINE(ACE_SSL_SOCK_Acceptor) - -#if defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "SSL_SOCK_Acceptor.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ - -int -ACE_SSL_SOCK_Acceptor::shared_accept_start (ACE_Time_Value *timeout, - int restart, - int &in_blocking_mode) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::shared_accept_start"); - - ACE_HANDLE handle = this->get_handle (); - - // Handle the case where we're doing a timed <accept>. - if (timeout != 0) - { - if (ACE::handle_timed_accept (handle, - timeout, - restart) == -1) - return -1; - else - { - in_blocking_mode = ACE_BIT_DISABLED (ACE::get_flags (handle), - ACE_NONBLOCK); - // Set the handle into non-blocking mode if it's not already - // in it. - if (in_blocking_mode - && ACE::set_flags (handle, - ACE_NONBLOCK) == -1) - return -1; - } - } - - return 0; -} - -int -ACE_SSL_SOCK_Acceptor::shared_accept_finish (ACE_SSL_SOCK_Stream& new_stream, - int in_blocking_mode, - int reset_new_handle) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::shared_accept_finish ()"); - - ACE_HANDLE new_handle = new_stream.get_handle (); - - // Check to see if we were originally in blocking mode, and if so, - // set the <new_stream>'s handle and <this> handle to be in blocking - // mode. - if (in_blocking_mode) - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - - // Only disable ACE_NONBLOCK if we weren't in non-blocking mode - // originally. - ACE::clr_flags (this->get_handle (), - ACE_NONBLOCK); - ACE::clr_flags (new_handle, - ACE_NONBLOCK); - } - -#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) - if (reset_new_handle) - // Reset the event association inherited by the new handle. - ::WSAEventSelect ((SOCKET) new_handle, 0, 0); -#else - ACE_UNUSED_ARG (reset_new_handle); -#endif /* ACE_WIN32 */ - - return new_handle == ACE_INVALID_HANDLE ? -1 : 0; -} - -// General purpose routine for accepting new connections. -int -ACE_SSL_SOCK_Acceptor::accept (ACE_SSL_SOCK_Stream &new_stream, - ACE_Addr *remote_addr, - ACE_Time_Value *timeout, - int restart, - int reset_new_handle) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::accept"); - - int in_blocking_mode = 0; - if (this->shared_accept_start (timeout, - restart, - in_blocking_mode) == -1) - return -1; - else - { - // On Win32 the third parameter to <accept> must be a NULL - // pointer if we want to ignore the client's address. - int *len_ptr = 0; - sockaddr *addr = 0; - int len = 0; - - if (remote_addr != 0) - { - len = remote_addr->get_size (); - len_ptr = &len; - addr = (sockaddr *) remote_addr->get_addr (); - } - - do - new_stream.set_handle (ACE_OS::accept (this->get_handle (), - addr, - len_ptr)); - while (new_stream.get_handle () == ACE_INVALID_HANDLE - && restart != 0 - && errno == EINTR - && timeout == 0); - - // Reset the size of the addr, which is only necessary for UNIX - // domain sockets. - if (new_stream.get_handle () != ACE_INVALID_HANDLE - && remote_addr != 0) - remote_addr->set_size (len); - } - - if(!new_stream.ssl_init_finished () - && new_stream.get_SSL_fd () != new_stream.get_handle ()) - { - if (new_stream.set_SSL_fd (new_stream.get_handle ()) - == -1) - return -1; - } - - return (((new_stream.accept () == -1) - && errno == EAGAIN - && timeout == 0) ? - -1 : - this->shared_accept_finish (new_stream, - in_blocking_mode, - reset_new_handle)); -} - -int -ACE_SSL_SOCK_Acceptor::accept (ACE_SSL_SOCK_Stream &new_stream, - ACE_Accept_QoS_Params qos_params, - ACE_Addr *remote_addr, - ACE_Time_Value *timeout, - int restart, - int reset_new_handle) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::accept"); - - int in_blocking_mode = 0; - if (this->shared_accept_start (timeout, - restart, - in_blocking_mode) == -1) - return -1; - else - { - // On Win32 the third parameter to <accept> must be a NULL - // pointer if we want to ignore the client's address. - int *len_ptr = 0; - sockaddr *addr = 0; - int len = 0; - - if (remote_addr != 0) - { - len = remote_addr->get_size (); - len_ptr = &len; - addr = (sockaddr *) remote_addr->get_addr (); - } - - do - new_stream.set_handle (ACE_OS::accept (this->get_handle (), - addr, - len_ptr, - qos_params)); - while (new_stream.get_handle () == ACE_INVALID_HANDLE - && restart != 0 - && errno == EINTR - && timeout == 0); - - // Reset the size of the addr, which is only necessary for UNIX - // domain sockets. - if (new_stream.get_handle () != ACE_INVALID_HANDLE - && remote_addr != 0) - remote_addr->set_size (len); - } - - if(!new_stream.ssl_init_finished () - && new_stream.get_SSL_fd () != new_stream.get_handle ()) - { - if (new_stream.set_SSL_fd (new_stream.get_handle ()) - == -1) - return -1; - } - - return (((new_stream.accept() == -1) - && errno == EAGAIN - && timeout == 0) ? - -1 : - this->shared_accept_finish (new_stream, - in_blocking_mode, - reset_new_handle)); -} - -int -ACE_SSL_SOCK_Acceptor::enable (int value) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::enable"); - switch (value) - { -#ifdef SIGURG - case SIGURG: - case ACE_SIGURG: -#endif /* SIGURG */ - case SIGIO: - case ACE_SIGIO: - case ACE_CLOEXEC: - ACE_NOTSUP_RETURN (-1); - case ACE_NONBLOCK: - return this->acceptor_.enable (value); - default: - return -1; - } - return 0; -} -int -ACE_SSL_SOCK_Acceptor::disable (int value) const -{ - ACE_TRACE("ACE_SSL_SOCK_Acceptor::disable"); - switch (value) - { -#ifdef SIGURG - case SIGURG: - case ACE_SIGURG: -#endif /* SIGURG */ - case SIGIO: - case ACE_SIGIO: - case ACE_CLOEXEC: - ACE_NOTSUP_RETURN (-1); - case ACE_NONBLOCK: - return this->acceptor_.disable (value); - default: - return -1; - } - return 0; -} - -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/SSL_SOCK_Acceptor.h b/ace/SSL/SSL_SOCK_Acceptor.h deleted file mode 100644 index 3e9c18d3e3d..00000000000 --- a/ace/SSL/SSL_SOCK_Acceptor.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// SSL_SOCK_Acceptor.h -// -// = AUTHOR -// John Heitmann and Chris Zimman -// -// ============================================================================ - -#ifndef ACE_SSL_SOCK_ACCEPTOR_H -#define ACE_SSL_SOCK_ACCEPTOR_H - -#include "SSL_SOCK_Stream.h" -#include "ace/SOCK_Acceptor.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_SSL) - -class ACE_SSL_Export ACE_SSL_SOCK_Acceptor -{ - // = TITLE - // Defines a factory that creates new <ACE_SSL_SOCK_Stream>s passively. - // - // = DESCRIPTION - // The <ACE_SSL_SOCK_Acceptor> has its own <ACE_SOCK_Acceptor> which - // handles virtually all of the socket acceptance. This class is a wrapper - // which only adds the ssl acceptance. -public: - // = Initialization and termination methods. - ACE_SSL_SOCK_Acceptor (void); - // Default constructor. - - ACE_SSL_SOCK_Acceptor (const ACE_Addr &local_sap, - int reuse_addr = 0, - int protocol_family = PF_INET, - int backlog = ACE_DEFAULT_BACKLOG, - int protocol = 0); - // Initiate a passive mode ssl/BSD-style acceptor socket. - // <local_sap> is the address that we-re going to listen for - // connections on. - - ACE_SSL_SOCK_Acceptor (const ACE_Addr &local_sap, - ACE_Protocol_Info *protocolinfo, - ACE_SOCK_GROUP g, - u_long flags, - int reuse_addr, - int protocol_family, - int backlog = ACE_DEFAULT_BACKLOG, - int protocol = 0); - // Initialize a passive-mode QoS-enabled acceptor socket. Returns 0 - // on success and -1 on failure. - - int open (const ACE_Addr &local_sap, - int reuse_addr = 0, - int protocol_family = PF_INET, - int backlog = ACE_DEFAULT_BACKLOG, - int protocol = 0); - // Initiate a passive mode ssl/BSD-style acceptor socket. - // <local_sap> is the address that we-re going to listen for - // connections on. - - int close (void); - - ~ACE_SSL_SOCK_Acceptor (void); - // Default dtor. - - // = Passive connection <accept> methods. - int accept (ACE_SSL_SOCK_Stream &new_stream, - ACE_Addr *remote_addr = 0, - ACE_Time_Value *timeout = 0, - int restart = 1, - int reset_new_handle = 0) const; - // Accept a new <ACE_SSL_SOCK_Stream> connection. A <timeout> of 0 - // means block forever, a <timeout> of {0, 0} means poll. <restart> - // == 1 means "restart if interrupted," i.e., if errno == EINTR. - - int accept (ACE_SSL_SOCK_Stream &new_stream, - ACE_Accept_QoS_Params qos_params, - ACE_Addr *remote_addr = 0, - ACE_Time_Value *timeout = 0, - int restart = 1, - int reset_new_handle = 0) const; - // Accept a new <ACE_SSL_SOCK_Stream> connection using the RVSP QoS - // information in <qos_params>. A <timeout> of 0 means block - // forever, a <timeout> of {0, 0} means poll. <restart> == 1 means - // "restart if interrupted," i.e., if errno == EINTR. - - int control (int cmd, void *) const; - // Interface for ioctl. - - // = Common I/O handle options related to sockets. - - int enable (int value) const; - // Enable asynchronous I/O (ACE_SIGIO), urgent data (ACE_SIGURG), - // non-blocking I/O (ACE_NONBLOCK), or close-on-exec (ACE_CLOEXEC), - // which is passed as the <value>. - - int disable (int value) const; - // Disable asynchronous I/O (ACE_SIGIO), urgent data (ACE_SIGURG), - // non-blocking I/O (ACE_NONBLOCK), or close-on-exec (ACE_CLOEXEC), - // which is passed as the <value>. - - ACE_HANDLE get_handle (void) const; - // Get the underlying handle. - - void set_handle (ACE_HANDLE handle); - // Set the underlying handle. - - int get_local_addr (ACE_Addr &) const; - // Gets the address which is being listened on. - - // = Meta-type info - typedef ACE_INET_Addr PEER_ADDR; - typedef ACE_SSL_SOCK_Stream PEER_STREAM; - - void dump (void) const; - // Dump the state of an object. - - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - -protected: - - int shared_accept_start (ACE_Time_Value *timeout, - int restart, - int &in_blocking_mode) const; - // Perform operations that must occur before <ACE_OS::accept> is - // called. - - int shared_accept_finish (ACE_SSL_SOCK_Stream& new_stream, - int in_blocking_mode, - int reset_new_handle) const; - // Perform operations that must occur after <ACE_OS::accept> is - // called. - -private: - ACE_SOCK_Acceptor acceptor_; - // The BSD-socket workhorse -}; - -#if !defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "SSL_SOCK_Acceptor.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ - -#endif /* ACE_SSL_SOCK_ACCEPTOR_H */ -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/SSL_SOCK_Acceptor.i b/ace/SSL/SSL_SOCK_Acceptor.i deleted file mode 100644 index a75b7b1b374..00000000000 --- a/ace/SSL/SSL_SOCK_Acceptor.i +++ /dev/null @@ -1,113 +0,0 @@ -// -*- C++ -*- -// $Id$ - -// SSL_SOCK_Acceptor.i - -#if defined (ACE_HAS_SSL) - -// Do nothing routine for constructor. - -ACE_INLINE -ACE_SSL_SOCK_Acceptor::ACE_SSL_SOCK_Acceptor (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::ACE_SSL_SOCK_Acceptor"); -} - -ACE_INLINE -ACE_SSL_SOCK_Acceptor::ACE_SSL_SOCK_Acceptor (const ACE_Addr &local_sap, - int reuse_addr, - int protocol_family, - int backlog, - int protocol) - : acceptor_ (local_sap, reuse_addr, protocol_family, backlog, protocol) -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::ACE_SSL_SOCK_Acceptor"); -} -// Performs the timed accept operation. - -ACE_INLINE -ACE_SSL_SOCK_Acceptor::ACE_SSL_SOCK_Acceptor (const ACE_Addr &local_sap, - ACE_Protocol_Info *protocolinfo, - ACE_SOCK_GROUP g, - u_long flags, - int reuse_addr, - int protocol_family, - int backlog, - int protocol) - : acceptor_ (local_sap, - protocolinfo, - g, - flags, - reuse_addr, - protocol_family, - backlog, - protocol) -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::ACE_SSL_SOCK_Acceptor"); -} - -ACE_INLINE int -ACE_SSL_SOCK_Acceptor::open (const ACE_Addr &local_sap, - int reuse_addr, - int protocol_family, - int backlog, - int protocol) -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::open"); - return this->acceptor_.open (local_sap, - reuse_addr, - protocol_family, - backlog, - protocol); -} - -ACE_INLINE int -ACE_SSL_SOCK_Acceptor::close (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::close ()"); - return this->acceptor_.close (); -} - - -ACE_INLINE -ACE_SSL_SOCK_Acceptor::~ACE_SSL_SOCK_Acceptor (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::~ACE_SSL_SOCK_Acceptor"); -} - -ACE_INLINE int -ACE_SSL_SOCK_Acceptor::control (int cmd, void* dummy) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::control"); - return this->acceptor_.control (cmd, dummy); -} - -ACE_INLINE ACE_HANDLE -ACE_SSL_SOCK_Acceptor::get_handle (void) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::get_handle"); - return this->acceptor_.get_handle (); -} - -ACE_INLINE void -ACE_SSL_SOCK_Acceptor::set_handle (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::set_handle"); - this->acceptor_.set_handle (handle); -} - -ACE_INLINE int -ACE_SSL_SOCK_Acceptor::get_local_addr (ACE_Addr &addr) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::get_local_addr"); - return this->acceptor_.get_local_addr (addr); -} - -ACE_INLINE void -ACE_SSL_SOCK_Acceptor::dump (void) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Acceptor::dump"); - this->acceptor_.dump (); -} - -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/SSL_SOCK_Connector.cpp b/ace/SSL/SSL_SOCK_Connector.cpp deleted file mode 100644 index 67a2a931861..00000000000 --- a/ace/SSL/SSL_SOCK_Connector.cpp +++ /dev/null @@ -1,318 +0,0 @@ -// SSL_SOCK_Connector.cpp -// $Id$ - - -#include "SSL_SOCK_Connector.h" - -#if defined (ACE_HAS_SSL) - -#include "ace/Handle_Set.h" -#include "ace/INET_Addr.h" - -#include <openssl/err.h> - -#if defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "SSL_SOCK_Connector.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ - - -ACE_ALLOC_HOOK_DEFINE(ACE_SSL_SOCK_Connector) - -int -ACE_SSL_SOCK_Connector::shared_connect_start (ACE_SSL_SOCK_Stream &new_stream, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::shared_connect_start"); - - if (local_sap != ACE_Addr::sap_any) - { - sockaddr *laddr = ACE_reinterpret_cast (sockaddr *, - local_sap.get_addr ()); - size_t size = local_sap.get_size (); - - if (ACE_OS::bind (new_stream.get_handle (), - laddr, - size) == -1) - { - // Save/restore errno. - ACE_Errno_Guard error (errno); - new_stream.close (); - return -1; - } - } - - // Enable non-blocking, if required. - if (timeout != 0 && new_stream.disable (ACE_NONBLOCK) == -1) - return -1; - else - return 0; -} - -int -ACE_SSL_SOCK_Connector::shared_connect_finish (ACE_SSL_SOCK_Stream &new_stream, - ACE_Time_Value *timeout, - int result) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::shared_connect_finish"); - // Save/restore errno. - ACE_Errno_Guard error (errno); - - if (result == -1 && timeout != 0) - { - // Check whether the connection is in progress. - if (error == EINPROGRESS || error == EWOULDBLOCK) - { - // This expression checks if we were polling. - if (timeout->sec () == 0 - && timeout->usec () == 0) - error = EWOULDBLOCK; - // Wait synchronously using timeout. - else if (this->complete (new_stream, - 0, - timeout) == -1) - error = errno; - else - return 0; - } - } - - // EISCONN is treated specially since this routine may be used to - // check if we are already connected. - if (result != -1 || error == EISCONN) - // Start out with non-blocking disabled on the <new_stream>. - new_stream.disable (ACE_NONBLOCK); - else if (!(error == EWOULDBLOCK || error == ETIMEDOUT)) - new_stream.close (); - - return result; - -} - -int -ACE_SSL_SOCK_Connector::connect (ACE_SSL_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int flags, - int perms, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::connect"); - if ((new_stream.get_handle () == ACE_INVALID_HANDLE) && - this->connector_.connect (new_stream.peer (), - remote_sap, - timeout, - local_sap, - reuse_addr, - flags, - perms, - protocol_family, - protocol) == -1) { - return -1; - } - - if (new_stream.get_SSL_fd () != new_stream.get_handle ()) - { - new_stream.set_SSL_fd (new_stream.get_handle ()); - - if (timeout) - new_stream.disable (ACE_NONBLOCK); - } - - return new_stream.connect (); - -} - -int -ACE_SSL_SOCK_Connector::connect (ACE_SSL_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_QoS_Params qos_params, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - ACE_Protocol_Info *protocolinfo, - ACE_SOCK_GROUP g, - u_long flags, - int reuse_addr, - int perms, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::connect"); - if ((new_stream.get_handle () == ACE_INVALID_HANDLE) && - connector_.connect (new_stream.peer (), - remote_sap, - qos_params, - timeout, - local_sap, - protocolinfo, - g, - flags, - reuse_addr, - perms, - protocol_family, - protocol) == -1) { - return -1; - } - - if (new_stream.get_SSL_fd () != new_stream.get_handle ()) - { - new_stream.set_SSL_fd (new_stream.get_handle ()); - - if (timeout) - new_stream.disable (ACE_NONBLOCK); - } - - return new_stream.connect (); -} - -// Try to complete a non-blocking connection. - -int -ACE_SSL_SOCK_Connector::complete (ACE_SSL_SOCK_Stream &new_stream, - ACE_Addr *remote_sap, - ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::complete"); - if (this->connector_.complete (new_stream.peer (), - remote_sap, - tv) == -1) { - return -1; - } - - if (new_stream.get_SSL_fd () != new_stream.get_handle ()) - { - new_stream.set_SSL_fd (new_stream.get_handle ()); - - if (tv) - new_stream.disable (ACE_NONBLOCK); - } - - return new_stream.connect (); -} - - -ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector ( - ACE_SSL_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - int reuse_addr, - int flags, - int perms, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector"); - if (this->connect (new_stream, - remote_sap, - timeout, - local_sap, - reuse_addr, - flags, - perms, - protocol_family, - protocol) == -1 - && timeout != 0 - && !(errno == EWOULDBLOCK || errno == ETIME)) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("%p\n"), - ASYS_TEXT ( - "ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector" - ))); - else - { - if (new_stream.get_SSL_fd () != new_stream.get_handle ()) - { - if (new_stream.set_SSL_fd (new_stream.get_handle ()) - == -1) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("ACE_SSL_SOCK_Connector::" - "ACE_SSL_SOCK_Connector: " - "invalid handle\n"))); - - if (timeout) - new_stream.disable (ACE_NONBLOCK); - } - - if (new_stream.connect () != 0) - { -// ACE_ERROR ((LM_ERROR, -// ASYS_TEXT ("%p\n"), -// ASYS_TEXT ("ACE_SSL_SOCK_Connector::" -// "ACE_SSL_SOCK_Connector" -// ))); - - ::ERR_print_errors_fp (stderr); - } - } -} - - - -ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector ( - ACE_SSL_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_QoS_Params qos_params, - ACE_Time_Value *timeout, - const ACE_Addr &local_sap, - ACE_Protocol_Info *protocolinfo, - ACE_SOCK_GROUP g, - u_long flags, - int reuse_addr, - int perms, - int protocol_family, - int protocol) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector"); - - if (this->connect (new_stream, - remote_sap, - qos_params, - timeout, - local_sap, - protocolinfo, - g, - flags, - reuse_addr, - perms, - protocol_family, - protocol) == -1 - && timeout != 0 - && !(errno == EWOULDBLOCK || errno == ETIME)) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("%p\n"), - ASYS_TEXT ( - "ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector" - ))); - else - { - if (new_stream.get_SSL_fd () != new_stream.get_handle()) - { - if (new_stream.set_SSL_fd (new_stream.get_handle ()) - == -1) - ACE_ERROR ((LM_ERROR, - ASYS_TEXT ("ACE_SSL_SOCK_Connector::" - "ACE_SSL_SOCK_Connector: " - "invalid handle\n"))); - - if (timeout) - new_stream.disable (ACE_NONBLOCK); - } - - if (new_stream.connect () != 0) - { -// ACE_ERROR ((LM_ERROR, -// ASYS_TEXT ("%p\n"), -// ASYS_TEXT ("ACE_SSL_SOCK_Connector::" -// "ACE_SSL_SOCK_Connector" -// ))); - - ::ERR_print_errors_fp (stderr); - } - } -} - -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/SSL_SOCK_Connector.h b/ace/SSL/SSL_SOCK_Connector.h deleted file mode 100644 index 36ae878090e..00000000000 --- a/ace/SSL/SSL_SOCK_Connector.h +++ /dev/null @@ -1,195 +0,0 @@ -// -*- C++ -*- -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// SSL_SOCK_Connector.h -// -// = AUTHOR -// John Heitmann -// Chris Zimman -// Carlos O'Ryan <coryan@cs.wustl.edu> -// Ossama Othman <othman@cs.wustl.edu> -// -// ============================================================================ - -#ifndef ACE_SSL_SOCK_CONNECTOR_H -#define ACE_SSL_SOCK_CONNECTOR_H - -#include "SSL_SOCK_Stream.h" -#include "ace/SOCK_Connector.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#if defined (ACE_HAS_SSL) - -class ACE_SSL_Export ACE_SSL_SOCK_Connector -{ - // = TITLE - // Defines a factory that creates new <ACE_Stream>s actively. - // - // = DESCRIPTION - // The <ACE_SOCK_Connector> doesn't have a socket of its own, - // i.e., it simply "borrows" the one from the ACE_SOCK_Stream - // that's being connected. The reason for this is that the - // underlying socket API doesn't use a "factory" socket to connect - // "data-mode" sockets. Therefore, there's no need to inherit - // <ACE_SOCK_Connector> from <ACE_SOCK>. A nice side-effect of - // this is that <ACE_SOCK_Connector>'s do not store state so they - // can be used reentrantly in multi-threaded programs. -public: - // = Initialization and termination methods. - ACE_SSL_SOCK_Connector (void); - // Default constructor. - - ACE_SSL_SOCK_Connector (ACE_SSL_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = 0, - int perms = 0, - int protocol_family = PF_INET, - int protocol = 0); - // Actively connect and produce a <new_stream> if things go well. - // The <remote_sap> is the address that we are trying to connect - // with. The <timeout> is the amount of time to wait to connect. - // If it's 0 then we block indefinitely. If *timeout == {0, 0} then - // the connection is done using non-blocking mode. In this case, if - // the connection can't be made immediately the value of -1 is - // returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then - // this is the amount of time to wait before timing out. If the - // time expires before the connection is made <errno == ETIME>. The - // <local_sap> is the value of local address to bind to. If it's - // the default value of <ACE_Addr::sap_any> then the user is letting - // the OS do the binding. If <reuse_addr> == 1 then the - // <local_addr> is reused, even if it hasn't been cleanedup yet. - - ACE_SSL_SOCK_Connector (ACE_SSL_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_QoS_Params qos_params, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - ACE_Protocol_Info *protocolinfo = 0, - ACE_SOCK_GROUP g = 0, - u_long flags = 0, - int reuse_addr = 0, - int perms = 0, - int protocol_family = PF_INET, - int protocol = 0); - // Actively connect and produce a <new_stream> if things go well. - // The <remote_sap> is the address that we are trying to connect - // with. The <qos_params> contains QoS parameters that are passed - // to RSVP. The <timeout> is the amount of time to wait to connect. - // If it's 0 then we block indefinitely. If *timeout == {0, 0} then - // the connection is done using non-blocking mode. In this case, if - // the connection can't be made immediately the value of -1 is - // returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then - // this is the amount of time to wait before timing out. If the - // time expires before the connection is made <errno == ETIME>. The - // <local_sap> is the value of local address to bind to. If it's - // the default value of <ACE_Addr::sap_any> then the user is letting - // the OS do the binding. If <reuse_addr> == 1 then the - // <local_addr> is reused, even if it hasn't been cleanedup yet. - - int connect (ACE_SSL_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - int reuse_addr = 0, - int flags = 0, - int perms = 0, - int protocol_family = PF_INET, - int protocol = 0); - // Actively connect and produce a <new_stream> if things go well. - // The <remote_sap> is the address that we are trying to connect - // with. The <timeout> is the amount of time to wait to connect. - // If it's 0 then we block indefinitely. If *timeout == {0, 0} then - // the connection is done using non-blocking mode. In this case, if - // the connection can't be made immediately the value of -1 is - // returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then - // this is the amount of time to wait before timing out. If the - // time expires before the connection is made <errno == ETIME>. The - // <local_sap> is the value of local address to bind to. If it's - // the default value of <ACE_Addr::sap_any> then the user is letting - // the OS do the binding. If <reuse_addr> == 1 then the - // <local_addr> is reused, even if it hasn't been cleanedup yet. - - int connect (ACE_SSL_SOCK_Stream &new_stream, - const ACE_Addr &remote_sap, - ACE_QoS_Params qos_params, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = ACE_Addr::sap_any, - ACE_Protocol_Info *protocolinfo = 0, - ACE_SOCK_GROUP g = 0, - u_long flags = 0, - int reuse_addr = 0, - int perms = 0, - int protocol_family = PF_INET, - int protocol = 0); - // Actively connect and produce a <new_stream> if things go well. - // The <remote_sap> is the address that we are trying to connect - // with. The <qos_params> contains QoS parameters that are passed - // to RSVP. The <timeout> is the amount of time to wait to connect. - // If it's 0 then we block indefinitely. If *timeout == {0, 0} then - // the connection is done using non-blocking mode. In this case, if - // the connection can't be made immediately the value of -1 is - // returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then - // this is the amount of time to wait before timing out. If the - // time expires before the connection is made <errno == ETIME>. The - // <local_sap> is the value of local address to bind to. If it's - // the default value of <ACE_Addr::sap_any> then the user is letting - // the OS do the binding. If <reuse_addr> == 1 then the - // <local_addr> is reused, even if it hasn't been cleanedup yet. - - ~ACE_SSL_SOCK_Connector (void); - // Default dtor. - - // = Completion routine. - int complete (ACE_SSL_SOCK_Stream &new_stream, - ACE_Addr *remote_sap = 0, - ACE_Time_Value *timeout = 0); - // Try to complete a non-blocking connection. - // If connection completion is successful then <new_stream> contains - // the connected ACE_SOCK_Stream. If <remote_sap> is non-NULL then it - // will contain the address of the connected peer. - - int reset_new_handle (ACE_HANDLE handle); - // Resets any event associations on this handle - - // = Meta-type info - typedef ACE_INET_Addr PEER_ADDR; - typedef ACE_SSL_SOCK_Stream PEER_STREAM; - - void dump (void) const; - // Dump the state of an object. - - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. -protected: - int shared_connect_start(ACE_SSL_SOCK_Stream &new_stream, - ACE_Time_Value *timeout = 0, - const ACE_Addr &local_sap = 0); - - int shared_connect_finish(ACE_SSL_SOCK_Stream &new_stream, - ACE_Time_Value *timeout = 0, - int result = 0); - -private: - ACE_SOCK_Connector connector_; - // The class that does all of the non-secure socket connection. - // It is default contructed, and susequently used by connect(). -}; - -#if !defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "SSL_SOCK_Connector.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ - -#endif /* ACE_SSL_SOCK_CONNECTOR_H */ -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/SSL_SOCK_Connector.i b/ace/SSL/SSL_SOCK_Connector.i deleted file mode 100644 index b27cecf5f6f..00000000000 --- a/ace/SSL/SSL_SOCK_Connector.i +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// SSL_SOCK_Connector.i - -#if defined (ACE_HAS_SSL) - -ASYS_INLINE -ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::ACE_SSL_SOCK_Connector"); -} - -ASYS_INLINE -ACE_SSL_SOCK_Connector::~ACE_SSL_SOCK_Connector (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::~ACE_SSL_SOCK_Connector"); -} - -ASYS_INLINE int -ACE_SSL_SOCK_Connector::reset_new_handle (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::reset_new_handle"); - return this->connector_.reset_new_handle (handle); -} - -ASYS_INLINE void -ACE_SSL_SOCK_Connector::dump (void) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Connector::dump"); -} - -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/SSL_SOCK_Stream.cpp b/ace/SSL/SSL_SOCK_Stream.cpp deleted file mode 100644 index 106fef22f32..00000000000 --- a/ace/SSL/SSL_SOCK_Stream.cpp +++ /dev/null @@ -1,546 +0,0 @@ -// SSL_SOCK_Stream.cpp -// $Id$ - -#define ACE_BUILD_DLL - -#include "SSL_SOCK_Stream.h" -#include "ace/Handle_Set.h" - -#if defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "SSL_SOCK_Stream.i" -#endif - -#if defined (ACE_HAS_SSL) - -ACE_ALLOC_HOOK_DEFINE(ACE_SSL_SOCK_Stream) - -ssize_t -ACE_SSL_SOCK_Stream::sendv (const iovec iov[], - size_t n) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::sendv"); - - // Mimics ACE_OS::sendv. - int result = 0; - ssize_t bytes_sent = 0; - for (size_t i = 0; i < n && result != -1; i++) - { - result = this->send (iov[i].iov_base, - iov[i].iov_len); - bytes_sent += iov[i].iov_len; // Gets ignored on error anyway - } - - if (result == -1) - return -1; - - return bytes_sent; -} - -ssize_t -ACE_SSL_SOCK_Stream::recvv (iovec *io_vec, - const ACE_Time_Value *timeout) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recvv"); - - // From <ACE_SOCK_IO::recvv>. -#if defined (FIONREAD) - ACE_Handle_Set handle_set; - handle_set.reset (); - handle_set.set_bit (this->get_handle ()); - - io_vec->iov_base = 0; - - // Check the status of the current socket. - switch (ACE_OS::select (int (this->get_handle ()) + 1, - handle_set, - 0, 0, - timeout)) - { - case -1: - return -1; - /* NOTREACHED */ - case 0: - errno = ETIME; - return -1; - /* NOTREACHED */ - default: - // Goes fine, fallthrough to get data - break; - } - - u_long inlen; - - - if (ACE_OS::ioctl (this->get_handle (), - FIONREAD, - (u_long *) &inlen) == -1) - return -1; - else if (inlen > 0) - { - ACE_NEW_RETURN (io_vec->iov_base, - char[inlen], - -1); - io_vec->iov_len = this->recv (io_vec->iov_base, - inlen); - return io_vec->iov_len; - } - else - return 0; -#else - ACE_UNUSED_ARG (io_vec); - ACE_UNUSED_ARG (timeout); - ACE_NOTSUP_RETURN (-1); -#endif /* FIONREAD */ -} - -ssize_t -ACE_SSL_SOCK_Stream::send (const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::send"); - - if (flags) - ACE_NOTSUP_RETURN (-1); - - // Mimics <ACE::send>. - if (timeout == 0) - return this->send (buf, len); - - int val = 0; - if (ACE::enter_send_timedwait (this->get_handle (), - timeout, - val) == -1) - return -1; - else - { - ssize_t bytes_transferred = this->send (buf, len); - ACE::restore_non_blocking_mode (this->get_handle (), val); - return bytes_transferred; - } -} - -ssize_t -ACE_SSL_SOCK_Stream::recv (void *buf, - size_t n, - int flags, - const ACE_Time_Value *timeout) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recv"); - - // Mimics code in <ACE::recv>. - int peek = 0; - - if (flags) - { - if ((flags | MSG_PEEK) == MSG_PEEK) - peek = 1; - else - ACE_NOTSUP_RETURN (-1); - } - - if (timeout == 0) - return this->recv (buf, n, flags); - { - int val = 0; - if (ACE::enter_recv_timedwait (this->get_handle (), - timeout, - val) == -1) - return -1; - else - { - ssize_t bytes_transferred = this->recv (buf, n, flags); - ACE::restore_non_blocking_mode (this->get_handle (), val); - return bytes_transferred; - } - } -} - - -ssize_t -ACE_SSL_SOCK_Stream::send (size_t n, - ...) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::send"); - - // Mimics <ACE_SOCK_IO::send (...)>. - va_list argp; - size_t total_tuples = n / 2; - iovec *iovp; -#if defined (ACE_HAS_ALLOCA) - iovp = (iovec *) alloca (total_tuples * sizeof (iovec)); -#else - ACE_NEW_RETURN (iovp, - iovec[total_tuples], - -1); -#endif /* !defined (ACE_HAS_ALLOCA) */ - - va_start (argp, n); - - for (size_t i = 0; i < total_tuples; i++) - { - iovp[i].iov_base = va_arg (argp, char *); - iovp[i].iov_len = va_arg (argp, ssize_t); - } - - ssize_t result = this->sendv (iovp, - total_tuples); -#if !defined (ACE_HAS_ALLOCA) - delete [] iovp; -#endif /* !defined (ACE_HAS_ALLOCA) */ - va_end (argp); - return result; -} - -ssize_t -ACE_SSL_SOCK_Stream::recv (size_t n, - ...) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recv"); - size_t total_tuples = n / 2; - va_list argp; - va_start (argp, n); - - ssize_t result = 0; - ssize_t bytes_recv = 0; - for (size_t i = 0; i < total_tuples; i++) - { - result = this->recv_n (va_arg (argp, char *), va_arg (argp, ssize_t)); - if (result == -1) - return -1; - bytes_recv += result; - } - - va_end (argp); - return bytes_recv; -} - -ssize_t -ACE_SSL_SOCK_Stream::send_n (const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::send_n"); - - //no support for send flags in SSL - if (flags != 0) - ACE_NOTSUP_RETURN (-1); - - /* This code mimics ACE::send_n */ - // Total number of bytes written. - size_t bytes_transferred = 0; - - // Actual number of bytes written in each <send> attempt - ssize_t n = 0; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - n = this->send ((const char*) buf + bytes_transferred, - len - bytes_transferred, - flags, - timeout); - - if (n == -1) - { - // If blocked, try again. - if (errno == EWOULDBLOCK) - { - n = 0; - continue; - } - - // - // No timeouts in this version. - // - - // Other errors. - return -1; - } - else if (n == 0) - break; - } - - return bytes_transferred; -} - -ssize_t -ACE_SSL_SOCK_Stream::recv_n (void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recv_n"); - - if (flags != 0) - { - if ((flags | MSG_PEEK) != MSG_PEEK) - ACE_NOTSUP_RETURN (-1); - } - - size_t bytes_transferred = 0; - ssize_t n = 0; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - n = this->recv ((char*) buf + bytes_transferred, - len - bytes_transferred, - flags, - timeout); -// if (n == -1 || n == 0) -// break; - if (n == -1) - { - // If blocked, try again. - if (errno == EWOULDBLOCK) - { - n = 0; - continue; - } - - // - // No timeouts in this version. - // - - // Other errors. - return -1; - } - else if (n == 0) - break; - } - - return bytes_transferred; -} - -ssize_t -ACE_SSL_SOCK_Stream::recv_n (void *buf, int len, int flags) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recv_n"); - - if (flags != 0) - { - if ((flags | MSG_PEEK) != MSG_PEEK) - ACE_NOTSUP_RETURN (-1); - } - - ssize_t bytes_transferred = 0; - ssize_t n = 0; - - for (bytes_transferred = 0; - bytes_transferred < len; - bytes_transferred += n) - { - n = this->recv ((char*) buf + bytes_transferred, - len - bytes_transferred, - flags); - - if (n == -1) - { - // If blocked, try again. - if (errno == EWOULDBLOCK) - { - n = 0; - continue; - } - - // - // No timeouts in this version. - // - - // Other errors. - return -1; - } - else if (n == 0) - break; - } - - return bytes_transferred; -} - -ssize_t -ACE_SSL_SOCK_Stream::send_n (const void *buf, int len, int flags) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::send_n"); - - // Send flags are unsupported in SSL - if (flags != 0) - ACE_NOTSUP_RETURN (-1); - - /* The following code mimics <ACE::send_n> */ - size_t bytes_transferred = 0; - ssize_t n = 0; - - for (bytes_transferred = 0; - bytes_transferred < (size_t) len; - bytes_transferred += n) - { - n = this->send ((const char*) buf + bytes_transferred, - len - bytes_transferred, - flags); - - if (n == -1) - { - // If blocked, try again. - if (errno == EWOULDBLOCK) - { - n = 0; - continue; - } - - // - // No timeouts in this version. - // - - // Other errors. - return -1; - } - else if (n == 0) - break; - } - - return bytes_transferred; -} - - -//Taken from OS.cpp, writev () -ssize_t -ACE_SSL_SOCK_Stream::sendv_n (const iovec iov[], size_t n) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::sendv_n"); - size_t length = 0; - size_t i; - - // Determine the total length of all the buffers in <iov>. - for (i = 0; i < n; i++) - if (ACE_static_cast (const int, iov[i].iov_len) < 0) - return -1; - else - length += iov[i].iov_len; - - char *buf; - -# if defined (ACE_HAS_ALLOCA) - buf = (char *) alloca (length); -# else - ACE_NEW_RETURN (buf, - char[length], - -1); -# endif /* !defined (ACE_HAS_ALLOCA) */ - - char *ptr = buf; - - for (i = 0; i < n; i++) - { - ACE_OS::memcpy (ptr, iov[i].iov_base, iov[i].iov_len); - ptr += iov[i].iov_len; - } - - ssize_t result = this->send_n (buf, length); -# if !defined (ACE_HAS_ALLOCA) - delete [] buf; -# endif /* !defined (ACE_HAS_ALLOCA) */ - return result; -} - -// Taken straight from OS.cpp, readv () -ssize_t -ACE_SSL_SOCK_Stream::recvv_n (iovec iov[], size_t n) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recvv_n"); - ssize_t length = 0; - size_t i; - - for (i = 0; i < n; i++) - if (ACE_static_cast (int, iov[i].iov_len) < 0) - return -1; - else - length += iov[i].iov_len; - - char *buf; -# if defined (ACE_HAS_ALLOCA) - buf = (char *) alloca (length); -# else - ACE_NEW_RETURN (buf, - char[length], - -1); -# endif /* !defined (ACE_HAS_ALLOCA) */ - - length = this->recv_n (buf, length); - - if (length != -1) - { - char *ptr = buf; - int copyn = length; - - for (i = 0; - i < n && copyn > 0; - i++) - { - ACE_OS::memcpy (iov[i].iov_base, ptr, - // iov_len is int on some platforms, size_t - // on others - copyn > (int) iov[i].iov_len - ? (size_t) iov[i].iov_len - : (size_t) copyn); - ptr += iov[i].iov_len; - copyn -= iov[i].iov_len; - } - } - -# if !defined (ACE_HAS_ALLOCA) - delete [] buf; -# endif /* !defined (ACE_HAS_ALLOCA) */ - return length; -} - - -int -ACE_SSL_SOCK_Stream::enable (int value) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::enable"); - switch (value) - { -#ifdef SIGURG - case SIGURG: - case ACE_SIGURG: -#endif /* SIGURG */ - case SIGIO: - case ACE_SIGIO: - case ACE_CLOEXEC: - ACE_NOTSUP_RETURN (-1); - case ACE_NONBLOCK: - return this->stream_.enable (value); - default: - return -1; - } - return 0; -} - -int -ACE_SSL_SOCK_Stream::disable (int value) const -{ - ACE_TRACE("ACE_SSL_SOCK_Stream::disable"); - switch (value) - { -#ifdef SIGURG - case SIGURG: - case ACE_SIGURG: -#endif /* SIGURG */ - case SIGIO: - case ACE_SIGIO: - case ACE_CLOEXEC: - ACE_NOTSUP_RETURN (-1); - case ACE_NONBLOCK: - return this->stream_.disable (value); - default: - return -1; - } - return 0; -} - -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/SSL_SOCK_Stream.h b/ace/SSL/SSL_SOCK_Stream.h deleted file mode 100644 index 0be8331982f..00000000000 --- a/ace/SSL/SSL_SOCK_Stream.h +++ /dev/null @@ -1,263 +0,0 @@ -// -*- C++ -*- -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// ace -// -// = FILENAME -// SSL_SOCK_Stream.h -// -// = AUTHOR -// John Heitmann -// Carlos O'Ryan <coryan@cs.wustl.edu> -// Ossama Othman <othman@cs.wustl.edu> -// -// ============================================================================ - -#ifndef ACE_SSL_SOCK_STREAM_H -#define ACE_SSL_SOCK_STREAM_H - -#include "SSL.h" - -#if defined (ACE_HAS_SSL) - -#include "ace/SOCK_Stream.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -class ACE_SSL_Export ACE_SSL_SOCK_Stream : public ACE_SSL -{ - // = TITLE - // Defines methods in the <ACE_SSL_SOCK_Stream> abstraction. - // - // = DESCRIPTION - // This adds ssl functionality to an <ACE_SOCK_IO> interface by - // wrapping around an <ACE_SSL_SOCK_Stream> implementation. - // -public: - // = Initializtion and termination functions. - - ACE_SSL_SOCK_Stream (void); - // Constructor (sets the underlying <ACE_HANDLE> with <h>, and - // <SSL*> with <session>). If the handle in <session> does not - // match <h>, it will set <session's> handle to <h>. - - ACE_SSL_SOCK_Stream (ACE_HANDLE h); - // Constructor (sets <ACE_HANDLE> with the handle in <session> - // and the underlying <SSL*> with session. - - ~ACE_SSL_SOCK_Stream (void); - //Destructor - - ssize_t send (const void *buf, - size_t n, - int flags) const; - // Send an <n> byte buffer to the ssl socket using - // the semantics of <send(3n)>. ACE+SSL supports no - // flags for sending at this time. - - ssize_t recv (void *buf, - size_t n, - int flags) const; - // Recv an <n> byte buffer from the ssl socket using - // the semantics of <recv(3n)>. ACE+SSL supports MSG_PEEK, - // but no other flags at this time. - - - ssize_t send (const void *buf, - size_t n) const; - // Send an <n> byte buffer to the ssl socket using - // the semantics of <write(2)>. - - ssize_t recv (void *buf, - size_t n) const; - // Recv an <n> byte buffer from the ssl socket using - // the semantics of <read(2)>. - - ssize_t sendv (const iovec iov[], - size_t n) const; - // Send an <iovec> of size <n> to the ssl socket. - - - ssize_t recvv (iovec *io_vec, - const ACE_Time_Value *timeout = 0) const; - // Allows a client to read from a socket without having to provide a - // buffer to read. This method determines how much data is in the - // socket, allocates a buffer of this size, reads in the data, and - // returns the number of bytes read. The caller is responsible for - // deleting the member in the <iov_base> field of <io_vec> using - // delete [] io_vec->iov_base. - - - ssize_t send (const void *buf, - size_t n, - int flags, - const ACE_Time_Value *timeout) const; - // Wait to to <timeout> amount of time to send up to <n> bytes into - // <buf> (uses the <send> call). If <send> times out - // a -1 is returned with <errno == ETIME>. If it succeeds the - // number of bytes sent is returned. No flags are supported. - - ssize_t recv (void *buf, - size_t n, - int flags, - const ACE_Time_Value *timeout) const; - // Wait up to <timeout> amount of time to receive up to <n> bytes - // into <buf> (uses the <recv> call). If <recv> times - // out a -1 is returned with <errno == ETIME>. If it succeeds the - // number of bytes received is returned. MSG_PEEK is the only - // supported flag. - - ssize_t send (const void *buf, - size_t n, - const ACE_Time_Value *timeout) const; - // Wait to to <timeout> amount of time to send up to <n> bytes into - // <buf> (uses the <send> call). If <send> times out - // a -1 is returned with <errno == ETIME>. If it succeeds the - // number of bytes sent is returned. - - ssize_t recv (void *buf, - size_t n, - const ACE_Time_Value *timeout) const; - // Wait up to <timeout> amount of time to receive up to <n> bytes - // into <buf> (uses the <recv> call). If <recv> times - // out a -1 is returned with <errno == ETIME>. If it succeeds the - // number of bytes received is returned. - - ssize_t send (size_t n, - ...) const; - // Send <n> varargs messages to the connected ssl socket. - - ssize_t recv (size_t n, - ...) const; - // Recv <n> varargs messages to the connected ssl socket. - - ssize_t send_n (const void *buf, int n) const; - // Send <n> bytes, keep trying until <n> are sent. - - ssize_t recv_n (void *buf, int n) const; - // Recv <n> bytes, keep trying until <n> are received. - - // = In the following four methods, only MSG_PEEK is supported - // for recv_n, and no flags are supported for send_n. - ssize_t send_n (const void *buf, int n, int flags) const; - // Send <n> bytes, keep trying until <n> are sent. - - ssize_t recv_n (void *buf, int n, int flags) const; - // Recv <n> bytes, keep trying until <n> are sent. - - ssize_t send_n (const void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout) const; - // Try to send exactly <len> bytes into <buf> (uses - // the <send> call). If <send> blocks for longer than <timeout> the - // number of bytes actually sent is returned with <errno == ETIME>. - // If a timeout does not occur, <send_n> return <len> (i.e., the - // number of bytes requested to be sent). - - ssize_t recv_n (void *buf, - size_t len, - int flags, - const ACE_Time_Value *timeout) const; - // Try to recv exactly <len> bytes into <buf> (uses - // the <recv> call). The <ACE_Time_Value> indicates how long - // to blocking trying to receive. If <timeout> == 0, the caller - // will block until action is possible, else will wait until the - // relative time specified in *<timeout> elapses). If <recv> blocks - // for longer than <timeout> the number of bytes actually read is - // returned with <errno == ETIME>. If a timeout does not occur, - // <recv_n> return <len> (i.e., the number of bytes requested to be - // read). - - ssize_t sendv_n (const iovec iov[], - size_t n) const; - // Send an <iovec> of size <n> to the connected socket. - // Will block until all bytes are sent or an error - // occurs. - - ssize_t recvv_n (iovec iov[], - size_t n) const; - // Receive an <iovec> of size <n> to the connected socket. - - - // = Selectively close endpoints. - int close_reader (void); - // Close down the reader. - - int close_writer (void); - // Close down the writer. - - int close (void); - //Close down the socket. - - // = Meta-type info - typedef ACE_INET_Addr PEER_ADDR; - - void dump (void) const; - // Dump the state of an object. - - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. - - int set_option (int level, - int option, - void *optval, - int optlen) const; - // Wrapper around the setsockopt() system call. - - int get_option (int level, - int option, - void *optval, - int *optlen) const; - // Wrapper around the getsockopt() system call. - - int control (int cmd, void *) const; - // Interface for ioctl. - - // = Common I/O handle options related to sockets. - - int enable (int value) const; - // Enable asynchronous I/O (ACE_SIGIO), urgent data (ACE_SIGURG), - // non-blocking I/O (ACE_NONBLOCK), or close-on-exec (ACE_CLOEXEC), - // which is passed as the <value>. - - int disable (int value) const; - // Disable asynchronous I/O (ACE_SIGIO), urgent data (ACE_SIGURG), - // non-blocking I/O (ACE_NONBLOCK), or close-on-exec (ACE_CLOEXEC), - // which is passed as the <value>. - - int get_local_addr (ACE_Addr &) const; - // Return the local endpoint address in the referenced <ACE_Addr>. - - int get_remote_addr (ACE_Addr &) const; - // Return the address of the remotely connected peer (if there is - // one), in the referenced ACE_Addr. Returns 0 if successful, else -1. - - ACE_HANDLE get_handle (void) const; - // Get the underlying handle - - void set_handle (ACE_HANDLE handle); - // Set the underlying handle - - friend class ACE_SSL_SOCK_Connector; - friend class ACE_SSL_SOCK_Acceptor; - -private: - ACE_SOCK_Stream& peer (void); - // Return the underlying <ACE_SOCK_Stream> which ssl runs on top of. - - ACE_SOCK_Stream stream_; - // The stream which works under the ssl connection. -}; - -#if !defined (ACE_LACKS_INLINE_FUNCTIONS) -#include "SSL_SOCK_Stream.i" -#endif /* ACE_LACKS_INLINE_FUNCTIONS */ - -#endif /* ACE_SSL_SOCK_STREAM_H */ -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/SSL_SOCK_Stream.i b/ace/SSL/SSL_SOCK_Stream.i deleted file mode 100644 index 14955943823..00000000000 --- a/ace/SSL/SSL_SOCK_Stream.i +++ /dev/null @@ -1,238 +0,0 @@ -// -*- C++ -*- -// $Id$ - -// SOCK_Stream.i - -#if defined (ACE_HAS_SSL) - -ASYS_INLINE -ACE_SSL_SOCK_Stream::ACE_SSL_SOCK_Stream (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::ACE_SSL_SOCK_Stream"); -} - -ASYS_INLINE -ACE_SSL_SOCK_Stream::ACE_SSL_SOCK_Stream (ACE_HANDLE h) - : stream_ (h) -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::ACE_SSL_SOCK_Stream"); -} - -ASYS_INLINE -ACE_SSL_SOCK_Stream::~ACE_SSL_SOCK_Stream (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::~ACE_SSL_SOCK_Stream"); -} - -ASYS_INLINE ssize_t -ACE_SSL_SOCK_Stream::send (const void *buf, - size_t n, - int flags) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::send"); - - if (!this->ssl_init_finished ()) - { - ACE_DEBUG ((LM_DEBUG, "ACE_SSL_SOCK_Stream::send - init\n")); - return -1; - } - - // No send flags are supported in SSL. - if (flags != 0) - ACE_NOTSUP_RETURN (-1); - - int r = - ::SSL_write (this->ssl_, ACE_static_cast (const char*, buf), n); - - // ACE_DEBUG ((LM_DEBUG, "ACE_SSL_SOCK_Stream::send - %d/%d\n", - // r, n)); - return r; -} - -ASYS_INLINE ssize_t -ACE_SSL_SOCK_Stream::recv (void *buf, - size_t n, - int flags) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recv"); - - if (!this->ssl_init_finished ()) - { - ACE_DEBUG ((LM_DEBUG, "ACE_SSL_SOCK_Stream::recv - init\n")); - return -1; - } - - if (flags) - { - if (ACE_BIT_ENABLED (flags, MSG_PEEK)) - return ::SSL_peek (this->ssl_, ACE_static_cast (char*, buf), n); - ACE_NOTSUP_RETURN (-1); - } - int r = - ::SSL_read (this->ssl_, ACE_static_cast (char *, buf), n); - - // ACE_DEBUG ((LM_DEBUG, "ACE_SSL_SOCK_Stream::recv - %d/%d\n", - // r, n)); - return r; -} - -ASYS_INLINE ssize_t -ACE_SSL_SOCK_Stream::send (const void *buf, - size_t n) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::send"); - - if (!this->ssl_init_finished ()) - { - ACE_DEBUG ((LM_DEBUG, "ACE_SSL_SOCK_Stream::send - init\n")); - return -1; - } - - int r = ::SSL_write (this->ssl_, ACE_static_cast (const char *, buf), n); - ACE_DEBUG ((LM_DEBUG, "ACE_SSL_SOCK_Stream::send - %d/%d\n", - r, n)); - return r; -} - -ASYS_INLINE ssize_t -ACE_SSL_SOCK_Stream::recv (void *buf, - size_t n) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recv"); - if (!this->ssl_init_finished ()) - { - ACE_DEBUG ((LM_DEBUG, "ACE_SSL_SOCK_Stream::recv - init\n")); - return -1; - } - - int r = ::SSL_read (this->ssl_, ACE_static_cast (char*, buf), n); - ACE_DEBUG ((LM_DEBUG, "ACE_SSL_SOCK_Stream::recv - %d/%d\n", - r, n)); - return r; -} - -ASYS_INLINE ssize_t -ACE_SSL_SOCK_Stream::send (const void *buf, - size_t len, - const ACE_Time_Value *timeout) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::send"); - return this->send (buf, len, 0, timeout); -} - -ASYS_INLINE ssize_t -ACE_SSL_SOCK_Stream::recv (void *buf, - size_t n, - const ACE_Time_Value *timeout) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recv"); - return this->recv (buf, n, 0, timeout); -} - -ASYS_INLINE ssize_t -ACE_SSL_SOCK_Stream::recv_n (void *buf, int buf_size) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::recv_n"); - return this->recv_n (buf, buf_size, 0); -} - -ASYS_INLINE ssize_t -ACE_SSL_SOCK_Stream::send_n (const void *buf, int len) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::send_n"); - return this->send_n (buf, len, 0); -} - -ASYS_INLINE int -ACE_SSL_SOCK_Stream::close_reader (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::close_reader"); - return this->stream_.close_reader (); -} - -ASYS_INLINE int -ACE_SSL_SOCK_Stream::close_writer (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::close_writer"); - return this->stream_.close_writer (); -} - -ASYS_INLINE int -ACE_SSL_SOCK_Stream::close (void) -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::close"); - - (void) this->ssl_close (); - - return this->stream_.close (); -} - -ASYS_INLINE void -ACE_SSL_SOCK_Stream::dump (void) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::dump"); - this->stream_.dump (); -} - -ASYS_INLINE ACE_SOCK_Stream& -ACE_SSL_SOCK_Stream::peer () { - ACE_TRACE ("ACE_SSL_SOCK_Stream::peer"); - return this->stream_; -} - -ASYS_INLINE int -ACE_SSL_SOCK_Stream::control (int cmd, void* dummy) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::control"); - return this->stream_.control (cmd, dummy); -} - -ASYS_INLINE int -ACE_SSL_SOCK_Stream::set_option (int level, - int option, - void *optval, - int optlen) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::set_option"); - return this->stream_.set_option (level, option, optval, optlen); -} - -ASYS_INLINE int -ACE_SSL_SOCK_Stream::get_option (int level, - int option, - void *optval, - int *optlen) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::get_option"); - return this->stream_.get_option (level, option, optval, optlen); -} - -ASYS_INLINE int -ACE_SSL_SOCK_Stream::get_local_addr (ACE_Addr &addr) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::get_local_addr"); - return this->stream_.get_local_addr (addr); -} - -ASYS_INLINE int -ACE_SSL_SOCK_Stream::get_remote_addr (ACE_Addr &addr) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::get_remote_addr"); - return this->stream_.get_remote_addr (addr); -} - -ASYS_INLINE ACE_HANDLE -ACE_SSL_SOCK_Stream::get_handle (void) const -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::get_handle"); - return this->stream_.get_handle (); -} - -ASYS_INLINE void -ACE_SSL_SOCK_Stream::set_handle (ACE_HANDLE handle) -{ - ACE_TRACE ("ACE_SSL_SOCK_Stream::set_handle"); - this->stream_.set_handle (handle); -} - -#endif /* ACE_HAS_SSL */ diff --git a/ace/SSL/sslconf.h b/ace/SSL/sslconf.h deleted file mode 100644 index e3585208bb8..00000000000 --- a/ace/SSL/sslconf.h +++ /dev/null @@ -1,37 +0,0 @@ -// -*- C++ -*- -// $Id$ -// ============================================================================ -// -// = LIBRARY -// TAO_SSLIOP -// -// = FILENAME -// sslconf.h -// -// = AUTHOR -// Carlos O'Ryan <coryan@ece.uci.edu> -// -// ============================================================================ - - -#ifndef ACE_SSLCONF_H -#define ACE_SSLCONF_H - -#if !defined (ACE_DEFAULT_SSL_CERT_FILE) -#define ACE_DEFAULT_SSL_CERT_FILE "/etc/ssl/cert.pem" -#endif /* ACE_DEFAULT_SSL_CERT_FILE */ - -#if !defined (ACE_DEFAULT_SSL_CERT_DIR) -#define ACE_DEFAULT_SSL_CERT_DIR "/etc/ssl/certs" -#endif /* ACE_DEFAULT_SSL_CERT_DIR */ - -#if !defined (ACE_SSL_CERT_FILE_ENV) -#define ACE_SSL_CERT_FILE_ENV "SSL_CERT_FILE" -#endif /* ACE_SSL_CERT_FILE_ENV */ - -#if !defined (ACE_SSL_CERT_DIR_ENV) -#define ACE_SSL_CERT_DIR_ENV "SSL_CERT_DIR" -#endif /* ACE_SSL_CERT_DIR_ENV */ - -#endif /* ACE_SSLCONF_H */ - |