Expand description
Parser and encoder for ETSI C-ITS (V2X) messages including GeoNetworking headers and optionally Radiotap and IEEE 802.11 headers. It supports UPER, XER and JER ASN.1 encodings for parsing and encoding.
Supported messages/ standards: See documentation of the ItsMessage variants.
§Decoding
A packet can be decoded using the de::decode function:
let data = &[0x02, 0x02, 0xde, 0x14, 0x0c, 0xe5]; // provide actual message buffer here
#[cfg(feature = "_etsi")]
match c_its_parser::de::decode(data, c_its_parser::Headers::RadioTap802LlcGnBtp) {
#[cfg(feature = "cam_1_4_1")]
Ok(c_its_parser::ItsMessage::Cam {
geonetworking: _,
transport: _,
etsi: cam,
}) => {
println!("Got a CAM: {cam:?}")
}
Ok(msg) => println!("Got: {msg:?}"),
Err(err) => println!("Failed to parse message: {err}"),
}The headers argument needs to specify which headers are present: None, GeoNetworking + BTP or Radiotap + 802.11p + LLC + GeoNetworking + BTP.
Headers are expected to be present in binary form.
When no headers are present, it can auto-detect the ASN.1 encoding (UPER/ XER/ JER) and decodes the message.
This means, that XER and JER message buffers can only be decoded without headers.
§Encoding
To encode an ItsMessage struct, call the encode() method supplying the intended encoding rules.
Again, XER and JER messages can only be encoded without headers.
GeoNetworking and transport (BTP) headers will be added when present if UPER encoding is used.
§Feature Flags
This library has several feature flags to allow fine-grained control over the feature set and additional dependencies.
By default, all V2X messages and conversion to and from JSON are enabled.
If only some messages, or even just specific versions of messages are needed, they can be enabled one-by-one, e.g. using denm to enable both denm_1_3_1 and denm_2_2_1 support.
When no parsing of the geonetworking and pcap headers is needed, the transport feature can be disabled.
Besides parsing, the Rust API also provides helper functions to convert between ETSI data types and “normal”/ SI units. Additional conversions are only available by adding some feature flags:
Modules§
- de
- C-ITS Message Decoding
- en
- C-ITS Message Encoding
- standards
- C-ITS ASN.1 Message Definitions and Utilities
- transport
- GeoNetworking Transport Layer Parser
Enums§
- Encoding
Rules - Choice of ASN.1 encoding rule
- Headers
- Choice which message headers are present in the binary message buffer
- ItsMessage
- Wrapper for C-ITS messages
- Packet
Traits§
Functions§
- remove_
pcap_ headers - Strips Radiotap, IEEE 802.11p and LLC headers from a binary message buffer