Kea  2.1.7-git
isc::asiolink::TLSSocket< C > Class Template Reference

The TLSSocket class is a concrete derived class of IOAsioSocket that represents a TLS socket. More...

#include <tls_socket.h>

+ Inheritance diagram for isc::asiolink::TLSSocket< C >:

Public Member Functions

 TLSSocket (TlsStream< C > &stream)
 Constructor from a TLS stream. More...
 
 TLSSocket (IOService &service, TlsContextPtr context)
 Constructor. More...
 
virtual ~TLSSocket ()
 Destructor. More...
 
virtual void asyncReceive (void *data, size_t length, size_t offset, IOEndpoint *endpoint, C &callback)
 Receive Asynchronously. More...
 
virtual void asyncSend (const void *data, size_t length, const IOEndpoint *endpoint, C &callback)
 Send Asynchronously. More...
 
void asyncSend (const void *data, size_t length, C &callback)
 Send Asynchronously without count. More...
 
virtual void cancel ()
 Cancel I/O On Socket. More...
 
virtual void close ()
 Close socket. More...
 
virtual TlsStream< C >::lowest_layer_type & getASIOSocket () const
 Returns reference to the underlying ASIO socket. More...
 
virtual int getNative () const
 Return file descriptor of underlying socket. More...
 
virtual int getProtocol () const
 Return protocol of socket. More...
 
virtual TlsStream< C > & getTlsStream () const
 Returns reference to the underlying TLS stream. More...
 
virtual void handshake (C &callback)
 Perform Handshake. More...
 
virtual bool isOpenSynchronous () const
 Is "open()" synchronous predicate. More...
 
bool isUsable () const
 Checks if the connection is usable. More...
 
virtual void open (const IOEndpoint *endpoint, C &callback)
 Open Socket. More...
 
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. More...
 
virtual void shutdown (C &callback)
 TLS shutdown. More...
 

Additional Inherited Members

Detailed Description

template<typename C>
class isc::asiolink::TLSSocket< C >

The TLSSocket class is a concrete derived class of IOAsioSocket that represents a TLS socket.

Template Parameters
CCallback type.

Definition at line 27 of file tls_socket.h.

Constructor & Destructor Documentation

◆ TLSSocket() [1/2]

template<typename C>
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.

Parameters
streamThe TLS stream.

Definition at line 261 of file tls_socket.h.

◆ TLSSocket() [2/2]

