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 moreSource§impl Debug for Dot15d4Layer
impl Debug for Dot15d4Layer
Source§impl From<Dot15d4Layer> for LayerEnum
impl From<Dot15d4Layer> for LayerEnum
Source§fn from(v: Dot15d4Layer) -> LayerEnum
fn from(v: Dot15d4Layer) -> LayerEnum
Source§impl Layer for Dot15d4Layer
impl Layer for Dot15d4Layer
Source§fn header_len(&self, buf: &[u8]) -> usize
fn header_len(&self, buf: &[u8]) -> usize
Source§fn answers(&self, buf: &[u8], other: &Self, other_buf: &[u8]) -> bool
fn answers(&self, buf: &[u8], other: &Self, other_buf: &[u8]) -> bool
Source§fn field_names(&self) -> &'static [&'static str]
fn field_names(&self) -> &'static [&'static str]
Source§impl LayerDispatch for Dot15d4Layer
impl LayerDispatch for Dot15d4Layer
Source§fn dispatch_kind(&self) -> LayerKind
fn dispatch_kind(&self) -> LayerKind
Source§fn dispatch_index(&self) -> &LayerIndex
fn dispatch_index(&self) -> &LayerIndex
Source§fn dispatch_summary(&self, buf: &[u8]) -> String
fn dispatch_summary(&self, buf: &[u8]) -> String
Source§fn dispatch_header_len(&self, buf: &[u8]) -> usize
fn dispatch_header_len(&self, buf: &[u8]) -> usize
Source§fn dispatch_field_names(&self) -> &'static [&'static str]
fn dispatch_field_names(&self) -> &'static [&'static str]
Source§fn dispatch_get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
fn dispatch_get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Source§fn dispatch_set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
fn dispatch_set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Auto Trait Implementations§
impl Freeze for Dot15d4Layer
impl RefUnwindSafe for Dot15d4Layer
impl Send for Dot15d4Layer
impl Sync for Dot15d4Layer
impl Unpin for Dot15d4Layer
impl UnsafeUnpin for Dot15d4Layer
impl UnwindSafe for Dot15d4Layer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more