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 
11 #include <mutex>
12 
15 #include "common/doip_message.h"
16 #include "sockets/socket_handler.h"
19 
20 namespace doip_client {
21 namespace channel {
22 namespace tcp_channel {
23 
24 // Forward declaration
25 class DoipTcpChannel;
26 
30 class DoipTcpChannelHandler final {
31  public:
36 
44  DoipTcpChannelHandler(sockets::TcpSocketHandler &tcp_socket_handler, DoipTcpChannel &channel);
45 
49  void Start();
50 
55  void Stop();
56 
61  void Reset();
62 
71  uds_transport::UdsMessageConstPtr routing_activation_request) noexcept
73 
81  auto SendDiagnosticRequest(uds_transport::UdsMessageConstPtr diagnostic_request) noexcept
83 
89  void HandleMessage(TcpMessagePtr tcp_rx_message) noexcept;
90 
95  auto IsRoutingActivated() noexcept -> bool;
96 
97  private:
105  auto ProcessDoIPHeader(DoipMessage &doip_rx_message, std::uint8_t &nack_code) noexcept -> bool;
106 
114  auto ProcessDoIPPayloadLength(std::uint32_t payload_len, std::uint16_t payload_type) noexcept
115  -> bool;
116 
122  void ProcessDoIPPayload(DoipMessage &doip_payload) noexcept;
123 
128 
133 
138 };
139 
140 } // namespace tcp_channel
141 } // namespace channel
142 } // namespace doip_client
143 #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.
sockets::TcpSocketHandler::MessagePtr TcpMessagePtr
Type alias for Tcp message pointer.
DoipTcpChannelHandler(sockets::TcpSocketHandler &tcp_socket_handler, DoipTcpChannel &channel)
Constructs an instance of DoipTcpChannelHandler.
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.
Handler class to manage different socket of various client (Udp / Tcp)
typename Client::MessagePtr MessagePtr
Type alias for message pointer.
std::unique_ptr< const UdsMessage > UdsMessageConstPtr
Definition: uds_message.h:69