Compare commits
3 Commits
ca1b59e4c6
...
bbd9623256
Author | SHA1 | Date | |
---|---|---|---|
bbd9623256 | |||
5ea6d1f975 | |||
c87a95b167 |
@ -3,6 +3,19 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
enum PacketType {
|
||||
Beacon,
|
||||
ProbeRequest,
|
||||
ProbeResponse,
|
||||
Data,
|
||||
RequestToSend,
|
||||
ClearToSend,
|
||||
Acknowledgment,
|
||||
BlockAcknowledgment,
|
||||
NoData,
|
||||
Unknown
|
||||
};
|
||||
|
||||
struct Packet {
|
||||
uint64_t timestampMicros;
|
||||
|
||||
@ -16,7 +29,7 @@ struct Packet {
|
||||
unsigned int frequency;
|
||||
unsigned char dataRate;
|
||||
|
||||
std::string type;
|
||||
PacketType type;
|
||||
};
|
||||
|
||||
#endif /* C42FA9F6_8CF3_453F_8FA0_918E543DCD59 */
|
||||
|
@ -10,6 +10,19 @@
|
||||
#include "../helper/split.hpp"
|
||||
#include "../helper/timestampConvert.hpp"
|
||||
#include "../helper/find.hpp"
|
||||
#include "../helper/vector-stats.hpp"
|
||||
#include <unordered_map>
|
||||
|
||||
const std::unordered_map<std::string, PacketType> PACKET_TYPE_MAP({
|
||||
{"Beacon", PacketType::Beacon},
|
||||
{"Probe Request", PacketType::ProbeRequest},
|
||||
{"Probe Response", PacketType::ProbeResponse},
|
||||
{"Data", PacketType::Data},
|
||||
{"Request-To-Send", PacketType::RequestToSend},
|
||||
{"Clear-To-Send", PacketType::ClearToSend},
|
||||
{"Acknowledgment", PacketType::Acknowledgment},
|
||||
{"BA", PacketType::BlockAcknowledgment}
|
||||
});
|
||||
|
||||
void textPacketHandler(std::vector<std::string> textPacket){
|
||||
/// Here we have to parse the packet
|
||||
@ -63,6 +76,26 @@ void textPacketHandler(std::vector<std::string> textPacket){
|
||||
packet.srcMac = sAddr;
|
||||
packet.dstMac = dAddr;
|
||||
packet.bssid = bssidAddr;
|
||||
|
||||
// Identify type of packet
|
||||
// -> comes right after the addresses
|
||||
int typeIndex = max(std::vector({saIndex, daIndex, bssidIndex, taIndex, raIndex}))+1;
|
||||
PacketType type = PacketType::Unknown;
|
||||
if(typeIndex == headerData.size()) type = PacketType::NoData;
|
||||
else {
|
||||
std::string textType = headerData[typeIndex];
|
||||
|
||||
// Check for incomplete types
|
||||
if(textType == "Probe"){
|
||||
textType += " "+ headerData[typeIndex+1];
|
||||
}
|
||||
|
||||
// If type is in map, use map-value, otherwise keep default
|
||||
if(PACKET_TYPE_MAP.find(textType) != PACKET_TYPE_MAP.end())
|
||||
type = PACKET_TYPE_MAP[textType];
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
#endif /* EE781A91_6D07_47AC_B3C4_F99E29F3731F */
|
||||
|
15
helper/vector-stats.hpp
Normal file
15
helper/vector-stats.hpp
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef C437A277_1F23_496D_9B69_A21D771ECA91
|
||||
#define C437A277_1F23_496D_9B69_A21D771ECA91
|
||||
|
||||
#include <vector>
|
||||
#include <limits.h>
|
||||
|
||||
int max(std::vector<int> vec){
|
||||
int max = INT_MIN;
|
||||
for(int i=0; i<vec.size(); ++i){
|
||||
if(vec[i] > max) max = vec[i];
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
#endif /* C437A277_1F23_496D_9B69_A21D771ECA91 */
|
Loading…
x
Reference in New Issue
Block a user