suricata
stream-tcp.h File Reference
#include "stream-tcp-private.h"
#include "stream.h"
#include "stream-tcp-reassemble.h"
Include dependency graph for stream-tcp.h:

Go to the source code of this file.

Data Structures

struct  TcpStreamCnf_
 
struct  StreamTcpThread_
 

Macros

#define STREAM_VERBOSE   FALSE
 
#define STREAMTCP_INIT_FLAG_CHECKSUM_VALIDATION   BIT_U8(0)
 
#define STREAMTCP_INIT_FLAG_DROP_INVALID   BIT_U8(1)
 
#define STREAMTCP_INIT_FLAG_BYPASS   BIT_U8(2)
 
#define STREAMTCP_INIT_FLAG_INLINE   BIT_U8(3)
 

Typedefs

typedef struct TcpStreamCnf_ TcpStreamCnf
 
typedef struct StreamTcpThread_ StreamTcpThread
 
typedef int(* StreamReassembleRawFunc) (void *data, const uint8_t *input, const uint32_t input_len)
 

Enumerations

enum  { STREAM_HAS_UNPROCESSED_SEGMENTS_NONE = 0, STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION = 1 }
 

Functions

void StreamTcpInitConfig (char)
 To initialize the stream global configuration data. More...
 
void StreamTcpFreeConfig (char)
 
void StreamTcpRegisterTests (void)
 
void StreamTcpSessionPktFree (Packet *)
 Function to return the stream segments back to the pool. More...
 
void StreamTcpInitMemuse (void)
 
void StreamTcpIncrMemuse (uint64_t)
 
void StreamTcpDecrMemuse (uint64_t)
 
int StreamTcpSetMemcap (uint64_t)
 Update memcap value. More...
 
uint64_t StreamTcpGetMemcap (void)
 Return memcap value. More...
 
int StreamTcpCheckMemcap (uint64_t)
 Check if alloc'ing "size" would mean we're over memcap. More...
 
uint64_t StreamTcpMemuseCounter (void)
 
uint64_t StreamTcpReassembleMemuseGlobalCounter (void)
 
PacketStreamTcpPseudoSetup (Packet *, uint8_t *, uint32_t)
 Function to fetch a packet from the packet allocation queue for creation of the pseudo packet from the reassembled stream. More...
 
int StreamTcpSegmentForEach (const Packet *p, uint8_t flag, StreamSegmentCallback CallbackFunc, void *data)
 Run callback function on each TCP segment. More...
 
void StreamTcpReassembleConfigEnableOverlapCheck (void)
 
void TcpSessionSetReassemblyDepth (TcpSession *ssn, uint32_t size)
 
int StreamReassembleLog (TcpSession *ssn, TcpStream *stream, StreamReassembleRawFunc Callback, void *cb_data, uint64_t progress_in, uint64_t *progress_out, bool eof)
 
int StreamReassembleRaw (TcpSession *ssn, const Packet *p, StreamReassembleRawFunc Callback, void *cb_data, uint64_t *progress_out, bool respect_inspect_depth)
 
void StreamReassembleRawUpdateProgress (TcpSession *ssn, Packet *p, uint64_t progress)
 update stream engine after detection More...
 
void StreamTcpDetectLogFlush (ThreadVars *tv, StreamTcpThread *stt, Flow *f, Packet *p, PacketQueue *pq)
 create packets in both directions to flush out logging and detection before switching protocols. In IDS mode, create first in packet dir, 2nd in opposing In IPS mode, do the reverse. Flag TCP engine that data needs to be inspected regardless of how far we are wrt inspect limits. More...
 
TmEcode StreamTcp (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *)
 
int StreamNeedsReassembly (const TcpSession *ssn, uint8_t direction)
 see what if any work the TCP session still needs More...
 
TmEcode StreamTcpThreadInit (ThreadVars *, void *, void **)
 
TmEcode StreamTcpThreadDeinit (ThreadVars *tv, void *data)
 
int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt, PacketQueue *pq)
 
void StreamTcpSessionClear (void *ssnptr)
 Function to return the stream back to the pool. It returns the segments in the stream to the segment pool. More...
 
void StreamTcpSessionCleanup (TcpSession *ssn)
 Session cleanup function. Does not free the ssn. More...
 
void StreamTcpStreamCleanup (TcpStream *stream)
 
