| 
    Diag-Client-Lib
    
   | 
 
Class used to create a tls socket for handling transmission and reception of tcp message from driver. More...
#include <tls_client_.h>
Public Types | |
| enum class | TlsErrorCode : std::uint8_t {  kOpenFailed , kBindingFailed , kConnectFailed , kTlsHandshakeFailed , kGenericError }  | 
| TLS error code.  More... | |
| using | TcpHandlerRead = std::function< void(message::tcp::TcpMessagePtr)> | 
| Tcp function template used for reception.  More... | |
Public Member Functions | |
| TlsClientSocket (std::string_view local_ip_address, std::uint16_t local_port_num, TcpHandlerRead tcp_handler_read, std::string_view ca_certification_path) | |
| Constructs an instance of TlsClientSocket.  More... | |
| ~TlsClientSocket () | |
| Destruct an instance of TcpClientSocket.  More... | |
| core_type::Result< void, TlsErrorCode > | Open () | 
| Function to Open the socket.  More... | |
| core_type::Result< void, TlsErrorCode > | ConnectToHost (std::string_view host_ip_address, std::uint16_t host_port_num) | 
| Function to connect to remote ip address and port number.  More... | |
| core_type::Result< void, TlsErrorCode > | DisconnectFromHost () | 
| Function to Disconnect from host.  More... | |
| core_type::Result< void, TlsErrorCode > | Transmit (message::tcp::TcpMessageConstPtr tcp_message) | 
| Function to trigger transmission.  More... | |
| core_type::Result< void, TlsErrorCode > | Destroy () | 
| Function to destroy the socket.  More... | |
Private Types | |
| using | Tcp = boost::asio::ip::tcp | 
| Type alias for tcp protocol.  More... | |
| using | TcpSocket = Tcp::socket | 
| Type alias for tcp socket.  More... | |
| using | TlsStream = boost::asio::ssl::stream< TcpSocket > | 
| Type alias for tls stream wrapping tcp socket.  More... | |
| using | TcpIpAddress = boost::asio::ip::address | 
| Type alias for tcp ip address.  More... | |
| using | TcpErrorCodeType = boost::system::error_code | 
| Type alias for tcp error codes.  More... | |
Private Member Functions | |
| TlsStream::lowest_layer_type & | GetNativeTcpSocket () | 
| Function to get the native tcp socket under tls socket.  More... | |
| void | HandleMessage () | 
| Function to handle the reception of tcp message.  More... | |
Private Attributes | |
| std::string | local_ip_address_ | 
| Store local ip address.  More... | |
| std::uint16_t | local_port_num_ | 
| Store local port number.  More... | |
| boost::asio::io_context | io_context_ | 
| boost io context  More... | |
| boost::asio::ssl::context | io_ssl_context_ | 
| boost io ssl context  More... | |
| TlsStream | tls_socket_ | 
| Store ssl socket.  More... | |
| std::atomic_bool | exit_request_ | 
| Flag to terminate the thread.  More... | |
| std::atomic_bool | running_ | 
| Flag to start the thread.  More... | |
| std::condition_variable | cond_var_ | 
| Conditional variable to block the thread.  More... | |
| std::mutex | mutex_ | 
| mutex to lock critical section  More... | |
| std::thread | thread_ | 
| The thread itself.  More... | |
| TcpHandlerRead | tcp_handler_read_ | 
| Store the handler.  More... | |
Class used to create a tls socket for handling transmission and reception of tcp message from driver.
Definition at line 27 of file tls_client_.h.
      
  | 
  private | 
Type alias for tcp protocol.
Definition at line 106 of file tls_client_.h.
      
  | 
  private | 
Type alias for tcp error codes.
Definition at line 126 of file tls_client_.h.
| using boost_support::socket::tcp::TlsClientSocket::TcpHandlerRead = std::function<void(message::tcp::TcpMessagePtr)> | 
Tcp function template used for reception.
Definition at line 43 of file tls_client_.h.
      
  | 
  private | 
Type alias for tcp ip address.
Definition at line 121 of file tls_client_.h.
      
  | 
  private | 
Type alias for tcp socket.
Definition at line 111 of file tls_client_.h.
      
  | 
  private | 
Type alias for tls stream wrapping tcp socket.
Definition at line 116 of file tls_client_.h.
      
  | 
  strong | 
TLS error code.
| Enumerator | |
|---|---|
| kOpenFailed | |
| kBindingFailed | |
| kConnectFailed | |
| kTlsHandshakeFailed | |
| kGenericError | |
Definition at line 32 of file tls_client_.h.
| boost_support::socket::tcp::TlsClientSocket::TlsClientSocket | ( | std::string_view | local_ip_address, | 
| std::uint16_t | local_port_num, | ||
| TcpHandlerRead | tcp_handler_read, | ||
| std::string_view | ca_certification_path | ||
| ) | 
Constructs an instance of TlsClientSocket.
| [in] | local_ip_address | The local ip address | 
| [in] | local_port_num | The local port number | 
| [in] | tcp_handler_read | The handler to send received data to user | 
| [in] | ca_certification_path | The path to root ca certificate | 
Definition at line 51 of file tls_client_.cpp.
References cond_var_, exit_request_, HandleMessage(), io_ssl_context_, mutex_, boost_support::socket::tcp::anonymous_namespace{tls_client_.cpp}::print_cn_name(), running_, thread_, and tls_socket_.

