From 78ffbd6e6489b26eb8d90d7f8664038407b9a041 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 12 May 2018 13:43:47 +0200 Subject: [PATCH] code sanitization --- src/blecsan.cpp | 20 ++++++++------------ src/macsniff.cpp | 8 ++++---- src/main.h | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/blecsan.cpp b/src/blecsan.cpp index 3524e0af..51b6a563 100644 --- a/src/blecsan.cpp +++ b/src/blecsan.cpp @@ -125,28 +125,24 @@ static void gap_callback_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_pa ESP_LOGD(TAG, "Addr_type : %s", bt_addr_t_to_string(p->scan_rst.ble_addr_type)); ESP_LOGD(TAG, "RSSI : %d", p->scan_rst.rssi); - if (!( cfg.rssilimit == 0 ) || (p->scan_rst.rssi > cfg.rssilimit )) { // rssi is negative value + if ((cfg.rssilimit) && (p->scan_rst.rssi < cfg.rssilimit )) { // rssi is negative value ESP_LOGI(TAG, "BLTH RSSI %d -> ignoring (limit: %d)", p->scan_rst.rssi, cfg.rssilimit); break; } #ifdef VENDORFILTER - if (p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RANDOM) goto skip; - if (p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RPA_RANDOM) goto skip; - + if ((p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RANDOM) || (p->scan_rst.ble_addr_type == BLE_ADDR_TYPE_RPA_RANDOM)) { + ESP_LOGD(TAG, "BT device filtered"); + break; + } + #endif // add this device and show new count total if it was not previously added if (cfg.blescan) // count only if BLE scan is enabled mac_add((uint8_t *) p->scan_rst.bda, p->scan_rst.rssi, MAC_SNIFF_BLE); - break; - - skip: - ESP_LOGD(TAG, "BT device filtered"); - break; - - + /* to be improved in vendorfilter if: // you can search for elements in the payload using the @@ -175,7 +171,7 @@ static void gap_callback_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_pa */ - } + } // evaluate sniffed packet break; default: diff --git a/src/macsniff.cpp b/src/macsniff.cpp index 331feb35..fbaa01d6 100644 --- a/src/macsniff.cpp +++ b/src/macsniff.cpp @@ -107,11 +107,11 @@ void wifi_sniffer_packet_handler(void* buff, wifi_promiscuous_pkt_type_t type) { const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)ppkt->payload; const wifi_ieee80211_mac_hdr_t *hdr = &ipkt->hdr; - if (( cfg.rssilimit == 0 ) || (ppkt->rx_ctrl.rssi > cfg.rssilimit )) { // rssi is negative value - uint8_t *p = (uint8_t *) hdr->addr2; - mac_add(p, ppkt->rx_ctrl.rssi, MAC_SNIFF_WIFI) ; - } else { + if ((cfg.rssilimit) && (ppkt->rx_ctrl.rssi < cfg.rssilimit )) { // rssi is negative value ESP_LOGI(TAG, "WiFi RSSI %d -> ignoring (limit: %d)", ppkt->rx_ctrl.rssi, cfg.rssilimit); + } else { + uint8_t *p = (uint8_t *) hdr->addr2; + mac_add(p, ppkt->rx_ctrl.rssi, MAC_SNIFF_WIFI) ; } } diff --git a/src/main.h b/src/main.h index adae07fb..b9556935 100644 --- a/src/main.h +++ b/src/main.h @@ -1,6 +1,6 @@ // program version - note: increment version after modifications to configData_t struct!! -#define PROGVERSION "1.3.41" // use max 10 chars here! +#define PROGVERSION "1.3.42" // use max 10 chars here! #define PROGNAME "PAXCNT" //--- Declarations ---