From 324199ea6ab3f304d562885812dbd5266b15592e Mon Sep 17 00:00:00 2001 From: LccGitHub <1003364293@qq.com> Date: Mon, 2 Feb 2026 15:59:45 +0800 Subject: [PATCH] fix for compile error link libpcap v10.1 compile error for libcap v10.1 multiple definition of `pcap_filter'; iftop.o:(.bss+0x10): first defined here /libpcap.a(bpf_filter.o): in function `pcap_filter_with_aux_data': --- iftop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iftop.c b/iftop.c index 06778d6..98453a2 100644 --- a/iftop.c +++ b/iftop.c @@ -70,7 +70,7 @@ int history_len = 1; pthread_mutex_t tick_mutex; pcap_t* pd; /* pcap descriptor */ -struct bpf_program pcap_filter; +struct bpf_program iftop_pcap_filter; pcap_handler packet_handler; sig_atomic_t foad; @@ -631,12 +631,12 @@ char *set_filter_code(const char *filter) { sprintf(x, "(%s) and (ip or ip6)", filter); } else x = xstrdup("ip or ip6"); - if (pcap_compile(pd, &pcap_filter, x, 1, 0) == -1) { + if (pcap_compile(pd, &iftop_pcap_filter, x, 1, 0) == -1) { xfree(x); return pcap_geterr(pd); } xfree(x); - if (pcap_setfilter(pd, &pcap_filter) == -1) + if (pcap_setfilter(pd, &iftop_pcap_filter) == -1) return pcap_geterr(pd); else return NULL;