Skip to main content

Dot11

Struct Dot11 

Source
pub struct Dot11 { /* private fields */ }
Expand description

IEEE 802.11 MAC layer.

Implementations§

Source§

impl Dot11

Source

pub fn new() -> Self

Create a three-address data MAC header with deterministic safe defaults.

Source

pub fn management(subtype: Dot11ManagementSubtype) -> Self

Create a management frame with the given subtype.

Source

pub fn control(subtype: Dot11ControlSubtype) -> Self

Create a control frame with the given subtype.

Source

pub fn data() -> Self

Create a data frame.

Source

pub fn qos_data() -> Self

Create a QoS data frame with a zero QoS control field.

Source

pub fn beacon() -> Self

Create a beacon management frame.

Source

pub fn probe_request() -> Self

Create a probe request management frame.

Source

pub fn probe_response() -> Self

Create a probe response management frame.

Source

pub fn association_request() -> Self

Create an association request management frame.

Source

pub fn association_response() -> Self

Create an association response management frame.

Source

pub fn reassociation_request() -> Self

Create a reassociation request management frame.

Source

pub fn reassociation_response() -> Self

Create a reassociation response management frame.

Source

pub fn authentication() -> Self

Create an authentication management frame.

Source

pub fn deauthentication() -> Self

Create a deauthentication management frame.

Source

pub fn disassociation() -> Self

Create a disassociation management frame.

Source

pub fn action() -> Self

Create an action management frame with a zero category field.

Source

pub fn action_no_ack() -> Self

Create an action-no-ack management frame with a zero category field.

Source

pub fn ack() -> Self

Create an ACK control frame.

Source

pub fn rts() -> Self

Create an RTS control frame.

Source

pub fn cts() -> Self

Create a CTS control frame.

Source

pub fn block_ack() -> Self

Create a Block Ack control frame.

Source

pub fn block_ack_request() -> Self

Create a Block Ack Request control frame.

Source

pub fn ps_poll() -> Self

Create a PS-Poll control frame.

Source

pub fn cf_end() -> Self

Create a CF-End control frame.

Source

pub fn cf_end_cf_ack() -> Self

Create a CF-End + CF-Ack control frame.

Source

pub fn frame_control(self, frame_control: Dot11FrameControl) -> Self

Set the frame-control field.

Source

pub fn more_fragments(self, enabled: bool) -> Self

Set or clear the More Fragments frame-control bit.

Source

pub fn duration_id(self, duration_id: u16) -> Self

Set the duration/ID field.

Source

pub fn addr1(self, addr: impl Into<MacAddr>) -> Self

Set address 1.

Source

pub fn addr2(self, addr: impl Into<MacAddr>) -> Self

Set address 2.

Source

pub fn addr3(self, addr: impl Into<MacAddr>) -> Self

Set address 3.

Source

pub fn addr4(self, addr: impl Into<MacAddr>) -> Self

Set address 4.

Source

pub fn sequence_control(self, sequence_control: Dot11SequenceControl) -> Self

Set the sequence-control field.

Source

pub fn sequence_number(self, sequence_number: u16) -> Self

Set the twelve-bit sequence number in the sequence-control field.

Source

pub fn fragment_number(self, fragment_number: u8) -> Self

Set the four-bit fragment number in the sequence-control field.

Source

pub fn qos_control(self, qos_control: u16) -> Self

Set the QoS control field.

Source

pub fn with_qos_control_fields(self, qos_control: Dot11QosControl) -> Self

Set the QoS control field from typed subfields.

Source

pub fn ht_control(self, ht_control: u32) -> Self

Set the HT Control field.

Source

pub fn fixed_parameters(self, fixed_parameters: impl Into<Vec<u8>>) -> Self

Set raw fixed management-field bytes to emit after the MAC header.

Source

pub fn with_beacon_fixed_fields( self, fixed_fields: Dot11BeaconFixedFields, ) -> Self

Set Beacon fixed fields without changing the frame subtype.

Source

pub fn with_probe_response_fixed_fields( self, fixed_fields: Dot11BeaconFixedFields, ) -> Self

Set Probe Response fixed fields without changing the frame subtype.

Source

pub fn with_association_request_fixed_fields( self, fixed_fields: Dot11AssociationRequestFixedFields, ) -> Self

Set Association Request fixed fields without changing the frame subtype.

Source

pub fn with_association_response_fixed_fields( self, fixed_fields: Dot11AssociationResponseFixedFields, ) -> Self

Set Association Response fixed fields without changing the frame subtype.

Source

pub fn with_reassociation_request_fixed_fields( self, fixed_fields: Dot11ReassociationRequestFixedFields, ) -> Self

Set Reassociation Request fixed fields without changing the frame subtype.

Source

pub fn with_reassociation_response_fixed_fields( self, fixed_fields: Dot11AssociationResponseFixedFields, ) -> Self

Set Reassociation Response fixed fields without changing the frame subtype.

Source

pub fn with_authentication_fixed_fields( self, fixed_fields: Dot11AuthenticationFixedFields, ) -> Self

Set Authentication fixed fields without changing the frame subtype.

