Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Ssl Class Reference

Ssl is a wrapper for the SSL structure in the OpenSSL library. The object is thread safe. Ssl provides a read/write timeout. More...

#include <Ssl.h>

List of all members.

Public Methods

 Ssl ()
 ~Ssl ()
void setTimeOut (bool infinite, int tv_sec, int tv_usec)
bool open (bool server_mode, SslCtx &ssl_ctx, OS_SPEC_SOCKET_TYPE sock)
void shutdown (void)
int read (void *buff, int count)
int write (void *buff, int count)
SSL * getSsl (void)
OS_SPEC_SOCKET_TYPE getStream (void)

Private Attributes

SSL * m_ssl
Mutex m_lock
OS_SPEC_SOCKET_TYPE m_sock
bool m_timeout_infinite
timeval m_timeout


Detailed Description

Ssl is a wrapper for the SSL structure in the OpenSSL library. The object is thread safe. Ssl provides a read/write timeout.

Definition at line 11 of file Ssl.h.


Constructor & Destructor Documentation

Ssl::Ssl
 

Definition at line 11 of file Ssl.cpp.

Ssl::~Ssl
 

Definition at line 21 of file Ssl.cpp.


Member Function Documentation

SSL * Ssl::getSsl void
 

Get internal SSL struct.

Definition at line 194 of file Ssl.cpp.

OS_SPEC_SOCKET_TYPE Ssl::getStream void
 

Get stream associated with SSL.

Definition at line 204 of file Ssl.cpp.

bool Ssl::open bool server_mode,
SslCtx & ssl_ctx,
OS_SPEC_SOCKET_TYPE sock
 

Establishes an SSL connection.

Parameters:
sever_mode   true for server side, false for client side.
ssl_ctx   The SSL context, which in this case will provide the certificates to Ssl.
sock   A socket over which the ssl-connection is esablished.
Returns:
true on success, false otherwise.

Definition at line 54 of file Ssl.cpp.

Referenced by SslConnection::accept(), and SslConnection::connect().

int Ssl::read void * buff,
int count
 

Attempts to read up to 'count' bytes from the ssl-connection into the buffer starting at 'buff'. read() waits for packets during the timeout period if timeout is set, i.e. if the timeout is not infinite. Otherwise, read() waits for packets forever. read() internally lock Ssl class while reading.

Parameters:
buff   The starting address of the buffer to store receiving data.
count   The maximum size of data to be read.
Returns:
The number of bytes read. Zero indicates the connection is closed. On timeout, -10 is returned. On error, -1 is returned.

Definition at line 128 of file Ssl.cpp.

Referenced by SslConnection::read().

void Ssl::setTimeOut bool infinite,
int tv_sec,
int tv_usec
 

Sets the timeout during which Ssl waits for packets. The "read" function returns an error if no packet arrives within timeout period.

Parameters:
infinite   If infinite is true, the read() call waits for packets forever. Otherwise, timeout is tv_sec seconds + tv_usec microseconds.
tv_sec   Number of seconds for timeout period.
rv_usec   Number of micro seconds for timeout period.

Definition at line 37 of file Ssl.cpp.

Referenced by SslConnection::accept(), and SslConnection::connect().

void Ssl::shutdown void
 

Closes the established SSL connection by sending shutdown requests.

Definition at line 103 of file Ssl.cpp.

Referenced by ~Ssl().

int Ssl::write void * buff,
int count
 

write() writes up to 'count' bytes to the SSL connection from the buffer starting at 'buff'. write() waits for the condition in which Ssl can send packets during the timeout period if timeout is set. Otherwise, write() waits for the condition forever. write() internally lock Ssl class while writing.

Parameters:
buff   the starting address of sending data.
count   the size of sending data.
Returns:
The number of bytes written. Zero indicates nothing was written. On timeout, -10 is returned. On error, -1 is returned.

Definition at line 167 of file Ssl.cpp.

Referenced by SslConnection::write().


Member Data Documentation

Mutex Ssl::m_lock [private]
 

Definition at line 33 of file Ssl.h.

OS_SPEC_SOCKET_TYPE Ssl::m_sock [private]
 

Definition at line 34 of file Ssl.h.

SSL* Ssl::m_ssl [private]
 

Definition at line 32 of file Ssl.h.

struct timeval Ssl::m_timeout [private]
 

Definition at line 36 of file Ssl.h.

bool Ssl::m_timeout_infinite [private]
 

Definition at line 35 of file Ssl.h.


The documentation for this class was generated from the following files:
Generated at Thu Jul 11 13:31:59 2002 for Peekabooty by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001