Tech News
← Back to articles

libwifi: an 802.11 frame parsing and generation library written in C (2023)

read original related products more articles

static int got_radiotap = 0; int main(int argc, const char *argv[]) { pcap_t handle = {0}; char errbuf[PCAP_ERRBUF_SIZE] = {0}; if ((handle = pcap_create(argv[2], errbuf)) == NULL) { exit(EXIT_FAILURE); } if (pcap_activate(handle) != 0) { pcap_close(handle); exit(EXIT_FAILURE); } int linktype = pcap_datalink(handle); if (linktype == DLT_IEEE802_11_RADIO) { got_radiotap = 1; } else if (linktype == DLT_IEEE802_11) { got_radiotap = 0; } else { pcap_close(handle); exit(EXIT_FAILURE); } pd = pcap_dump_open(handle, PCAP_SAVEFILE); pcap_loop(handle, -1 /*INFINITY*/, &parse_packet, (unsigned char *) pd); }