int StreamTcpBypassEnabled (void)
 
int StreamTcpInlineDropInvalid (void)
 See if stream engine is dropping invalid packet in inline mode. More...
 
int StreamTcpInlineMode (void)
 See if stream engine is operating in inline mode. More...
 
int TcpSessionPacketSsnReuse (const Packet *p, const Flow *f, const void *tcp_ssn)
 

Variables

TcpStreamCnf stream_config
 

Detailed Description

Macro Definition Documentation

#define STREAM_VERBOSE   FALSE

Definition at line 33 of file stream-tcp.h.

Referenced by PostRunDeinit(), and PreRunInit().

#define STREAMTCP_INIT_FLAG_BYPASS   BIT_U8(2)

Definition at line 38 of file stream-tcp.h.

Referenced by StreamTcpBypassEnabled(), and StreamTcpInitConfig().

#define STREAMTCP_INIT_FLAG_CHECKSUM_VALIDATION   BIT_U8(0)

Definition at line 36 of file stream-tcp.h.

Referenced by StreamTcp(), and StreamTcpInitConfig().

#define STREAMTCP_INIT_FLAG_DROP_INVALID   BIT_U8(1)

Definition at line 37 of file stream-tcp.h.

Referenced by StreamTcpInitConfig(), and StreamTcpInlineDropInvalid().

#define STREAMTCP_INIT_FLAG_INLINE   BIT_U8(3)

Typedef Documentation

typedef int(* StreamReassembleRawFunc) (void *data, const uint8_t *input, const uint32_t input_len)

Definition at line 130 of file stream-tcp.h.

typedef struct TcpStreamCnf_ TcpStreamCnf

Enumeration Type Documentation

anonymous enum
Enumerator
STREAM_HAS_UNPROCESSED_SEGMENTS_NONE 
STREAM_HAS_UNPROCESSED_SEGMENTS_NEED_ONLY_DETECTION 

Definition at line 167 of file stream-tcp.h.

Function Documentation

int StreamNeedsReassembly ( const TcpSession ssn,
uint8_t  direction 
)
int StreamReassembleLog ( TcpSession ssn,
TcpStream stream,
StreamReassembleRawFunc  Callback,
void *  cb_data,
uint64_t  progress_in,
uint64_t *  progress_out,
bool  eof 
)

Definition at line 1684 of file stream-tcp-reassemble.c.

References TcpStream_::flags, SCEnter, SCReturnInt, STREAMTCP_STREAM_FLAG_NOREASSEMBLY, StreamTcpReassembleAppLayer(), and UPDATE_DIR_OPPOSING.

Here is the call graph for this function:

int StreamReassembleRaw ( TcpSession ssn,
const Packet p,
StreamReassembleRawFunc  Callback,
void *  cb_data,
uint64_t *  progress_out,
bool  respect_inspect_depth 
)
void StreamReassembleRawUpdateProgress ( TcpSession ssn,
Packet p,
uint64_t  progress 
)

update stream engine after detection

Tasked with progressing the 'progress' for Raw reassembly. 2 main scenario's:

  1. progress is != 0, so we use this
  2. progress is 0, meaning the detect engine didn't touch raw at all. In this case we need to look into progressing raw anyway.

Additionally, this function is tasked with disabling raw reassembly if the app-layer requested to disable it.

Definition at line 1260 of file stream-tcp-reassemble.c.

References TcpStream_::base_seq, StreamingBuffer_::buf_offset, BUG_ON, TcpSession_::client, DEBUG_VALIDATE_BUG_ON, TcpStream_::flags, TcpSession_::flags, Packet_::flags, TcpStream_::last_ack, StreamingBufferBlock::len, TcpStream_::min_inspect_depth, StreamingBufferBlock::offset, Packet_::payload, payload_len, Packet_::payload_len, Packet_::pcap_cnt, PKT_IS_TOSERVER, PKT_STREAM_ADD, TcpStream_::raw_progress_rel, RB_EMPTY, TcpStreamCnf_::reassembly_toclient_chunk_size, TcpStreamCnf_::reassembly_toserver_chunk_size, TcpStream_::sb, SBB_RB_FIND_INCLUSIVE(), StreamingBuffer_::sbb_tree, SCEnter, SCLogDebug, TcpSession_::server, STREAM_APP_PROGRESS, STREAM_BASE_OFFSET, stream_config, STREAM_RAW_PROGRESS, StreamingBufferGetData(), StreamingBufferSBBGetData(), STREAMTCP_FLAG_APP_LAYER_DISABLED, STREAMTCP_STREAM_FLAG_DISABLE_RAW, STREAMTCP_STREAM_FLAG_GAP, STREAMTCP_STREAM_FLAG_NEW_RAW_DISABLED, STREAMTCP_STREAM_FLAG_NOREASSEMBLY, STREAMTCP_STREAM_FLAG_TRIGGER_RAW, TCP_GET_SEQ, and TcpStream_::window.

Referenced by SigMatchSignaturesGetSgh().

Here is the call graph for this function:

Here is the caller graph for this function:

int StreamTcpBypassEnabled ( void  )

Definition at line 6271 of file stream-tcp.c.

References TcpStreamCnf_::flags, stream_config, and STREAMTCP_INIT_FLAG_BYPASS.

Referenced by StreamTcpPacket().

Here is the caller graph for this function:

int StreamTcpCheckMemcap ( uint64_t  size)

Check if alloc'ing "size" would mean we're over memcap.

Return values
1if in bounds
0if not in bounds

Definition at line 168 of file stream-tcp.c.

References SC_ATOMIC_GET, and stream_config.

Referenced by StreamTcpSessionPktFree(), and TcpSackCompare().

Here is the caller graph for this function:

void StreamTcpDecrMemuse ( uint64_t  )

Definition at line 135 of file stream-tcp.c.

References BUG_ON, RunmodeIsUnittests(), SC_ATOMIC_GET, SC_ATOMIC_SUB, SCLogDebug, and StreamTcpMemuseCounter().

Referenced by StreamTcpSessionCleanup(), StreamTcpSessionPktFree(), and TcpSackCompare().

Here is the call graph for this function:

Here is the caller graph for this function:

void StreamTcpDetectLogFlush ( ThreadVars tv,
StreamTcpThread stt,
Flow f,
Packet p,
PacketQueue pq 
)

create packets in both directions to flush out logging and detection before switching protocols. In IDS mode, create first in packet dir, 2nd in opposing In IPS mode, do the reverse. Flag TCP engine that data needs to be inspected regardless of how far we are wrt inspect limits.

Definition at line 6205 of file stream-tcp.c.

References TcpSession_::client, TcpStream_::flags, PKT_IS_TOSERVER, Flow_::protoctx, TcpSession_::server, STREAMTCP_STREAM_FLAG_TRIGGER_RAW, StreamTcpInlineMode(), and ts.

Here is the call graph for this function:

void StreamTcpFreeConfig ( char  )

Definition at line 669 of file stream-tcp.c.

References TcpSession_::client, TcpStream_::flags, Packet_::flow, FLOW_STATE_CLOSED, FLOW_STATE_ESTABLISHED, FlowUpdateState(), PKT_IS_PSEUDOPKT, PKT_IS_TOCLIENT, PKT_IS_TOSERVER, PoolThreadFree(), PoolThreadGetById(), Flow_::protoctx, TcpSession_::pstate, TcpStreamCnf_::reassembly_depth, TcpSession_::reassembly_depth, TcpStream_::sb, TcpStreamCnf_::sbcnf, SC_ATOMIC_DESTROY, SCLogDebug, SCMutexDestroy, SCMutexLock, SCMutexUnlock, TcpSession_::server, TcpSession_::state, stream_config, TcpStreamCnf_::stream_init_flags, STREAMING_BUFFER_INITIALIZER, StreamTcpReassembleFree(), TCP_CLOSE_WAIT, TCP_CLOSED, TCP_CLOSING, TCP_ESTABLISHED, TCP_FIN_WAIT1, TCP_FIN_WAIT2, TcpStream_::tcp_flags, TCP_LAST_ACK, TCP_NONE, TcpSession_::tcp_packet_flags, TCP_TIME_WAIT, and Packet_::tcph.

Referenced by AppLayerParserRestoreParserTable(), DetectBypassRegister(), DetectDceIfaceRegister(), DetectDceOpnumRegister(), DetectDceStubDataRegister(), DetectDNP3Register(), DetectDnsQueryRegister(), DetectEngineInspectENIP(), DetectEngineInspectModbus(), DetectEngineStateResetTxs(), DetectFtpbounceRegister(), DetectHttpRequestLineRegister(), DetectHttpResponseLineRegister(), DetectLuaRegister(), DetectPcrePayloadMatch(), DetectSshSoftwareVersionRegister(), DetectSshVersionRegister(), DetectSslStateRegister(), DetectSslVersionRegister(), DetectTemplateRustBufferRegister(), DetectTlsFingerprintRegister(), DetectTlsIssuerRegister(), DetectTlsJa3HashRegister(), DetectTlsJa3StringRegister(), DetectTlsSerialRegister(), DetectTlsSniRegister(), DetectTlsSubjectRegister(), DetectTlsValidityRegister(), DetectTlsVersionRegister(), DetectUricontentRegister(), DetectUrilenValidateContent(), FTPAtExitPrintStats(), HtpConfigRestoreBackup(), HTPFileClose(), PostRunDeinit(), RegisterDCERPCParsers(), RegisterDCERPCUDPParsers(), RegisterDNP3Parsers(), RegisterENIPTCPParsers(), RegisterModbusParsers(), RegisterSMBParsers(), RegisterSSHParsers(), RegisterSSLParsers(), SMTPParserCleanup(), and StreamTcpUTDeinit().

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t StreamTcpGetMemcap ( void  )

Return memcap value.

Parameters
memcapmemcap value

Definition at line 196 of file stream-tcp.c.

References SC_ATOMIC_GET, and stream_config.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

void StreamTcpIncrMemuse ( uint64_t  )

Definition at line 128 of file stream-tcp.c.

References SC_ATOMIC_ADD, SCLogDebug, and StreamTcpMemuseCounter().

Referenced by StreamTcpSessionPktFree(), and TcpSackCompare().

Here is the call graph for this function:

Here is the caller graph for this function:

void StreamTcpInitConfig ( char  quiet)

To initialize the stream global configuration data.

Parameters
quietIt tells the mode of operation, if it is TRUE nothing will be get printed.

Definition at line 365 of file stream-tcp.c.

References TcpStreamCnf_::async_oneside, ConfGetBool(), ConfGetInt(), ConfGetNode(), ConfGetValue(), EngineModeIsIPS(), TcpStreamCnf_::flags, FlowSetProtoFreeFunc(), TcpStreamCnf_::max_synack_queued, TcpStreamCnf_::midstream, ParseSizeStringU16(), ParseSizeStringU32(), ParseSizeStringU64(), PoolThreadInit(), TcpStreamCnf_::prealloc_sessions, TcpStreamCnf_::reassembly_depth, TcpStreamCnf_::reassembly_toclient_chunk_size, TcpStreamCnf_::reassembly_toserver_chunk_size, RunmodeIsUnittests(), SC_ATOMIC_GET, SC_ATOMIC_INIT, SC_ATOMIC_SET, SC_ERR_INVALID_VALUE, SC_ERR_SIZE_PARSE, SC_WARN_OPTION_OBSOLETE, SCLogDebug, SCLogError, SCLogWarning, SCMutexLock, SCMutexUnlock, StatsRegisterGlobalCounter(), stream_config, TcpStreamCnf_::stream_init_flags, STREAMTCP_DEFAULT_MAX_SYNACK_QUEUED, STREAMTCP_DEFAULT_MEMCAP, STREAMTCP_DEFAULT_PREALLOC, STREAMTCP_DEFAULT_REASSEMBLY_MEMCAP, STREAMTCP_DEFAULT_TOCLIENT_CHUNK_SIZE, STREAMTCP_DEFAULT_TOSERVER_CHUNK_SIZE, STREAMTCP_INIT_FLAG_BYPASS, STREAMTCP_INIT_FLAG_CHECKSUM_VALIDATION, STREAMTCP_INIT_FLAG_DROP_INVALID, STREAMTCP_INIT_FLAG_INLINE, STREAMTCP_STREAM_FLAG_DISABLE_RAW, StreamTcpInitMemuse(), StreamTcpMemuseCounter(), StreamTcpReassembleInit(), StreamTcpSessionClear(), and WarnInvalidConfEntry.

