25#ifndef SURICATA_STREAM_TCP_H
26#define SURICATA_STREAM_TCP_H
35#define STREAM_VERBOSE false
38#define STREAMTCP_INIT_FLAG_CHECKSUM_VALIDATION BIT_U8(0)
39#define STREAMTCP_INIT_FLAG_DROP_INVALID BIT_U8(1)
40#define STREAMTCP_INIT_FLAG_BYPASS BIT_U8(2)
41#define STREAMTCP_INIT_FLAG_INLINE BIT_U8(3)
43#define STREAMTCP_INIT_FLAG_DROP_URG BIT_U8(4)
47#define TCP_STREAM_URGENT_DEFAULT TCP_STREAM_URGENT_INLINE
144 void *data,
const uint8_t *input,
const uint32_t input_len,
const uint64_t
offset);
147 void *cb_data,
const uint64_t
offset,
const bool eof);
150 uint64_t *progress_out,
const bool eof);
153 uint64_t *progress_out,
bool respect_inspect_depth);
176static inline int StreamTcpCheckFlowDrops(
Packet *p)
216 const uint32_t progress);
TmEcode StreamTcp(ThreadVars *, Packet *, void *, PacketQueueNoLock *)
void StreamTcpInitMemuse(void)
int StreamTcpBypassEnabled(void)
TmEcode StreamTcpThreadDeinit(ThreadVars *tv, void *data)
void StreamTcpSessionCleanup(TcpSession *ssn)
Session cleanup function. Does not free the ssn.
int StreamTcpSetMemcap(uint64_t)
Update memcap value.
int StreamReassembleRaw(TcpSession *ssn, const Packet *p, StreamReassembleRawFunc Callback, void *cb_data, uint64_t *progress_out, bool respect_inspect_depth)
void StreamTcpReassembleConfigEnableOverlapCheck(void)
int StreamTcpSegmentForSession(const Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
Run callback function on each TCP segment in both directions of a session.
bool StreamTcpInlineMode(void)
See if stream engine is operating in inline mode.
void StreamTcpRegisterTests(void)
struct StreamTcpThread_ StreamTcpThread
void StreamTcpSessionPktFree(Packet *)
Function to return the stream segments back to the pool.
void StreamTcpFreeConfig(bool)
@ TCP_STREAM_URGENT_INLINE
bool TcpSessionPacketSsnReuse(const Packet *p, const Flow *f, const void *tcp_ssn)
void StreamTcpDecrMemuse(uint64_t)
uint64_t StreamTcpGetUsable(const TcpStream *stream, const bool eof)
void StreamTcpStreamCleanup(TcpStream *stream)
void StreamReassembleRawUpdateProgress(TcpSession *ssn, Packet *p, const uint64_t progress)
update stream engine after detection
const char * StreamTcpStateAsString(const enum TcpState)
void StreamTcpIncrMemuse(uint64_t)
enum ExceptionPolicy StreamTcpSsnMemcapGetExceptionPolicy(void)
int StreamTcpSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
struct TcpStreamCnf_ TcpStreamCnf
enum ExceptionPolicy StreamTcpReassemblyMemcapGetExceptionPolicy(void)
TmEcode StreamTcpThreadInit(ThreadVars *, void *, void **)
void TcpSessionSetReassemblyDepth(TcpSession *ssn, uint32_t size)
uint64_t StreamTcpGetMemcap(void)
Return memcap value.
@ STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION
@ STREAM_HAS_UNPROCESSED_SEGMENTS_NONE
int(* StreamReassembleRawFunc)(void *data, const uint8_t *input, const uint32_t input_len, const uint64_t offset)
int StreamReassembleLog(const TcpSession *ssn, const TcpStream *stream, StreamReassembleRawFunc Callback, void *cb_data, const uint64_t progress_in, uint64_t *progress_out, const bool eof)
uint64_t StreamDataRightEdge(const TcpStream *stream, const bool eof)
TcpStreamCnf stream_config
int StreamTcpPacket(ThreadVars *tv, Packet *p, StreamTcpThread *stt, PacketQueueNoLock *pq)
void StreamTcpInitConfig(bool)
To initialize the stream global configuration data.
void StreamTcpDetectLogFlush(ThreadVars *tv, StreamTcpThread *stt, Flow *f, Packet *p, PacketQueueNoLock *pq)
create packets in both directions to flush out logging and detection before switching protocols....
const char * StreamTcpSsnStateAsString(const TcpSession *ssn)
void StreamTcpSessionClear(void *ssnptr)
Function to return the stream back to the pool. It returns the segments in the stream to the segment ...
int StreamTcpCheckMemcap(uint64_t)
Check if alloc'ing "size" would mean we're over memcap.
uint64_t StreamTcpMemuseCounter(void)
enum ExceptionPolicy StreamMidstreamGetExceptionPolicy(void)
uint8_t StreamNeedsReassembly(const TcpSession *ssn, uint8_t direction)
see what if any work the TCP session still needs
void StreamTcpUpdateAppLayerProgress(TcpSession *ssn, char direction, const uint32_t progress)
update reassembly progress
int StreamReassembleForFrame(TcpSession *ssn, TcpStream *stream, StreamReassembleRawFunc Callback, void *cb_data, const uint64_t offset, const bool eof)
int(* StreamSegmentCallback)(const Packet *, TcpSegment *, void *, const uint8_t *, uint32_t)
simple fifo queue for packets
uint16_t counter_tcp_ack_unseen_data
uint16_t counter_tcp_ssn_from_pool
uint16_t counter_tcp_invalid_checksum
uint16_t counter_tcp_pseudo
uint16_t counter_tcp_ssn_memcap
uint16_t counter_tcp_active_sessions
uint16_t counter_tcp_sessions
TcpReassemblyThreadCtx * ra_ctx
uint16_t counter_tcp_midstream_pickups
ExceptionPolicyCounters counter_tcp_midstream_eps
uint16_t counter_tcp_ssn_from_cache
ExceptionPolicyCounters counter_tcp_ssn_memcap_eps
uint16_t counter_tcp_wrong_thread
uint32_t prealloc_sessions
enum ExceptionPolicy reassembly_memcap_policy
SC_ATOMIC_DECLARE(uint64_t, reassembly_memcap)
enum ExceptionPolicy midstream_policy
uint16_t reassembly_toserver_chunk_size
uint32_t reassembly_depth
uint16_t reassembly_toclient_chunk_size
uint8_t max_synack_queued
enum TcpStreamUrgentHandling urgent_policy
SC_ATOMIC_DECLARE(uint64_t, memcap)
StreamingBufferConfig sbcnf
enum TcpStreamUrgentHandling urgent_oob_limit_policy
uint32_t prealloc_segments
uint16_t stream_init_flags
enum ExceptionPolicy ssn_memcap_policy
Per thread variable structure.
int EngineModeIsIPS(void)