Source

pub fn with_deauthentication_fixed_fields( self, fixed_fields: Dot11ReasonCodeFixedFields, ) -> Self

Set Deauthentication fixed fields without changing the frame subtype.

Source

pub fn with_disassociation_fixed_fields( self, fixed_fields: Dot11ReasonCodeFixedFields, ) -> Self

Set Disassociation fixed fields without changing the frame subtype.

Source

pub fn with_action_fixed_fields( self, fixed_fields: Dot11ActionFixedFields, ) -> Self

Set Action fixed fields without changing the frame subtype.

Source

pub fn tag(self, tag: Dot11TaggedParameter) -> Self

Append a raw tagged parameter.

Source

pub fn tags(self, tags: impl Into<Vec<Dot11TaggedParameter>>) -> Self

Replace raw tagged parameters.

Source

pub fn ssid(self, ssid: impl Into<Vec<u8>>) -> Self

Append an SSID tagged parameter.

Source

pub fn supported_rates(self, rates: impl Into<Vec<u8>>) -> Self

Append a Supported Rates tagged parameter.

Source

pub fn ds_parameter_set(self, current_channel: u8) -> Self

Append a DS Parameter Set tagged parameter with the current channel.

Source

pub fn tim(self, data: impl Into<Vec<u8>>) -> Self

Append a raw TIM tagged parameter.

Source

pub fn rsn(self, data: impl Into<Vec<u8>>) -> Self

Append a raw RSN tagged parameter.

Source

pub fn with_rsn_information(self, rsn: &RsnInformation) -> Result<Self>

Append an RSN tagged parameter from typed RSN information.

Source

pub fn frame_control_value(&self) -> Dot11FrameControl

Current frame-control value.

Source

pub fn frame_type(&self) -> Dot11FrameType

Current typed frame type.

Source

pub fn management_subtype(&self) -> Option<Dot11ManagementSubtype>

Current typed management subtype, when applicable.

Source

pub fn control_subtype(&self) -> Option<Dot11ControlSubtype>

Current typed control subtype, when applicable.

Source

pub fn data_subtype(&self) -> Option<Dot11DataSubtype>

Current typed data subtype, when applicable.

Source

pub fn duration_id_value(&self) -> Option<u16>

Current duration/ID field value, if present.

Source

pub fn addr1_value(&self) -> Option<MacAddr>

Current address 1 value, if present.

Source

pub fn addr2_value(&self) -> Option<MacAddr>

Current address 2 value, if present.

Source

pub fn addr3_value(&self) -> Option<MacAddr>

Current address 3 value, if present.

Source

pub fn addr4_value(&self) -> Option<MacAddr>

Current address 4 value, if present.

Source

pub fn receiver(&self) -> Option<MacAddr>

Receiver address for data, management, or supported control frames.

Source

pub fn transmitter(&self) -> Option<MacAddr>

Transmitter address for data, management, or supported two-address control frames.

Source

pub fn destination(&self) -> Option<MacAddr>

Destination address for data or management frames.

Source

pub fn source(&self) -> Option<MacAddr>

Source address for data or management frames.

Source

pub fn bssid(&self) -> Option<MacAddr>

BSSID address for data or management frames when the role is defined.

Source

pub fn fourth_address(&self) -> Option<MacAddr>

Fourth address for four-address data frames when present.

Source

pub fn sequence_control_value(&self) -> Option<Dot11SequenceControl>

Current sequence-control field value, if present.

Source

pub fn sequence_number_value(&self) -> Option<u16>

Current sequence-number subfield value, if the frame has sequence control.

Source

pub fn fragment_number_value(&self) -> Option<u8>

Current fragment-number subfield value, if the frame has sequence control.

Source

pub fn qos_control_value(&self) -> Option<u16>

Current QoS control field value, if present.

Source

pub fn qos_control_fields(&self) -> Option<Dot11QosControl>

Current typed QoS control field value, if present.

Source

pub fn ht_control_value(&self) -> Option<u32>

Current HT Control field value, if present.

Source

pub fn fixed_parameters_value(&self) -> &[u8]

Raw fixed management-field bytes.

Source

pub fn raw_fixed_parameters(&self) -> &[u8]

Raw fixed management-field bytes, including unsupported or malformed shapes.

Source

pub fn management_fixed_fields(&self) -> Dot11ManagementFixedFields<'_>

Typed management fixed fields, or raw bytes when the shape is unsupported.

Source

pub fn beacon_fixed_fields(&self) -> Option<Dot11BeaconFixedFields>

Beacon fixed fields when this frame has the supported Beacon shape.

Source

pub fn probe_response_fixed_fields(&self) -> Option<Dot11BeaconFixedFields>

Probe Response fixed fields when this frame has the supported shape.

Source

pub fn association_request_fixed_fields( &self, ) -> Option<Dot11AssociationRequestFixedFields>

Association Request fixed fields when this frame has the supported shape.

Source

pub fn association_response_fixed_fields( &self, ) -> Option<Dot11AssociationResponseFixedFields>

Association Response fixed fields when this frame has the supported shape.

