1use crate::capabilities::{ClientCapabilities, StaCapabilities};
6use crate::ie;
7use crate::mac::CapabilityInfo;
8use fidl_fuchsia_wlan_ieee80211 as fidl_ieee80211;
9use fidl_fuchsia_wlan_mlme as fidl_mlme;
10use zerocopy::IntoBytes;
11
12pub fn fake_ht_capabilities_cbw(chanwidth: ie::ChanWidthSet) -> ie::HtCapabilities {
13 let mut ht_cap = ie::fake_ht_capabilities();
14 ht_cap.ht_cap_info = ht_cap.ht_cap_info.with_chan_width_set(chanwidth);
15 ht_cap
16}
17
18pub fn fake_capability_info() -> CapabilityInfo {
19 CapabilityInfo(0)
20 .with_ess(false)
21 .with_ibss(false)
22 .with_cf_pollable(false)
23 .with_cf_poll_req(false)
24 .with_privacy(false)
25 .with_short_preamble(true)
26 .with_spectrum_mgmt(false)
27 .with_qos(false)
28 .with_short_slot_time(false)
29 .with_apsd(false)
30 .with_radio_measurement(false)
31 .with_delayed_block_ack(false)
32 .with_immediate_block_ack(false)
33}
34
35pub fn fake_5ghz_band_capability() -> fidl_mlme::BandCapability {
36 fidl_mlme::BandCapability {
37 band: fidl_ieee80211::WlanBand::FiveGhz,
38 basic_rates: vec![0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c],
39 primary_channels: vec![
40 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
41 144, 149, 153, 157, 161, 165,
42 ]
43 .into_iter()
44 .map(|n| fidl_ieee80211::ChannelNumber {
45 number: n,
46 band: fidl_ieee80211::WlanBand::FiveGhz,
47 })
48 .collect(),
49 ht_cap: None,
50 vht_cap: None,
51 }
52}
53
54pub fn fake_5ghz_band_capability_ht(chanwidth: ie::ChanWidthSet) -> fidl_mlme::BandCapability {
55 let bc = fake_5ghz_band_capability();
56 fidl_mlme::BandCapability {
57 ht_cap: Some(Box::new(fidl_ieee80211::HtCapabilities {
58 bytes: fake_ht_capabilities_cbw(chanwidth).as_bytes().try_into().unwrap(),
59 })),
60 ..bc
61 }
62}
63
64pub fn fake_5ghz_band_capability_vht() -> fidl_mlme::BandCapability {
65 let bc = fake_5ghz_band_capability();
66 fidl_mlme::BandCapability {
67 ht_cap: Some(Box::new(fidl_ieee80211::HtCapabilities {
68 bytes: fake_ht_capabilities_cbw(ie::ChanWidthSet::TWENTY_FORTY)
69 .as_bytes()
70 .try_into()
71 .unwrap(),
72 })),
73 vht_cap: Some(Box::new(fidl_ieee80211::VhtCapabilities {
74 bytes: ie::fake_vht_capabilities().as_bytes().try_into().unwrap(),
75 })),
76 ..bc
77 }
78}
79
80pub fn fake_2ghz_band_capability() -> fidl_mlme::BandCapability {
81 fidl_mlme::BandCapability {
82 band: fidl_ieee80211::WlanBand::TwoGhz,
83 basic_rates: vec![0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c],
84 primary_channels: vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
85 .into_iter()
86 .map(|n| fidl_ieee80211::ChannelNumber {
87 number: n,
88 band: fidl_ieee80211::WlanBand::TwoGhz,
89 })
90 .collect(),
91 ht_cap: None,
92 vht_cap: None,
93 }
94}
95
96pub fn fake_2ghz_band_capability_ht() -> fidl_mlme::BandCapability {
97 fidl_mlme::BandCapability {
98 ht_cap: Some(Box::new(fidl_ieee80211::HtCapabilities {
99 bytes: fake_ht_capabilities_cbw(ie::ChanWidthSet::TWENTY_FORTY)
100 .as_bytes()
101 .try_into()
102 .unwrap(),
103 })),
104 ..fake_2ghz_band_capability()
105 }
106}
107
108pub fn fake_client_capabilities() -> ClientCapabilities {
109 let rates = vec![0x02, 0x04, 0x0b, 0x16, 0x0c, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c];
110 ClientCapabilities(StaCapabilities {
111 capability_info: fake_capability_info(),
112 rates: rates.into_iter().map(ie::SupportedRate).collect(),
113 ht_cap: Some(ie::fake_ht_capabilities()),
114 vht_cap: Some(ie::fake_vht_capabilities()),
115 })
116}