Referenced by AppLayerParserRestoreParserTable(), DetectBypassRegister(), DetectDceIfaceRegister(), DetectDceOpnumRegister(), DetectDceStubDataRegister(), DetectDNP3Register(), DetectDnsQueryRegister(), DetectEngineInspectENIP(), DetectEngineInspectModbus(), DetectEngineStateResetTxs(), DetectFtpbounceRegister(), DetectHttpRequestLineRegister(), DetectHttpResponseLineRegister(), DetectLuaRegister(), DetectPcrePayloadMatch(), DetectSshSoftwareVersionRegister(), DetectSshVersionRegister(), DetectSslStateRegister(), DetectSslVersionRegister(), DetectTemplateRustBufferRegister(), DetectTlsFingerprintRegister(), DetectTlsIssuerRegister(), DetectTlsJa3HashRegister(), DetectTlsJa3StringRegister(), DetectTlsSerialRegister(), DetectTlsSniRegister(), DetectTlsSubjectRegister(), DetectTlsValidityRegister(), DetectTlsVersionRegister(), DetectUricontentRegister(), DetectUrilenValidateContent(), FTPAtExitPrintStats(), HtpConfigRestoreBackup(), HTPFileClose(), PreRunInit(), RegisterDCERPCParsers(), RegisterDCERPCUDPParsers(), RegisterDNP3Parsers(), RegisterENIPTCPParsers(), RegisterModbusParsers(), RegisterSMBParsers(), RegisterSSHParsers(), RegisterSSLParsers(), SMTPParserCleanup(), and StreamTcpUTInit().

Here is the call graph for this function:

Here is the caller graph for this function:

void StreamTcpInitMemuse ( void  )

Definition at line 123 of file stream-tcp.c.

References SC_ATOMIC_INIT.

Referenced by StreamTcpInitConfig(), and UtRunTests().

Here is the caller graph for this function:

int StreamTcpInlineDropInvalid ( void  )

See if stream engine is dropping invalid packet in inline mode.

Return values
0no
1yes

Definition at line 339 of file stream-tcp.c.

References TcpStreamCnf_::flags, RandomGet(), stream_config, STREAMTCP_INIT_FLAG_DROP_INVALID, and STREAMTCP_INIT_FLAG_INLINE.

Referenced by StreamTcpPacket().

Here is the call graph for this function:

Here is the caller graph for this function:

int StreamTcpInlineMode ( void  )
uint64_t StreamTcpMemuseCounter ( void  )

Definition at line 156 of file stream-tcp.c.

References SC_ATOMIC_GET.

Referenced by RunModeUnixSocketGetDefaultMode(), StreamTcpDecrMemuse(), StreamTcpIncrMemuse(), StreamTcpInitConfig(), and UtRunTests().

Here is the caller graph for this function:

int StreamTcpPacket ( ThreadVars tv,
Packet p,
StreamTcpThread stt,
PacketQueue pq 
)

Definition at line 4674 of file stream-tcp.c.

References Flow_::alproto, TcpStreamCnf_::async_oneside, TcpSession_::client, StreamTcpThread_::counter_tcp_rst, StreamTcpThread_::counter_tcp_syn, StreamTcpThread_::counter_tcp_synack, StreamTcpThread_::counter_tcp_wrong_thread, DEBUG_ASSERT_FLOW_LOCKED, DecodeSetNoPacketInspectionFlag, DecodeSetNoPayloadInspectionFlag, TcpStream_::flags, TcpSession_::flags, Flow_::flags, Packet_::flags, Packet_::flow, FLOW_WRONG_THREAD, FlowGetPacketDirection(), g_detect_disabled, ThreadVars_::id, Packet_::ip4h, Packet_::ip6h, TcpStream_::isn, TcpStream_::last_ack, PacketQueue_::len, Packet_::level4_comp_csum, Packet_::livedev, TcpStreamCnf_::midstream, PACKET_DROP, PacketBypassCallback(), PacketDequeue(), PacketEnqueue(), Packet_::payload_len, Packet_::pcap_cnt, PcapIncreaseInvalidChecksum(), PKT_IGNORE_CHECKSUM, PKT_IS_IPV4, PKT_IS_IPV6, PKT_IS_TOCLIENT, PKT_IS_TOSERVER, PKT_PSEUDO_STREAM_END, Packet_::pkt_src, PKT_SRC_WIRE, PKT_STREAM_EST, PKT_STREAM_MODIFIED, PKT_STREAM_NO_EVENTS, PKT_STREAM_NOPCAPLOG, Flow_::protoctx, StreamTcpThread_::pseudo_queue, StreamTcpThread_::ra_ctx, ReCalculateChecksum(), SC_ATOMIC_ADD, SCEnter, SCLogDebug, SCReturnInt, SEQ_EQ, TcpSession_::server, TcpSession_::state, StatsIncr(), stream_config, STREAM_PKT_BROKEN_ACK, STREAM_WRONG_THREAD, STREAMTCP_FLAG_ASYNC, STREAMTCP_FLAG_BYPASS, STREAMTCP_STREAM_FLAG_DEPTH_REACHED, STREAMTCP_STREAM_FLAG_GAP, STREAMTCP_STREAM_FLAG_NOREASSEMBLY, StreamTcpBypassEnabled(), StreamTcpDisableAppLayer(), StreamTcpInlineDropInvalid(), StreamTcpReassembleHandleSegment(), StreamTcpSessionPktFree(), StreamTcpSetEvent, TCP_ESTABLISHED, TcpStream_::tcp_flags, TCP_GET_ACK, TCP_GET_HLEN, TCP_GET_SEQ, TCP_LAST_ACK, TCP_NONE, TcpSession_::tcp_packet_flags, Packet_::tcph, TH_ACK, TH_RST, TH_SYN, Flow_::thread_id, TOCLIENT, TOSERVER, TRUE, and unlikely.