template<typename C>
isc::asiolink::TLSSocket< C >::TLSSocket ( IOService 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.

Parameters
serviceI/O Service object used to manage the socket.
contextPointer to TLS context.

Definition at line 269 of file tls_socket.h.

◆ ~TLSSocket()

template<typename C>
virtual isc::asiolink::TLSSocket< C >::~TLSSocket ( )
inlinevirtual

Destructor.

Definition at line 48 of file tls_socket.h.

Member Function Documentation

◆ asyncReceive()

template<typename C>
void isc::asiolink::TLSSocket< C >::asyncReceive ( void *  data,
size_t  length,
size_t  offset,
IOEndpoint endpoint,
C &  callback 
)
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.

Parameters
dataBuffer to receive incoming message.
lengthLength of the data buffer.
offsetOffset into buffer where data is to be put.
endpointSource of the communication.
callbackCallback object.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 383 of file tls_socket.h.

Referenced by isc::asiolink::TLSSocket< SocketCallback >::isUsable().

◆ asyncSend() [1/2]

template<typename C>
void isc::asiolink::TLSSocket< C >::asyncSend ( const void *  data,
size_t  length,
const IOEndpoint endpoint,
C &  callback 
)
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.

Parameters
dataData to send.
lengthLength of data to send.
endpointTarget of the send. (Unused for a TLS socket because that was determined when the connection was opened.)
callbackCallback object.
Exceptions
BufferTooLargeon 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.

Todo:
arrange for the buffer passed to be preceded by the count

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 348 of file tls_socket.h.

Referenced by isc::asiolink::TLSSocket< SocketCallback >::isUsable().

◆ asyncSend() [2/2]

template<typename C>
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.

Parameters
dataData to send.
lengthLength of data to send.
callbackCallback object.
Exceptions
BufferTooLargeon attempt to send a buffer larger than 64kB.

Definition at line 325 of file tls_socket.h.

◆ cancel()

template<typename C >
void isc::asiolink::TLSSocket< C >::cancel ( )
virtual

◆ close()

template<typename C >
void isc::asiolink::TLSSocket< C >::close ( )
virtual

◆ getASIOSocket()

template<typename C>
virtual TlsStream<C>::lowest_layer_type& isc::asiolink::TLSSocket< C >::getASIOSocket ( ) const
inlinevirtual

Returns reference to the underlying ASIO socket.

Returns
Reference to underlying ASIO socket.

Definition at line 215 of file tls_socket.h.

Referenced by isc::asiolink::TLSAcceptor< C >::asyncAccept().

◆ getNative()

template<typename C>
virtual int isc::asiolink::TLSSocket< C >::getNative ( ) const
inlinevirtual

Return file descriptor of underlying socket.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 51 of file tls_socket.h.

Referenced by isc::asiolink::TLSSocket< SocketCallback >::isUsable().

◆ getProtocol()

template<typename C>
virtual int isc::asiolink::TLSSocket< C >::getProtocol ( ) const
inlinevirtual

Return protocol of socket.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 60 of file tls_socket.h.

◆ getTlsStream()

template<typename C>
virtual TlsStream<C>& isc::asiolink::TLSSocket< C >::getTlsStream ( ) const
inlinevirtual

Returns reference to the underlying TLS stream.

Returns
Reference to underlying TLS stream.

Definition at line 222 of file tls_socket.h.

◆ handshake()

template<typename C>
void isc::asiolink::TLSSocket< C >::handshake ( C &  callback)
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.

Parameters
callbackCallback object.

Definition at line 313 of file tls_socket.h.

Referenced by isc::asiolink::TLSSocket< SocketCallback >::isUsable().

◆ isOpenSynchronous()

template<typename C>
virtual bool isc::asiolink::TLSSocket< C >::isOpenSynchronous ( ) const
inlinevirtual

Is "open()" synchronous predicate.

Indicates that the opening of a TLS socket is asynchronous.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 67 of file tls_socket.h.

◆ isUsable()

template<typename C>
bool isc::asiolink::TLSSocket< C >::isUsable ( ) const
inline

Checks if the connection is usable.

The connection is usable if the socket is open and the peer has not closed its connection.

Returns
true if the connection is usable.

Definition at line 77 of file tls_socket.h.

◆ open()

template<typename C>
void isc::asiolink::TLSSocket< C >::open ( const IOEndpoint endpoint,
C &  callback 
)
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.

Parameters
endpointEndpoint to which the socket will connect.
callbackCallback object.

the derived class and the two classes differ on return type.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 278 of file tls_socket.h.

Referenced by isc::asiolink::TLSSocket< SocketCallback >::isUsable(), and isc::asiolink::TLSSocket< SocketCallback >::open().

◆ processReceivedData()

template<typename C >
bool isc::asiolink::TLSSocket< C >::processReceivedData ( const void *  staging,
size_t  length,
size_t &  cumulative,
size_t &  offset,
size_t &  expected,
isc::util::OutputBufferPtr outbuff 
)
virtual

Process received data packet.

See the description of IOAsioSocket::receiveComplete for a complete description of this method.

Parameters
stagingPointer to the start of the staging buffer.
lengthAmount of data in the staging buffer.
cumulativeAmount of data received before the staging buffer is processed.
offsetUnused.
expectedunused.
outbuffOutput buffer. Data in the staging buffer is be copied to this output buffer in the call.
Returns
Always true.

Implements isc::asiolink::IOAsioSocket< C >.

Definition at line 424 of file tls_socket.h.

Referenced by isc::asiolink::TLSSocket< SocketCallback >::isUsable().

◆ shutdown()

template<typename C>
void isc::asiolink::TLSSocket< C >::shutdown ( C &  callback)
virtual

TLS shutdown.

The callback is called on completion i.e. when the peer performs a shutdown or a close.

Definition at line 498 of file tls_socket.h.

Referenced by isc::asiolink::TLSSocket< SocketCallback >::isUsable().


The documentation for this class was generated from the following file: