pub struct Dot15d4Layer {
pub index: LayerIndex,
}Expand description
IEEE 802.15.4 MAC frame layer (without FCS).
This is a zero-copy view into the packet buffer. The header length is variable depending on the address modes specified in the FCF.
Fields§
§index: LayerIndexImplementations§
Source§impl Dot15d4Layer
impl Dot15d4Layer
Sourcepub fn validate(buf: &[u8], offset: usize) -> Result<(), FieldError>
pub fn validate(buf: &[u8], offset: usize) -> Result<(), FieldError>
Validate that the buffer has enough bytes for at least the minimum header.
Sourcepub fn fcf_raw(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn fcf_raw(&self, buf: &[u8]) -> Result<u16, FieldError>
Read the raw 16-bit Frame Control Field.
Sourcepub fn fcf_frametype(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn fcf_frametype(&self, buf: &[u8]) -> Result<u8, FieldError>
Frame type (3 bits): 0=Beacon, 1=Data, 2=Ack, 3=Command.
Sourcepub fn fcf_security(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn fcf_security(&self, buf: &[u8]) -> Result<bool, FieldError>
Security Enabled flag.
Sourcepub fn fcf_pending(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn fcf_pending(&self, buf: &[u8]) -> Result<bool, FieldError>
Frame Pending flag.
Sourcepub fn fcf_ackreq(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn fcf_ackreq(&self, buf: &[u8]) -> Result<bool, FieldError>
ACK Request flag.
Sourcepub fn fcf_panidcompress(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn fcf_panidcompress(&self, buf: &[u8]) -> Result<bool, FieldError>
PAN ID Compression flag (intra-PAN).
Sourcepub fn fcf_destaddrmode(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn fcf_destaddrmode(&self, buf: &[u8]) -> Result<u8, FieldError>
Destination Address Mode (2 bits): 0=None, 2=Short, 3=Long.
Sourcepub fn fcf_framever(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn fcf_framever(&self, buf: &[u8]) -> Result<u8, FieldError>
Frame Version (2 bits).
Sourcepub fn fcf_srcaddrmode(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn fcf_srcaddrmode(&self, buf: &[u8]) -> Result<u8, FieldError>
Source Address Mode (2 bits): 0=None, 2=Short, 3=Long.
Sourcepub fn set_seqnum(&self, buf: &mut [u8], val: u8) -> Result<(), FieldError>
pub fn set_seqnum(&self, buf: &mut [u8], val: u8) -> Result<(), FieldError>
Set sequence number.
Sourcepub fn dest_panid(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
pub fn dest_panid(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
Destination PAN ID (2 bytes, LE).
Returns None if dest_addr_mode == 0.
Sourcepub fn dest_addr_short(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
pub fn dest_addr_short(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
Destination short address (2 bytes, LE).
Returns None if dest_addr_mode != SHORT.
Sourcepub fn dest_addr_long(&self, buf: &[u8]) -> Result<Option<u64>, FieldError>
pub fn dest_addr_long(&self, buf: &[u8]) -> Result<Option<u64>, FieldError>
Destination long address (8 bytes, LE).
Returns None if dest_addr_mode != LONG.
Sourcepub fn src_panid(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
pub fn src_panid(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
Source PAN ID (2 bytes, LE).
Returns None if src_addr_mode == 0 or PAN ID compressed.
Sourcepub fn src_addr_short(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
pub fn src_addr_short(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
Source short address (2 bytes, LE).
Returns None if src_addr_mode != SHORT.
Sourcepub fn src_addr_long(&self, buf: &[u8]) -> Result<Option<u64>, FieldError>
pub fn src_addr_long(&self, buf: &[u8]) -> Result<Option<u64>, FieldError>
Source long address (8 bytes, LE).
Returns None if src_addr_mode != LONG.
Sourcepub fn set_fcf_frametype(
&self,
buf: &mut [u8],
val: u8,
) -> Result<(), FieldError>
pub fn set_fcf_frametype( &self, buf: &mut [u8], val: u8, ) -> Result<(), FieldError>
Set the frame type in the FCF.
Sourcepub fn set_fcf_security(
&self,
buf: &mut [u8],
val: bool,
) -> Result<(), FieldError>
pub fn set_fcf_security( &self, buf: &mut [u8], val: bool, ) -> Result<(), FieldError>
Set the security enabled flag in the FCF.
Sourcepub fn set_fcf_pending(
&self,
buf: &mut [u8],
val: bool,
) -> Result<(), FieldError>
pub fn set_fcf_pending( &self, buf: &mut [u8], val: bool, ) -> Result<(), FieldError>
Set the frame pending flag in the FCF.
Sourcepub fn set_fcf_ackreq(
&self,
buf: &mut [u8],
val: bool,
) -> Result<(), FieldError>
pub fn set_fcf_ackreq( &self, buf: &mut [u8], val: bool, ) -> Result<(), FieldError>
Set the ACK request flag in the FCF.
Sourcepub fn set_fcf_panidcompress(
&self,
buf: &mut [u8],
val: bool,
) -> Result<(), FieldError>
pub fn set_fcf_panidcompress( &self, buf: &mut [u8], val: bool, ) -> Result<(), FieldError>
Set the PAN ID compression flag in the FCF.
Sourcepub fn set_fcf_destaddrmode(
&self,
buf: &mut [u8],
val: u8,
) -> Result<(), FieldError>
pub fn set_fcf_destaddrmode( &self, buf: &mut [u8], val: u8, ) -> Result<(), FieldError>
Set the destination address mode in the FCF.
Sourcepub fn set_fcf_framever(
&self,
buf: &mut [u8],
val: u8,
) -> Result<(), FieldError>
pub fn set_fcf_framever( &self, buf: &mut [u8], val: u8, ) -> Result<(), FieldError>
Set the frame version in the FCF.
Sourcepub fn set_fcf_srcaddrmode(
&self,
buf: &mut [u8],
val: u8,
) -> Result<(), FieldError>
pub fn set_fcf_srcaddrmode( &self, buf: &mut [u8], val: u8, ) -> Result<(), FieldError>
Set the source address mode in the FCF.
Sourcepub fn set_dest_panid(&self, buf: &mut [u8], val: u16) -> Result<(), FieldError>
pub fn set_dest_panid(&self, buf: &mut [u8], val: u16) -> Result<(), FieldError>
Set the destination PAN ID.
Sourcepub fn set_dest_addr_short(
&self,
buf: &mut [u8],
val: u16,
) -> Result<(), FieldError>
pub fn set_dest_addr_short( &self, buf: &mut [u8], val: u16, ) -> Result<(), FieldError>
Set the destination short address.
Sourcepub fn set_dest_addr_long(
&self,
buf: &mut [u8],
val: u64,
) -> Result<(), FieldError>
pub fn set_dest_addr_long( &self, buf: &mut [u8], val: u64, ) -> Result<(), FieldError>
Set the destination long address.
Sourcepub fn set_src_panid(&self, buf: &mut [u8], val: u16) -> Result<(), FieldError>
pub fn set_src_panid(&self, buf: &mut [u8], val: u16) -> Result<(), FieldError>
Set the source PAN ID.
Sourcepub fn set_src_addr_short(
&self,
buf: &mut [u8],
val: u16,
) -> Result<(), FieldError>
pub fn set_src_addr_short( &self, buf: &mut [u8], val: u16, ) -> Result<(), FieldError>
Set the source short address.
Sourcepub fn set_src_addr_long(
&self,
buf: &mut [u8],
val: u64,
) -> Result<(), FieldError>
pub fn set_src_addr_long( &self, buf: &mut [u8], val: u64, ) -> Result<(), FieldError>
Set the source long address.
Sourcepub fn get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
pub fn get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Get a field value by name.
Sourcepub fn set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
pub fn set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Set a field value by name.
Sourcepub fn field_names() -> &'static [&'static str]
pub fn field_names() -> &'static [&'static str]
Get the list of field names.
Sourcepub fn next_layer(&self, buf: &[u8]) -> Option<LayerKind>
pub fn next_layer(&self, buf: &[u8]) -> Option<LayerKind>
Determine the next layer kind based on frame type.
Sourcepub fn format_long_addr(addr: u64) -> String
pub fn format_long_addr(addr: u64) -> String
Format a long address as a colon-separated hex string.
Trait Implementations§
Source§impl Clone for Dot15d4Layer
impl Clone for Dot15d4Layer
Source§fn clone(&self) -> Dot15d4Layer
fn clone(&self) -> Dot15d4Layer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more