Public domain
/* Automaticly choose a valid network device using pcap */
/* compile : gcc -lpcap dev.c */
#include <stdlib.h>
#include <pcap.h>
int main()
{
char *dev;
char errbuf[PCAP_ERRBUF_SIZE];
if((dev=pcap_lookupdev(errbuf)) == NULL) {
printf("%s\n",errbuf);
exit(EXIT_FAILURE);
}
printf("DEV: %s\n",dev);
exit(EXIT_SUCCESS);
}
BY: Pejman Moghadam
TAG: c, pcap
DATE: 2011-02-22 00:30:00