Skip to content

File syn_doip.h

FileList > proto > syn_doip.h

Go to the source code of this file

SyntropicOS ISO 13400-2 Diagnostic over IP (DoIP) Protocol Stack. More...

  • #include "syntropic/proto/syn_uds.h"
  • #include "syntropic/syntropic.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_DoIP_Header
ISO 13400-2 DoIP Header Structure (8 bytes)
struct SYN_DoIP_Server
DoIP Server State Structure.

Public Functions

Type Name
uint16_t syn_doip_encode_header (const SYN_DoIP_Header * hdr, uint8_t * buf, uint16_t max_len)
Encode 8-byte DoIP Header into target buffer.
bool syn_doip_init (SYN_DoIP_Server * server, uint16_t logical_address)
Initialize DoIP Server instance.
bool syn_doip_parse_header (const uint8_t * buf, uint16_t len, SYN_DoIP_Header * hdr)
Parse 8-byte DoIP Header from raw buffer.
bool syn_doip_process_msg (SYN_DoIP_Server * server, SYN_UDS_Server * uds, const uint8_t * rx_buf, uint16_t rx_len, uint8_t * tx_buf, uint16_t max_tx_len, uint16_t * tx_len)
Process incoming DoIP message (UDP or TCP) and route UDS requests to syn_uds.
bool syn_doip_set_identifiers (SYN_DoIP_Server * server, const uint8_t vin, const uint8_t eid, const uint8_t gid)
Set VIN, EID, and GID parameters for vehicle identification responses.

Macros

Type Name
define SYN_DOIP_DEFAULT_PORT 13400U
define SYN_DOIP_HEADER_SIZE 8U
define SYN_DOIP_INVERSE_PROTOCOL_VERSION 0xFDU
define SYN_DOIP_NACK_INCORRECT_PATTERN 0x00U
define SYN_DOIP_NACK_INVALID_PAYLOAD_LENGTH 0x04U
define SYN_DOIP_NACK_MESSAGE_TOO_LARGE 0x02U
define SYN_DOIP_NACK_OUT_OF_MEMORY 0x03U
define SYN_DOIP_NACK_UNKNOWN_PAYLOAD_TYPE 0x01U
define SYN_DOIP_PROTOCOL_VERSION 0x02U
define SYN_DOIP_ROUTING_DENIED_DIFFERENT_PORT 0x04U
define SYN_DOIP_ROUTING_DENIED_UNKNOWN_TESTER 0x02U
define SYN_DOIP_ROUTING_SUCCESS 0x00U
define SYN_DOIP_TYPE_ALIVE_CHECK_REQ 0x0007U
define SYN_DOIP_TYPE_ALIVE_CHECK_RESP 0x0008U
define SYN_DOIP_TYPE_DIAGNOSTIC_MSG 0x8001U
define SYN_DOIP_TYPE_DIAGNOSTIC_MSG_ACK 0x8002U
define SYN_DOIP_TYPE_DIAGNOSTIC_MSG_NACK 0x8003U
define SYN_DOIP_TYPE_GENERIC_NACK 0x0000U
define SYN_DOIP_TYPE_ROUTING_ACTIVATION_REQ 0x0005U
define SYN_DOIP_TYPE_ROUTING_ACTIVATION_RESP 0x0006U
define SYN_DOIP_TYPE_VEHICLE_ANNOUNCEMENT 0x0004U
define SYN_DOIP_TYPE_VEHICLE_ID_REQ 0x0001U
define SYN_DOIP_TYPE_VEHICLE_ID_REQ_EID 0x0002U
define SYN_DOIP_TYPE_VEHICLE_ID_REQ_VIN 0x0003U

Detailed Description

Implements lightweight, zero-malloc ISO 13400-2 DoIP header serialization, vehicle identification, routing activation, and UDS (ISO 14229-1) message routing over TCP/UDP.

Public Functions Documentation

function syn_doip_encode_header

Encode 8-byte DoIP Header into target buffer.

uint16_t syn_doip_encode_header (
    const SYN_DoIP_Header * hdr,
    uint8_t * buf,
    uint16_t max_len
) 

Parameters:

  • hdr Input header structure.
  • buf Output buffer.
  • max_len Output buffer capacity (must be >= 8).

Returns:

Length written (8), or 0 on error.


function syn_doip_init

Initialize DoIP Server instance.

bool syn_doip_init (
    SYN_DoIP_Server * server,
    uint16_t logical_address
) 

Parameters:

  • server Pointer to DoIP server instance.
  • logical_address ECU logical address (e.g. 0x1001).

Returns:

true on success, false if server is NULL.


function syn_doip_parse_header

Parse 8-byte DoIP Header from raw buffer.

bool syn_doip_parse_header (
    const uint8_t * buf,
    uint16_t len,
    SYN_DoIP_Header * hdr
) 

Parameters:

  • buf Input buffer.
  • len Input buffer length.
  • hdr Output header structure.

Returns:

true if header is valid, false otherwise.


function syn_doip_process_msg

Process incoming DoIP message (UDP or TCP) and route UDS requests to syn_uds.

bool syn_doip_process_msg (
    SYN_DoIP_Server * server,
    SYN_UDS_Server * uds,
    const uint8_t * rx_buf,
    uint16_t rx_len,
    uint8_t * tx_buf,
    uint16_t max_tx_len,
    uint16_t * tx_len
) 

Parameters:

  • server Pointer to DoIP server instance.
  • uds Pointer to UDS server instance.
  • rx_buf Incoming raw DoIP packet.
  • rx_len Incoming packet length.
  • tx_buf Output buffer for DoIP response frame.
  • max_tx_len Maximum output buffer capacity.
  • tx_len Output pointer for written response length.

