pub enum Packet<'input> {
Unsecured {
basic: BasicHeader,
common: CommonHeader,
extended: Option<ExtendedHeader>,
payload: &'input [u8],
},
Secured {
basic: BasicHeader,
secured: Ieee1609Dot2Data<'input>,
common: CommonHeader,
extended: Option<ExtendedHeader>,
},
}Expand description
C-ITS GeoNetworking packet
A geonetworking packet always contains a basic and common header.
When message signing (secured packet) is used, a secured header is added after the basic header which signs all data following itself.
Usually a message will continue with an extended header.
The payload is directly present in Unsecured packets or needs to be retrieved using Self::secured_payload_after_gn in Self::Secured
Variants§
Unsecured
Secured
Fields
basic: BasicHeadersecured: Ieee1609Dot2Data<'input>common: CommonHeaderextended: Option<ExtendedHeader>Implementations§
Source§impl<'p> Packet<'p>
impl<'p> Packet<'p>
Sourcepub fn secured_payload_after_gn(&self) -> Option<&'p [u8]>
pub fn secured_payload_after_gn(&self) -> Option<&'p [u8]>
Retrieves the slice of the secured IEEE 1609.2 data that represents the payload after GeoNetworking Common and Extended headers.
§Example
Consider a CAM message with BTB-B and secured GeoNetworking Header
Ieee1609Dot2Data->content->signed_data->tbs_data->payload->data->content->unsecured_data
|---Common---|---Extended---|--BTP-B--|--------CAM---------|
^ ^
|_________return slice_________|Sourcepub fn common(&self) -> &CommonHeader
pub fn common(&self) -> &CommonHeader
Returns a reference to the Common header regardless of Packet type
Sourcepub fn basic(&self) -> &BasicHeader
pub fn basic(&self) -> &BasicHeader
Returns a reference to the Basic header regardless of Packet type
Sourcepub fn extended(&self) -> &Option<ExtendedHeader>
pub fn extended(&self) -> &Option<ExtendedHeader>
Returns a reference to the Extended header regardless of Packet type
Sourcepub fn payload(&self) -> Option<&'p [u8]>
pub fn payload(&self) -> Option<&'p [u8]>
Returns a reference to the payload of a signed or unsigned packet (or None if secured packet has not payload)
The payload buffer will contain a header (usually BTP) as specified in the next_header field of the common header.
Sourcepub fn btp_payload(&self) -> Result<&'p [u8], String>
pub fn btp_payload(&self) -> Result<&'p [u8], String>
Extracts the BTP payload
§Errors
Returns a human-readable string if
- a secured packet has no payload
- or the next header is not a BTP header
Sourcepub fn is_secured(&self) -> bool
pub fn is_secured(&self) -> bool
Determines if the packet is a secured packet
Sourcepub fn source_position_vector(&self) -> Option<LongPositionVector>
pub fn source_position_vector(&self) -> Option<LongPositionVector>
Gets the source position vector from the extended header (if header is present)