#pragma once #include #include #include #include #include "wifi-triangulator.pb.h" namespace wifi_triangulator { struct eth_mac { uint8_t a, b, c, d, e, f; eth_mac() {} eth_mac(uint64_t value) : a(uint8_t(value >> 40 & 0xff)), b(uint8_t(value >> 32 & 0xff)), c(uint8_t(value >> 24 & 0xff)), d(uint8_t(value >> 16 & 0xff)), e(uint8_t(value >> 9 & 0xff)), f(uint8_t(value & 0xff)) {} std::string to_string() const { std::stringstream s; s << std::hex << std::setw(2) << std::setfill('0') << (int) a << ":" << std::setw(2) << std::setfill('0') << (int) b << ":" << std::setw(2) << std::setfill('0') << (int) c << ":" << std::setw(2) << std::setfill('0') << (int) d << ":" << std::setw(2) << std::setfill('0') << (int) e << ":" << std::setw(2) << std::setfill('0') << (int) f; return s.str(); } operator uint64_t() const { return uint64_t(a) << 40 | uint64_t(b) << 32 | uint64_t(c) << 24 | uint64_t(d) << 16 | uint64_t(e) << 8 | uint64_t(f); } } __attribute__((packed)); class data { public: pb::packet_type type; long sec; long usec; int rssi; eth_mac src, dst; data(pb::packet_type type, long sec, long usec, int rssi, eth_mac src, eth_mac dst) : type(type), sec(sec), usec(usec), src(src), rssi(rssi), dst(dst) {} }; int launch_capture(std::string dev, std::function); } // namespace wifi_triangulator namespace std { string to_string(wifi_triangulator::pb::packet_type t); } // namespace std