From d4365c56cb88df64cd065f2ab4e76aa2c1c5c769 Mon Sep 17 00:00:00 2001 From: Jan Wasserbauer Date: Sun, 10 Oct 2021 09:35:33 +0200 Subject: [PATCH] Fixed libcap with "any" device setting. Changed the default libpcap interface to "any". --- in_pcap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/in_pcap.c b/in_pcap.c index dbd2151..0cea2bb 100644 --- a/in_pcap.c +++ b/in_pcap.c @@ -3,25 +3,24 @@ #include #include +#include #include "params.h" #include "in.h" static pcap_t *p; +static char *device; + int in_init(void) { - char *device; char error[PCAP_ERRBUF_SIZE]; struct bpf_program filter; #ifdef SCANLOGD_DEVICE device = SCANLOGD_DEVICE; #else - if (!(device = pcap_lookupdev(error))) { - fprintf(stderr, "pcap_lookupdev: %s\n", error); - return 1; - } + device = "any"; #endif if (!(p = pcap_open_live(device, sizeof(struct header), @@ -64,6 +63,9 @@ void in_run(void (*process_packet)(struct header *packet, int size)) hw_size = 14; } + if(device == NULL || strcmp(device, "any") == 0) + hw_size += 2; + while (1) if ((packet = (char *)pcap_next(p, &header))) { packet += hw_size;