1
0
Fork 0

Merging upstream version 2.1.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-08 12:06:41 +01:00
parent 4feb155734
commit 14c3c7c9ac
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
58 changed files with 177 additions and 159 deletions

View file

@ -1,6 +1,6 @@
DNSCAP DNSCAP
Copyright (c) 2016-2022, OARC, Inc. Copyright (c) 2016-2023, OARC, Inc.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

20
configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for dnscap 2.1.0. # Generated by GNU Autoconf 2.69 for dnscap 2.1.1.
# #
# Report bugs to <dnscap-users@dns-oarc.net>. # Report bugs to <dnscap-users@dns-oarc.net>.
# #
@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='dnscap' PACKAGE_NAME='dnscap'
PACKAGE_TARNAME='dnscap' PACKAGE_TARNAME='dnscap'
PACKAGE_VERSION='2.1.0' PACKAGE_VERSION='2.1.1'
PACKAGE_STRING='dnscap 2.1.0' PACKAGE_STRING='dnscap 2.1.1'
PACKAGE_BUGREPORT='dnscap-users@dns-oarc.net' PACKAGE_BUGREPORT='dnscap-users@dns-oarc.net'
PACKAGE_URL='https://github.com/DNS-OARC/dnscap/issues' PACKAGE_URL='https://github.com/DNS-OARC/dnscap/issues'
@ -1353,7 +1353,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures dnscap 2.1.0 to adapt to many kinds of systems. \`configure' configures dnscap 2.1.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1424,7 +1424,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of dnscap 2.1.0:";; short | recursive ) echo "Configuration of dnscap 2.1.1:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1556,7 +1556,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
dnscap configure 2.1.0 dnscap configure 2.1.1
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1979,7 +1979,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by dnscap $as_me 2.1.0, which was It was created by dnscap $as_me 2.1.1, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -2842,7 +2842,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='dnscap' PACKAGE='dnscap'
VERSION='2.1.0' VERSION='2.1.1'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -15015,7 +15015,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by dnscap $as_me 2.1.0, which was This file was extended by dnscap $as_me 2.1.1, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -15082,7 +15082,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
dnscap config.status 2.1.0 dnscap config.status 2.1.1
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View file

@ -1,4 +1,4 @@
# Copyright (c) 2016-2022, OARC, Inc. # Copyright (c) 2016-2023, OARC, Inc.
# Copyright (c) 2007, The Measurement Factory, Inc. # Copyright (c) 2007, The Measurement Factory, Inc.
# Copyright (c) 2007, Internet Systems Consortium, Inc. # Copyright (c) 2007, Internet Systems Consortium, Inc.
# All rights reserved. # All rights reserved.
@ -33,7 +33,7 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
AC_PREREQ(2.61) AC_PREREQ(2.61)
AC_INIT([dnscap], [2.1.0], [dnscap-users@dns-oarc.net], [dnscap], [https://github.com/DNS-OARC/dnscap/issues]) AC_INIT([dnscap], [2.1.1], [dnscap-users@dns-oarc.net], [dnscap], [https://github.com/DNS-OARC/dnscap/issues])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects]) AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AC_CONFIG_SRCDIR([src/dnscap.c]) AC_CONFIG_SRCDIR([src/dnscap.c])
AC_CONFIG_HEADER([src/config.h]) AC_CONFIG_HEADER([src/config.h])

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2022, OARC, Inc. * Copyright (c) 2018-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -246,9 +246,11 @@ int anonaes128_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto,
for (;;) { for (;;) {
if (only_clients && sport == dns_port) { if (only_clients && sport == dns_port) {
if (sport != dport) {
from = 0; from = 0;
break; break;
} }
}
if (only_servers && sport != dns_port) { if (only_servers && sport != dns_port) {
from = 0; from = 0;
break; break;
@ -292,9 +294,11 @@ int anonaes128_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto,
for (;;) { for (;;) {
if (only_clients && dport == dns_port) { if (only_clients && dport == dns_port) {
if (dport != sport) {
to = 0; to = 0;
break; break;
} }
}
if (only_servers && dport != dns_port) { if (only_servers && dport != dns_port) {
to = 0; to = 0;
break; break;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2022, OARC, Inc. * Copyright (c) 2018-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -182,9 +182,11 @@ int anonmask_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto, un
for (;;) { for (;;) {
if (only_clients && sport == mask_port) { if (only_clients && sport == mask_port) {
if (sport != dport) {
from = 0; from = 0;
break; break;
} }
}
if (only_servers && sport != mask_port) { if (only_servers && sport != mask_port) {
from = 0; from = 0;
break; break;
@ -210,9 +212,11 @@ int anonmask_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto, un
for (;;) { for (;;) {
if (only_clients && dport == mask_port) { if (only_clients && dport == mask_port) {
if (dport != sport) {
to = 0; to = 0;
break; break;
} }
}
if (only_servers && dport != mask_port) { if (only_servers && dport != mask_port) {
to = 0; to = 0;
break; break;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2022, OARC, Inc. * Copyright (c) 2018-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -397,9 +397,11 @@ int cryptopan_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto, u
#ifdef USE_OPENSSL #ifdef USE_OPENSSL
for (;;) { for (;;) {
if (only_clients && sport == dns_port) { if (only_clients && sport == dns_port) {
if (sport != dport) {
from = 0; from = 0;
break; break;
} }
}
if (only_servers && sport != dns_port) { if (only_servers && sport != dns_port) {
from = 0; from = 0;
break; break;
@ -433,9 +435,11 @@ int cryptopan_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto, u
for (;;) { for (;;) {
if (only_clients && dport == dns_port) { if (only_clients && dport == dns_port) {
if (dport != sport) {
to = 0; to = 0;
break; break;
} }
}
if (only_servers && dport != dns_port) { if (only_servers && dport != dns_port) {
to = 0; to = 0;
break; break;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2022, OARC, Inc. * Copyright (c) 2018-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -187,9 +187,11 @@ int cryptopant_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto,
#ifdef USE_CRYPTOPANT #ifdef USE_CRYPTOPANT
for (;;) { for (;;) {
if (only_clients && sport == dns_port) { if (only_clients && sport == dns_port) {
if (sport != dport) {
from = 0; from = 0;
break; break;
} }
}
if (only_servers && sport != dns_port) { if (only_servers && sport != dns_port) {
from = 0; from = 0;
break; break;
@ -211,9 +213,11 @@ int cryptopant_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto,
for (;;) { for (;;) {
if (only_clients && dport == dns_port) { if (only_clients && dport == dns_port) {
if (dport != sport) {
to = 0; to = 0;
break; break;
} }
}
if (only_servers && dport != dns_port) { if (only_servers && dport != dns_port) {
to = 0; to = 0;
break; break;

View file

@ -12,7 +12,7 @@
* Below is the original copyright notice from txtout.c. * Below is the original copyright notice from txtout.c.
*/ */
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2022, OARC, Inc. * Copyright (c) 2018-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -273,9 +273,11 @@ int ipcrypt_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto, uns
{ {
for (;;) { for (;;) {
if (only_clients && sport == dns_port) { if (only_clients && sport == dns_port) {
if (sport != dport) {
from = 0; from = 0;
break; break;
} }
}
if (only_servers && sport != dns_port) { if (only_servers && sport != dns_port) {
from = 0; from = 0;
break; break;
@ -309,9 +311,11 @@ int ipcrypt_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto, uns
for (;;) { for (;;) {
if (only_clients && dport == dns_port) { if (only_clients && dport == dns_port) {
if (dport != sport) {
to = 0; to = 0;
break; break;
} }
}
if (only_servers && dport != dns_port) { if (only_servers && dport != dns_port) {
to = 0; to = 0;
break; break;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,7 +1,7 @@
/* /*
* Author Roy Arends * Author Roy Arends
* *
* Copyright (c) 2017-2022, OARC, Inc. * Copyright (c) 2017-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,6 +1,6 @@
#!/usr/bin/env perl #!/usr/bin/env perl
# #
# Copyright (c) 2018-2022, OARC, Inc. # Copyright (c) 2018-2023, OARC, Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
.\" Copyright (c) 2017-2022, OARC, Inc. .\" Copyright (c) 2017-2023, OARC, Inc.
.\" All rights reserved. .\" All rights reserved.
.\" .\"
.\" Redistribution and use in source and binary forms, with or without .\" Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -566,7 +566,6 @@ int rssm_close(my_bpftimeval ts)
struct tm tm; struct tm tm;
if (dont_fork_on_close) { if (dont_fork_on_close) {
struct tm tm;
gmtime_r((time_t*)&open_ts.tv_sec, &tm); gmtime_r((time_t*)&open_ts.tv_sec, &tm);
strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm); strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm);
close_ts = ts; close_ts = ts;
@ -721,7 +720,7 @@ void rssm_output(const char* descr, iaddr from, iaddr to, uint8_t proto, unsigne
counts.dns_tcp_responses_sent_ipv6++; counts.dns_tcp_responses_sent_ipv6++;
} }
} }
if (ldns_pkt_arcount(pkt)) { if (ldns_pkt_edns(pkt)) {
rcode |= ((uint16_t)ldns_pkt_edns_extended_rcode(pkt) << 4); rcode |= ((uint16_t)ldns_pkt_edns_extended_rcode(pkt) << 4);
} }
counts.rcodes[rcode]++; counts.rcodes[rcode]++;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -564,71 +564,71 @@ void parse_args(int argc, char* argv[])
char* fn = strdup(optarg); char* fn = strdup(optarg);
char* t; char* t;
char sn[256]; char sn[256];
struct plugin* p = calloc(1, sizeof(*p)); struct plugin* pl = calloc(1, sizeof(*pl));
assert(p != NULL); assert(pl != NULL);
INIT_LINK(p, link); INIT_LINK(pl, link);
t = strrchr(fn, '/'); t = strrchr(fn, '/');
p->name = strdup(t ? t + 1 : fn); pl->name = strdup(t ? t + 1 : fn);
if ((t = strstr(p->name, ".so"))) if ((t = strstr(pl->name, ".so")))
*t = 0; *t = 0;
p->handle = dlopen(fn, RTLD_NOW); pl->handle = dlopen(fn, RTLD_NOW);
if (!p->handle) { if (!pl->handle) {
logerr("%s: %s", fn, dlerror()); logerr("%s: %s", fn, dlerror());
exit(1); exit(1);
} }
snprintf(sn, sizeof(sn), "%s_type", p->name); snprintf(sn, sizeof(sn), "%s_type", pl->name);
p->type = dlsym(p->handle, sn); pl->type = dlsym(pl->handle, sn);
if (p->type) { if (pl->type) {
p->pt = (*p->type)(); pl->pt = (*pl->type)();
switch (p->pt) { switch (pl->pt) {
case plugin_output: case plugin_output:
case plugin_filter: case plugin_filter:
break; break;
default: default:
logerr("invalid plugin type for plugin '%s'", p->name); logerr("invalid plugin type for plugin '%s'", pl->name);
exit(1); exit(1);
} }
} else { } else {
p->pt = plugin_output; pl->pt = plugin_output;
} }
snprintf(sn, sizeof(sn), "%s_start", p->name); snprintf(sn, sizeof(sn), "%s_start", pl->name);
p->start = dlsym(p->handle, sn); pl->start = dlsym(pl->handle, sn);
snprintf(sn, sizeof(sn), "%s_stop", p->name); snprintf(sn, sizeof(sn), "%s_stop", pl->name);
p->stop = dlsym(p->handle, sn); pl->stop = dlsym(pl->handle, sn);
snprintf(sn, sizeof(sn), "%s_open", p->name); snprintf(sn, sizeof(sn), "%s_open", pl->name);
p->open = dlsym(p->handle, sn); pl->open = dlsym(pl->handle, sn);
snprintf(sn, sizeof(sn), "%s_close", p->name); snprintf(sn, sizeof(sn), "%s_close", pl->name);
p->close = dlsym(p->handle, sn); pl->close = dlsym(pl->handle, sn);
snprintf(sn, sizeof(sn), "%s_output", p->name); snprintf(sn, sizeof(sn), "%s_output", pl->name);
p->output = dlsym(p->handle, sn); pl->output = dlsym(pl->handle, sn);
if (p->pt == plugin_output && !p->output) { if (pl->pt == plugin_output && !pl->output) {
logerr("%s", dlerror()); logerr("%s", dlerror());
exit(1); exit(1);
} }
snprintf(sn, sizeof(sn), "%s_filter", p->name); snprintf(sn, sizeof(sn), "%s_filter", pl->name);
p->filter = dlsym(p->handle, sn); pl->filter = dlsym(pl->handle, sn);
if (p->pt == plugin_filter && !p->filter) { if (pl->pt == plugin_filter && !pl->filter) {
logerr("%s", dlerror()); logerr("%s", dlerror());
exit(1); exit(1);
} }
snprintf(sn, sizeof(sn), "%s_usage", p->name); snprintf(sn, sizeof(sn), "%s_usage", pl->name);
p->usage = dlsym(p->handle, sn); pl->usage = dlsym(pl->handle, sn);
snprintf(sn, sizeof(sn), "%s_extension", p->name); snprintf(sn, sizeof(sn), "%s_extension", pl->name);
p->extension = dlsym(p->handle, sn); pl->extension = dlsym(pl->handle, sn);
if (p->extension) { if (pl->extension) {
(*p->extension)(DNSCAP_EXT_IS_RESPONDER, (void*)is_responder); (*pl->extension)(DNSCAP_EXT_IS_RESPONDER, (void*)is_responder);
(*p->extension)(DNSCAP_EXT_IA_STR, (void*)_ia_str); (*pl->extension)(DNSCAP_EXT_IA_STR, (void*)_ia_str);
(*p->extension)(DNSCAP_EXT_TCPSTATE_GETCURR, (void*)_tcpstate_getcurr); (*pl->extension)(DNSCAP_EXT_TCPSTATE_GETCURR, (void*)_tcpstate_getcurr);
(*p->extension)(DNSCAP_EXT_TCPSTATE_RESET, (void*)_tcpstate_reset); (*pl->extension)(DNSCAP_EXT_TCPSTATE_RESET, (void*)_tcpstate_reset);
(*p->extension)(DNSCAP_EXT_SET_IADDR, (void*)set_iaddr); (*pl->extension)(DNSCAP_EXT_SET_IADDR, (void*)set_iaddr);
} }
snprintf(sn, sizeof(sn), "%s_getopt", p->name); snprintf(sn, sizeof(sn), "%s_getopt", pl->name);
p->getopt = dlsym(p->handle, sn); pl->getopt = dlsym(pl->handle, sn);
if (p->getopt) if (pl->getopt)
(*p->getopt)(&argc, &argv); (*pl->getopt)(&argc, &argv);
APPEND(plugins, p, link); APPEND(plugins, pl, link);
if (dumptrace) if (dumptrace)
fprintf(stderr, "Plugin '%s' loaded\n", p->name); fprintf(stderr, "Plugin '%s' loaded\n", pl->name);
free(fn); free(fn);
} break; } break;
case 'U': case 'U':

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,4 +1,4 @@
.\" Copyright (c) 2016-2022, OARC, Inc. .\" Copyright (c) 2016-2023, OARC, Inc.
.\" All rights reserved. .\" All rights reserved.
.\" .\"
.\" Redistribution and use in source and binary forms, with or without .\" Redistribution and use in source and binary forms, with or without

View file

@ -4,7 +4,7 @@
*/ */
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -4,7 +4,7 @@
*/ */
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -4,7 +4,7 @@
*/ */
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -241,8 +241,6 @@ int dumper_close(my_bpftimeval ts)
dumper = FALSE; dumper = FALSE;
} }
} else if (options.dump_format == cbor) { } else if (options.dump_format == cbor) {
int ret;
if (dump_type == to_stdout) { if (dump_type == to_stdout) {
ret = dump_cbor(stdout); ret = dump_cbor(stdout);
@ -265,8 +263,6 @@ int dumper_close(my_bpftimeval ts)
} }
} }
} else if (options.dump_format == cds) { } else if (options.dump_format == cds) {
int ret;
if (dump_type == to_stdout) { if (dump_type == to_stdout) {
ret = dump_cds(stdout); ret = dump_cds(stdout);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016-2022, OARC, Inc. * Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2022, OARC, Inc. * Copyright (c) 2018-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -356,7 +356,7 @@ int pcap_handle_tcp_segment(u_char* segment, int len, uint32_t seq, tcpstate_ptr
if (!tcpstate->segbuf[s]) if (!tcpstate->segbuf[s])
continue; continue;
/* TODO: seq >= 0 */ /* TODO: seq >= 0 */
if (tcpstate->segbuf[s]->seq - seq > 0 && tcpstate->segbuf[s]->seq - seq < dnslen) { if (tcpstate->segbuf[s]->seq > seq && tcpstate->segbuf[s]->seq - seq < dnslen) {
tcp_segbuf_t* segbuf = tcpstate->segbuf[s]; tcp_segbuf_t* segbuf = tcpstate->segbuf[s];
tcpstate->segbuf[s] = NULL; tcpstate->segbuf[s] = NULL;
dfprintf(1, "pcap_handle_tcp_segment: %s", "message reassembled"); dfprintf(1, "pcap_handle_tcp_segment: %s", "message reassembled");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2022, OARC, Inc. * Copyright (c) 2018-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2022, OARC, Inc. * Copyright (c) 2018-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -48,6 +48,17 @@ tcpstate_ptr tcpstate_find(iaddr from, iaddr to, unsigned sport, unsigned dport,
static time_t next_gc = 0; static time_t next_gc = 0;
tcpstate_ptr tcpstate; tcpstate_ptr tcpstate;
#ifndef __clang_analyzer__
/* disabled during scan-build due to false-positives */
if (t >= next_gc || tcpstate_count > MAX_TCP_IDLE_COUNT) {
/* garbage collect stale states */
while ((tcpstate = TAIL(tcpstates)) && tcpstate->last_use < t - MAX_TCP_IDLE_TIME) {
tcpstate_discard(tcpstate, "gc stale");
}
next_gc = t + TCP_GC_TIME;
}
#endif
for (tcpstate = HEAD(tcpstates); for (tcpstate = HEAD(tcpstates);
tcpstate != NULL; tcpstate != NULL;
tcpstate = NEXT(tcpstate, link)) { tcpstate = NEXT(tcpstate, link)) {
@ -63,22 +74,11 @@ tcpstate_ptr tcpstate_find(iaddr from, iaddr to, unsigned sport, unsigned dport,
} }
} }
if (t >= next_gc || tcpstate_count > MAX_TCP_IDLE_COUNT) {
/* garbage collect stale states */
time_t min_last_use = t - MAX_TCP_IDLE_TIME;
while ((tcpstate = TAIL(tcpstates)) && tcpstate->last_use < min_last_use) {
UNLINK(tcpstates, tcpstate, link);
tcpstate_count--;
}
next_gc = t + TCP_GC_TIME;
}
return tcpstate; return tcpstate;
} }
tcpstate_ptr tcpstate_new(iaddr from, iaddr to, unsigned sport, unsigned dport) tcpstate_ptr tcpstate_new(iaddr from, iaddr to, unsigned sport, unsigned dport)
{ {
tcpstate_ptr tcpstate = calloc(1, sizeof *tcpstate); tcpstate_ptr tcpstate = calloc(1, sizeof *tcpstate);
if (tcpstate == NULL) { if (tcpstate == NULL) {
/* Out of memory; recycle the least recently used */ /* Out of memory; recycle the least recently used */
@ -86,6 +86,7 @@ tcpstate_ptr tcpstate_new(iaddr from, iaddr to, unsigned sport, unsigned dport)
"discarding some TCP state early"); "discarding some TCP state early");
tcpstate = TAIL(tcpstates); tcpstate = TAIL(tcpstates);
assert(tcpstate != NULL); assert(tcpstate != NULL);
UNLINK(tcpstates, tcpstate, link);
} else { } else {
tcpstate_count++; tcpstate_count++;
} }
@ -98,6 +99,13 @@ tcpstate_ptr tcpstate_new(iaddr from, iaddr to, unsigned sport, unsigned dport)
return tcpstate; return tcpstate;
} }
tcpstate_ptr _curr_tcpstate = 0;
tcpstate_ptr tcpstate_getcurr(void)
{
return _curr_tcpstate;
}
/* Discard this packet. If it's part of TCP stream, all subsequent pkts on /* Discard this packet. If it's part of TCP stream, all subsequent pkts on
* the same tcp stream will also be discarded. */ * the same tcp stream will also be discarded. */
void tcpstate_discard(tcpstate_ptr tcpstate, const char* msg) void tcpstate_discard(tcpstate_ptr tcpstate, const char* msg)
@ -110,16 +118,11 @@ void tcpstate_discard(tcpstate_ptr tcpstate, const char* msg)
tcpreasm_free(tcpstate->reasm); tcpreasm_free(tcpstate->reasm);
} }
free(tcpstate); free(tcpstate);
tcpstate_count--; if (_curr_tcpstate == tcpstate) {
return; _curr_tcpstate = 0;
}
tcpstate_count--;
} }
}
tcpstate_ptr _curr_tcpstate = 0;
tcpstate_ptr tcpstate_getcurr(void)
{
return _curr_tcpstate;
} }
void tcpstate_reset(tcpstate_ptr tcpstate, const char* msg) void tcpstate_reset(tcpstate_ptr tcpstate, const char* msg)

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2022, OARC, Inc. * Copyright (c) 2018-2023, OARC, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without