Kea 2.7.5
|
The TLSSocket
class is a concrete derived class of IOAsioSocket
that represents a TLS socket.
More...
#include <tls_socket.h>
Public Member Functions | |
TLSSocket (const IOServicePtr &service, TlsContextPtr context) | |
Constructor. | |
TLSSocket (TlsStream< C > &stream) | |
Constructor from a TLS stream. | |
virtual | ~TLSSocket () |
Destructor. | |
virtual void | asyncReceive (void *data, size_t length, size_t offset, IOEndpoint *endpoint, C &callback) |
Receive Asynchronously. | |
void | asyncSend (const void *data, size_t length, C &callback) |
Send Asynchronously without count. | |
virtual void | asyncSend (const void *data, size_t length, const IOEndpoint *endpoint, C &callback) |
Send Asynchronously. | |
virtual void | cancel () |
Cancel I/O On Socket. | |
virtual void | close () |
Close socket. | |
virtual TlsStream< C >::lowest_layer_type & | getASIOSocket () const |
Returns reference to the underlying ASIO socket. | |
virtual int | getNative () const |
Return file descriptor of underlying socket. | |
virtual int | getProtocol () const |
Return protocol of socket. | |
virtual TlsStream< C > & | getTlsStream () const |
Returns reference to the underlying TLS stream. | |
virtual void | handshake (C &callback) |
Perform Handshake. | |
virtual bool | isOpenSynchronous () const |
Is "open()" synchronous predicate. | |
bool | isUsable () const |
Checks if the connection is usable. | |
virtual void | open (const IOEndpoint *endpoint, C &callback) |
Open Socket. | |
virtual bool | processReceivedData (const void *staging, size_t length, size_t &cumulative, size_t &offset, size_t &expected, isc::util::OutputBufferPtr &outbuff) |
Process received data packet. | |
virtual void | shutdown (C &callback) |
TLS shutdown. | |
Public Member Functions inherited from isc::asiolink::IOAsioSocket< C > | |
virtual | ~IOAsioSocket ()=default |
The destructor. | |
Public Member Functions inherited from isc::asiolink::IOSocket | |
virtual | ~IOSocket () |
The destructor. | |
Additional Inherited Members | |
Public Types inherited from isc::asiolink::IOSocket | |
typedef boost::asio::socket_base::reuse_address | ReuseAddress |
Represents SO_REUSEADDR socket option. | |
Static Public Member Functions inherited from isc::asiolink::IOSocket | |
static IOSocket & | getDummyUDPSocket () |
Return a non-usable "dummy" UDP socket for testing. | |
static IOSocket & | getDummyTCPSocket () |
Return a non-usable "dummy" TCP socket for testing. | |
Protected Member Functions inherited from isc::asiolink::IOAsioSocket< C > | |
IOAsioSocket () | |
The default constructor. | |
Protected Member Functions inherited from isc::asiolink::IOSocket | |
IOSocket () | |
The default constructor. | |
The TLSSocket
class is a concrete derived class of IOAsioSocket
that represents a TLS socket.
C | Callback type. |
Definition at line 28 of file tls_socket.h.
isc::asiolink::TLSSocket< C >::TLSSocket | ( | TlsStream< C > & | stream | ) |
Constructor from a TLS stream.
It is assumed that the caller will open and close the stream, so these operations are a no-op for that stream.
stream | The TLS stream. |
Definition at line 265 of file tls_socket.h.
isc::asiolink::TLSSocket< C >::TLSSocket | ( | const IOServicePtr & | service, |
TlsContextPtr | context ) |
Constructor.
Used when the TLSSocket is being asked to manage its own internal socket. In this case, the open() and close() methods are used.
service | I/O Service object used to manage the socket. |
context | Pointer to TLS context. |
Definition at line 273 of file tls_socket.h.
|
virtual |
Destructor.
Definition at line 282 of file tls_socket.h.
|
virtual |
Receive Asynchronously.
Calls the underlying socket's async_receive() method to read a packet of data from a remote endpoint. Arrival of the data is signalled via a call to the callback function.
data | Buffer to receive incoming message. |
length | Length of the data buffer. |
offset | Offset into buffer where data is to be put. |
endpoint | Source of the communication. |
callback | Callback object. |
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 392 of file tls_socket.h.
References isc::asiolink::TCPEndpoint::getASIOEndpoint(), isc_throw, and isc_throw_assert.
void isc::asiolink::TLSSocket< C >::asyncSend | ( | const void * | data, |
size_t | length, | ||
C & | callback ) |
Send Asynchronously without count.
This variant of the method sends data over the TLS socket without preceding the data with a data count. Eventually, we should migrate the virtual method to not insert the count but there are existing classes using the count. Once this migration is done, the existing virtual method should be replaced by this method.
data | Data to send. |
length | Length of data to send. |
callback | Callback object. |
BufferTooLarge | on attempt to send a buffer larger than 64kB. |
Definition at line 336 of file tls_socket.h.
References isc_throw.
|
virtual |
Send Asynchronously.
Calls the underlying socket's async_send() method to send a packet of data asynchronously to the remote endpoint. The callback will be called on completion.
data | Data to send. |
length | Length of data to send. |
endpoint | Target of the send. (Unused for a TLS socket because that was determined when the connection was opened.) |
callback | Callback object. |
BufferTooLarge | on attempt to send a buffer larger than 64kB. |
Need to copy the data into a temporary buffer and precede it with a two-byte count field.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 358 of file tls_socket.h.
References isc_throw.
|
virtual |
Cancel I/O On Socket.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 496 of file tls_socket.h.
|
virtual |
Close socket.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 517 of file tls_socket.h.
|
inlinevirtual |
Returns reference to the underlying ASIO socket.
Definition at line 216 of file tls_socket.h.
|
inlinevirtual |
Return file descriptor of underlying socket.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 52 of file tls_socket.h.
Referenced by isc::asiolink::TLSSocket< C >::isUsable().
|
inlinevirtual |
Return protocol of socket.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 61 of file tls_socket.h.
|
inlinevirtual |
Returns reference to the underlying TLS stream.
Definition at line 223 of file tls_socket.h.
|
virtual |
Perform Handshake.
Perform the TLS handshake. This is an asynchronous operation, completion of which will be signalled via a call to the callback function.
callback | Callback object. |
Definition at line 324 of file tls_socket.h.
References isc_throw.
|
inlinevirtual |
Is "open()" synchronous predicate.
Indicates that the opening of a TLS socket is asynchronous.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 68 of file tls_socket.h.
|
inline |
Checks if the connection is usable.
The connection is usable if the socket is open and the peer has not closed its connection.
Definition at line 78 of file tls_socket.h.
References isc::asiolink::TLSSocket< C >::getNative().
|
virtual |
Open Socket.
Opens the TLS socket. This is an asynchronous operation, completion of which will be signalled via a call to the callback function.
endpoint | Endpoint to which the socket will connect. |
callback | Callback object. |
the derived class and the two classes differ on return type.
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 289 of file tls_socket.h.
References isc_throw_assert.
|
virtual |
Process received data packet.
See the description of IOAsioSocket::receiveComplete for a complete description of this method.
staging | Pointer to the start of the staging buffer. |
length | Amount of data in the staging buffer. |
cumulative | Amount of data received before the staging buffer is processed. |
offset | Unused. |
expected | unused. |
outbuff | Output buffer. Data in the staging buffer is be copied to this output buffer in the call. |
Implements isc::asiolink::IOAsioSocket< C >.
Definition at line 432 of file tls_socket.h.
References isc::util::readUint16().
|
virtual |
TLS shutdown.
The callback is called on completion i.e. when the peer performs a shutdown or a close.
Definition at line 505 of file tls_socket.h.
References isc_throw.