20bool wifi_frame_parse(
const uint8_t *frame, uint16_t len, WifiFrameInfo *out)
22 if (!frame || !out || len < 10)
26 memset(out, 0,
sizeof(*out));
28 const uint8_t fc0 = frame[0];
29 const uint8_t fc1 = frame[1];
30 out->type = (WifiFrameType)((fc0 >> 2) & 0x3);
31 out->subtype = (uint8_t)((fc0 >> 4) & 0xF);
32 out->to_ds = (fc1 & 0x01) != 0;
33 out->from_ds = (fc1 & 0x02) != 0;
34 out->protected_frame = (fc1 & 0x40) != 0;
36 if (out->type == WifiFrameType::WIFI_FT_CTRL)
49 out->seq = (uint16_t)(((uint16_t)frame[22] | ((uint16_t)frame[23] << 8)) >> 4);
50 out->is_qos = (out->type == WifiFrameType::WIFI_FT_DATA) && (out->subtype & 0x08) != 0;
52 const bool has_addr4 = out->to_ds && out->from_ds;
62 if (out->is_qos && (fc1 & 0x80))
72 const uint8_t *a1 = frame + 4;
73 const uint8_t *a2 = frame + 10;
74 const uint8_t *a3 = frame + 16;
75 if (!out->to_ds && !out->from_ds)
82 else if (!out->to_ds && out->from_ds)
89 else if (out->to_ds && !out->from_ds)
98 out->src = frame + 24;
116 pc_promisc_sink_fn sink =
nullptr;
122bool pc_promisc_begin(uint8_t channel, pc_promisc_sink_fn sink)
128 s_promisc.sink = sink;
133 s_promisc.sink =
nullptr;
139void pc_promisc_set_channel(uint8_t channel)
144void pc_promisc_end(
void)
147 s_promisc.sink =
nullptr;
152bool pc_promisc_begin(uint8_t, pc_promisc_sink_fn)
156void pc_promisc_set_channel(uint8_t)
160void pc_promisc_end(
void)
bool pc_phy_monitor_begin(uint8_t, pc_phy_frame_fn)
Enter monitor mode on channel, delivering frames to cb.
void pc_phy_monitor_end(void)
Leave monitor mode.
void pc_phy_monitor_set_channel(uint8_t)
Retune monitor mode to channel.
Layer 1 (Physical) - link bring-up and live egress-interface reporting.
Wi-Fi promiscuous (monitor) capture (PC_ENABLE_PROMISC) - passive 802.11 sniffing.