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
Copyright (c) 2016-2022, OARC, Inc.
Copyright (c) 2016-2023, OARC, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without

20
configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh
# 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>.
#
@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='dnscap'
PACKAGE_TARNAME='dnscap'
PACKAGE_VERSION='2.1.0'
PACKAGE_STRING='dnscap 2.1.0'
PACKAGE_VERSION='2.1.1'
PACKAGE_STRING='dnscap 2.1.1'
PACKAGE_BUGREPORT='dnscap-users@dns-oarc.net'
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.
# This message is too long to be a string in the A/UX 3.1 sh.
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]...
@ -1424,7 +1424,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of dnscap 2.1.0:";;
short | recursive ) echo "Configuration of dnscap 2.1.1:";;
esac
cat <<\_ACEOF
@ -1556,7 +1556,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
dnscap configure 2.1.0
dnscap configure 2.1.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@ -1979,7 +1979,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
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
$ $0 $@
@ -2842,7 +2842,7 @@ fi
# Define the identity of the package.
PACKAGE='dnscap'
VERSION='2.1.0'
VERSION='2.1.1'
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
# values after options handling.
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
CONFIG_FILES = $CONFIG_FILES
@ -15082,7 +15082,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
dnscap config.status 2.1.0
dnscap config.status 2.1.1
configured by $0, generated by GNU Autoconf 2.69,
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, Internet Systems Consortium, Inc.
# All rights reserved.
@ -33,7 +33,7 @@
# POSSIBILITY OF SUCH DAMAGE.
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])
AC_CONFIG_SRCDIR([src/dnscap.c])
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.
*
* Redistribution and use in source and binary forms, with or without
@ -246,8 +246,10 @@ int anonaes128_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto,
for (;;) {
if (only_clients && sport == dns_port) {
from = 0;
break;
if (sport != dport) {
from = 0;
break;
}
}
if (only_servers && sport != dns_port) {
from = 0;
@ -292,8 +294,10 @@ int anonaes128_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto,
for (;;) {
if (only_clients && dport == dns_port) {
to = 0;
break;
if (dport != sport) {
to = 0;
break;
}
}
if (only_servers && dport != dns_port) {
to = 0;

View file

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

View file

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

View file

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

View file

@ -12,7 +12,7 @@
* Below is the original copyright notice from txtout.c.
*/
/*
* Copyright (c) 2016-2022, OARC, Inc.
* Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved.
*
* 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.
*
* Redistribution and use in source and binary forms, with or without
@ -273,8 +273,10 @@ int ipcrypt_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto, uns
{
for (;;) {
if (only_clients && sport == dns_port) {
from = 0;
break;
if (sport != dport) {
from = 0;
break;
}
}
if (only_servers && sport != dns_port) {
from = 0;
@ -309,8 +311,10 @@ int ipcrypt_filter(const char* descr, iaddr* from, iaddr* to, uint8_t proto, uns
for (;;) {
if (only_clients && dport == dns_port) {
to = 0;
break;
if (dport != sport) {
to = 0;
break;
}
}
if (only_servers && dport != dns_port) {
to = 0;

View file

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

View file

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

View file

@ -1,6 +1,6 @@
#!/usr/bin/env perl
#
# Copyright (c) 2018-2022, OARC, Inc.
# Copyright (c) 2018-2023, OARC, Inc.
# All rights reserved.
#
# 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.
.\"
.\" 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.
*
* Redistribution and use in source and binary forms, with or without
@ -566,7 +566,6 @@ int rssm_close(my_bpftimeval ts)
struct tm tm;
if (dont_fork_on_close) {
struct tm tm;
gmtime_r((time_t*)&open_ts.tv_sec, &tm);
strftime(sbuf, sizeof(sbuf), "%Y%m%d.%H%M%S", &tm);
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++;
}
}
if (ldns_pkt_arcount(pkt)) {
if (ldns_pkt_edns(pkt)) {
rcode |= ((uint16_t)ldns_pkt_edns_extended_rcode(pkt) << 4);
}
counts.rcodes[rcode]++;

View file

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

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2022, OARC, Inc.
* Copyright (c) 2016-2023, OARC, Inc.
* All rights reserved.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
.\"
.\" 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* Redistribution and use in source and binary forms, with or without
@ -241,8 +241,6 @@ int dumper_close(my_bpftimeval ts)
dumper = FALSE;
}
} else if (options.dump_format == cbor) {
int ret;
if (dump_type == to_stdout) {
ret = dump_cbor(stdout);
@ -265,8 +263,6 @@ int dumper_close(my_bpftimeval ts)
}
}
} else if (options.dump_format == cds) {
int ret;
if (dump_type == to_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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* 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])
continue;
/* 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];
tcpstate->segbuf[s] = NULL;
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.
*
* 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.
*
* 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;
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);
tcpstate != NULL;
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;
}
tcpstate_ptr tcpstate_new(iaddr from, iaddr to, unsigned sport, unsigned dport)
{
tcpstate_ptr tcpstate = calloc(1, sizeof *tcpstate);
if (tcpstate == NULL) {
/* 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");
tcpstate = TAIL(tcpstates);
assert(tcpstate != NULL);
UNLINK(tcpstates, tcpstate, link);
} else {
tcpstate_count++;
}
@ -98,6 +99,13 @@ tcpstate_ptr tcpstate_new(iaddr from, iaddr to, unsigned sport, unsigned dport)
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
* the same tcp stream will also be discarded. */
void tcpstate_discard(tcpstate_ptr tcpstate, const char* msg)
@ -110,18 +118,13 @@ void tcpstate_discard(tcpstate_ptr tcpstate, const char* msg)
tcpreasm_free(tcpstate->reasm);
}
free(tcpstate);
if (_curr_tcpstate == tcpstate) {
_curr_tcpstate = 0;
}
tcpstate_count--;
return;
}
}
tcpstate_ptr _curr_tcpstate = 0;
tcpstate_ptr tcpstate_getcurr(void)
{
return _curr_tcpstate;
}
void tcpstate_reset(tcpstate_ptr tcpstate, const char* msg)
{
if (options.allow_reset_tcpstate && tcpstate) {

View file

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