Skip to main content

Dot11Builder

Struct Dot11Builder 

Source
pub struct Dot11Builder {
    pub proto: u8,
    pub frame_type: u8,
    pub subtype: u8,
    pub flags: u8,
    pub duration: u16,
    pub addr1: MacAddress,
    pub addr2: MacAddress,
    pub addr3: MacAddress,
    pub addr4: Option<MacAddress>,
    pub seq_ctrl: u16,
    pub body: Vec<u8>,
    pub with_fcs: bool,
}
Expand description

Builder for constructing 802.11 frames with a fluent API.

§Example

let frame = Dot11Builder::new()
    .frame_type(types::frame_type::MANAGEMENT)
    .subtype(types::mgmt_subtype::BEACON)
    .addr1(MacAddress::BROADCAST)
    .addr2(bssid)
    .addr3(bssid)
    .build();

Fields§

§proto: u8

Protocol version (default 0).

§frame_type: u8

Frame type (Management/Control/Data).

§subtype: u8

Frame subtype.

§flags: u8

Flags byte (to_DS, from_DS, retry, etc.).

§duration: u16

Duration/ID field.

§addr1: MacAddress

Address 1 (receiver/destination).

§addr2: MacAddress

Address 2 (transmitter/source).

§addr3: MacAddress

Address 3 (BSSID or other).

§addr4: Option<MacAddress>

Address 4 (only in WDS mode).

§seq_ctrl: u16

Sequence Control field.

§body: Vec<u8>

Frame body payload (management body, data, etc.).

§with_fcs: bool

Whether to append FCS.

Implementations§

Source§

impl Dot11Builder

Source

pub fn new() -> Self

Create a new builder with default values.

Source

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

Set the protocol version (usually 0).

Source

pub fn frame_type(self, ft: u8) -> Self

Set the frame type.

Source

pub fn subtype(self, st: u8) -> Self

Set the frame subtype.

Source

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

Set the flags byte.

Source

pub fn to_ds(self, val: bool) -> Self

Set the to_DS flag.

Source

pub fn from_ds(self, val: bool) -> Self

Set the from_DS flag.

Source

pub fn retry(self, val: bool) -> Self

Set the retry flag.

Source

pub fn protected(self, val: bool) -> Self

Set the protected frame flag.

Source

pub fn duration(self, dur: u16) -> Self

Set the Duration/ID field.

Source

pub fn addr1(self, mac: MacAddress) -> Self

Set Address 1 (receiver/destination).

Source

pub fn addr2(self, mac: MacAddress) -> Self

Set Address 2 (transmitter/source).

Source

pub fn addr3(self, mac: MacAddress) -> Self

Set Address 3 (BSSID or other).

Source

pub fn addr4(self, mac: MacAddress) -> Self

Set Address 4 (WDS mode).

Source

pub fn seq_ctrl(self, sc: u16) -> Self

Set the Sequence Control field directly.

Source

pub fn seq_num(self, seq: u16, frag: u8) -> Self

Set sequence number and fragment number.

Source

pub fn body(self, body: Vec<u8>) -> Self

Set the frame body (payload after the header).

Source

pub fn with_fcs(self, enable: bool) -> Self

Enable FCS (Frame Check Sequence) appending.

Source

pub fn header_size(&self) -> usize

Calculate the header size based on frame type and addresses.

Source

pub fn build(&self) -> Vec<u8>

Build the frame bytes.

Source

pub fn beacon(bssid: MacAddress) -> Self

Create a Beacon frame builder.

Source

pub fn probe_request(src: MacAddress) -> Self

Create a Probe Request frame builder.

Source

pub fn probe_response(dst: MacAddress, bssid: MacAddress) -> Self

Create a Probe Response frame builder.

Source

pub fn authentication( dst: MacAddress, src: MacAddress, bssid: MacAddress, ) -> Self

Create an Authentication frame builder.

Source

pub fn deauthentication( dst: MacAddress, src: MacAddress, bssid: MacAddress, ) -> Self

Create a Deauthentication frame builder.

Source

pub fn assoc_request(dst: MacAddress, src: MacAddress) -> Self

Create an Association Request frame builder.

Source

pub fn ack(dst: MacAddress) -> Self

Create an ACK frame builder.

Source

pub fn rts(dst: MacAddress, src: MacAddress) -> Self

Create an RTS frame builder.

Source

pub fn cts(dst: MacAddress) -> Self

Create a CTS frame builder.

Source

pub fn data_to_ap(bssid: MacAddress, src: MacAddress, dst: MacAddress) -> Self

Create a Data frame builder (to AP: to_DS=1).

Source

pub fn data_from_ap(dst: MacAddress, bssid: MacAddress, src: MacAddress) -> Self

Create a Data frame builder (from AP: from_DS=1).

Source

pub fn qos_data_to_ap( bssid: MacAddress, src: MacAddress, dst: MacAddress, ) -> Self

Create a QoS Data frame builder (to AP: to_DS=1).

Source

pub fn data_wds( ra: MacAddress, ta: MacAddress, da: MacAddress, sa: MacAddress, ) -> Self

Create a WDS Data frame builder (to_DS=1, from_DS=1).

Source

pub fn build_beacon( bssid: MacAddress, timestamp: u64, beacon_interval: u16, capability: u16, ies: &[Dot11Elt], ) -> Vec<u8>

Build a beacon frame with the given body parameters and IEs.

Source

pub fn build_probe_request(src: MacAddress, ies: &[Dot11Elt]) -> Vec<u8>

Build a probe request frame with the given IEs.

Source

pub fn build_probe_response( dst: MacAddress, bssid: MacAddress, timestamp: u64, beacon_interval: u16, capability: u16, ies: &[Dot11Elt], ) -> Vec<u8>

Build a probe response frame with the given body parameters and IEs.

Source

pub fn build_auth( dst: MacAddress, src: MacAddress, bssid: MacAddress, algo: u16, seqnum: u16, status: u16, ) -> Vec<u8>

Build an authentication frame.

Source

pub fn build_deauth( dst: MacAddress, src: MacAddress, bssid: MacAddress, reason: u16, ) -> Vec<u8>

Build a deauthentication frame.

Source

pub fn build_assoc_request( dst: MacAddress, src: MacAddress, capability: u16, listen_interval: u16, ies: &[Dot11Elt], ) -> Vec<u8>

Build an association request frame.

Source

pub fn build_assoc_response( dst: MacAddress, bssid: MacAddress, capability: u16, status: u16, aid: u16, ies: &[Dot11Elt], ) -> Vec<u8>

Build an association response frame.

Source

pub fn build_qos_data( bssid: MacAddress, src: MacAddress, dst: MacAddress, tid: u8, payload: &[u8], ) -> Vec<u8>

Build a data frame with QoS header.

Trait Implementations§

Source§

impl Clone for Dot11Builder

Source§

fn clone(&self) -> Dot11Builder

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Dot11Builder

Source§

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

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

impl Default for Dot11Builder

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V