PTLib
Version 2.10.4
|
This class will start a secure SSL based channel. More...
#include <pssl.h>
Public Types | |
enum | VerifyMode { VerifyNone, VerifyPeer, VerifyPeerMandatory } |
Public Member Functions | |
PSSLChannel (PSSLContext *context=NULL, PBoolean autoDeleteContext=false) | |
Create a new channel given the context. | |
PSSLChannel (PSSLContext &context) | |
~PSSLChannel () | |
Close and clear the SSL channel. | |
virtual PBoolean | Read (void *buf, PINDEX len) |
Low level read from the channel. | |
virtual PBoolean | Write (const void *buf, PINDEX len) |
Low level write to the channel. | |
virtual PBoolean | Close () |
Close the channel. | |
virtual PBoolean | Shutdown (ShutdownValue) |
Close one or both of the data streams associated with a channel. | |
virtual PString | GetErrorText (ErrorGroup group=NumErrorGroups) const |
Get error message description. | |
virtual PBoolean | ConvertOSError (int error, ErrorGroup group=LastGeneralError) |
Convert an operating system error into platform independent error. | |
PBoolean | Accept () |
Accept a new inbound connection (server). | |
PBoolean | Accept (PChannel &channel) |
Accept a new inbound connection (server). | |
PBoolean | Accept (PChannel *channel, PBoolean autoDelete=true) |
Accept a new inbound connection (server). | |
PBoolean | Connect () |
Connect to remote server. | |
PBoolean | Connect (PChannel &channel) |
Connect to remote server. | |
PBoolean | Connect (PChannel *channel, PBoolean autoDelete=true) |
Connect to remote server. | |
PBoolean | UseCertificate (const PSSLCertificate &certificate) |
Use the certificate specified. | |
PBoolean | UsePrivateKey (const PSSLPrivateKey &key) |
Use the private key file specified. | |
void | SetVerifyMode (VerifyMode mode) |
PSSLContext * | GetContext () const |
virtual PBoolean | RawSSLRead (void *buf, PINDEX &len) |
![]() | |
PIndirectChannel () | |
Create a new indirect channel without any channels to redirect to. | |
~PIndirectChannel () | |
Close the indirect channel, deleting read/write channels if desired. | |
Comparison | Compare (const PObject &obj) const |
Determine if the two objects refer to the same indirect channel. | |
virtual PString | GetName () const |
Get the name of the channel. | |
virtual PBoolean | IsOpen () const |
Determine if the channel is currently open and read and write operations can be executed on it. | |
virtual bool | SetLocalEcho (bool localEcho) |
Set local echo mode. | |
virtual PChannel * | GetBaseReadChannel () const |
This function returns the eventual base channel for reading of a series of indirect channels provided by descendents of PIndirectChannel . | |
virtual PChannel * | GetBaseWriteChannel () const |
This function returns the eventual base channel for writing of a series of indirect channels provided by descendents of PIndirectChannel . | |
PBoolean | Open (PChannel &channel) |
Set the channel for both read and write operations. | |
PBoolean | Open (PChannel *channel, PBoolean autoDelete=true) |
Set the channel for both read and write operations. | |
PBoolean | Open (PChannel *readChannel, PChannel *writeChannel, PBoolean autoDeleteRead=true, PBoolean autoDeleteWrite=true) |
Set the channel for both read and write operations. | |
PChannel * | GetReadChannel () const |
Get the channel used for read operations. | |
bool | SetReadChannel (PChannel *channel, bool autoDelete=true, bool closeExisting=false) |
Set the channel for read operations. | |
PChannel * | GetWriteChannel () const |
Get the channel used for write operations. | |
PBoolean | SetWriteChannel (PChannel *channel, bool autoDelete=true, bool closeExisting=false) |
Set the channel for read operations. | |
![]() | |
PBoolean | SetErrorValues (Errors errorCode, int osError, ErrorGroup group=LastGeneralError) |
Set error values to those specified. | |
PChannel () | |
Create the channel. | |
~PChannel () | |
Close down the channel. | |
virtual PINDEX | HashFunction () const |
Calculate a hash value for use in sets and dictionaries. | |
int | GetHandle () const |
Get the integer operating system handle for the channel. | |
void | SetReadTimeout (const PTimeInterval &time) |
Set the timeout for read operations. | |
PTimeInterval | GetReadTimeout () const |
Get the timeout for read operations. | |
virtual PINDEX | GetLastReadCount () const |
Get the number of bytes read by the last Read() call. | |
virtual int | ReadChar () |
Read a single 8 bit byte from the channel. | |
PBoolean | ReadBlock (void *buf, PINDEX len) |
Read len bytes into the buffer from the channel. | |
PString | ReadString (PINDEX len) |
Read len character into a string from the channel. | |
virtual PBoolean | ReadAsync (void *buf, PINDEX len) |
Begin an asynchronous read from channel. | |
virtual void | OnReadComplete (void *buf, PINDEX len) |
User callback function for when a ReadAsync() call has completed or timed out. | |
void | SetWriteTimeout (const PTimeInterval &time) |
Set the timeout for write operations to complete. | |
PTimeInterval | GetWriteTimeout () const |
Get the timeout for write operations to complete. | |
virtual PBoolean | Write (const void *buf, PINDEX len, const void *mark) |
Low level write to the channel with marker. | |
virtual PINDEX | GetLastWriteCount () const |
Get the number of bytes written by the last Write() call. | |
PBoolean | WriteChar (int c) |
Write a single character to the channel. | |
PBoolean | WriteString (const PString &str) |
Write a string to the channel. | |
virtual PBoolean | WriteAsync (const void *buf, PINDEX len) |
Begin an asynchronous write from channel. | |
virtual void | OnWriteComplete (const void *buf, PINDEX len) |
User callback function for when a WriteAsync() call has completed or timed out. | |
virtual bool | FlowControl (const void *flowData) |
Flow Control information Pass data to the channel for flowControl determination. | |
PBoolean | SetBufferSize (PINDEX newSize) |
Set the iostream buffer size for reads and writes. | |
PBoolean | SendCommandString (const PString &command) |
Send a command meta-string. | |
void | AbortCommandString () |
Abort a command string that is in progress. | |
Errors | GetErrorCode (ErrorGroup group=NumErrorGroups) const |
Get normalised error code. | |
int | GetErrorNumber (ErrorGroup group=NumErrorGroups) const |
Get OS errro code. | |
virtual PBoolean | Read (const VectorOfSlice &slices) |
Low level scattered read from the channel. | |
virtual PBoolean | Write (const VectorOfSlice &slices) |
Low level scattered write to the channel. | |
![]() | |
virtual | ~PObject () |
virtual PObject * | Clone () const |
Create a copy of the class on the heap. | |
virtual const char * | GetClass (unsigned ancestor=0) const |
Get the current dynamic type of the object instance. | |
PBoolean | IsClass (const char *cls) const |
virtual PBoolean | InternalIsDescendant (const char *clsName) const |
Determine if the dynamic type of the current instance is a descendent of the specified class. | |
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const |
Determine the byte wise comparison of two objects. | |
bool | operator== (const PObject &obj) const |
Compare the two objects. | |
bool | operator!= (const PObject &obj) const |
Compare the two objects. | |
bool | operator< (const PObject &obj) const |
Compare the two objects. | |
bool | operator> (const PObject &obj) const |
Compare the two objects. | |
bool | operator<= (const PObject &obj) const |
Compare the two objects. | |
bool | operator>= (const PObject &obj) const |
Compare the two objects. | |
virtual void | PrintOn (ostream &strm) const |
Output the contents of the object to the stream. | |
virtual void | ReadFrom (istream &strm) |
Input the contents of the object from the stream. |
Protected Member Functions | |
virtual PBoolean | OnOpen () |
This callback is executed when the Open() function is called with open channels. |
Protected Attributes | |
PSSLContext * | context |
PBoolean | autoDeleteContext |
ssl_st * | ssl |
![]() | |
PChannel * | readChannel |
Channel for read operations. | |
PBoolean | readAutoDelete |
Automatically delete read channel on destruction. | |
PChannel * | writeChannel |
Channel for write operations. | |
PBoolean | writeAutoDelete |
Automatically delete write channel on destruction. | |
PReadWriteMutex | channelPointerMutex |
Race condition prevention on closing channel. | |
![]() | |
int | os_handle |
The operating system file handle return by standard open() function. | |
Errors | lastErrorCode [NumErrorGroups+1] |
The platform independant error code. | |
int | lastErrorNumber [NumErrorGroups+1] |
The operating system error number (eg as returned by errno). | |
PINDEX | lastReadCount |
Number of byte last read by the Read() function. | |
PINDEX | lastWriteCount |
Number of byte last written by the Write() function. | |
PTimeInterval | readTimeout |
Timeout for read operations. | |
PTimeInterval | writeTimeout |
Timeout for write operations. | |
PString | channelName |
PMutex | px_threadMutex |
PXBlockType | px_lastBlockType |
PThread * | px_readThread |
PThread * | px_writeThread |
PMutex | px_writeMutex |
PThread * | px_selectThread [3] |
PMutex | px_selectMutex [3] |
Additional Inherited Members | |
![]() | |
static PBoolean | ConvertOSError (int libcReturnValue, Errors &lastError, int &osError) |
Convert an operating system error into platform independent error. | |
static PString | GetErrorText (Errors lastError, int osError=0) |
Get error message description. | |
![]() |
This class will start a secure SSL based channel.
PSSLChannel::PSSLChannel | ( | PSSLContext * | context = NULL , |
PBoolean | autoDeleteContext = false |
||
) |
Create a new channel given the context.
If no context is given a default one is created.
context | Context for SSL channel |
autoDeleteContext | Flag for context to be automatically deleted. |
PSSLChannel::PSSLChannel | ( | PSSLContext & | context | ) |
context | Context for SSL channel |
PSSLChannel::~PSSLChannel | ( | ) |
Close and clear the SSL channel.
PBoolean PSSLChannel::Accept | ( | ) |
Accept a new inbound connection (server).
This version expects that the indirect channel has already been opened using Open() beforehand.
Accept a new inbound connection (server).
channel | Channel to attach to. |
Accept a new inbound connection (server).
channel | Channel to attach to. |
autoDelete | Flag for if channel should be automatically deleted. |
|
virtual |
Close the channel.
This will detach itself from the read and write channels and delete both of them if they are auto delete.
Reimplemented from PIndirectChannel.
PBoolean PSSLChannel::Connect | ( | ) |
Connect to remote server.
This version expects that the indirect channel has already been opened using Open() beforehand.
Connect to remote server.
channel | Channel to attach to. |
Connect to remote server.
channel | Channel to attach to. |
autoDelete | Flag for if channel should be automatically deleted. |
|
virtual |
Convert an operating system error into platform independent error.
The internal error codes are set by this function. They may be obtained via the GetErrorCode()
and GetErrorNumber()
functions.
Reimplemented from PChannel.
|
inline |
References context.
|
virtual |
Get error message description.
Return a string indicating the error message that may be displayed to the user. The error for the last I/O operation in this object is used.
Reimplemented from PIndirectChannel.
|
protectedvirtual |
This callback is executed when the Open() function is called with open channels.
It may be used by descendent channels to do any handshaking required by the protocol that channel embodies.
The default behaviour "connects" the channel to the OpenSSL library.
Reimplemented from PIndirectChannel.
|
virtual |
|
virtual |
Low level read from the channel.
This function may block until the requested number of characters were read or the read timeout was reached. The GetLastReadCount() function returns the actual number of bytes read.
This will use the readChannel
pointer to actually do the read. If readChannel
is null the this asserts.
The GetErrorCode() function should be consulted after Read() returns false to determine what caused the failure.
Reimplemented from PIndirectChannel.
void PSSLChannel::SetVerifyMode | ( | VerifyMode | mode | ) |
|
inlinevirtual |
Close one or both of the data streams associated with a channel.
The behavour here is to pass the shutdown on to its read and write channels.
Reimplemented from PIndirectChannel.
PBoolean PSSLChannel::UseCertificate | ( | const PSSLCertificate & | certificate | ) |
Use the certificate specified.
PBoolean PSSLChannel::UsePrivateKey | ( | const PSSLPrivateKey & | key | ) |
Use the private key file specified.
|
virtual |
Low level write to the channel.
This function will block until the requested number of characters are written or the write timeout is reached. The GetLastWriteCount() function returns the actual number of bytes written.
This will use the writeChannel
pointer to actually do the write. If writeChannel
is null the this asserts.
The GetErrorCode() function should be consulted after Write() returns false to determine what caused the failure.
Reimplemented from PIndirectChannel.
|
protected |
|
protected |
Referenced by GetContext().
|
protected |