Referenced by StreamTcp().

Here is the call graph for this function:

Here is the caller graph for this function:

Packet* StreamTcpPseudoSetup ( Packet parent,
uint8_t *  pkt,
uint32_t  len 
)

Function to fetch a packet from the packet allocation queue for creation of the pseudo packet from the reassembled stream.

Parameters
parentPointer to the parent of the pseudo packet
pktpointer to the raw packet of the parent
lenlength of the packet
Returns
upon success returns the pointer to the new pseudo packet otherwise NULL

Definition at line 5856 of file stream-tcp.c.

References Packet_::datalink, Packet_::dp, Packet_::dst, Packet_::flow, GET_PKT_DATA, GET_PKT_LEN, Packet_::ip4h, Packet_::ip6h, IPV4_GET_HLEN, IPV4_GET_IPLEN, IPV6_GET_PLEN, IPV6_HEADER_LEN, PacketCopyData(), PacketGetFromQueueOrAlloc(), Packet_::payload, Packet_::payload_len, PKT_IS_IPV4, PKT_IS_IPV6, Packet_::proto, PSEUDO_PKT_SET_IPV4HDR, PSEUDO_PKT_SET_IPV6HDR, PSEUDO_PKT_SET_TCPHDR, Packet_::recursion_level, Packet_::root, SCEnter, SCReturnPtr, SET_IPV4_DST_ADDR, SET_IPV4_SRC_ADDR, SET_IPV6_DST_ADDR, SET_IPV6_SRC_ADDR, SET_TCP_DST_PORT, SET_TCP_SRC_PORT, SET_TUNNEL_PKT, Packet_::sp, Packet_::src, Packet_::tcph, Packet_::ts, and TUNNEL_INCR_PKT_TPR.

Referenced by StreamTcpPseudoPacketCreateStreamEndPacket().

Here is the call graph for this function:

Here is the caller graph for this function:

void StreamTcpReassembleConfigEnableOverlapCheck ( void  )

Definition at line 38 of file stream-tcp-list.c.

References RB_GENERATE(), and TcpSegmentCompare().

Referenced by DetectEngineEventRegister(), and StreamTcpAppLayerIsDisabled().

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t StreamTcpReassembleMemuseGlobalCounter ( void  )

Definition at line 132 of file stream-tcp-reassemble.c.

References SC_ATOMIC_GET.

Referenced by RunModeUnixSocketGetDefaultMode(), StreamTcpReassembleDecrMemuse(), StreamTcpReassembleIncrMemuse(), StreamTcpReassembleInit(), and UtRunTests().

Here is the caller graph for this function:

void StreamTcpRegisterTests ( void  )

Definition at line 10757 of file stream-tcp.c.

References StreamTcpReassembleRegisterTests(), StreamTcpSackRegisterTests(), and UtRegisterTest().

Here is the call graph for this function:

int StreamTcpSegmentForEach ( const Packet p,
uint8_t  flag,
StreamSegmentCallback  CallbackFunc,
void *  data 
)

