Diag-Client-Lib
doip_udp_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_UDP_CHANNEL_DOIP_UDP_CHANNEL_HANDLER_H_
9 #define DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CHANNEL_UDP_CHANNEL_DOIP_UDP_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 udp_channel {
23 
24 // Forward declaration
25 class DoipUdpChannel;
26 
30 class DoipUdpChannelHandler final {
31  public:
36 
46  DoipUdpChannelHandler(sockets::UdpSocketHandler &udp_socket_handler_broadcast,
47  sockets::UdpSocketHandler &udp_socket_handler_unicast,
48  DoipUdpChannel &channel);
49 
58  uds_transport::UdsMessageConstPtr vehicle_identification_request) noexcept
60 
66  void HandleMessageUnicast(UdpMessagePtr udp_rx_message) noexcept;
67 
73  void HandleMessageBroadcast(UdpMessagePtr udp_rx_message) noexcept;
74 
75  private:
83  auto ProcessDoIPHeader(DoipMessage &doip_rx_message, std::uint8_t &nack_code) noexcept -> bool;
84 
92  static auto ProcessDoIPPayloadLength(std::uint32_t payload_len,
93  std::uint16_t payload_type) noexcept -> bool;
94 
100  void ProcessDoIPPayload(DoipMessage &doip_payload, DoipMessage::RxSocketType socket_type =
102 
107 
112 
117 };
118 } // namespace udp_channel
119 } // namespace channel
120 } // namespace doip_client
121 
122 #endif //DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CHANNEL_UDP_CHANNEL_DOIP_UDP_CHANNEL_HANDLER_H_
Immutable class to store received doip message.
Definition: doip_message.h:21
RxSocketType
Definition of socket type from where the request was received.
Definition: doip_message.h:31
Class to handle udp received messages from lower layer.
std::mutex channel_handler_lock
Mutex to protect critical section.
auto ProcessDoIPHeader(DoipMessage &doip_rx_message, std::uint8_t &nack_code) noexcept -> bool
Function to process doip header in received response.
VehicleDiscoveryHandler vehicle_discovery_handler_
Handler to process vehicle discovery messages.
sockets::UdpSocketHandler::MessagePtr UdpMessagePtr
Type alias for Tcp message pointer.
auto SendVehicleIdentificationRequest(uds_transport::UdsMessageConstPtr vehicle_identification_request) noexcept -> uds_transport::UdsTransportProtocolMgr::TransmissionResult
Function to vehicle identification request to the connected network.
void ProcessDoIPPayload(DoipMessage &doip_payload, DoipMessage::RxSocketType socket_type=DoipMessage::RxSocketType::kUnicast)
Function to process the doip payload.
VehicleIdentificationHandler vehicle_identification_handler_
Handler to process vehicle identification req/res messages.
DoipUdpChannelHandler(sockets::UdpSocketHandler &udp_socket_handler_broadcast, sockets::UdpSocketHandler &udp_socket_handler_unicast, DoipUdpChannel &channel)
Constructs an instance of DoipUdpChannelHandler.
void HandleMessageUnicast(UdpMessagePtr udp_rx_message) noexcept
Function to process the received unicast udp message.
static auto ProcessDoIPPayloadLength(std::uint32_t payload_len, std::uint16_t payload_type) noexcept -> bool
Function to verify payload length of various payload type.
void HandleMessageBroadcast(UdpMessagePtr udp_rx_message) noexcept
Function to process the received broadcast udp message.
Class to manage a udp channel as per DoIP protocol.
Class used as a handler to process vehicle announcement messages.
Class used as a handler to process vehicle identification req/ res 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