new 32bit hash logic

This commit is contained in:
Klaus K Wilting 2018-03-31 15:09:53 +02:00
parent df6cb25b38
commit 27af81ab5c
3 changed files with 49 additions and 37 deletions

View File

@ -20,6 +20,7 @@
#define WIFI_CHANNEL_MAX 13 // total channel number to scan #define WIFI_CHANNEL_MAX 13 // total channel number to scan
#define WIFI_MY_COUNTRY "EU" // for Wifi RF settings #define WIFI_MY_COUNTRY "EU" // for Wifi RF settings
#define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec. #define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec.
#define WIFI_MAC_FILTER_MASK 0x000000000003 // filter local and group MACs
// Default LoRa Spreadfactor // Default LoRa Spreadfactor
#define LORASFDEFAULT 9 // 7 ... 12 #define LORASFDEFAULT 9 // 7 ... 12

View File

@ -1,30 +1,38 @@
/* /*
Porting - 2014 Alex K * RokkitHash - Arduino port for Paul Hsieh's "SuperFastHash"
Algorithm (c) Paul Hsieh http://www.azillionmonkeys.com/qed/hash.html *
* A very quick hash function, (c) Paul Hsieh
*
The latest version of this library may be found at: * See http://www.azillionmonkeys.com/qed/hash.html for more information
https://github.com/mrbio/Arduino-rokkit-hash * about its inner workings
*
Permission is hereby granted, free of charge, to any person obtaining * - Initial Arduino version: 2014 Alex K
a copy of this software and associated documentation files (the * - 8-bit improvements: robtillaart
"Software"), to deal in the Software without restriction, including * - Current maintainer: SukkoPera <software@sukkology.net>
without limitation the rights to use, copy, modify, merge, publish, *
distribute, sublicense, and/or sell copies of the Software, and to * See http://forum.arduino.cc/index.php?topic=226686.0 for some talk
permit persons to whom the Software is furnished to do so, subject to * about the various improvements.
the following conditions: *
* Permission is hereby granted, free of charge, to any person obtaining
The above copyright notice and this permission notice shall be * a copy of this software and associated documentation files (the
included in all copies or substantial portions of the Software. * "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * distribute, sublicense, and/or sell copies of the Software, and to
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * permit persons to whom the Software is furnished to do so, subject to
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * the following conditions:
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE *
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * The above copyright notice and this permission notice shall be
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * included in all copies or substantial portions of the Software.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
*/ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <inttypes.h> #include <inttypes.h>

View File

@ -74,20 +74,23 @@ void wifi_sniffer_packet_handler(void* buff, wifi_promiscuous_pkt_type_t type) {
if ( std::find(vendors.begin(), vendors.end(), vendor2int) != vendors.end() ) { if ( std::find(vendors.begin(), vendors.end(), vendor2int) != vendors.end() ) {
#endif #endif
// if ( addr2int & WIFI_MAC_FILTER_MASK == 0) {
// log rssi info for scanned MAC // log rssi info for scanned MAC
ESP_LOGI(TAG, "WiFi RSSI: %02d", ppkt->rx_ctrl.rssi); ESP_LOGI(TAG, "WiFi RSSI: %02d", ppkt->rx_ctrl.rssi);
// if found new unique MAC hash it and increment counter on display // hash MAC, and if new unique one, store hash in container and increment counter on display
itoa(addr2int, macbuf, 10); // convert 64 bit MAC to decimal string itoa(addr2int, macbuf, 10); // convert 64 bit MAC to base 10 decimal string
hashedmac = rokkit(macbuf, 10); // hash MAC for privacy, use 10 chars to store in uint32_t set hashedmac = rokkit(macbuf, 10); // hash MAC for privacy, use 10 chars to fit in uint32_t container
newmac = macs.insert(hashedmac); // store hashed MAC if new unique newmac = macs.insert(hashedmac); // store hashed MAC if new unique
//if ( (newmac.second) && ((uint32_t)hdr->addr2[0] & 0x03 == 0) ) { // filter local and group MACs
if (newmac.second) { if (newmac.second) {
macnum++; macnum++; // increment MAC counter
itoa(macnum, counter, 10); // 10 -> decimal counter value itoa(macnum, counter, 10); // base 10 decimal counter value
u8x8.draw2x2String(0, 0, counter); u8x8.draw2x2String(0, 0, counter);
ESP_LOGI(TAG, "#%04i -> Hash %u", macnum, hashedmac); ESP_LOGI(TAG, "#%04i: MAC %llx -> Hash %u", macnum, addr2int, hashedmac);
} }
// }
#ifdef VENDORFILTER #ifdef VENDORFILTER
} }