Run callback function on each TCP segment.

Note
when stream engine is running in inline mode all segments are used, in IDS/non-inline mode only ack'd segments are iterated.
Must be called under flow lock.
Returns
-1 in case of error, the number of segment in case of success

Definition at line 6227 of file stream-tcp.c.

References TcpSession_::client, TcpStreamCnf_::flags, Packet_::flow, FLOW_PKT_TOSERVER, TcpStream_::last_ack, Flow_::protoctx, RB_FOREACH, TcpStream_::sb, TcpSegment::sbseg, SCLogDebug, TcpStream_::seg_tree, TcpSegment::seq, SEQ_LT, TcpSession_::server, stream_config, StreamingBufferSegmentGetData(), and STREAMTCP_INIT_FLAG_INLINE.

Referenced by StreamSegmentForEach().

Here is the call graph for this function:

Here is the caller graph for this function:

void StreamTcpSessionCleanup ( TcpSession ssn)

Session cleanup function. Does not free the ssn.

Parameters
ssntcp session

Definition at line 215 of file stream-tcp.c.

References TcpSession_::client, TcpStateQueue_::next, TcpSession_::queue, TcpSession_::queue_len, SCEnter, SCFree, SCReturn, TcpSession_::server, StreamTcpDecrMemuse(), and StreamTcpStreamCleanup().

Referenced by StreamTcpSessionClear(), StreamTcpSessionPktFree(), StreamTcpUTClearSession(), and UTHRemoveSessionFromFlow().

Here is the call graph for this function:

Here is the caller graph for this function:

void StreamTcpSessionClear ( void *  ssnptr)

Function to return the stream back to the pool. It returns the segments in the stream to the segment pool.

This function is called when the flow is destroyed, so it should free everything related to the tcp session. So including the app layer data. We are guaranteed to only get here when the flow's use_cnt is 0.

Parameters
ssnVoid ptr to the ssn.

Definition at line 249 of file stream-tcp.c.

References PoolThreadReturn(), TcpSession_::res, SCEnter, SCMutexLock, SCMutexUnlock, SCReturn, and StreamTcpSessionCleanup().

Referenced by StreamTcpInitConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

void StreamTcpSessionPktFree ( Packet p)

Function to return the stream segments back to the pool.

We don't clear out the app layer storage here as that is under protection of the "use_cnt" reference counter in the flow. This function is called when the use_cnt is always at least 1 (this pkt has incremented the flow use_cnt itself), so we don't bother.

Parameters
pPacket used to identify the stream.

Definition at line 283 of file stream-tcp.c.

References TcpSession_::client, Packet_::flow, Flow_::protoctx, SCEnter, SCMalloc, SCReturn, TcpSession_::server, StreamTcpCheckMemcap(), StreamTcpDecrMemuse(), StreamTcpIncrMemuse(), StreamTcpReturnStreamSegments(), StreamTcpSessionCleanup(), and unlikely.

Referenced by StreamTcpPacket().

Here is the call graph for this function:

Here is the caller graph for this function:

int StreamTcpSetMemcap ( uint64_t  size)

Update memcap value.

Parameters
sizenew memcap value

Definition at line 181 of file stream-tcp.c.

References SC_ATOMIC_GET, SC_ATOMIC_SET, and stream_config.

Referenced by RunModeUnixSocketGetDefaultMode().

Here is the caller graph for this function:

void StreamTcpStreamCleanup ( TcpStream stream)

Definition at line 202 of file stream-tcp.c.

References TcpStream_::sb, StreamingBufferClear(), StreamTcpReturnStreamSegments(), and StreamTcpSackFreeList().

Referenced by StreamTcpSessionCleanup(), and StreamTcpUTClearStream().

Here is the call graph for this function:

Here is the caller graph for this function:

int TcpSessionPacketSsnReuse ( const Packet p,
const Flow f,
const void *  tcp_ssn 
)

Definition at line 5091 of file stream-tcp.c.

References Packet_::proto, and Packet_::tcph.

void TcpSessionSetReassemblyDepth ( TcpSession ssn,
uint32_t  size 
)

Definition at line 6288 of file stream-tcp.c.

References TcpSession_::reassembly_depth.

Referenced by AppLayerIncTxCounter(), and DetectFilestoreRegister().

Here is the caller graph for this function:

Variable Documentation