pub struct Dot11Layer {
pub index: LayerIndex,
}Expand description
IEEE 802.11 layer - a zero-copy view into the packet buffer.
Provides lazy field access for all 802.11 header fields. The Frame Control field is always little-endian.
Frame Control layout (2 bytes, little-endian):
Byte 0: [subtype(4) | type(2) | protocol_version(2)]
Byte 1: [order | protected | more_data | pwr_mgt | retry | more_frag | from_ds | to_ds]Fields§
§index: LayerIndexImplementations§
Source§impl Dot11Layer
impl Dot11Layer
Sourcepub fn validate(buf: &[u8], offset: usize) -> Result<(), FieldError>
pub fn validate(buf: &[u8], offset: usize) -> Result<(), FieldError>
Validate that the buffer contains enough data for this layer.
Sourcepub fn frame_control_raw(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn frame_control_raw(&self, buf: &[u8]) -> Result<u16, FieldError>
Read the raw Frame Control field (2 bytes, little-endian).
Sourcepub fn protocol_version(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn protocol_version(&self, buf: &[u8]) -> Result<u8, FieldError>
Protocol version (2 bits from FC byte 0, bits 0-1).
Sourcepub fn frame_type(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn frame_type(&self, buf: &[u8]) -> Result<u8, FieldError>
Frame type (2 bits from FC byte 0, bits 2-3).
Sourcepub fn subtype(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn subtype(&self, buf: &[u8]) -> Result<u8, FieldError>
Frame subtype (4 bits from FC byte 0, bits 4-7).
Sourcepub fn flags(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn flags(&self, buf: &[u8]) -> Result<u8, FieldError>
Flags byte (FC byte 1, bits 8-15 of the FC word).
Sourcepub fn from_ds(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn from_ds(&self, buf: &[u8]) -> Result<bool, FieldError>
From DS flag (bit 1 of flags byte).
Sourcepub fn more_frag(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn more_frag(&self, buf: &[u8]) -> Result<bool, FieldError>
More Fragments flag (bit 2 of flags byte).
Sourcepub fn pwr_mgt(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn pwr_mgt(&self, buf: &[u8]) -> Result<bool, FieldError>
Power Management flag (bit 4 of flags byte).
Sourcepub fn more_data(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn more_data(&self, buf: &[u8]) -> Result<bool, FieldError>
More Data flag (bit 5 of flags byte).
Sourcepub fn protected(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn protected(&self, buf: &[u8]) -> Result<bool, FieldError>
Protected Frame flag (bit 6 of flags byte).
Sourcepub fn htc_order(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn htc_order(&self, buf: &[u8]) -> Result<bool, FieldError>
HTC/Order flag (bit 7 of flags byte).
Sourcepub fn duration(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn duration(&self, buf: &[u8]) -> Result<u16, FieldError>
Duration/ID field (2 bytes, little-endian).
Sourcepub fn addr1(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
pub fn addr1(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
Address 1 (always present, 6 bytes at offset 4).
Sourcepub fn addr2(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
pub fn addr2(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
Address 2 (present in most frames except some control frames).
Sourcepub fn addr3(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
pub fn addr3(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
Address 3 (present in management and data frames).
Sourcepub fn addr4(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
pub fn addr4(&self, buf: &[u8]) -> Result<MacAddress, FieldError>
Address 4 (only present in WDS frames: to_DS=1 AND from_DS=1).
Sourcepub fn has_addr4(&self, buf: &[u8]) -> bool
pub fn has_addr4(&self, buf: &[u8]) -> bool
Check if this frame has a 4th address field (WDS mode).
Sourcepub fn is_control(&self, buf: &[u8]) -> bool
pub fn is_control(&self, buf: &[u8]) -> bool
Check if this is a control frame (which may have fewer addresses).
Sourcepub fn seq_ctrl_raw(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn seq_ctrl_raw(&self, buf: &[u8]) -> Result<u16, FieldError>
Raw Sequence Control field (2 bytes, little-endian).
Sourcepub fn fragment_num(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn fragment_num(&self, buf: &[u8]) -> Result<u8, FieldError>
Fragment number (lower 4 bits of Sequence Control).
Sourcepub fn sequence_num(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn sequence_num(&self, buf: &[u8]) -> Result<u16, FieldError>
Sequence number (upper 12 bits of Sequence Control).
Sourcepub fn compute_header_len(&self, buf: &[u8]) -> usize
pub fn compute_header_len(&self, buf: &[u8]) -> usize
Calculate the actual header length based on frame type and flags.
Sourcepub fn set_frame_control(
&self,
buf: &mut [u8],
fc: u16,
) -> Result<(), FieldError>
pub fn set_frame_control( &self, buf: &mut [u8], fc: u16, ) -> Result<(), FieldError>
Write the Frame Control field (little-endian).
Sourcepub fn set_duration(&self, buf: &mut [u8], dur: u16) -> Result<(), FieldError>
pub fn set_duration(&self, buf: &mut [u8], dur: u16) -> Result<(), FieldError>
Write the Duration/ID field (little-endian).
Sourcepub fn set_addr1(
&self,
buf: &mut [u8],
mac: MacAddress,
) -> Result<(), FieldError>
pub fn set_addr1( &self, buf: &mut [u8], mac: MacAddress, ) -> Result<(), FieldError>
Write Address 1.
Sourcepub fn set_addr2(
&self,
buf: &mut [u8],
mac: MacAddress,
) -> Result<(), FieldError>
pub fn set_addr2( &self, buf: &mut [u8], mac: MacAddress, ) -> Result<(), FieldError>
Write Address 2.
Sourcepub fn set_addr3(
&self,
buf: &mut [u8],
mac: MacAddress,
) -> Result<(), FieldError>
pub fn set_addr3( &self, buf: &mut [u8], mac: MacAddress, ) -> Result<(), FieldError>
Write Address 3.
Sourcepub fn set_addr4(
&self,
buf: &mut [u8],
mac: MacAddress,
) -> Result<(), FieldError>
pub fn set_addr4( &self, buf: &mut [u8], mac: MacAddress, ) -> Result<(), FieldError>
Write Address 4.
Sourcepub fn set_seq_ctrl(&self, buf: &mut [u8], sc: u16) -> Result<(), FieldError>
pub fn set_seq_ctrl(&self, buf: &mut [u8], sc: u16) -> Result<(), FieldError>
Write the Sequence Control field (little-endian).
Sourcepub fn field_names() -> &'static [&'static str]
pub fn field_names() -> &'static [&'static str]
Field names for dynamic access.
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.
Trait Implementations§
Source§impl Clone for Dot11Layer
impl Clone for Dot11Layer
Source§fn clone(&self) -> Dot11Layer
fn clone(&self) -> Dot11Layer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more