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 
13 #include "common/doip_message.h"
17 
18 namespace doip_client {
19 namespace channel {
20 namespace udp_channel {
21 
22 // Forward declaration
23 class DoipUdpChannel;
24 
28 class DoipUdpChannelHandler final {
29  public:
34 
44  DoipUdpChannelHandler(sockets::UdpSocketHandler &udp_socket_handler_broadcast,
45  sockets::UdpSocketHandler &udp_socket_handler_unicast, DoipUdpChannel &channel);
46 
54  auto SendVehicleIdentificationRequest(uds_transport::UdsMessageConstPtr vehicle_identification_request) noexcept
56 
62  void HandleMessageUnicast(UdpMessagePtr udp_rx_message) noexcept;
63 
69  void HandleMessageBroadcast(UdpMessagePtr udp_rx_message) noexcept;
70 
71  private:
79  auto ProcessDoIPHeader(DoipMessage &doip_rx_message, std::uint8_t &nack_code) noexcept -> bool;
80 
88  static auto ProcessDoIPPayloadLength(std::uint32_t payload_len, std::uint16_t payload_type) noexcept -> bool;
89 
95  void ProcessDoIPPayload(DoipMessage &doip_payload,
97 
102 
107 
112 };
113 } // namespace udp_channel
114 } // namespace channel
115 } // namespace doip_client
116 
117 #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.
sockets::UdpSocketHandler::UdpMessagePtr UdpMessagePtr
Type alias for Tcp message pointer.
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.
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.
Class used to create a udp socket for handling transmission and reception of udp message from driver.
boost_support::socket::udp::UdpMessagePtr UdpMessagePtr
Type alias for Udp message pointer.
std::unique_ptr< const UdsMessage > UdsMessageConstPtr
Definition: uds_message.h:69