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_MY_COUNTRY "EU" // for Wifi RF settings
#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
#define LORASFDEFAULT 9 // 7 ... 12

View File

@ -1,30 +1,38 @@
/*
Porting - 2014 Alex K
Algorithm (c) Paul Hsieh http://www.azillionmonkeys.com/qed/hash.html
The latest version of this library may be found at:
https://github.com/mrbio/Arduino-rokkit-hash
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of 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.
*/
* RokkitHash - Arduino port for Paul Hsieh's "SuperFastHash"
*
* A very quick hash function, (c) Paul Hsieh
*
* See http://www.azillionmonkeys.com/qed/hash.html for more information
* about its inner workings
*
* - Initial Arduino version: 2014 Alex K
* - 8-bit improvements: robtillaart
* - Current maintainer: SukkoPera <software@sukkology.net>
*
* See http://forum.arduino.cc/index.php?topic=226686.0 for some talk
* about the various improvements.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of 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>

View File

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