stream-tcp-list.c File Reference
#include "suricata-common.h"
#include "rust.h"
#include "stream-tcp-private.h"
#include "stream-tcp.h"
#include "stream-tcp-reassemble.h"
#include "stream-tcp-inline.h"
#include "stream-tcp-list.h"
#include "util-streaming-buffer.h"
#include "util-print.h"
#include "util-validate.h"
#include "app-layer-frames.h"
#include "tests/stream-tcp-list.c"
Include dependency graph for stream-tcp-list.c:

Go to the source code of this file.


void StreamTcpReassembleConfigEnableOverlapCheck (void)
 RB_GENERATE (TCPSEG, TcpSegment, rb, TcpSegmentCompare)
int TcpSegmentCompare (struct TcpSegment *a, struct TcpSegment *b)
 compare function for the Segment tree More...
int StreamTcpReassembleInsertSegment (ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, TcpStream *stream, TcpSegment *seg, Packet *p, uint32_t pkt_seq, uint8_t *pkt_data, uint16_t pkt_datalen)
void StreamTcpPruneSession (Flow *f, uint8_t flags)
 Remove idle TcpSegments from TcpSession. More...

Detailed Description

Segment list functions for insertions, overlap handling, removal and more.

Definition in file stream-tcp-list.c.

Function Documentation


TcpSegment  ,
rb  ,

◆ StreamTcpPruneSession()

void StreamTcpPruneSession ( Flow f,
uint8_t  flags 

Remove idle TcpSegments from TcpSession.

Checks app progress and raw progress and progresses them if needed, slides the streaming buffer, then gets rid of excess segments.

flagsdirection flags

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

References TcpSession_::client, flags, TcpStream_::flags, TcpSession_::flags, Flow_::protoctx, TcpStream_::sb, TcpStreamCnf_::sbcnf, SCEnter, SCLogDebug, SCReturn, TcpSession_::server, stream_config, StreamingBufferClear(), STREAMTCP_FLAG_APP_LAYER_DISABLED, STREAMTCP_STREAM_FLAG_DEPTH_REACHED, STREAMTCP_STREAM_FLAG_DISABLE_RAW, STREAMTCP_STREAM_FLAG_NOREASSEMBLY, and StreamTcpReturnStreamSegments().

Here is the call graph for this function:

◆ StreamTcpReassembleConfigEnableOverlapCheck()

void StreamTcpReassembleConfigEnableOverlapCheck ( void  )

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

◆ StreamTcpReassembleInsertSegment()

int StreamTcpReassembleInsertSegment ( ThreadVars tv,
TcpReassemblyThreadCtx ra_ctx,
TcpStream stream,
TcpSegment seg,
Packet p,
uint32_t  pkt_seq,
uint8_t *  pkt_data,
uint16_t  pkt_datalen 
0 ok
-1 segment not inserted due to memcap issue
segsegment, this function takes total ownership

In case of error, this function returns the segment to the pool

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

References SCEnter.

Referenced by StreamTcpUTAddSegmentWithByte(), and StreamTcpUTAddSegmentWithPayload().

Here is the caller graph for this function:

◆ TcpSegmentCompare()

int TcpSegmentCompare ( struct TcpSegment a,
struct TcpSegment b 

compare function for the Segment tree

Main sort point is the sequence number. When sequence numbers are equal compare payload_len as well. This way the tree is sorted by seq, and in case of duplicate seqs we are sorted small to large.

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

References TcpSegment::payload_len, TcpSegment::seq, SEQ_GT, and SEQ_LT.