Diag-Client-Lib
Public Types | Public Member Functions | Protected Attributes | Private Attributes | List of all members
uds_transport::Connection Class Referenceabstract

Interface class to handle connection between two layers. More...

#include <connection.h>

Inheritance diagram for uds_transport::Connection:
Inheritance graph
[legend]
Collaboration diagram for uds_transport::Connection:
Collaboration graph
[legend]

Public Types

using ConnectionId = std::uint8_t
 Type alias for connection id. More...
 
using InitializationResult = uds_transport::UdsTransportProtocolHandler::InitializationResult
 Type alias for Initialization result. More...
 

Public Member Functions

 Connection (ConnectionId connection_id, uds_transport::ConversionHandler const &conversation_handler) noexcept
 Constructor to create a new connection. More...
 
virtual ~Connection ()=default
 Destruct an instance of Connection. More...
 
virtual InitializationResult Initialize ()=0
 Function to initialize the connection. More...
 
ConnectionId GetConnectionId () noexcept
 Function to get the connection id. More...
 
virtual void Start ()=0
 Function to start the connection. More...
 
virtual void Stop ()=0
 Function to stop the connection. More...
 
virtual bool IsConnectToHost ()=0
 Function to check if connected to host remote server. More...
 
virtual UdsTransportProtocolMgr::ConnectionResult ConnectToHost (UdsMessageConstPtr message)=0
 Function to establish connection to remote host server. More...
 
virtual UdsTransportProtocolMgr::DisconnectionResult DisconnectFromHost ()=0
 Function to disconnect from remote host server. More...
 
virtual std::pair< UdsTransportProtocolMgr::IndicationResult, UdsMessagePtrIndicateMessage (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. More...
 
virtual UdsTransportProtocolMgr::TransmissionResult Transmit (UdsMessageConstPtr message)=0
 Function to transmit a valid Uds message. More...
 
virtual void HandleMessage (UdsMessagePtr message)=0
 Function to Hands over a valid received Uds message. More...
 
ConnectionId GetConnectionId () const
 Function to get the connection id. More...
 

Protected Attributes

uds_transport::ConversionHandler const & conversation_handler_
 Store the conversation handler. More...
 

Private Attributes

ConnectionId connection_id_
 Store the connection id. More...
 

Detailed Description

Interface class to handle connection between two layers.

Definition at line 23 of file connection.h.

Member Typedef Documentation

◆ ConnectionId

Type alias for connection id.

Definition at line 28 of file connection.h.

◆ InitializationResult

Type alias for Initialization result.

Definition at line 33 of file connection.h.

Constructor & Destructor Documentation

◆ Connection()

uds_transport::Connection::Connection ( ConnectionId  connection_id,
uds_transport::ConversionHandler const &  conversation_handler 
)
inlinenoexcept

Constructor to create a new connection.

Parameters
[in]connection_idThe connection identification
[in]conversation_handlerThe reference to conversation handler

Definition at line 42 of file connection.h.

43  : conversation_handler_{conversation_handler},
44  connection_id_{connection_id} {}
uds_transport::ConversionHandler const & conversation_handler_
Store the conversation handler.
Definition: connection.h:148
ConnectionId connection_id_
Store the connection id.
Definition: connection.h:154

◆ ~Connection()

virtual uds_transport::Connection::~Connection ( )
virtualdefault

Destruct an instance of Connection.

Member Function Documentation

◆ ConnectToHost()

virtual UdsTransportProtocolMgr::ConnectionResult uds_transport::Connection::ConnectToHost ( UdsMessageConstPtr  message)
pure virtual

Function to establish connection to remote host server.

Parameters
[in]messageThe connection message
Returns
Connection result

Implemented in doip_client::connection::DoipUdpConnection, and doip_client::connection::DoipTcpConnection.

◆ DisconnectFromHost()

virtual UdsTransportProtocolMgr::DisconnectionResult uds_transport::Connection::DisconnectFromHost ( )
pure virtual

Function to disconnect from remote host server.

Returns
Disconnection result

Implemented in doip_client::connection::DoipUdpConnection, and doip_client::connection::DoipTcpConnection.

◆ GetConnectionId() [1/2]

ConnectionId uds_transport::Connection::GetConnectionId ( ) const
inline

Function to get the connection id.

Returns
The connection id

Definition at line 142 of file connection.h.

142 { return connection_id_; }

References connection_id_.

◆ GetConnectionId() [2/2]

ConnectionId uds_transport::Connection::GetConnectionId ( )
inlinenoexcept

Function to get the connection id.

Returns
The connection id

Definition at line 61 of file connection.h.

61 { return connection_id_; }

References connection_id_.

◆ HandleMessage()

virtual void uds_transport::Connection::HandleMessage ( UdsMessagePtr  message)
pure virtual

Function to Hands over a valid received Uds message.

Parameters
[in]messageThe Uds message ptr (unique_ptr semantics) with the request. Ownership of the UdsMessage is given back to the conversation here

Implemented in doip_client::connection::DoipUdpConnection, and doip_client::connection::DoipTcpConnection.

Referenced by doip_client::channel::tcp_channel::DoipTcpChannel::HandleMessage(), and doip_client::channel::udp_channel::DoipUdpChannel::HandleMessage().

Here is the caller graph for this function:

◆ IndicateMessage()

virtual std::pair<UdsTransportProtocolMgr::IndicationResult, UdsMessagePtr> uds_transport::Connection::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 
)
pure virtual

