#include "config.h"
#endif
-#include "tcp_module.h"
-#include "tcp_normalizer.h"
-
#include "main/snort_config.h"
#include "profiler/profiler_defs.h"
#include "stream/paf.h"
#include "stream/paf_stats.h"
#include "trace/trace.h"
+#include "trace/trace_api.h"
+#include "tcp_module.h"
+#include "tcp_normalizer.h"
#include "tcp_trace.h"
using namespace snort;
THREAD_LOCAL ProfileStats s5TcpPerfStats;
THREAD_LOCAL const Trace* stream_tcp_trace = nullptr;
+THREAD_LOCAL bool stream_tcp_trace_enabled = false;
-#ifdef DEBUG_MSGS
static const TraceOption stream_tcp_trace_options[] =
{
{ "segments", TRACE_SEGMENTS, "enable stream TCP segments trace logging" },
{ nullptr, 0, nullptr }
};
-#endif
const PegInfo tcp_pegs[] =
{
}
void StreamTcpModule::set_trace(const Trace* trace) const
-{ stream_tcp_trace = trace; }
+{
+ stream_tcp_trace = trace;
+ stream_tcp_trace_enabled = trace_enabled(stream_tcp_trace, TRACE_SEGMENTS) ||
+ trace_enabled(stream_tcp_trace, TRACE_STATE);
+}
const TraceOption* StreamTcpModule::get_trace_options() const
{
-#ifndef DEBUG_MSGS
- return nullptr;
-#else
return stream_tcp_trace_options;
-#endif
}
const RuleMap* StreamTcpModule::get_rules() const
return statext[t.get_tcp_state()];
}
-#ifndef DEBUG_MSGS
-void S5TraceTCP(const TcpSegmentDescriptor&, const snort::Packet*) { }
-#else
#define LCL(p, x) ((p).x() - (p).get_iss())
#define RMT(p, x, q) ((p).x - (q).get_iss())
uint32_t rseq = txd ? tsd.get_seq() - txd : tsd.get_seq();
uint32_t rack = rxd ? tsd.get_ack() - rxd : tsd.get_ack();
- debug_logf(stream_tcp_trace, TRACE_STATE, p,
+ trace_logf(DEFAULT_TRACE_LOG_LEVEL, stream_tcp_trace, TRACE_STATE, p,
FMTu64("-3") " %s %s=0x%02x Seq=%-4u Ack=%-4u Win=%-4u Len=%-4hu%s\n",
tsd.get_packet_number(), meta_ack_marker, flags, h->th_flags, rseq, rack, tsd.get_wnd(),
tsd.get_len(), order);
inline void TraceSession(const snort::Flow* flow, const snort::Packet* p)
{
- debug_logf(stream_tcp_trace, TRACE_STATE, p,
+ trace_logf(DEFAULT_TRACE_LOG_LEVEL, stream_tcp_trace, TRACE_STATE, p,
" LWS: ST=0x%x SF=0x%x CP=%hu SP=%hu\n", (unsigned)flow->session_state,
flow->ssn_state.session_flags, flow->client_port, flow->server_port);
}
}
if ( !ss.str().empty() )
- debug_logf(stream_tcp_trace, TRACE_SEGMENTS, p, " %s\n", ss.str().c_str());
+ trace_logf(DEFAULT_TRACE_LOG_LEVEL, stream_tcp_trace, TRACE_SEGMENTS, p, " %s\n", ss.str().c_str());
assert(trp.trs.sos.seg_count == segs);
assert(trp.trs.sos.seg_bytes_logical == bytes);
uint32_t ua = a.get_snd_una() ? LCL(a, get_snd_una) : 0;
uint32_t ns = a.get_snd_nxt() ? LCL(a, get_snd_nxt) : 0;
- debug_logf(stream_tcp_trace, TRACE_STATE, p,
+ trace_logf(DEFAULT_TRACE_LOG_LEVEL, stream_tcp_trace, TRACE_STATE, p,
" %s ST=%s UA=%-4u NS=%-4u LW=%-5u RN=%-4u RW=%-4u ISS=%-4u IRS=%-4u\n",
s, stream_tcp_state_to_str(a), ua, ns, a.get_snd_wnd( ),
RMT(a, rcv_nxt, b), RMT(a, r_win_base, b), a.get_iss(), a.get_irs());
unsigned paf = a.is_splitter_paf() ? 2 : 0;
unsigned fpt = a.get_flush_policy() ? 192 : 0;
- debug_logf(stream_tcp_trace, TRACE_STATE, p,
+ trace_logf(DEFAULT_TRACE_LOG_LEVEL, stream_tcp_trace, TRACE_STATE, p,
" FP=%s:%-4u SC=%-4u FL=%-4u SL=%-5u BS=%-4u\n",
flushxt[a.get_flush_policy() + paf], fpt,
a.reassembler.get_seg_count(), a.reassembler.get_flush_count(),
TraceState(srv, cli, sdir, p);
}
-#endif // DEBUG_MSGS