Diag-Client-Lib
doip_udp_channel.cpp
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 
10 
11 namespace doip_client {
12 namespace channel {
13 namespace udp_channel {
14 
15 udp_channel::DoipUdpChannel::DoipUdpChannel(std::string_view udp_ip_address, std::uint16_t port_num,
16  uds_transport::Connection &connection)
17  : udp_socket_handler_broadcast_{udp_ip_address, port_num, UdpSocketHandler::PortType::kUdp_Broadcast, *this},
18  udp_socket_handler_unicast_{udp_ip_address, port_num, UdpSocketHandler::PortType::kUdp_Unicast, *this},
19  udp_channel_handler_{udp_socket_handler_broadcast_, udp_socket_handler_unicast_, *this},
20  connection_{connection} {}
21 
25 }
26 
30 }
31 
33  udp_channel_handler_.HandleMessageBroadcast(std::move(udp_rx_message));
34 }
35 
37  udp_channel_handler_.HandleMessageUnicast(std::move(udp_rx_message));
38 }
39 
42  return udp_channel_handler_.SendVehicleIdentificationRequest(std::move(message));
43 }
44 
45 std::pair<uds_transport::UdsTransportProtocolMgr::IndicationResult, uds_transport::UdsMessagePtr>
49  std::size_t size, uds_transport::Priority priority,
50  uds_transport::ProtocolKind protocol_kind, core_type::Span<std::uint8_t> payload_info) {
51  return connection_.IndicateMessage(source_addr, target_addr, type, channel_id, size, priority, protocol_kind,
52  payload_info);
53 }
54 
56  connection_.HandleMessage(std::move(message));
57 }
58 
59 } // namespace udp_channel
60 } // namespace channel
61 } // namespace doip_client
auto SendVehicleIdentificationRequest(uds_transport::UdsMessageConstPtr vehicle_identification_request) noexcept -> uds_transport::UdsTransportProtocolMgr::TransmissionResult
Function to vehicle identification request to the connected network.
void HandleMessageUnicast(UdpMessagePtr udp_rx_message) noexcept
Function to process the received unicast udp message.
void HandleMessageBroadcast(UdpMessagePtr udp_rx_message) noexcept
Function to process the received broadcast udp message.
uds_transport::UdsTransportProtocolMgr::TransmissionResult Transmit(uds_transport::UdsMessageConstPtr message)
Function to transmit a Vehicle Identification request.
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.
UdpSocketHandler udp_socket_handler_broadcast_
Store the udp socket handler for broadcast messages.
UdpSocketHandler udp_socket_handler_unicast_
Store the udp socket handler for unicast messages.
sockets::UdpSocketHandler::UdpMessagePtr UdpMessagePtr
Type alias for Udp message pointer.
DoipUdpChannel(std::string_view udp_ip_address, std::uint16_t port_num, uds_transport::Connection &connection)
Constructs an instance of UdpChannel.
void ProcessReceivedUdpUnicast(UdpMessagePtr udp_rx_message)
Function to process the received Udp unicast message from socket layer.
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.
void Stop()
Function to stop the channel.
void ProcessReceivedUdpBroadcast(UdpMessagePtr udp_rx_message)
Function to process the received Udp broadcast message from socket layer.
uds_transport::Connection & connection_
Store the reference to doip connection.
DoipUdpChannelHandler udp_channel_handler_
Store the doip channel handler.
Class used to create a udp socket for handling transmission and reception of udp message from driver.
void Stop()
Function to stop the socket handler.
void Start()
Function to start the socket handler.
Interface class to handle connection between two layers.
Definition: connection.h:23
virtual std::pair< UdsTransportProtocolMgr::IndicationResult, UdsMessagePtr > IndicateMessage(UdsMessage::Address source_addr, UdsMessage::Address target_addr, UdsMessage::TargetAddressType type, ChannelID channel_id, std::size_t size, Priority priority, ProtocolKind protocol_kind, core_type::Span< std::uint8_t > payload_info)=0
Function to indicate a start of reception of message.
virtual void HandleMessage(UdsMessagePtr message)=0
Function to Hands over a valid received Uds message.
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