Diag-Client-Lib
doip_tcp_channel.h
Go to the documentation of this file.
1 /* Diagnostic Client library
2  * Copyright (C) 2024 Avijit Dey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 #ifndef DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CHANNEL_TCP_CHANNEL_DOIP_TCP_CHANNEL_H_
9 #define DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CHANNEL_TCP_CHANNEL_DOIP_TCP_CHANNEL_H_
10 
11 #include <memory>
12 #include <string_view>
13 #include <utility>
14 
18 
19 namespace doip_client {
20 namespace channel {
21 namespace tcp_channel {
22 
26 class DoipTcpChannel final {
27  public:
32 
42  DoipTcpChannel(std::string_view tcp_ip_address, std::uint16_t port_num, uds_transport::Connection &connection);
43 
47  ~DoipTcpChannel() = default;
48 
52  void Start();
53 
57  void Stop();
58 
63  bool IsConnectToHost();
64 
72 
78 
104  std::pair<uds_transport::UdsTransportProtocolMgr::IndicationResult, uds_transport::UdsMessagePtr> IndicateMessage(
108  core_type::Span<std::uint8_t> payload_info);
109 
116 
124 
131  void ProcessReceivedTcpMessage(TcpMessagePtr tcp_rx_message);
132 
133  private:
138 
143 
148 
153 };
154 
155 } // namespace tcp_channel
156 } // namespace channel
157 } // namespace doip_client
158 #endif // DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CHANNEL_TCP_CHANNEL_DOIP_TCP_CHANNEL_H_
Class to handle tcp received messages from lower layer.
Class to manage a tcp channel as per DoIP protocol.
void Stop()
Function to stop the channel.
uds_transport::Connection & connection_
Store the reference to doip connection.
void HandleMessage(uds_transport::UdsMessagePtr message)
Function to Hands over a valid received Uds message to upper layer.
void Start()
Function to start the channel.
DoipTcpChannelHandler tcp_channel_handler_
Store the doip channel handler.
std::pair< uds_transport::UdsTransportProtocolMgr::IndicationResult, uds_transport::UdsMessagePtr > IndicateMessage(uds_transport::UdsMessage::Address source_addr, uds_transport::UdsMessage::Address target_addr, uds_transport::UdsMessage::TargetAddressType type, uds_transport::ChannelID channel_id, std::size_t size, uds_transport::Priority priority, uds_transport::ProtocolKind protocol_kind, core_type::Span< std::uint8_t > payload_info)
Function to indicate a start of reception of message.
sockets::TcpSocketHandler::TcpMessagePtr TcpMessagePtr
Type alias for Tcp message pointer.
~DoipTcpChannel()=default
Destruct an instance of TcpChannel.
bool IsConnectToHost()
Function to check if connected to host remote server.
uds_transport::UdsTransportProtocolMgr::ConnectionResult ConnectToHost(uds_transport::UdsMessageConstPtr message)
Function to establish connection to remote host server.
void ProcessReceivedTcpMessage(TcpMessagePtr tcp_rx_message)
Function to process the received Tcp message from socket layer.
uds_transport::UdsTransportProtocolMgr::DisconnectionResult DisconnectFromHost()
Function to disconnect from remote host server.
DoipTcpChannel(std::string_view tcp_ip_address, std::uint16_t port_num, uds_transport::Connection &connection)
Constructs an instance of TcpChannel.
uds_transport::UdsTransportProtocolMgr::TransmissionResult Transmit(uds_transport::UdsMessageConstPtr message)
Function to transmit a valid Uds message.
TcpSocketHandler tcp_socket_handler_
Store the tcp socket handler.
Class used to create a tcp socket for handling transmission and reception of tcp message from driver.
boost_support::socket::tcp::TcpMessagePtr TcpMessagePtr
Type alias for Tcp message pointer.
Interface class to handle connection between two layers.
Definition: connection.h:23
std::string_view ProtocolKind
std::unique_ptr< const UdsMessage > UdsMessageConstPtr
Definition: uds_message.h:69
std::unique_ptr< UdsMessage > UdsMessagePtr
Definition: uds_message.h:71
uint32_t ChannelID
std::uint8_t Priority