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:
| Feature | Adds |
|---|---|
| (none) | no_std borrowed messages, try_frame framing, encode/decode |
alloc | Owned mirrors (messages::OwnedMessage) that outlive the receive buffer |
std | std-backed I/O and error traits |
codec | message_codec::MessageCodec, a tokio-util Encoder/Decoder |
client | The async client::Client |
server | The 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_framedelimits a frame from a byte buffer without owning any I/O resource;messages::Payload::decodethen interprets the body. Seeexamples/bare_metal_codec.rs. - Bare-metal entity (server):
bare_metal_entity::Entityis a complete sans-io ISO 13400-2 entity — vehicle announcement, routing activation, diagnostic-message dispatch — driven through platform callbacks, forno_stdtargets with a single diagnostic TCP socket. - Async client:
client::Clienthandles connection, routing activation, and acknowledgements (requires theclientfeature). Seeexamples/simple_client.rs. - Async server: implement
server::ServerConnectionHandlerand hand it toserver::Server(requires theserverfeature). Seeexamples/echo_server.rs.
Re-exports§
pub use logical_address::LogicalAddress;
Modules§
- bare_
metal_ entity - Bare-metal
DoIPentity (server) forno_stdtargets. - client
DoIPtester (client) connection: establishes routing activation with aDoIPentity and exchanges diagnostic messages over the resulting TCP connection.- connection
- Connection Module
- logical_
address DoIPlogical addressing (LogicalAddress), the identifier space used to address testers, ECUs, and gateways on aDoIPnetwork, per ISO 13400-2.- message_
codec tokio_util::codecadapter that frames and decodes/encodesOwnedMessagevalues directly on a byte stream, soDoIPconnections can be driven withFramedRead/FramedWriteinstead of manual buffer management.- messages
DoIPmessage types: the generic header, thePayloadenum covering everyDoIPpayload type this crate supports, and the concrete request/response structs for each one, per ISO 13400-2.- server
DoIPentity (server) side of a connection: accepts tester TCP connections, drives routing activation, and dispatches diagnostic messages to the implementing application through itsServerConnectionHandlerimplementation.Serveritself 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
DoIPframe 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
DoIPThis 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_DATAsocket is established. Timeout is 2 seconds. - TCP_
TLS_ PORT - TCP port for
DoIPover TLS, per ISO 13400-2. Not currently used by this crate: connections are established in the clear viaTCP_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
DoIPDiagnostic 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
DoIPThis 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.