From bf98de1c7b955e6fd3ca9e40f9c0f96104e76c7c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 11 Sep 2024 14:02:44 +0200 Subject: Merging upstream version 2.2.1. Signed-off-by: Daniel Baumann --- src/args.c | 2 +- src/args.h | 2 +- src/assert.c | 2 +- src/bpft.c | 4 ++-- src/bpft.h | 2 +- src/daemon.c | 2 +- src/daemon.h | 2 +- src/dnscap.1.in | 8 ++++---- src/dnscap.c | 2 +- src/dnscap.h | 2 +- src/dnscap_common.h | 2 +- src/dump_cbor.c | 2 +- src/dump_cbor.h | 2 +- src/dump_cds.c | 2 +- src/dump_cds.h | 2 +- src/dump_dns.c | 2 +- src/dump_dns.h | 2 +- src/dumper.c | 4 ++-- src/dumper.h | 2 +- src/endian_compat.h | 2 +- src/endpoint.c | 2 +- src/endpoint.h | 2 +- src/hashtbl.c | 2 +- src/hashtbl.h | 2 +- src/iaddr.c | 2 +- src/iaddr.h | 2 +- src/log.c | 2 +- src/log.h | 2 +- src/memzero.c | 2 +- src/memzero.h | 2 +- src/network.c | 2 +- src/network.h | 2 +- src/options.c | 2 +- src/options.h | 2 +- src/pcaps.c | 2 +- src/pcaps.h | 2 +- src/sig.c | 2 +- src/sig.h | 2 +- src/tcpreasm.c | 2 +- src/tcpreasm.h | 2 +- src/tcpstate.c | 2 +- src/tcpstate.h | 2 +- src/test/Makefile.am | 8 +++++--- src/test/Makefile.in | 15 ++++++++++++--- src/test/gen_icmp.py | 10 ++++++++++ src/test/icmp.gold | 4 ++++ src/test/icmp.pcap | Bin 0 -> 160 bytes src/test/test_icmp.sh | 11 +++++++++++ 48 files changed, 89 insertions(+), 53 deletions(-) create mode 100644 src/test/gen_icmp.py create mode 100644 src/test/icmp.gold create mode 100644 src/test/icmp.pcap create mode 100755 src/test/test_icmp.sh (limited to 'src') diff --git a/src/args.c b/src/args.c index d4b1c0d..9a0c611 100644 --- a/src/args.c +++ b/src/args.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/args.h b/src/args.h index 3d34784..c5b1365 100644 --- a/src/args.h +++ b/src/args.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/assert.c b/src/assert.c index 4c86762..796db9c 100644 --- a/src/assert.c +++ b/src/assert.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/bpft.c b/src/bpft.c index 8ce1b56..80393e9 100644 --- a/src/bpft.c +++ b/src/bpft.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -86,7 +86,7 @@ void prepare_bpft(void) else len += text_add(&bpfl, "("); /* ( transports ... */ if (wanticmp) { - len += text_add(&bpfl, " ( ip proto 1 or ip proto 58 ) or"); + len += text_add(&bpfl, " ( icmp or icmp6 ) or"); } if (wantfrags) { len += text_add(&bpfl, " ( ip[6:2] & 0x1fff != 0 or ip6[6] = 44 ) or"); diff --git a/src/bpft.h b/src/bpft.h index fd0ca9f..23ca7ec 100644 --- a/src/bpft.h +++ b/src/bpft.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/daemon.c b/src/daemon.c index 83e614c..819bbab 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/daemon.h b/src/daemon.h index e120eaf..a8e248a 100644 --- a/src/daemon.h +++ b/src/daemon.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dnscap.1.in b/src/dnscap.1.in index 55289cb..9ee0f66 100644 --- a/src/dnscap.1.in +++ b/src/dnscap.1.in @@ -1,4 +1,4 @@ -.\" Copyright (c) 2016-2023, OARC, Inc. +.\" Copyright (c) 2016-2024 OARC, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -226,8 +226,8 @@ This depends on the libpcap version. If you want to make sure you're capturing on all interfaces then use the special "any" or "all" (depends on system). -More than one interface may be selected which will cause output to be -interleaved from all selected interfaces. +Can be specified more than once to select multiple interfaces, this will +cause output to be interleaved from all selected interfaces. .TP .B \-p Asks that the interface not be put into promiscuous mode. @@ -468,7 +468,7 @@ VLAN id 4095 can be used to specify all vlans. .BI "\-L " vlan Captures 802.1Q encapsulated packets matching the specified vlans AND packets without VLAN tags. -Can be specified more than one to select multiple vlans. +Can be specified more than once to select multiple vlans. VLAN id 4095 can be used to specify all vlans. .TP .BI "\-u " port diff --git a/src/dnscap.c b/src/dnscap.c index a3e2ba1..038ec61 100644 --- a/src/dnscap.c +++ b/src/dnscap.c @@ -4,7 +4,7 @@ */ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dnscap.h b/src/dnscap.h index e079ec9..2a8acf2 100644 --- a/src/dnscap.h +++ b/src/dnscap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dnscap_common.h b/src/dnscap_common.h index a1f05d9..eff2603 100644 --- a/src/dnscap_common.h +++ b/src/dnscap_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dump_cbor.c b/src/dump_cbor.c index 89cf5be..c287330 100644 --- a/src/dump_cbor.c +++ b/src/dump_cbor.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dump_cbor.h b/src/dump_cbor.h index a032cd8..6cdb1ec 100644 --- a/src/dump_cbor.h +++ b/src/dump_cbor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dump_cds.c b/src/dump_cds.c index 3f680b5..64cfd24 100644 --- a/src/dump_cds.c +++ b/src/dump_cds.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dump_cds.h b/src/dump_cds.h index 3eb2818..124dbbe 100644 --- a/src/dump_cds.h +++ b/src/dump_cds.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dump_dns.c b/src/dump_dns.c index 121a97e..a71145f 100644 --- a/src/dump_dns.c +++ b/src/dump_dns.c @@ -4,7 +4,7 @@ */ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dump_dns.h b/src/dump_dns.h index e3394f3..194233f 100644 --- a/src/dump_dns.h +++ b/src/dump_dns.h @@ -4,7 +4,7 @@ */ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/dumper.c b/src/dumper.c index 88d83fd..1c57784 100644 --- a/src/dumper.c +++ b/src/dumper.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -325,7 +325,7 @@ int dumper_close(my_bpftimeval ts) int x; if (!p->close) continue; - x = (*p->close)(ts); + x = (*p->close)(); if (x) logerr("%s_close returned %d", p->name, x); } diff --git a/src/dumper.h b/src/dumper.h index ffef7cd..5671c90 100644 --- a/src/dumper.h +++ b/src/dumper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/endian_compat.h b/src/endian_compat.h index b7b89c1..37752de 100644 --- a/src/endian_compat.h +++ b/src/endian_compat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/endpoint.c b/src/endpoint.c index a2b848f..3de077f 100644 --- a/src/endpoint.c +++ b/src/endpoint.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/endpoint.h b/src/endpoint.h index 2ad2cf3..cf224e2 100644 --- a/src/endpoint.h +++ b/src/endpoint.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/hashtbl.c b/src/hashtbl.c index c497b78..f788838 100644 --- a/src/hashtbl.c +++ b/src/hashtbl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/hashtbl.h b/src/hashtbl.h index d049ca5..283353b 100644 --- a/src/hashtbl.h +++ b/src/hashtbl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/iaddr.c b/src/iaddr.c index bbe47be..67c0fc8 100644 --- a/src/iaddr.c +++ b/src/iaddr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/iaddr.h b/src/iaddr.h index 452ca14..7f4fbde 100644 --- a/src/iaddr.h +++ b/src/iaddr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/log.c b/src/log.c index 4cd5fa7..34f96c0 100644 --- a/src/log.c +++ b/src/log.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/log.h b/src/log.h index be93ddd..f055864 100644 --- a/src/log.h +++ b/src/log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/memzero.c b/src/memzero.c index 6b983a4..99dad49 100644 --- a/src/memzero.c +++ b/src/memzero.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/memzero.h b/src/memzero.h index 02ede71..8e73470 100644 --- a/src/memzero.h +++ b/src/memzero.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/network.c b/src/network.c index 9fc1f00..0258739 100644 --- a/src/network.c +++ b/src/network.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/network.h b/src/network.h index 0d1bb5f..440262f 100644 --- a/src/network.h +++ b/src/network.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/options.c b/src/options.c index ce0c047..1dab3e2 100644 --- a/src/options.c +++ b/src/options.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/options.h b/src/options.h index ce601e1..96b1a8c 100644 --- a/src/options.h +++ b/src/options.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/pcaps.c b/src/pcaps.c index f89b9bb..501f094 100644 --- a/src/pcaps.c +++ b/src/pcaps.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/pcaps.h b/src/pcaps.h index 554b8b8..e1a59a7 100644 --- a/src/pcaps.h +++ b/src/pcaps.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/sig.c b/src/sig.c index de01508..591238b 100644 --- a/src/sig.c +++ b/src/sig.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/sig.h b/src/sig.h index f93d1f4..5fe59e9 100644 --- a/src/sig.h +++ b/src/sig.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, OARC, Inc. + * Copyright (c) 2016-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/tcpreasm.c b/src/tcpreasm.c index 7dc82fa..8c49c8d 100644 --- a/src/tcpreasm.c +++ b/src/tcpreasm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2023, OARC, Inc. + * Copyright (c) 2018-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/tcpreasm.h b/src/tcpreasm.h index 37260e0..34ddef3 100644 --- a/src/tcpreasm.h +++ b/src/tcpreasm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2023, OARC, Inc. + * Copyright (c) 2018-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/tcpstate.c b/src/tcpstate.c index b11c701..eb73056 100644 --- a/src/tcpstate.c +++ b/src/tcpstate.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2023, OARC, Inc. + * Copyright (c) 2018-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/tcpstate.h b/src/tcpstate.h index 2f77ddb..e5dd08a 100644 --- a/src/tcpstate.h +++ b/src/tcpstate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2023, OARC, Inc. + * Copyright (c) 2018-2024 OARC, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/test/Makefile.am b/src/test/Makefile.am index 1918400..91d11a5 100644 --- a/src/test/Makefile.am +++ b/src/test/Makefile.am @@ -16,11 +16,12 @@ CLEANFILES = test*.log test*.trs \ test13.out \ test14.out \ test_regex_match.out \ - edns.out + edns.out \ + test_icmp.out TESTS = test1.sh test2.sh test3.sh test4.sh test5.sh test6.sh test7.sh \ test8.sh test9.sh test10.sh test11.sh test12.sh test13.sh test14.sh \ - test_regex_match.sh test_edns.sh + test_regex_match.sh test_edns.sh test_icmp.sh EXTRA_DIST = $(TESTS) \ dns.gold dns.pcap \ @@ -36,4 +37,5 @@ EXTRA_DIST = $(TESTS) \ dns6.pcap test10.gold \ test14.gold \ test_regex_match.gold \ - edns.pcap edns.gold + edns.pcap edns.gold \ + gen_icmp.py icmp.pcap icmp.gold diff --git a/src/test/Makefile.in b/src/test/Makefile.in index 1aff4ee..5c51d7c 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -481,11 +481,12 @@ CLEANFILES = test*.log test*.trs \ test13.out \ test14.out \ test_regex_match.out \ - edns.out + edns.out \ + test_icmp.out TESTS = test1.sh test2.sh test3.sh test4.sh test5.sh test6.sh test7.sh \ test8.sh test9.sh test10.sh test11.sh test12.sh test13.sh test14.sh \ - test_regex_match.sh test_edns.sh + test_regex_match.sh test_edns.sh test_icmp.sh EXTRA_DIST = $(TESTS) \ dns.gold dns.pcap \ @@ -501,7 +502,8 @@ EXTRA_DIST = $(TESTS) \ dns6.pcap test10.gold \ test14.gold \ test_regex_match.gold \ - edns.pcap edns.gold + edns.pcap edns.gold \ + gen_icmp.py icmp.pcap icmp.gold all: all-am @@ -803,6 +805,13 @@ test_edns.sh.log: test_edns.sh --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +test_icmp.sh.log: test_icmp.sh + @p='test_icmp.sh'; \ + b='test_icmp.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ diff --git a/src/test/gen_icmp.py b/src/test/gen_icmp.py new file mode 100644 index 0000000..afee206 --- /dev/null +++ b/src/test/gen_icmp.py @@ -0,0 +1,10 @@ +import sys +from scapy.all import * + +pcap = sys.argv[1] + +pkts = [] +pkts.append(Ether()/IPv6(dst="2001:db8:dead::1")/ICMPv6DestUnreach()) +pkts.append(Ether()/IP(dst="0.0.0.0")/ICMP(type=3)) + +wrpcap(pcap, pkts) \ No newline at end of file diff --git a/src/test/icmp.gold b/src/test/icmp.gold new file mode 100644 index 0000000..8c05b66 --- /dev/null +++ b/src/test/icmp.gold @@ -0,0 +1,4 @@ +[48] 2024-09-10 08:52:52.252793 [#0 icmp.pcap 4095] \ + [fd00::242:ac11:9].0 [2001:db8:dead::1].0 +[28] 2024-09-10 08:52:52.253461 [#1 icmp.pcap 4095] \ + [172.17.0.9].0 [0.0.0.0].0 diff --git a/src/test/icmp.pcap b/src/test/icmp.pcap new file mode 100644 index 0000000..2aba75d Binary files /dev/null and b/src/test/icmp.pcap differ diff --git a/src/test/test_icmp.sh b/src/test/test_icmp.sh new file mode 100755 index 0000000..43f44e8 --- /dev/null +++ b/src/test/test_icmp.sh @@ -0,0 +1,11 @@ +#!/bin/sh -xe + +test -e icmp.pcap || ln -s "$srcdir/icmp.pcap" icmp.pcap + +../dnscap -g -I -r icmp.pcap 2>test_icmp.out + +mv test_icmp.out test_icmp.out.old +grep -v "^libgcov profiling error:" test_icmp.out.old > test_icmp.out +rm test_icmp.out.old + +diff test_icmp.out "$srcdir/icmp.gold" -- cgit v1.2.3