Diag-Client-Lib
doip_udp_channel.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_H_
9 #define DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CHANNEL_UDP_CHANNEL_DOIP_UDP_CHANNEL_H_
10 
11 #include <memory>
12 #include <string_view>
13 #include <utility>
14 
16 #include "sockets/socket_handler.h"
18 
19 namespace doip_client {
20 namespace channel {
21 namespace udp_channel {
22 
26 class DoipUdpChannel final {
27  public:
32 
37 
47  DoipUdpChannel(UdpSocketHandler udp_socket_handler_broadcast,
48  UdpSocketHandler udp_socket_handler_unicast,
49  uds_transport::Connection &connection);
50 
54  ~DoipUdpChannel() = default;
55 
59  void Start();
60 
64  void Stop();
65 
91  std::pair<uds_transport::UdsTransportProtocolMgr::IndicationResult, uds_transport::UdsMessagePtr>
95  uds_transport::ChannelID channel_id, std::size_t size,
98 
106 
113  void ProcessReceivedUdpBroadcast(UdpMessagePtr udp_rx_message);
114 
121  void ProcessReceivedUdpUnicast(UdpMessagePtr udp_rx_message);
122 
130 
131  private:
136 
141 
146 
151 };
152 } // namespace udp_channel
153 } // namespace channel
154 } // namespace doip_client
155 
156 #endif // DIAG_CLIENT_LIB_LIB_DOIP_CLIENT_CHANNEL_UDP_CHANNEL_DOIP_UDP_CHANNEL_H_
A view over a contiguous sequence of objects.
Definition: span.h:191
Class to handle udp received messages from lower layer.
Class to manage a udp channel as per DoIP protocol.
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.
~DoipUdpChannel()=default
Destruct an instance of UdpChannel.
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::MessagePtr UdpMessagePtr
Type alias for Udp message pointer.
DoipUdpChannel(UdpSocketHandler udp_socket_handler_broadcast, UdpSocketHandler udp_socket_handler_unicast, 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 const > 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.
Handler class to manage different socket of various client (Udp / Tcp)
typename Client::MessagePtr MessagePtr
Type alias for message pointer.
Interface class to handle connection between two layers.
Definition: connection.h:45
SocketHandler< boost_support::client::udp::UdpClient > UdpSocketHandler
Type alias of Udp socket handler.
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