| boost_support::socket::tcp::TlsClientSocket::~TlsClientSocket | ( | ) | 
Destruct an instance of TcpClientSocket.
Definition at line 109 of file tls_client_.cpp.
References cond_var_, exit_request_, mutex_, running_, and thread_.
| core_type::Result< void, TlsClientSocket::TlsErrorCode > boost_support::socket::tcp::TlsClientSocket::ConnectToHost | ( | std::string_view | host_ip_address, | 
| std::uint16_t | host_port_num | ||
| ) | 
Function to connect to remote ip address and port number.
| [in] | host_ip_address | The host ip address | 
| [in] | host_port_num | The host port number | 
Definition at line 161 of file tls_client_.cpp.
References cond_var_, FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), GetNativeTcpSocket(), kConnectFailed, kGenericError, kTlsHandshakeFailed, mutex_, running_, and tls_socket_.

| core_type::Result< void, TlsClientSocket::TlsErrorCode > boost_support::socket::tcp::TlsClientSocket::Destroy | ( | ) | 
Function to destroy the socket.
Definition at line 254 of file tls_client_.cpp.
References GetNativeTcpSocket(), and kGenericError.

| core_type::Result< void, TlsClientSocket::TlsErrorCode > boost_support::socket::tcp::TlsClientSocket::DisconnectFromHost | ( | ) | 
Function to Disconnect from host.
Definition at line 203 of file tls_client_.cpp.
References FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), GetNativeTcpSocket(), kGenericError, mutex_, running_, and tls_socket_.

      
  | 
  private | 
Function to get the native tcp socket under tls socket.
Definition at line 318 of file tls_client_.cpp.
References tls_socket_.
Referenced by ConnectToHost(), Destroy(), DisconnectFromHost(), HandleMessage(), Open(), and Transmit().

      
  | 
  private | 
Function to handle the reception of tcp message.
Definition at line 262 of file tls_client_.cpp.
References FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), GetNativeTcpSocket(), boost_support::message::tcp::kDoipheadrSize, running_, tcp_handler_read_, and tls_socket_.
Referenced by TlsClientSocket().


| core_type::Result< void, TlsClientSocket::TlsErrorCode > boost_support::socket::tcp::TlsClientSocket::Open | ( | ) | 
Function to Open the socket.
Definition at line 119 of file tls_client_.cpp.
References FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), GetNativeTcpSocket(), kBindingFailed, kGenericError, kOpenFailed, local_ip_address_, and local_port_num_.

| core_type::Result< void, TlsClientSocket::TlsErrorCode > boost_support::socket::tcp::TlsClientSocket::Transmit | ( | message::tcp::TcpMessageConstPtr | tcp_message | ) | 
Function to trigger transmission.
| [in] | tcp_message | The tcp message to be transmitted | 
Definition at line 228 of file tls_client_.cpp.
References FILE_NAME, boost_support::common::logger::LibBoostLogger::GetLibBoostLogger(), GetNativeTcpSocket(), kGenericError, and tls_socket_.

      
  | 
  private | 
Conditional variable to block the thread.
Definition at line 166 of file tls_client_.h.
Referenced by ConnectToHost(), TlsClientSocket(), and ~TlsClientSocket().
      
  | 
  private | 
Flag to terminate the thread.
Definition at line 156 of file tls_client_.h.
Referenced by TlsClientSocket(), and ~TlsClientSocket().
      
  | 
  private | 
boost io context
Definition at line 141 of file tls_client_.h.
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
mutex to lock critical section
Definition at line 171 of file tls_client_.h.
Referenced by ConnectToHost(), DisconnectFromHost(), TlsClientSocket(), and ~TlsClientSocket().
      
  | 
  private | 
Flag to start the thread.
Definition at line 161 of file tls_client_.h.
Referenced by ConnectToHost(), DisconnectFromHost(), HandleMessage(), TlsClientSocket(), and ~TlsClientSocket().
      
  | 
  private | 
      
  | 
  private | 
The thread itself.
Definition at line 176 of file tls_client_.h.
Referenced by TlsClientSocket(), and ~TlsClientSocket().
      
  | 
  private | 
Store ssl socket.
Definition at line 151 of file tls_client_.h.
Referenced by ConnectToHost(), DisconnectFromHost(), GetNativeTcpSocket(), HandleMessage(), TlsClientSocket(), and Transmit().