Diag-Client-Lib
dm_uds_message.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 DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_DM_UDS_MESSAGE_H
9 #define DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_DM_UDS_MESSAGE_H
10 /* includes */
14 
15 namespace diag {
16 namespace client {
17 namespace uds_message {
18 
20  public:
21  // ctor
22  DmUdsMessage(Address sa, Address ta, IpAddress host_ip_address, uds_transport::ByteVector &payload);
23 
24  // dtor
25  ~DmUdsMessage() noexcept override = default;
26 
27  private:
28  // SA
30 
31  // TA
33 
34  // TA type
36 
37  // Host Ip Address
38  std::string host_ip_address_;
39 
40  // store only UDS payload to be sent
42 
43  // add new metaInfo to this message.
44  void AddMetaInfo(std::shared_ptr<const MetaInfoMap>) override {
45  // Todo [Add meta info information]
46  }
47 
48  // Get the UDS message data starting with the SID (A_Data as per ISO)
49  const uds_transport::ByteVector &GetPayload() const override { return uds_payload_; }
50 
51  // return the underlying buffer for write access
53 
54  // Get the source address of the uds message.
55  Address GetSa() const noexcept override { return source_address_; }
56 
57  // Get the target address of the uds message.
58  Address GetTa() const noexcept override { return target_address_; }
59 
60  // Get the target address type (phys/func) of the uds message.
61  TargetAddressType GetTaType() const noexcept override { return target_address_type_; }
62 
63  // Get Host Ip address
64  IpAddress GetHostIpAddress() const noexcept override { return host_ip_address_; }
65 
66  // Get Host port number
67  PortNumber GetHostPortNumber() const noexcept override { return 13400U; }
68 };
69 
70 class DmUdsResponse final : public UdsMessage {
71  public:
72  explicit DmUdsResponse(ByteVector &payload);
73 
74  ~DmUdsResponse() noexcept override = default;
75 
76  private:
77  // store only UDS payload to be sent
79  // Host Ip Address
81 
82  // Get the UDS message data starting with the SID (A_Data as per ISO)
83  const ByteVector &GetPayload() const override { return uds_payload_; }
84 
85  // return the underlying buffer for write access
86  ByteVector &GetPayload() override { return uds_payload_; }
87 
88  // Get Host Ip address
89  IpAddress GetHostIpAddress() const noexcept override { return host_ip_address_; }
90 };
91 
92 } // namespace uds_message
93 } // namespace client
94 } // namespace diag
95 #endif // DIAGNOSTIC_CLIENT_LIB_APPL_SRC_DCM_SERVICE_DM_UDS_MESSAGE_H
Address GetSa() const noexcept override
~DmUdsMessage() noexcept override=default
const uds_transport::ByteVector & GetPayload() const override
IpAddress GetHostIpAddress() const noexcept override
uds_transport::ByteVector & GetPayload() override
PortNumber GetHostPortNumber() const noexcept override
TargetAddressType GetTaType() const noexcept override
DmUdsMessage(Address sa, Address ta, IpAddress host_ip_address, uds_transport::ByteVector &payload)
Address GetTa() const noexcept override
uds_transport::ByteVector & uds_payload_
void AddMetaInfo(std::shared_ptr< const MetaInfoMap >) override
const ByteVector & GetPayload() const override
Get the UDS message data starting with the SID (A_Data as per ISO)
ByteVector & GetPayload() override
Return the underlying buffer for write access.
~DmUdsResponse() noexcept override=default
IpAddress GetHostIpAddress() const noexcept override
Get the remote ip address present.
Class represents an UDS message exchanged between User of diag-client-lib and implementation of diag-...
std::vector< std::uint8_t > ByteVector
Type alias of byte vector type.
std::string_view IpAddress
Type alias of ip address type.
std::string_view IpAddress
Definition: uds_message.h:24
std::map< std::string, std::string > MetaInfoMap
Definition: uds_message.h:28
std::uint16_t PortNumber
Definition: uds_message.h:26
std::vector< std::uint8_t > ByteVector