doip_definitions/
lib.rs

1// region:      --- Configs
2#![cfg_attr(not(feature = "std"), no_std)] // Use no_std when the "std" feature is disabled
3#![warn(clippy::pedantic)]
4#![warn(missing_debug_implementations)]
5#![warn(missing_docs)]
6#![allow(clippy::module_name_repetitions)]
7// endregion:      --- Configs
8
9//! Diagnostics over Internet Protocol definition library
10//!
11//! This crate is built to act a definitive source for defintions of ISO-13400
12//! and `DoIP` protocol development. Using all the data structures provided one
13//! should be able to develop applications with certainty that they are abiding
14//! by regulatory standards.
15//!
16//! Each `DoIP` message contains a minimum length of 8 bytes of which is the
17//! [`header`], within this the header contains the length of the [`message`]
18//! and what type of payload the message is.
19
20// region:      --- Modules
21
22mod doip_header;
23mod doip_message;
24mod doip_payload;
25
26// -- Flatten
27
28// -- Public Modules
29/// Contains header related logic and data structures.
30///
31/// The `DoIP` header contains 4 items:
32/// - Protocol Version
33/// - Inverse Protocol Version
34/// - Payload Type
35/// - Payload Length
36///
37/// By default this library provides users with the option to use a different
38/// protocol version than what is currently in use, this is for backwards and future
39/// compatability.
40///
41/// The Inverse Protocol Version is the flipped byte of the protocol
42/// version, this is to validate the packet.
43///
44/// The payload length is given in a `u32` but in this library is written in
45/// `[u8; 4]` to remain close-to-network as possible.
46///
47/// This module contains the relevant structs, enums, and traits for developers
48/// to create custom headers.
49pub mod header {
50    pub use crate::doip_header::payload_type::*;
51    pub use crate::doip_header::version::*;
52    pub use crate::doip_header::DoipHeader;
53}
54
55/// Contains message data structures and internal payload type dependant structures.
56pub mod payload {
57    pub use crate::doip_payload::action_code::*;
58    pub use crate::doip_payload::activation_code::*;
59    pub use crate::doip_payload::activation_type::*;
60    pub use crate::doip_payload::diagnostic_ack::*;
61    pub use crate::doip_payload::diagnostic_nack::*;
62    pub use crate::doip_payload::nack_code::*;
63    pub use crate::doip_payload::node_type::*;
64    pub use crate::doip_payload::power_mode::*;
65    pub use crate::doip_payload::sync_status::*;
66    pub use crate::doip_payload::DoipPayload;
67
68    pub use crate::doip_payload::alive_check_request::*;
69    pub use crate::doip_payload::alive_check_response::*;
70    pub use crate::doip_payload::diagnostic_message::*;
71    pub use crate::doip_payload::diagnostic_message_ack::*;
72    pub use crate::doip_payload::diagnostic_message_nack::*;
73    pub use crate::doip_payload::entity_status_request::*;
74    pub use crate::doip_payload::entity_status_response::*;
75    pub use crate::doip_payload::generic_nack::*;
76    pub use crate::doip_payload::power_information_request::*;
77    pub use crate::doip_payload::power_information_response::*;
78    pub use crate::doip_payload::routing_activation_request::*;
79    pub use crate::doip_payload::routing_activation_response::*;
80    pub use crate::doip_payload::vehicle_announcement_message::*;
81    pub use crate::doip_payload::vehicle_identification_request::*;
82    pub use crate::doip_payload::vehicle_identification_request_eid::*;
83    pub use crate::doip_payload::vehicle_identification_request_vin::*;
84}
85
86/// The definitions found here are originally from Wireshark's repository. Wireshark
87/// is a packet sniffing tool with an already supported `DoIP` and UDS packet disassembly
88/// and so their definitions were lifted so to support this crate.
89pub mod definitions;
90
91/// Contains the implementations for the overarching `DoIP Message` structure.
92pub mod message {
93    pub use crate::doip_message::DoipMessage;
94}
95
96// endregion:      --- Modules
97
98// Python bindings (only available when std is enabled)
99#[cfg(feature = "std")]
100#[cfg(any(not(test), rust_analyzer))]
101mod bindings;
102
103// Panic handler for `no_std` environments, but only when `std` is not enabled
104#[cfg(not(feature = "std"))]
105#[panic_handler]
106fn panic(_info: &core::panic::PanicInfo) -> ! {
107    loop {}
108}