|
libdoip
0.1.0
DoIP (Diagnostics over Internet Protocol) ISO 13400 C++17 Library
|
Represents a complete DoIP message with internal ByteArray representation. More...
#include <DoIPMessage.h>

Public Member Functions | |
| DoIPMessage () | |
| Default constructor - creates invalid empty message. More... | |
| DoIPMessage (DoIPPayloadType payloadType, const ByteArray &payload) | |
| Constructs a DoIP message with payload type and data. More... | |
| DoIPMessage (DoIPPayloadType payloadType, ByteArray &&payload) | |
| Constructs a DoIP message with payload type and data (move semantics). More... | |
| DoIPMessage (DoIPPayloadType payloadType, std::initializer_list< uint8_t > init_list) | |
| Constructs a DoIP message with payload type and initializer list. More... | |
| DoIPMessage (DoIPPayloadType payloadType, const uint8_t *data, size_t size) | |
| Constructs a DoIP message from raw byte array. More... | |
| template<typename Iterator > | |
| DoIPMessage (DoIPPayloadType payloadType, Iterator first, Iterator last) | |
| Constructs a DoIP message from iterator range. More... | |
| DoIPPayloadType | getPayloadType () const |
| Gets the payload type of this message. More... | |
| ByteArrayRef | getPayload () const |
| Gets the payload data (without header). More... | |
| ByteArrayRef | getDiagnosticMessagePayload () const |
| Gets the payload data (without header). More... | |
| size_t | getPayloadSize () const |
| Gets the payload size in bytes (without header). More... | |
| size_t | getMessageSize () const |
| Get the complete message size (header + payload). More... | |
| ByteArrayRef | getData () const |
| Gets direct access to the complete message data for sending. More... | |
| const uint8_t * | data () const |
| Gets direct pointer to the message data (for legacy APIs). More... | |
| size_t | size () const |
| Gets the size for use with legacy APIs. More... | |
| const ByteArray & | asByteArray () const |
| Get the complete message as ByteArray. More... | |
| ByteArray | copyAsByteArray () const |
| Get a copy of the complete message as ByteArray. More... | |
| bool | hasSourceAddress () const |
| Check if the message has a Source Address field. More... | |
| std::optional< DoIPAddress > | getSourceAddress () const |
| Get the Source Address of the message (if message is a Diagnostic Message). More... | |
| std::optional< DoIPAddress > | getLogicalAddress () const |
| Get the Logical Address of the message (if message is a Vehicle Identification Response). More... | |
| std::optional< DoIPAddress > | getTargetAddress () const |
| Get the Target Address of the message (if message is a Diagnostic Message). More... | |
| std::optional< DoIpVin > | getVin () const |
| Get the vehicle identification number (VIN) if message is a Vehicle Identification Response. More... | |
| std::optional< DoIpEid > | getEid () const |
| Get the entity id (EID) if message is a Vehicle Identification Response. More... | |
| std::optional< DoIpGid > | getGid () const |
| Get the group id (GID) if message is a Vehicle Identification Response. More... | |
| std::optional< DoIPFurtherAction > | getFurtherActionRequest () const |
| Get the Further Action Request object if message is a Vehicle Identification Response. More... | |
| bool | isValid () const |
| Checks if the message is valid. More... | |
Static Public Member Functions | |
| static bool | isValidProtocolVersion (const uint8_t *data, size_t length, size_t offset=0) |
| Checks if the protocol version is valid. More... | |
| static std::optional< std::pair< DoIPPayloadType, uint32_t > > | tryParseHeader (const uint8_t *data, size_t length) |
| Gets the payload type from raw data. More... | |
| static std::optional< DoIPMessage > | tryParse (const uint8_t *data, size_t length) |
| Parse a DoIP message from raw data. More... | |
Protected Member Functions | |
| void | buildMessage (DoIPPayloadType payloadType, const ByteArray &payload) |
| Builds the internal message representation. More... | |
| bool | isValidProtocolVersion () const |
| Checks if the protocol version is valid. More... | |
| uint32_t | getPayloadLengthFromHeader () const |
| Gets the payload length from the header. More... | |
Protected Attributes | |
| ByteArray | m_data |
| Complete message data (header + payload) More... | |
Represents a complete DoIP message with internal ByteArray representation.
The message is stored internally as a complete ByteArray including the 8-byte header and payload. This eliminates the need for copying when sending messages.
Memory layout: [0] Protocol Version [1] Inverse Protocol Version [2-3] Payload Type (big-endian uint16_t) [4-7] Payload Length (big-endian uint32_t) [8...] Payload data
The message types are listed in table 17.
Definition at line 82 of file DoIPMessage.h.
|
inline |
Default constructor - creates invalid empty message.
Definition at line 88 of file DoIPMessage.h.
|
inlineexplicit |
Constructs a DoIP message with payload type and data.
| payloadType | The payload type for this message |
| payload | The payload data as a vector of bytes |
Definition at line 96 of file DoIPMessage.h.
References buildMessage().
|
inlineexplicit |
Constructs a DoIP message with payload type and data (move semantics).
| payloadType | The payload type for this message |
| payload | The payload data as a vector of bytes (moved) |
Definition at line 106 of file DoIPMessage.h.
References buildMessage().
|
inline |
Constructs a DoIP message with payload type and initializer list.
| payloadType | The payload type for this message |
| init_list | Initializer list of bytes for the payload |
Definition at line 116 of file DoIPMessage.h.
References buildMessage().
|
inlineexplicit |
Constructs a DoIP message from raw byte array.
| payloadType | The payload type for this message |
| data | Pointer to raw payload byte data |
| size | Number of bytes to copy from payload data |
Definition at line 128 of file DoIPMessage.h.
References buildMessage(), data(), and size().
|
inlineexplicit |
Constructs a DoIP message from iterator range.
| Iterator | Input iterator type |
| payloadType | The payload type for this message |
| first | Iterator to the beginning of the data range |
| last | Iterator to the end of the data range |
Definition at line 142 of file DoIPMessage.h.
References buildMessage().
|
inline |
Get the complete message as ByteArray.
Definition at line 240 of file DoIPMessage.h.
References m_data.
|
inlineprotected |
Builds the internal message representation.
| payloadType | The payload type |
| payload | The payload data |
Definition at line 452 of file DoIPMessage.h.
References doip::DOIP_HEADER_SIZE, m_data, doip::PROTOCOL_VERSION, doip::PROTOCOL_VERSION_INV, doip::ByteArray::writeEnum(), and doip::ByteArray::writeU32BE().
Referenced by DoIPMessage().
|
inline |
Get a copy of the complete message as ByteArray.
Definition at line 249 of file DoIPMessage.h.
References m_data.
|
inline |
Gets direct pointer to the message data (for legacy APIs).
Definition at line 222 of file DoIPMessage.h.
References m_data.
Referenced by DoIPMessage(), isValidProtocolVersion(), doip::DoIPClient::sendAliveCheckResponse(), doip::DoIPClient::sendDiagnosticMessage(), doip::DoIPConnection::sendProtocolMessage(), doip::DoIPClient::sendRoutingActivationRequest(), doip::DoIPClient::sendVehicleIdentificationRequest(), tryParse(), and tryParseHeader().
|
inline |
Gets direct access to the complete message data for sending.
This method returns a pointer and size without copying, making it efficient for network transmission.
Definition at line 213 of file DoIPMessage.h.
References m_data.
|
inline |
Gets the payload data (without header).
Definition at line 177 of file DoIPMessage.h.
References doip::DOIP_DIAG_HEADER_SIZE, and m_data.
Referenced by doip::operator<<().
|
inline |
Get the entity id (EID) if message is a Vehicle Identification Response.
Definition at line 327 of file DoIPMessage.h.
References getPayload(), getPayloadType(), and doip::VehicleIdentificationResponse.
|
inline |
Get the Further Action Request object if message is a Vehicle Identification Response.
Definition at line 353 of file DoIPMessage.h.
References getPayload(), getPayloadType(), and doip::VehicleIdentificationResponse.
|
inline |
Get the group id (GID) if message is a Vehicle Identification Response.
Definition at line 340 of file DoIPMessage.h.
References getPayload(), getPayloadType(), and doip::VehicleIdentificationResponse.
|
inline |
Get the Logical Address of the message (if message is a Vehicle Identification Response).
Definition at line 288 of file DoIPMessage.h.
References getPayload(), getPayloadType(), doip::readAddressFrom(), and doip::VehicleIdentificationResponse.
|
inline |
Get the complete message size (header + payload).
Definition at line 201 of file DoIPMessage.h.
References m_data.
|
inline |
Gets the payload data (without header).
Definition at line 165 of file DoIPMessage.h.
References doip::DOIP_HEADER_SIZE, and m_data.
Referenced by getEid(), getFurtherActionRequest(), getGid(), getLogicalAddress(), getSourceAddress(), getTargetAddress(), getVin(), hasSourceAddress(), and doip::operator<<().
|
inlineprotected |
Gets the payload length from the header.
Definition at line 491 of file DoIPMessage.h.
References doip::DOIP_HEADER_SIZE, m_data, and doip::ByteArray::readU32BE().
Referenced by isValid().
|
inline |
Gets the payload size in bytes (without header).
Definition at line 189 of file DoIPMessage.h.
References doip::DOIP_HEADER_SIZE, and m_data.
Referenced by isValid(), and doip::operator<<().
|
inline |
Gets the payload type of this message.
Definition at line 152 of file DoIPMessage.h.
References doip::DOIP_HEADER_SIZE, m_data, and doip::NegativeAck.
Referenced by getEid(), getFurtherActionRequest(), getGid(), getLogicalAddress(), getTargetAddress(), getVin(), hasSourceAddress(), doip::operator<<(), and doip::DoIPClient::receiveVehicleAnnouncement().
|
inline |
Get the Source Address of the message (if message is a Diagnostic Message).
Definition at line 274 of file DoIPMessage.h.
References getPayload(), hasSourceAddress(), and doip::readAddressFrom().
Referenced by doip::message::makeRoutingActivationResponse(), and doip::operator<<().
|
inline |
Get the Target Address of the message (if message is a Diagnostic Message).
Definition at line 301 of file DoIPMessage.h.
References doip::DiagnosticMessage, getPayload(), getPayloadType(), and doip::readAddressFrom().
Referenced by doip::operator<<().
|
inline |
Get the vehicle identification number (VIN) if message is a Vehicle Identification Response.
Definition at line 314 of file DoIPMessage.h.
References getPayload(), getPayloadType(), and doip::VehicleIdentificationResponse.
|
inline |
Check if the message has a Source Address field.
true in the case of success, false otherwise. Definition at line 258 of file DoIPMessage.h.
References doip::AliveCheckResponse, doip::DiagnosticMessage, getPayload(), getPayloadType(), doip::RoutingActivationRequest, and doip::RoutingActivationResponse.
Referenced by getSourceAddress().
|
inline |
Checks if the message is valid.
Definition at line 366 of file DoIPMessage.h.
References doip::DOIP_HEADER_SIZE, getPayloadLengthFromHeader(), getPayloadSize(), isValidProtocolVersion(), and m_data.
|
inlineprotected |
Checks if the protocol version is valid.
Definition at line 476 of file DoIPMessage.h.
References doip::ISO_13400_2010, doip::ISO_13400_2025, and m_data.
Referenced by isValid(), and tryParseHeader().
|
inlinestatic |
Checks if the protocol version is valid.
| data | Pointer to the byte array |
| length | Length of the data |
| offset | Offset to start checking from (default: 0) |
Definition at line 379 of file DoIPMessage.h.
References data(), doip::ISO_13400_2010, and doip::ISO_13400_2025.
|
inline |
Gets the size for use with legacy APIs.
Definition at line 231 of file DoIPMessage.h.
References m_data.
Referenced by DoIPMessage(), doip::DoIPClient::sendAliveCheckResponse(), doip::DoIPClient::sendDiagnosticMessage(), doip::DoIPConnection::sendProtocolMessage(), doip::DoIPDefaultConnection::sendProtocolMessage(), doip::DoIPClient::sendRoutingActivationRequest(), and doip::DoIPClient::sendVehicleIdentificationRequest().
|
inlinestatic |
Parse a DoIP message from raw data.
| data | Pointer to raw message data |
| length | Length of the data |
Definition at line 425 of file DoIPMessage.h.
References data(), doip::DOIP_HEADER_SIZE, m_data, and tryParseHeader().
Referenced by doip::DoIPClient::receiveMessage(), doip::DoIPClient::receiveUdpMessage(), and doip::DoIPClient::receiveVehicleAnnouncement().
|
inlinestatic |
Gets the payload type from raw data.
| data | Pointer to the byte array |
| length | Length of the data |
Definition at line 399 of file DoIPMessage.h.
References data(), doip::DOIP_HEADER_SIZE, isValidProtocolVersion(), doip::util::readU32BE(), and doip::toPayloadType().
Referenced by doip::DoIPConnection::receiveTcpMessage(), and tryParse().
|
protected |
Complete message data (header + payload)
Definition at line 444 of file DoIPMessage.h.
Referenced by asByteArray(), buildMessage(), copyAsByteArray(), data(), getData(), getDiagnosticMessagePayload(), getMessageSize(), getPayload(), getPayloadLengthFromHeader(), getPayloadSize(), getPayloadType(), isValid(), isValidProtocolVersion(), size(), and tryParse().