Skip to content

Instantly share code, notes, and snippets.

@kcoderhtml
Created January 17, 2024 14:13
Show Gist options
  • Save kcoderhtml/9cfb7362b63e61ccf48213f7289639b6 to your computer and use it in GitHub Desktop.
Save kcoderhtml/9cfb7362b63e61ccf48213f7289639b6 to your computer and use it in GitHub Desktop.
List devices for @ishan on slack
#include <pcap.h>
#include <stdlib.h>
int main() {
char errbuf[PCAP_ERRBUF_SIZE];
pcap_if_t* device;
if (pcap_findalldevs(&device, errbuf) == -1) {
fprintf(stderr, "Error finding devices : %s\n", errbuf);
exit(1);
}
for (pcap_if_t* d = device; d != NULL; d = d->next) {
printf("%s\n", d->name);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment