webserver: autodetect device name

This commit is contained in:
Vince Weaver 2016-11-20 00:15:43 -05:00
parent 5cab4ef193
commit 59324ef0f8
2 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,6 @@
CC = gcc
CFLAGS = -Wall -O2
LFLAGS =-lpcap
all: testarp

View File

@ -3,9 +3,15 @@
int main(int argc, char **argv) {
char device[]="wlan0";
char *device_name,errbuf[PCAP_ERRBUF_SIZE];
printf("Using device: %s\n", device);
device_name=pcap_lookupdev(errbuf);
if (device_name==NULL) {
fprintf(stderr,"Can't find default device\n");
return -1;
}
printf("Using device: %s\n", device_name);
return 0;