mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
Merge branch 'bugfix/add_sniffer_fcs_filter' into 'master'
example: Add sniffer FCSFAIL filter Closes IDFGH-4661 See merge request espressif/esp-idf!12249
This commit is contained in:
commit
9afd57057d
@ -73,7 +73,7 @@ void esp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint32_t len,
|
||||
return;
|
||||
}
|
||||
|
||||
req->ifx = ESP_IF_WIFI_STA;
|
||||
req->ifx = WIFI_IF_STA;
|
||||
memcpy(req->dest_mac, dest_mac, ETH_ALEN);
|
||||
req->no_ack = false;
|
||||
req->data_len = len;
|
||||
@ -373,7 +373,7 @@ static void esp_dpp_task(void *pvParameters )
|
||||
int channel;
|
||||
|
||||
channel = p->chan_list[counter++ % p->num_chan];
|
||||
esp_wifi_remain_on_channel(ESP_IF_WIFI_STA, WIFI_ROC_REQ, channel,
|
||||
esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_REQ, channel,
|
||||
BOOTSTRAP_ROC_WAIT_TIME, s_action_rx_cb);
|
||||
}
|
||||
break;
|
||||
@ -533,7 +533,7 @@ esp_supp_dpp_bootstrap_gen(const char *chan_list, enum dpp_bootstrap_type type,
|
||||
goto fail;
|
||||
}
|
||||
params->type = type;
|
||||
esp_wifi_get_mac(ESP_IF_WIFI_STA, params->mac);
|
||||
esp_wifi_get_mac(WIFI_IF_STA, params->mac);
|
||||
|
||||
if (uri_info) {
|
||||
params->info_len = strlen(uri_info);
|
||||
@ -608,7 +608,7 @@ esp_err_t esp_supp_dpp_start_listen(void)
|
||||
void esp_supp_dpp_stop_listen(void)
|
||||
{
|
||||
s_dpp_stop_listening = true;
|
||||
esp_wifi_remain_on_channel(ESP_IF_WIFI_STA, WIFI_ROC_CANCEL, 0, 0, NULL);
|
||||
esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_CANCEL, 0, 0, NULL);
|
||||
}
|
||||
|
||||
esp_err_t esp_supp_dpp_init(esp_supp_dpp_event_cb_t cb)
|
||||
|
@ -128,7 +128,7 @@ void esp_send_action_frame(uint8_t *dest_mac, const uint8_t *buf, uint32_t len,
|
||||
wifi_action_tx_req_t *req = os_zalloc(sizeof(*req) + len);;
|
||||
TEST_ASSERT( req != NULL);
|
||||
|
||||
req->ifx = ESP_IF_WIFI_STA;
|
||||
req->ifx = WIFI_IF_STA;
|
||||
memcpy(req->dest_mac, dest_mac, ETH_ALEN);
|
||||
req->no_ack = false;
|
||||
req->data_len = len;
|
||||
@ -155,7 +155,7 @@ TEST_CASE("Test scan and ROC simultaneously", "[Offchan]")
|
||||
|
||||
xEventGroupWaitBits(wifi_event, WIFI_START_EVENT, 1, 0, 5000 / portTICK_RATE_MS);
|
||||
|
||||
TEST_ESP_OK(esp_wifi_remain_on_channel(ESP_IF_WIFI_STA, WIFI_ROC_REQ, TEST_LISTEN_CHANNEL,
|
||||
TEST_ESP_OK(esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_REQ, TEST_LISTEN_CHANNEL,
|
||||
100, rx_cb));
|
||||
ESP_ERROR_CHECK(esp_wifi_scan_start(NULL, false));
|
||||
bits = xEventGroupWaitBits(wifi_event, WIFI_ROC_DONE_EVENT | WIFI_SCAN_DONE_EVENT,
|
||||
@ -164,7 +164,7 @@ TEST_CASE("Test scan and ROC simultaneously", "[Offchan]")
|
||||
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
ESP_ERROR_CHECK(esp_wifi_scan_start(NULL, false));
|
||||
TEST_ESP_OK(esp_wifi_remain_on_channel(ESP_IF_WIFI_STA, WIFI_ROC_REQ, TEST_LISTEN_CHANNEL,
|
||||
TEST_ESP_OK(esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_REQ, TEST_LISTEN_CHANNEL,
|
||||
100, rx_cb));
|
||||
bits = xEventGroupWaitBits(wifi_event, WIFI_ROC_DONE_EVENT | WIFI_SCAN_DONE_EVENT,
|
||||
pdTRUE, pdFALSE, 5000 / portTICK_RATE_MS);
|
||||
@ -221,17 +221,17 @@ static void test_wifi_roc(void)
|
||||
start_wifi_as_sta();
|
||||
|
||||
xEventGroupWaitBits(wifi_event, WIFI_START_EVENT, 1, 0, 5000 / portTICK_RATE_MS);
|
||||
TEST_ESP_OK(esp_wifi_get_mac(ESP_IF_WIFI_STA, mac));
|
||||
TEST_ESP_OK(esp_wifi_get_mac(WIFI_IF_STA, mac));
|
||||
sprintf(mac_str, MACSTR, MAC2STR(mac));
|
||||
unity_send_signal_param("Listener mac", mac_str);
|
||||
|
||||
TEST_ESP_OK(esp_wifi_remain_on_channel(ESP_IF_WIFI_STA, WIFI_ROC_REQ, TEST_LISTEN_CHANNEL,
|
||||
TEST_ESP_OK(esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_REQ, TEST_LISTEN_CHANNEL,
|
||||
10000, rx_cb));
|
||||
bits = xEventGroupWaitBits(wifi_event, WIFI_ROC_DONE_EVENT | WIFI_ACTION_RX_EVENT,
|
||||
pdTRUE, pdFALSE, portMAX_DELAY);
|
||||
/* Confirm that Frame has been received successfully */
|
||||
if (bits == WIFI_ACTION_RX_EVENT) {
|
||||
TEST_ESP_OK(esp_wifi_remain_on_channel(ESP_IF_WIFI_STA, WIFI_ROC_CANCEL, 0, 0, NULL));
|
||||
TEST_ESP_OK(esp_wifi_remain_on_channel(WIFI_IF_STA, WIFI_ROC_CANCEL, 0, 0, NULL));
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
stop_wifi();
|
||||
} else {
|
||||
|
@ -23,11 +23,12 @@
|
||||
|
||||
#define SNIFFER_DEFAULT_FILE_NAME "esp-sniffer"
|
||||
#define SNIFFER_FILE_NAME_MAX_LEN CONFIG_SNIFFER_PCAP_FILE_NAME_MAX_LEN
|
||||
#define SNIFFER_DEFAULT_CHANNEL (1)
|
||||
#define SNIFFER_PAYLOAD_FCS_LEN (4)
|
||||
#define SNIFFER_PROCESS_PACKET_TIMEOUT_MS (100)
|
||||
#define SNIFFER_DEFAULT_CHANNEL (1)
|
||||
#define SNIFFER_PAYLOAD_FCS_LEN (4)
|
||||
#define SNIFFER_PROCESS_PACKET_TIMEOUT_MS (100)
|
||||
#define SNIFFER_PROCESS_APPTRACE_TIMEOUT_US (100)
|
||||
#define SNIFFER_APPTRACE_RETRY (10)
|
||||
#define SNIFFER_APPTRACE_RETRY (10)
|
||||
#define SNIFFER_RX_FCS_ERR (0X41)
|
||||
|
||||
static const char *SNIFFER_TAG = "cmd_sniffer";
|
||||
#define SNIFFER_CHECK(a, str, goto_tag, ...) \
|
||||
@ -82,10 +83,11 @@ static uint32_t hash_func(const char *str, uint32_t max_num)
|
||||
|
||||
static void create_wifi_filter_hashtable(void)
|
||||
{
|
||||
char *wifi_filter_keys[SNIFFER_WLAN_FILTER_MAX] = {"mgmt", "data", "ctrl", "misc", "mpdu", "ampdu"};
|
||||
char *wifi_filter_keys[SNIFFER_WLAN_FILTER_MAX] = {"mgmt", "data", "ctrl", "misc", "mpdu", "ampdu", "fcsfail"};
|
||||
uint32_t wifi_filter_values[SNIFFER_WLAN_FILTER_MAX] = {WIFI_PROMIS_FILTER_MASK_MGMT, WIFI_PROMIS_FILTER_MASK_DATA,
|
||||
WIFI_PROMIS_FILTER_MASK_CTRL, WIFI_PROMIS_FILTER_MASK_MISC,
|
||||
WIFI_PROMIS_FILTER_MASK_DATA_MPDU, WIFI_PROMIS_FILTER_MASK_DATA_AMPDU
|
||||
WIFI_PROMIS_FILTER_MASK_DATA_MPDU, WIFI_PROMIS_FILTER_MASK_DATA_AMPDU,
|
||||
WIFI_PROMIS_FILTER_MASK_FCSFAIL
|
||||
};
|
||||
for (int i = 0; i < SNIFFER_WLAN_FILTER_MAX; i++) {
|
||||
uint32_t idx = hash_func(wifi_filter_keys[i], SNIFFER_WLAN_FILTER_MAX);
|
||||
@ -126,6 +128,7 @@ static void wifi_sniffer_cb(void *recv_buf, wifi_promiscuous_pkt_type_t type)
|
||||
packet_info.seconds = sniffer->rx_ctrl.timestamp / 1000000U;
|
||||
packet_info.microseconds = sniffer->rx_ctrl.timestamp % 1000000U;
|
||||
packet_info.length = sniffer->rx_ctrl.sig_len;
|
||||
|
||||
/* For now, the sniffer only dumps the length of the MISC type frame */
|
||||
if (type != WIFI_PKT_MISC && !sniffer->rx_ctrl.rx_state) {
|
||||
packet_info.length -= SNIFFER_PAYLOAD_FCS_LEN;
|
||||
@ -378,7 +381,7 @@ void register_sniffer(void)
|
||||
"name of the file storing the packets in pcap format");
|
||||
sniffer_args.interface = arg_str0("i", "interface", "<wlan>",
|
||||
"which interface to capture packet");
|
||||
sniffer_args.filter = arg_strn("F", "filter", "<mgmt|data|ctrl|misc|mpdu|ampdu>", 0, 6, "filter parameters");
|
||||
sniffer_args.filter = arg_strn("F", "filter", "<mgmt|data|ctrl|misc|mpdu|ampdu|fcsfail>", 0, 7, "filter parameters");
|
||||
sniffer_args.channel = arg_int0("c", "channel", "<channel>", "communication channel to use");
|
||||
sniffer_args.stop = arg_lit0(NULL, "stop", "stop running sniffer");
|
||||
sniffer_args.end = arg_end(1);
|
||||
|
@ -31,6 +31,7 @@ typedef enum {
|
||||
SNIFFER_WLAN_FILTER_MISC, /*!< MISC */
|
||||
SNIFFER_WLAN_FILTER_MPDU, /*!< MPDU */
|
||||
SNIFFER_WLAN_FILTER_AMPDU, /*!< AMPDU */
|
||||
SNIFFER_WLAN_FILTER_FCSFAIL, /*!< When this bit is set, the hardware will receive packets for which frame check sequence failed */
|
||||
SNIFFER_WLAN_FILTER_MAX
|
||||
} sniffer_wlan_filter_t;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user