Merging upstream version 2.1.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
4feb155734
commit
14c3c7c9ac
58 changed files with 177 additions and 159 deletions
92
src/args.c
92
src/args.c
|
@ -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':
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue