#include #include "wifi-triangulator/core.h" using namespace std; using namespace wifi_triangulator; void on_probe_request(const pb::probe &p) { cout << "PROBE REQUEST" << ", src=" << eth_mac(p.src()).to_string() << ", dst=" << eth_mac(p.dst()).to_string() << ", rssi=" << p.rssi() << flush << endl; } void on_envelope(pb::envelope envelope) { if (envelope.type() == pb::probe_request) { on_probe_request(envelope.probe()); } else { cout << to_string(envelope.type()) << endl; } } int main(int argc, char *argv[]) { GOOGLE_PROTOBUF_VERIFY_VERSION; if (argc != 1) { fprintf(stderr, "usage: %s\n", argv[0]); return EXIT_FAILURE; } int count = 0; uint8_t buffer[1 << 16]; while (!feof(stdin)) { pb::envelope envelope; uint16_t size; cin >> size; cin.read(reinterpret_cast(buffer), size); bool ok = envelope.ParseFromArray(buffer, size); if (!ok) { cerr << "bad read" << endl; continue; } // cerr << "count=" << count++ << endl; on_envelope(envelope); } google::protobuf::ShutdownProtobufLibrary(); return EXIT_SUCCESS; }