Skip to main content

Crate simple_doip

Crate simple_doip 

Source
Expand description

§Simple DoIP

An implementation of Diagnostics over IP (DoIP), the vehicle-diagnostics transport specified in ISO 13400-2.

§Design

The protocol core is no_std and zero-copy: messages::Message borrows directly from the receive buffer and never allocates. Wire primitives come from automotive_wire_codec, re-exported as wire so consumers do not need their own dependency on it.

Capability is layered by Cargo feature, each building on the previous:

FeatureAdds
(none)no_std borrowed messages, try_frame framing, encode/decode
allocOwned mirrors (messages::OwnedMessage) that outlive the receive buffer
stdstd-backed I/O and error traits
codecmessage_codec::MessageCodec, a tokio-util Encoder/Decoder
clientThe async client::Client
serverThe async server::Server

default = [], so an embedded target gets the no_std core with no allocator and no runtime.

§Where to start

  • Bare metal / sans-io: try_frame delimits a frame from a byte buffer without owning any I/O resource; messages::Payload::decode then interprets the body. See examples/bare_metal_codec.rs.
  • Bare-metal entity (server): bare_metal_entity::Entity is a complete sans-io ISO 13400-2 entity — vehicle announcement, routing activation, diagnostic-message dispatch — driven through platform callbacks, for no_std targets with a single diagnostic TCP socket.
  • Async client: client::Client handles connection, routing activation, and acknowledgements (requires the client feature). See examples/simple_client.rs.
  • Async server: implement server::ServerConnectionHandler and hand it to server::Server (requires the server feature). See examples/echo_server.rs.

Re-exports§

pub use logical_address::LogicalAddress;

Modules§

bare_metal_entity
Bare-metal DoIP entity (server) for no_std targets.
client
DoIP tester (client) connection: establishes routing activation with a DoIP entity and exchanges diagnostic messages over the resulting TCP connection.
connection
Connection Module
logical_address
DoIP logical addressing (LogicalAddress), the identifier space used to address testers, ECUs, and gateways on a DoIP network, per ISO 13400-2.
message_codec
tokio_util::codec adapter that frames and decodes/encodes OwnedMessage values directly on a byte stream, so DoIP connections can be driven with FramedRead/FramedWrite instead of manual buffer management.
messages
DoIP message types: the generic header, the Payload enum covering every DoIP payload type this crate supports, and the concrete request/response structs for each one, per ISO 13400-2.
server
DoIP entity (server) side of a connection: accepts tester TCP connections, drives routing activation, and dispatches diagnostic messages to the implementing application through its ServerConnectionHandler implementation. Server itself is the struct that owns the handler and drives the connection.
wire
Wire-codec types re-exported from automotive_wire_codec.

Structs§

RawFrame
A delimited, header-validated DoIP frame whose payload is NOT yet interpreted.

Enums§

Error
Errors surfaced by the client and server connection machinery (as opposed to MessageError, which covers wire-level encode/decode failures).

Constants§

TCP_PORT
Default TCP port for DoIP This is the port used for unencrypted connections Used for:
TCP_TIMEOUT_ALIVE_CHECK
Alive check for the maximum amount of time an entity waits for an alive check response after having made an alive check request. Timeout is 5 seconds.
TCP_TIMEOUT_GENERAL_INACTIVITY
General inactivity timeout for TCP connections. Timeout is 300 seconds (5 minutes).
TCP_TIMEOUT_INITIAL_INACTIVITY
Initial inactivity timeout in seconds for TCP connections directly after a TCP_DATA socket is established. Timeout is 2 seconds.
TCP_TLS_PORT
TCP port for DoIP over TLS, per ISO 13400-2. Not currently used by this crate: connections are established in the clear via TCP_PORT; there is no TLS support yet.
TESTER_LOGICAL_ADDRESS
An example logical address constant of uncertain provenance.
TIMEOUT_DIAGNOSTIC_MESSAGE_INITIAL
Time between receipt of the last byte of a DoIP Diagnostic Message and transmission of the ACK or NACK.
TIMEOUT_DIAGNOSTIC_MESSAGE_RESPONSE
After the timeout has elapsed, the request or response is considered to be lost and the request may be repeated
UDP_DISCOVERY_PORT
Default UDP port for DoIP This is the port used for discovery

Functions§

try_frame
Framing only: validate the 8-byte header and delimit one frame from the front of buf. Ok(None) = need more bytes. Never interprets the payload.