Function to indicate a start of reception of message.

This is called to indicate the reception of new message by underlying transport protocol handler

Parameters
[in]source_addrThe UDS source address of message
[in]target_addrThe UDS target address of message
[in]typeThe indication whether its is phys/func request
[in]channel_idThe transport protocol channel on which message start happened
[in]sizeThe size in bytes of the UdsMessage starting from SID
[in]priorityThe priority of the given message, used for prioritization of conversations
[in]protocol_kindThe identifier of protocol kind associated to message
[in]payload_infoThe view onto the first received payload bytes, if any. This view shall be used only within this function call. It is recommended that the TP provides at least the first two bytes of the request message, so the DM can identify a functional TesterPresent
Returns
std::pair< IndicationResult, UdsMessagePtr > The pair of IndicationResult and a pointer to UdsMessage owned/created by DM core and returned to the handler to get filled

Implemented in doip_client::connection::DoipUdpConnection, and doip_client::connection::DoipTcpConnection.

Referenced by doip_client::channel::tcp_channel::DoipTcpChannel::IndicateMessage(), and doip_client::channel::udp_channel::DoipUdpChannel::IndicateMessage().

Here is the caller graph for this function:

◆ Initialize()

virtual InitializationResult uds_transport::Connection::Initialize ( )
pure virtual

Function to initialize the connection.

Returns
The initialization result

Implemented in doip_client::connection::DoipUdpConnection, and doip_client::connection::DoipTcpConnection.

◆ IsConnectToHost()

virtual bool uds_transport::Connection::IsConnectToHost ( )
pure virtual

Function to check if connected to host remote server.

Returns
True if connection, False otherwise

Implemented in doip_client::connection::DoipUdpConnection, and doip_client::connection::DoipTcpConnection.

◆ Start()

virtual void uds_transport::Connection::Start ( )
pure virtual

Function to start the connection.

Implemented in doip_client::connection::DoipUdpConnection, and doip_client::connection::DoipTcpConnection.

◆ Stop()

virtual void uds_transport::Connection::Stop ( )
pure virtual

Function to stop the connection.

Implemented in doip_client::connection::DoipUdpConnection, and doip_client::connection::DoipTcpConnection.

◆ Transmit()

virtual UdsTransportProtocolMgr::TransmissionResult uds_transport::Connection::Transmit ( UdsMessageConstPtr  message)
pure virtual

Function to transmit a valid Uds message.

Parameters
[in]messageThe Uds message ptr (unique_ptr semantics) with the request.

Implemented in doip_client::connection::DoipUdpConnection, and doip_client::connection::DoipTcpConnection.

Member Data Documentation

◆ connection_id_

ConnectionId uds_transport::Connection::connection_id_
private

Store the connection id.

Definition at line 154 of file connection.h.

Referenced by GetConnectionId().

◆ conversation_handler_

uds_transport::ConversionHandler const& uds_transport::Connection::conversation_handler_
protected

The documentation for this class was generated from the following file: