DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
radio_sniff.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file radio_sniff.h
6 * @brief Receive-only radio channel sniffer -> pcap capture records (DETWS_ENABLE_RADIO_SNIFF).
7 *
8 * The RF gateway drivers (CC1101, LoRa, the Thread 802.15.4 RCP) can run receive-only - sniff a channel
9 * without joining - and the frames they pull off the air belong in the same capture pipeline as the CAN
10 * and Wi-Fi captures (shared_primitives/det_pcap). For 802.15.4 that means wrapping each frame in the
11 * Wireshark IEEE 802.15.4 **TAP** pseudo-header so the per-frame RSSI and channel travel with it, then a
12 * standard pcap record, giving a `.pcap` a wired Wireshark opens with the radio metadata intact.
13 *
14 * This is that pure framing: ::detws_radiosniff_global writes the pcap global header (DLT TAP), and
15 * ::detws_radiosniff_tap_record writes one record (TAP header + RSSI/channel TLVs + the MAC frame). The
16 * radio drivers own the receive; this owns the on-wire capture bytes. No heap, no stdlib, host-testable.
17 */
18
19#ifndef DETERMINISTICESPASYNCWEBSERVER_RADIO_SNIFF_H
20#define DETERMINISTICESPASYNCWEBSERVER_RADIO_SNIFF_H
21
22#include "ServerConfig.h"
24#include <stddef.h>
25#include <stdint.h>
26
27#if DETWS_ENABLE_RADIO_SNIFF
28
29/** @brief The TAP pseudo-header length this codec emits: 4 header + RSSI TLV(8) + channel TLV(8). */
30#define RADIO_SNIFF_TAP_LEN 20
31
32/** @brief Write the pcap global header for a TAP-framed 802.15.4 sniff. @return 24, or 0 on overflow. */
33size_t detws_radiosniff_global(uint8_t *out, size_t cap);
34
35/**
36 * @brief Encode a signed integer dBm value as an IEEE-754 float32 (little-endian bit pattern).
37 *
38 * The 802.15.4 TAP RSSI TLV carries a float; RSSI here is an integer dBm, so this builds the exact
39 * float bits by hand (e.g. -40 -> 0xC2200000). Exposed for testing.
40 */
41uint32_t detws_radiosniff_i2f32(int32_t dbm);
42
43/**
44 * @brief Write one capture record: a pcap record header, the 802.15.4 TAP pseudo-header carrying @p
45 * rssi_dbm and @p channel, then the raw MAC @p frame.
46 * @return total bytes written, or 0 on overflow / bad args.
47 */
48size_t detws_radiosniff_tap_record(uint8_t *out, size_t cap, const uint8_t *frame, size_t flen, int32_t rssi_dbm,
49 uint16_t channel, uint32_t ts_sec, uint32_t ts_usec);
50
51#endif // DETWS_ENABLE_RADIO_SNIFF
52#endif // DETERMINISTICESPASYNCWEBSERVER_RADIO_SNIFF_H
User-facing configuration for DeterministicESPAsyncWebServer.
libpcap file framing - the classic global + per-record headers, link-type agnostic.