58 lines
1.1 KiB
C++
58 lines
1.1 KiB
C++
/*
|
||
* © Copyright 2014 – Urheberrechtshinweis
|
||
* Alle Rechte vorbehalten / All Rights Reserved
|
||
*
|
||
* Programmcode ist urheberrechtlich geschuetzt.
|
||
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
|
||
* Keine Verwendung ohne explizite Genehmigung.
|
||
* (vgl. § 106 ff UrhG / § 97 UrhG)
|
||
*/
|
||
|
||
#ifndef INDOOR_WIFIRAW_H
|
||
#define INDOOR_WIFIRAW_H
|
||
|
||
#include <iostream>
|
||
|
||
/**
|
||
* parse raw binary wifi packets as defined within the standard
|
||
*/
|
||
class WiFiRAW {
|
||
|
||
public:
|
||
|
||
enum Tags {
|
||
TAG_SSID = 0x00
|
||
};
|
||
|
||
struct TaggedParams {
|
||
std::string ssid;
|
||
};
|
||
|
||
/** parsed tagged params within wifi packets: [tag][len][len-bytes][tag][len][len-bytes]... */
|
||
static TaggedParams parseTaggedParams(const uint8_t* data, const size_t len) {
|
||
|
||
TaggedParams res;
|
||
|
||
int pos = 0;
|
||
while(pos < len) {
|
||
|
||
const int tag = data[pos+0]; // the tag-ID
|
||
const int len = data[pos+1]; // the lenght of the following data
|
||
|
||
switch(tag) {
|
||
case TAG_SSID: res.ssid = std::string( (const char*) &(data[pos+2]), len); break;
|
||
}
|
||
|
||
// position at the start of the next tag
|
||
pos += 1 + 1 + len;
|
||
|
||
}
|
||
|
||
return res;
|
||
|
||
}
|
||
|
||
};
|
||
|
||
#endif // INDOOR_WIFIRAW_H
|