/* * rt_promisc.h * Shared promiscuous mode dispatcher. * * ESP32 supports only one promiscuous RX callback at a time. This module * multiplexes multiple consumers (stealth scan, karma, capture, ...) behind * a single IRAM callback and manages channel / enable state. */ #pragma once #include #include #include "esp_err.h" #include "esp_wifi_types.h" #ifdef __cplusplus extern "C" { #endif #define RT_PROMISC_MAX_HANDLERS 4 typedef void (*rt_promisc_cb_t)(void *buf, wifi_promiscuous_pkt_type_t type); typedef struct { rt_promisc_cb_t cb; /* callback (should be IRAM-safe) */ uint32_t filter_mask; /* WIFI_PROMIS_FILTER_MASK_* */ const char *tag; /* debug label */ } rt_promisc_handler_t; /* Initialise the dispatcher (call once, idempotent). */ void rt_promisc_init(void); /* Register a handler. Returns ESP_ERR_NO_MEM if table is full. */ esp_err_t rt_promisc_register(const rt_promisc_handler_t *h); /* Unregister a handler (matched by callback pointer). */ esp_err_t rt_promisc_unregister(const rt_promisc_handler_t *h); /* Enable promiscuous mode with the combined filter of all registered handlers. */ esp_err_t rt_promisc_enable(void); /* Disable promiscuous mode. */ esp_err_t rt_promisc_disable(void); /* Switch to a specific WiFi channel (1-14). */ esp_err_t rt_promisc_set_channel(uint8_t channel); /* True if promiscuous mode is currently active. */ bool rt_promisc_is_enabled(void); #ifdef __cplusplus } #endif