Skip to content

File syn_doip.c

FileList > proto > syn_doip.c

Go to the source code of this file

SyntropicOS ISO 13400-2 Diagnostic over IP (DoIP) Implementation.

  • #include "syntropic/proto/syn_doip.h"
  • #include <string.h>

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.

Public Static Functions

Type Name
bool build_generic_nack (uint8_t nack_code, uint8_t * tx_buf, uint16_t max_tx, uint16_t * tx_len)
Build DoIP Generic NACK response.
uint16_t peek_u16_be (const uint8_t * buf)
Unpack 16-bit unsigned integer from big-endian byte array.
uint32_t peek_u32_be (const uint8_t * buf)
Unpack 32-bit unsigned integer from big-endian byte array.
void poke_u16_be (uint16_t val, uint8_t * buf)
Pack 16-bit unsigned integer into big-endian byte array.
void poke_u32_be (uint32_t val, uint8_t * buf)
Pack 32-bit unsigned integer into big-endian byte array.

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.


Public Static Functions Documentation

function build_generic_nack

Build DoIP Generic NACK response.

static bool build_generic_nack (
    uint8_t nack_code,
    uint8_t * tx_buf,
    uint16_t max_tx,
    uint16_t * tx_len
) 

Parameters:

  • nack_code NACK error code.
  • tx_buf Target output buffer.
  • max_tx Capacity of tx_buf.
  • tx_len Output length pointer.

Returns:

true on success, false if buffer is too small.


function peek_u16_be

Unpack 16-bit unsigned integer from big-endian byte array.

static inline uint16_t peek_u16_be (
    const uint8_t * buf
) 

Parameters:

  • buf Input byte buffer.

Returns:

16-bit integer value.


function peek_u32_be

Unpack 32-bit unsigned integer from big-endian byte array.

static inline uint32_t peek_u32_be (
    const uint8_t * buf
) 

Parameters:

  • buf Input byte buffer.

Returns:

32-bit integer value.


function poke_u16_be

Pack 16-bit unsigned integer into big-endian byte array.

static inline void poke_u16_be (
    uint16_t val,
    uint8_t * buf
) 

Parameters:

  • val 16-bit integer value.
  • buf Target byte buffer.

function poke_u32_be

Pack 32-bit unsigned integer into big-endian byte array.

static inline void poke_u32_be (
    uint32_t val,
    uint8_t * buf
) 

Parameters:

  • val 32-bit integer value.
  • buf Target byte buffer.


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