From: Guy Harris Date: Sun, 20 Mar 2016 22:59:27 +0000 (-0700) Subject: We have to set the filter on every new file. X-Git-Tag: tcpdump-4.8.0~32 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/c66320c67034e581097c08bd8532ee479f98e692 We have to set the filter on every new file. Even if we haven't recompiled the filter, because the new file has the same DLT as the old file, we still need to apply it to the new file. --- diff --git a/tcpdump.c b/tcpdump.c index 534721a5..6f164e28 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -1840,19 +1840,24 @@ main(int argc, char **argv) * We're printing the decoded packets; * switch to the new DLT. * - * To do that, we need to recompile - * the filter, change the printer, - * and change the DLT name. + * To do that, we need to change + * the printer, change the DLT name, + * and recompile the filter with + * the new DLT. */ dlt = new_dlt; - if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) - error("%s", pcap_geterr(pd)); - if (pcap_setfilter(pd, &fcode) < 0) - error("%s", pcap_geterr(pd)); ndo->ndo_if_printer = get_if_printer(ndo, dlt); dlt_name = pcap_datalink_val_to_name(dlt); + if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) + error("%s", pcap_geterr(pd)); } + /* + * Set the filter on the new file. + */ + if (pcap_setfilter(pd, &fcode) < 0) + error("%s", pcap_geterr(pd)); + /* * Report the new file. */