Returns:

true if message was processed successfully, false on invalid request/null.


function syn_doip_set_identifiers

Set VIN, EID, and GID parameters for vehicle identification responses.

bool syn_doip_set_identifiers (
    SYN_DoIP_Server * server,
    const uint8_t vin,
    const uint8_t eid,
    const uint8_t gid
) 

Parameters:

  • server Pointer to DoIP server.
  • vin 17-byte VIN buffer.
  • eid 6-byte EID (MAC) buffer.
  • gid 6-byte GID buffer.

Returns:

true on success, false on NULL pointers.


Macro Definition Documentation

define SYN_DOIP_DEFAULT_PORT

#define SYN_DOIP_DEFAULT_PORT `13400U`

Standard DoIP TCP/UDP port


define SYN_DOIP_HEADER_SIZE

#define SYN_DOIP_HEADER_SIZE `8U`

Fixed 8-byte DoIP header size


define SYN_DOIP_INVERSE_PROTOCOL_VERSION

#define SYN_DOIP_INVERSE_PROTOCOL_VERSION `0xFDU`

Bitwise inverse of protocol version


define SYN_DOIP_NACK_INCORRECT_PATTERN

#define SYN_DOIP_NACK_INCORRECT_PATTERN `0x00U`

ISO 13400-2 Generic NACK Codes Incorrect header pattern


define SYN_DOIP_NACK_INVALID_PAYLOAD_LENGTH

#define SYN_DOIP_NACK_INVALID_PAYLOAD_LENGTH `0x04U`

Invalid payload length


define SYN_DOIP_NACK_MESSAGE_TOO_LARGE

#define SYN_DOIP_NACK_MESSAGE_TOO_LARGE `0x02U`

Message payload too large


define SYN_DOIP_NACK_OUT_OF_MEMORY

#define SYN_DOIP_NACK_OUT_OF_MEMORY `0x03U`

Out of memory


define SYN_DOIP_NACK_UNKNOWN_PAYLOAD_TYPE

#define SYN_DOIP_NACK_UNKNOWN_PAYLOAD_TYPE `0x01U`

Unknown payload type


define SYN_DOIP_PROTOCOL_VERSION

#define SYN_DOIP_PROTOCOL_VERSION `0x02U`

ISO 13400-2 Protocol Constants ISO 13400-2 protocol version


define SYN_DOIP_ROUTING_DENIED_DIFFERENT_PORT

#define SYN_DOIP_ROUTING_DENIED_DIFFERENT_PORT `0x04U`

Denied: Invalid socket port


define SYN_DOIP_ROUTING_DENIED_UNKNOWN_TESTER

#define SYN_DOIP_ROUTING_DENIED_UNKNOWN_TESTER `0x02U`

Denied: Unknown tester address


define SYN_DOIP_ROUTING_SUCCESS

#define SYN_DOIP_ROUTING_SUCCESS `0x00U`

ISO 13400-2 Routing Activation Response Codes Routing activation successful


define SYN_DOIP_TYPE_ALIVE_CHECK_REQ

#define SYN_DOIP_TYPE_ALIVE_CHECK_REQ `0x0007U`

Alive Check Request


define SYN_DOIP_TYPE_ALIVE_CHECK_RESP

#define SYN_DOIP_TYPE_ALIVE_CHECK_RESP `0x0008U`

Alive Check Response


define SYN_DOIP_TYPE_DIAGNOSTIC_MSG

#define SYN_DOIP_TYPE_DIAGNOSTIC_MSG `0x8001U`

UDS Diagnostic Message


define SYN_DOIP_TYPE_DIAGNOSTIC_MSG_ACK

#define SYN_DOIP_TYPE_DIAGNOSTIC_MSG_ACK `0x8002U`

Diagnostic Message Positive Ack


define SYN_DOIP_TYPE_DIAGNOSTIC_MSG_NACK

#define SYN_DOIP_TYPE_DIAGNOSTIC_MSG_NACK `0x8003U`

Diagnostic Message Negative Ack


define SYN_DOIP_TYPE_GENERIC_NACK

#define SYN_DOIP_TYPE_GENERIC_NACK `0x0000U`

ISO 13400-2 Payload Types Generic NACK payload type


define SYN_DOIP_TYPE_ROUTING_ACTIVATION_REQ

#define SYN_DOIP_TYPE_ROUTING_ACTIVATION_REQ `0x0005U`

Routing Activation Request


define SYN_DOIP_TYPE_ROUTING_ACTIVATION_RESP

#define SYN_DOIP_TYPE_ROUTING_ACTIVATION_RESP `0x0006U`

Routing Activation Response


define SYN_DOIP_TYPE_VEHICLE_ANNOUNCEMENT

#define SYN_DOIP_TYPE_VEHICLE_ANNOUNCEMENT `0x0004U`

Vehicle Announcement Message


define SYN_DOIP_TYPE_VEHICLE_ID_REQ

#define SYN_DOIP_TYPE_VEHICLE_ID_REQ `0x0001U`

Vehicle Identification Request


define SYN_DOIP_TYPE_VEHICLE_ID_REQ_EID

#define SYN_DOIP_TYPE_VEHICLE_ID_REQ_EID `0x0002U`

Vehicle ID Request with EID


define SYN_DOIP_TYPE_VEHICLE_ID_REQ_VIN

#define SYN_DOIP_TYPE_VEHICLE_ID_REQ_VIN `0x0003U`

Vehicle ID Request with VIN



The documentation for this class was generated from the following file src/syntropic/proto/syn_doip.h