![]() |
TSDuck v3.45-4725
MPEG Transport Stream Toolkit
|
Context of a TLS connection. More...
#include <tsTLSContext.h>


Public Member Functions | |
| TLSContext (Report *report, Object *owner=nullptr) | |
| Constructor. | |
| TLSContext (ReporterBase *delegate, Object *owner=nullptr) | |
| Constructor. | |
| virtual | ~TLSContext () override |
| Destructor. | |
| bool | eof () const |
| Check if the input TLS stream is terminated (peer shutdown). | |
| size_t | getDataSizeToSend () const |
| Get the size in bytes of TLS protocol data which are ready to send. | |
| bool | getDataToSend (ByteBlock &tls_data) |
| Get TLS protocol data to send. | |
| bool | initClient (const TLSConnectionBase ¶ms) |
| Initialize the client side of a connection. | |
| bool | initServer (void *cert) |
| Initialize the server side of a connection. | |
| bool | initShutdown (bool silent) |
| Generate a shutdown message to send to the peer. | |
| bool | isOwned () |
| Check if the object is owned. | |
| template<class OBJECT > requires std::derived_from<OBJECT, ts::Object> | |
| bool | isOwned () |
| Check if the object is owned by an object of a given type. | |
| bool | muteReport (bool mute) |
| Temporarily mute the associated report. | |
| bool | needReceive () const |
| Check if more TLS protocol data must be received in order to continue. | |
| bool | needSend () const |
| Check if some TLS protocol data must be sent. | |
| Object * | owner () |
| Get the address of the optional "owner" object which was specified in the constructor. | |
| template<class OBJECT > requires std::derived_from<OBJECT, ts::Object> | |
| OBJECT * | owner () |
| Get the address of the "owner" object which was specified in the constructor. | |
| bool | provideClearData (const void *data, size_t size, size_t &ret_size) |
| Send clear user data over the TLS connection. | |
| bool | provideReceivedData (const void *data, size_t size, size_t &ret_size, ByteBlock &clear_data) |
| Provide received TLS protocol data, collect clear data. | |
| Report & | report () const |
| Access the Report which is associated with this object. | |
| void | reset () |
| Clear the context, free all resources. | |
| bool | serverSide () const |
| Check if this is the server-side of the TLS connection. | |
| Report * | setReport (Report *report) |
| Associate this object with another Report to log errors. | |
| ReporterBase * | setReport (ReporterBase *delegate) |
| Associate this object with another ReporterBase to log errors. | |
| bool | shutdowning () const |
| Check if a TLS shutdown was generated. | |
Static Public Member Functions | |
| static UString | GetLibraryVersion () |
| Get the version of the underlying SSL/TLS library. | |
| static int | SilentLevel (bool silent) |
| Compute a log severity level from a "silent" parameter. | |
Context of a TLS connection.
This is state machine working on pure data, non-blocking, without network access.
Constructor.
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
| [in] | owner | Optional address of an "owner" object, typically an instance of class containing this object. |
|
explicit |
Constructor.
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, log messages are discarded. |
| [in] | owner | Optional address of an "owner" object, typically an instance of class containing this object. |
| bool ts::TLSContext::initClient | ( | const TLSConnectionBase & | params | ) |
Initialize the client side of a connection.
| [in] | params | TLS connection parameters. |
| bool ts::TLSContext::initServer | ( | void * | cert | ) |
Initialize the server side of a connection.
| [in] | cert | Pointer to server certificate.
|
|
inline |
Check if this is the server-side of the TLS connection.
| bool ts::TLSContext::provideClearData | ( | const void * | data, |
| size_t | size, | ||
| size_t & | ret_size | ||
| ) |
Send clear user data over the TLS connection.
Most of the time, this results in a TLS protocol packet to be sent. If the user data are too long, only some of them can be sent in the next TLS protocol packet.
| [in] | data | Address of the clear user message to sent. |
| [in] | size | Size in bytes of the clear user message to sent. |
| [out] | ret_size | Size of data which where consumed. If ret_size is less than size, the rest shall be submitted later. |
|
inline |
Check if some TLS protocol data must be sent.
The application must send the corresponding data and then call sendCompleted().
| size_t ts::TLSContext::getDataSizeToSend | ( | ) | const |
Get the size in bytes of TLS protocol data which are ready to send.
| bool ts::TLSContext::getDataToSend | ( | ByteBlock & | tls_data | ) |
Get TLS protocol data to send.
| [in,out] | tls_data | Binary data to send over the wire are appended into tls_data. |
|
inline |
Check if more TLS protocol data must be received in order to continue.
| bool ts::TLSContext::provideReceivedData | ( | const void * | data, |
| size_t | size, | ||
| size_t & | ret_size, | ||
| ByteBlock & | clear_data | ||
| ) |
Provide received TLS protocol data, collect clear data.
If the received data are too long, only some of them can be processed. In that case, it is possible that some data must be sent before accepting the rest of the received data.
| [in] | data | Address of the received data. |
| [in] | size | Size in bytes of the received data. |
| [out] | ret_size | Size of data which where consumed. If ret_size is less than size, the rest shall be submitted later. |
| [in,out] | clear_data | If any clear user data were extracted from the TLS protocol data, they are appended into clear_data. |
|
inline |
Check if the input TLS stream is terminated (peer shutdown).
| bool ts::TLSContext::initShutdown | ( | bool | silent | ) |
Generate a shutdown message to send to the peer.
| [in] | silent | If true, do not report errors through the logger. This is typically useful when the socket is in some error condition and closing it is necessary although it may generate additional meaningless errors. |
|
inline |
Check if a TLS shutdown was generated.
|
static |
Get the version of the underlying SSL/TLS library.
|
inherited |
Associate this object with another Report to log errors.
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
|
inherited |
Associate this object with another ReporterBase to log errors.
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, the previous explicit Report is used.. |
|
inherited |
Temporarily mute the associated report.
| [in] | mute | It true, report() will return a null report (log messages are discarded), until muteReport() is invoked again with mute set to false. |
|
inlinestaticinherited |
Compute a log severity level from a "silent" parameter.
Some subclass methods have a "silent" parameter to avoid reporting errors which may be insignificant, typically when closing a device after an error, in which case the close operation may produce other errors if the previous error left the device in an inconsistent state. While those errors should not be displayed as errors, we still display them at debug level.
| [in] | silent | If true, do not report errors, report debug messages instead. |
|
inlineinherited |
Get the address of the optional "owner" object which was specified in the constructor.
|
inherited |
Get the address of the "owner" object which was specified in the constructor.
This template version requires that the owner objet is set and of type OBJECT, or some subclass of it. If there is no owner object or if it is not compatible with the template class OBJECT, this is a fatal error and the application is terminated.
| OBJECT | A subclass of Object |
|
inlineinherited |
Check if the object is owned.
|
inlineinherited |
Check if the object is owned by an object of a given type.
| OBJECT | A subclass of Object |