Skip to content

Instantly share code, notes, and snippets.

@picatz
Created November 15, 2017 19:14
Show Gist options
  • Save picatz/1eec7ee6765ab825bb3080a9cbed7c24 to your computer and use it in GitHub Desktop.
Save picatz/1eec7ee6765ab825bb3080a9cbed7c24 to your computer and use it in GitHub Desktop.
Get interface to listen on
#include <pcap.h>
int main()
{
char *dev;
char errbuf[PCAP_ERRBUF_SIZE];
dev = pcap_lookupdev(errbuf);
/* Check for failure */
if (dev == NULL) {
fprintf(stderr, "Couldn't find a default interface: %s\n", errbuf);
return(1);
}
/* Success */
printf("%s\n", dev);
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment