Documentation
¶
Overview ¶
Package doip decodes DoIP — Diagnostics over Internet Protocol (ISO 13400) — the Ethernet/IP transport that carries vehicle diagnostics (UDS) in modern cars, replacing the OBD-II-over-CAN link. A DoIP edge node (the vehicle's diagnostic gateway) is reached over TCP/UDP 13400; a tester discovers it (vehicle identification), authorises a session (routing activation), then tunnels UDS diagnostic messages to the in-vehicle ECUs. DoIP is a real and growing automotive-security target: it is the network entry point to the whole diagnostic surface, the vehicle-identification response broadcasts the **VIN / EID / GID / logical address** (asset identification), and routing activation is the access-control gate (whose "denied due to missing authentication" response reveals the posture). A captured DoIP message identifies the **operation** — vehicle identification (+ the leaked VIN / EID / GID), routing activation (request type + response code), an alive check, an entity-status or power-mode query, or a diagnostic message — and, for a diagnostic message, lifts out the **UDS payload** for handoff to the UDS decoder. It joins the project's automotive family (internal/uds, kwp, obd2, xcp, isotp, canfd).
Wrap-vs-native judgement ¶
Native. A DoIP message is an 8-byte header (version + inverse version + payload type + payload length) followed by a fixed, payload-type-specific body. A byte-slice walk + a payload-type lookup; stdlib only, no new go.mod dep.
Verifiable / no confidently-wrong output ¶
The header layout, the payload-type table and the sub-code tables (generic NACK, routing-activation type / response, further-action, VIN/GID status, diagnostic NACK) are code-generated from scapy's authoritative DoIP layer (scapy.contrib.automotive.doip) and verified field-for-field against ISO 13400 message vectors. Only the standardised fields are decoded; the **diagnostic-message user data is a UDS message and is chained to the UDS decoder** (internal/uds) so the diagnostic service is decoded inline — the raw hex is kept alongside and a UDS decode failure degrades to an error + the raw hex (the established chain-to-inner-decoder pattern, cf. nsh/gre → ipdecode). Any trailing previous-message echo is surfaced raw. The inverse-version byte is validated (must be the one's-complement of the version); a declared payload length disagreeing with the buffer, or a body too short for the payload type, is reported, not guessed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
ProtocolVersion int `json:"protocol_version"`
ProtocolVersionName string `json:"protocol_version_name,omitempty"`
InverseVersionValid bool `json:"inverse_version_valid"`
PayloadType int `json:"payload_type"`
PayloadTypeHex string `json:"payload_type_hex"`
PayloadTypeName string `json:"payload_type_name"`
PayloadLength int `json:"payload_length"`
// Vehicle identification / announcement
VIN string `json:"vin,omitempty"`
LogicalAddr string `json:"logical_address,omitempty"`
EID string `json:"eid,omitempty"`
GID string `json:"gid,omitempty"`
FurtherAction string `json:"further_action,omitempty"`
VINGIDStatus string `json:"vin_gid_status,omitempty"`
// Routing activation
SourceAddr string `json:"source_address,omitempty"`
ActivationType string `json:"activation_type,omitempty"`
LogicalAddrTester string `json:"logical_address_tester,omitempty"`
LogicalAddrEntity string `json:"logical_address_doip_entity,omitempty"`
RoutingActivationResp string `json:"routing_activation_response,omitempty"`
// Diagnostic message
TargetAddr string `json:"target_address,omitempty"`
UDSPayloadHex string `json:"uds_payload_hex,omitempty"`
UDS *uds.UDS `json:"uds,omitempty"`
UDSDecodeError string `json:"uds_decode_error,omitempty"`
DiagACKCode string `json:"diagnostic_ack_code,omitempty"`
DiagNACKCode string `json:"diagnostic_nack_code,omitempty"`
// Generic NACK
NACKCode string `json:"nack_code,omitempty"`
// Entity status / power mode
NodeType string `json:"node_type,omitempty"`
MaxOpenSockets *int `json:"max_open_sockets,omitempty"`
CurOpenSockets *int `json:"current_open_sockets,omitempty"`
DiagnosticPower *int `json:"diagnostic_power_mode,omitempty"`
PayloadHex string `json:"payload_hex,omitempty"`
Notes []string `json:"notes,omitempty"`
}
Result is the decoded view of a DoIP message.