Diag-Client-Lib
doip_tcp_channel_handler.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_HANDLER_H_
9 #define DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CHANNEL_TCP_CHANNEL_DOIP_TCP_CHANNEL_HANDLER_H_
10 
13 #include "common/doip_message.h"
17 
18 namespace doip_client {
19 namespace channel {
20 namespace tcp_channel {
21 
22 // Forward declaration
23 class DoipTcpChannel;
24 
28 class DoipTcpChannelHandler final {
29  public:
34 
42  DoipTcpChannelHandler(sockets::TcpSocketHandler &tcp_socket_handler, DoipTcpChannel &channel);
43 
47  void Start();
48 
53  void Stop();
54 
59  void Reset();
60 
68  auto SendRoutingActivationRequest(uds_transport::UdsMessageConstPtr routing_activation_request) noexcept
70 
78  auto SendDiagnosticRequest(uds_transport::UdsMessageConstPtr diagnostic_request) noexcept
80 
86  void HandleMessage(TcpMessagePtr tcp_rx_message) noexcept;
87 
92  auto IsRoutingActivated() noexcept -> bool;
93 
94  private:
102  auto ProcessDoIPHeader(DoipMessage &doip_rx_message, std::uint8_t &nack_code) noexcept -> bool;
103 
111  auto ProcessDoIPPayloadLength(std::uint32_t payload_len, std::uint16_t payload_type) noexcept -> bool;
112 
118  void ProcessDoIPPayload(DoipMessage &doip_payload) noexcept;
119 
124 
129 
134 };
135 
136 } // namespace tcp_channel
137 } // namespace channel
138 } // namespace doip_client
139 #endif //DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CHANNEL_TCP_CHANNEL_DOIP_TCP_CHANNEL_HANDLER_H_
Immutable class to store received doip message.
Definition: doip_message.h:21
Class used as a handler to process routing activation messages.
Class to handle tcp received messages from lower layer.
auto ProcessDoIPPayloadLength(std::uint32_t payload_len, std::uint16_t payload_type) noexcept -> bool
Function to verify payload length of various payload type.
auto IsRoutingActivated() noexcept -> bool
Check if routing activation is active for this handler.
RoutingActivationHandler routing_activation_handler_
Handler to process routing activation req/ resp.
std::mutex channel_handler_lock
Mutex to protect critical section.
DiagnosticMessageHandler diagnostic_message_handler_
Handler to process diagnostic message req/ resp.
DoipTcpChannelHandler(sockets::TcpSocketHandler &tcp_socket_handler, DoipTcpChannel &channel)
Constructs an instance of DoipTcpChannelHandler.
sockets::TcpSocketHandler::TcpMessagePtr TcpMessagePtr
Type alias for Tcp message pointer.
auto SendDiagnosticRequest(uds_transport::UdsMessageConstPtr diagnostic_request) noexcept -> uds_transport::UdsTransportProtocolMgr::TransmissionResult
Function to send diagnostic request.
void ProcessDoIPPayload(DoipMessage &doip_payload) noexcept
Function to process the doip payload.
auto SendRoutingActivationRequest(uds_transport::UdsMessageConstPtr routing_activation_request) noexcept -> uds_transport::UdsTransportProtocolMgr::ConnectionResult
Function to send routing activation request.
auto ProcessDoIPHeader(DoipMessage &doip_rx_message, std::uint8_t &nack_code) noexcept -> bool
Function to process doip header in received response.
void HandleMessage(TcpMessagePtr tcp_rx_message) noexcept
Function to process the received message.
Class to manage a tcp channel as per DoIP protocol.
Class used as a handler to process routing activation messages.
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.
std::unique_ptr< const UdsMessage > UdsMessageConstPtr
Definition: uds_message.h:69