diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -255,7 +255,7 @@ void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *pa uint8_t type = ieee802_11_header->frame_1; - const char *type_str; + std::string type_str; switch (type) { case 0x40: type_str = "probe request"; @@ -290,8 +290,11 @@ void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *pa case 0x1a: type_str = "ps-poll"; break; - default: - type_str = nullptr; + default: { + std::stringstream s; + s << "0x" << std::hex << std::setw(2) << std::setfill('0') << (int) type; + type_str = s.str(); + } } // printf("ieee802_11_header->frame_ctl=%02x, %s\n", type, type_str ? type_str : "???"); @@ -316,7 +319,9 @@ void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *pa auto src = data.src.to_string(); auto dst = data.dst.to_string(); - printf("data: %lu.%lu, rssi=%d, src=%s, dst=%s\n", data.sec, data.usec, data.rssi, src.c_str(), dst.c_str()); + printf("timestamp=%lu, rssi=%d, src=%s, dst=%s, type=%s\n", ((data.sec * 1000 * 1000) + data.usec) * 1000, + data.rssi, src.c_str(), dst.c_str(), type_str.c_str()); + /// printf("\036{\"timestamp_us\": %lu, \"rssi\": %d, \"src\": \"%s\", \"dst\": \"%s\"}\n", data.sec * 1000 * 1000 + data.usec, data.rssi, src.c_str(), dst.c_str()); fflush(stdout); } |