Source

pub fn reassociation_request_fixed_fields( &self, ) -> Option<Dot11ReassociationRequestFixedFields>

Reassociation Request fixed fields when this frame has the supported shape.

Source

pub fn reassociation_response_fixed_fields( &self, ) -> Option<Dot11AssociationResponseFixedFields>

Reassociation Response fixed fields when this frame has the supported shape.

Source

pub fn authentication_fixed_fields( &self, ) -> Option<Dot11AuthenticationFixedFields>

Authentication fixed fields when this frame has the supported shape.

Source

pub fn deauthentication_fixed_fields( &self, ) -> Option<Dot11ReasonCodeFixedFields>

Deauthentication fixed fields when this frame has the supported shape.

Source

pub fn disassociation_fixed_fields(&self) -> Option<Dot11ReasonCodeFixedFields>

Disassociation fixed fields when this frame has the supported shape.

Source

pub fn action_fixed_fields(&self) -> Option<Dot11ActionFixedFields>

Action fixed fields when this frame has the supported Action shape.

Source

pub fn tags_value(&self) -> &[Dot11TaggedParameter]

Raw tagged parameters.

Source

pub fn tagged_parameters(&self) -> &[Dot11TaggedParameter]

Raw tagged parameters.

Source

pub fn rsn_information(&self) -> Option<Result<RsnInformation>>

First RSN information element carried by the raw tagged parameters.

Source

pub fn rsn_information_elements( &self, ) -> impl Iterator<Item = Result<RsnInformation>> + '_

RSN information elements carried by the raw tagged parameters.

Source

pub fn is_protected(&self) -> bool

Return true when the Protected Frame bit is set.

Source

pub fn has_more_fragments(&self) -> bool

Return true when the More Fragments frame-control bit is set.

Source

pub fn is_fragmented(&self) -> bool

Return true when this frame carries 802.11 fragmentation metadata.

crafter exposes this metadata for inspection but does not reassemble fragmented 802.11 payloads.

Source

pub fn encrypted_body_len(&self) -> Option<usize>

Decoded encrypted body length for protected data frames.

Source

pub fn minimum_header_len(&self) -> usize

Minimum header length implied by this frame’s type/subtype and flags.

This is the source-backed decode boundary: MAC header fields, optional address four, QoS control, HT Control when signaled by supported +HTC/Order shapes, and selected management fixed fields. It does not include tagged parameters or higher-layer payload bytes.

Source

pub fn minimum_header_len_for(frame_control: Dot11FrameControl) -> usize

Minimum header length implied by a frame-control word.

Source

pub fn header_len_from_bytes(bytes: impl AsRef<[u8]>) -> Result<usize>

Read frame control from bytes, compute the minimum header length, and return a structured error when the buffer is truncated before that boundary.

Trait Implementations§

Source§

impl Clone for Dot11

Source§

fn clone(&self) -> Dot11

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dot11

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Dot11

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<R> Div<R> for Dot11
where R: IntoPacket,

Source§

type Output = Packet

The resulting type after applying the / operator.
Source§

fn div(self, rhs: R) -> Self::Output

Performs the / operation. Read more
Source§

impl Eq for Dot11

Source§

impl Layer for Dot11

Source§

fn name(&self) -> &'static str

Stable layer name used by summaries and generated tools.
Source§

fn summary(&self) -> String

A one-line layer summary.
Source§

fn inspection_fields(&self) -> Vec<(&'static str, String)>

Stable field/value pairs used by packet inspection output.
Source§

fn encoded_len(&self) -> usize

Encoded length for this layer before dependent auto-fill.
Source§

fn compile(&self, _ctx: &LayerContext<'_>, out: &mut Vec<u8>) -> Result<()>

Encode this layer into out.
Source§

fn clone_layer(&self) -> Box<dyn Layer>

Clone this layer behind a trait object.
Source§

fn as_any(&self) -> &dyn Any

Return this layer as Any for typed packet access.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Return this layer mutably as Any for typed packet access.
Source§

fn into_any(self: Box<Self>) -> Box<dyn Any>

Convert an owned trait object into Any for downcasting.
Source§

fn encoded_len_with_context(&self, _ctx: &LayerContext<'_>) -> usize

Encoded length for this layer once neighboring-layer context is known. Read more
Source§

fn consumes_following(&self) -> bool

Whether this layer’s compile() emits all following layers itself. Read more
Source§

fn transport_checksum_context( &self, _transport_protocol: u8, ) -> Option<TransportChecksumContext>

Return pseudo-header data for a following transport layer, when present.
Source§

impl PartialEq for Dot11

Source§

fn eq(&self, other: &Dot11) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Dot11

Auto Trait Implementations§

§

impl Freeze for Dot11

§

impl RefUnwindSafe for Dot11

§

impl Send for Dot11

§

impl Sync for Dot11

§

impl Unpin for Dot11

§

impl UnsafeUnpin for Dot11

§

impl UnwindSafe for Dot11

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoPacket for T
where T: Layer,

Source§

fn into_packet(self) -> Packet

Convert this value into a packet.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.