24#ifndef SURICATA_STREAM_TCP_PRIVATE_H
25#define SURICATA_STREAM_TCP_PRIVATE_H
30#define STREAMTCP_QUEUE_FLAG_TS 0x01
31#define STREAMTCP_QUEUE_FLAG_WS 0x02
32#define STREAMTCP_QUEUE_FLAG_SACK 0x04
58#define TCPSEG_PKT_HDR_DEFAULT_SIZE 64
94#define TCP_SEG_LEN(seg) (seg)->payload_len
95#define TCP_SEG_OFFSET(seg) (seg)->sbseg.stream_offset
97#define SEG_SEQ_RIGHT_EDGE(seg) ((seg)->seq + TCP_SEG_LEN((seg)))
101#define STREAM_SEQ_RIGHT_EDGE(stream) (stream)->segs_right_edge
102#define STREAM_RIGHT_EDGE(stream) (STREAM_BASE_OFFSET((stream)) + (STREAM_SEQ_RIGHT_EDGE((stream)) - (stream)->base_seq))
104#define STREAM_HAS_SEEN_DATA(stream) StreamingBufferHasData(&(stream)->sb)
144#define STREAM_BASE_OFFSET(stream) ((stream)->sb.region.stream_offset)
145#define STREAM_APP_PROGRESS(stream) (STREAM_BASE_OFFSET((stream)) + (stream)->app_progress_rel)
146#define STREAM_RAW_PROGRESS(stream) (STREAM_BASE_OFFSET((stream)) + (stream)->raw_progress_rel)
147#define STREAM_LOG_PROGRESS(stream) (STREAM_BASE_OFFSET((stream)) + (stream)->log_progress_rel)
170#define STREAMTCP_FLAG_MIDSTREAM BIT_U32(0)
172#define STREAMTCP_FLAG_MIDSTREAM_ESTABLISHED BIT_U32(1)
174#define STREAMTCP_FLAG_MIDSTREAM_SYNACK BIT_U32(2)
176#define STREAMTCP_FLAG_TIMESTAMP BIT_U32(3)
178#define STREAMTCP_FLAG_SERVER_WSCALE BIT_U32(4)
180#define STREAMTCP_FLAG_CLOSED_BY_RST BIT_U32(5)
182#define STREAMTCP_FLAG_ASYNC BIT_U32(6)
185#define STREAMTCP_FLAG_4WHS BIT_U32(7)
188#define STREAMTCP_FLAG_DETECTION_EVASION_ATTEMPT BIT_U32(8)
190#define STREAMTCP_FLAG_CLIENT_SACKOK BIT_U32(9)
192#define STREAMTCP_FLAG_SACKOK BIT_U32(10)
194#define STREAMTCP_FLAG_LOSSY_BE_LIBERAL BIT_U32(11)
199#define STREAMTCP_FLAG_3WHS_CONFIRMED BIT_U32(12)
201#define STREAMTCP_FLAG_APP_LAYER_DISABLED BIT_U32(13)
203#define STREAMTCP_FLAG_BYPASS BIT_U32(14)
205#define STREAMTCP_FLAG_TCP_FAST_OPEN BIT_U32(15)
207#define STREAMTCP_FLAG_TFO_DATA_IGNORED BIT_U32(16)
209#define STREAMTCP_FLAG_ZWP_TS BIT_U32(17)
210#define STREAMTCP_FLAG_ZWP_TC BIT_U32(18)
217#define STREAMTCP_STREAM_FLAG_HAS_GAP BIT_U16(0)
219#define STREAMTCP_STREAM_FLAG_NOREASSEMBLY BIT_U16(1)
221#define STREAMTCP_STREAM_FLAG_KEEPALIVE BIT_U16(2)
223#define STREAMTCP_STREAM_FLAG_DEPTH_REACHED BIT_U16(3)
225#define STREAMTCP_STREAM_FLAG_TRIGGER_RAW BIT_U16(4)
228#define STREAMTCP_STREAM_FLAG_TIMESTAMP BIT_U16(5)
230#define STREAMTCP_STREAM_FLAG_ZERO_TIMESTAMP BIT_U16(6)
232#define STREAMTCP_STREAM_FLAG_APPPROTO_DETECTION_COMPLETED BIT_U16(7)
234#define STREAMTCP_STREAM_FLAG_APPPROTO_DETECTION_SKIPPED BIT_U16(8)
236#define STREAMTCP_STREAM_FLAG_NEW_RAW_DISABLED BIT_U16(9)
238#define STREAMTCP_STREAM_FLAG_DISABLE_RAW BIT_U16(10)
240#define STREAMTCP_STREAM_FLAG_RST_RECV BIT_U16(11)
247#define PAWS_24DAYS 2073600
249#define PKT_IS_IN_RIGHT_DIR(ssn, p) ((ssn)->flags & STREAMTCP_FLAG_MIDSTREAM_SYNACK ? \
250 PKT_IS_TOSERVER(p) ? (p)->flowflags &= ~FLOW_PKT_TOSERVER \
251 (p)->flowflags |= FLOW_PKT_TOCLIENT : (p)->flowflags &= ~FLOW_PKT_TOCLIENT \
252 (p)->flowflags |= FLOW_PKT_TOSERVER : 0)
256#define SEQ_EQ(a,b) ((int32_t)((a) - (b)) == 0)
257#define SEQ_LT(a,b) ((int32_t)((a) - (b)) < 0)
258#define SEQ_LEQ(a,b) ((int32_t)((a) - (b)) <= 0)
259#define SEQ_GT(a,b) ((int32_t)((a) - (b)) > 0)
260#define SEQ_GEQ(a,b) ((int32_t)((a) - (b)) >= 0)
261#define SEQ_MIN(a, b) (SEQ_LT((a), (b)) ? (a) : (b))
262#define SEQ_MAX(a, b) (SEQ_GT((a), (b)) ? (a) : (b))
264#define STREAMTCP_SET_RA_BASE_SEQ(stream, seq) { \
266 (stream)->base_seq = (seq) + 1; \
270#define StreamTcpSetEvent(p, e) \
272 if ((p)->flags & PKT_STREAM_NO_EVENTS) { \
273 SCLogDebug("not setting event %d on pkt %p (%" PRIu64 "), " \
274 "stream in known bad condition", \
275 (e), p, (p)->pcap_cnt); \
277 SCLogDebug("setting event %d on pkt %p (%" PRIu64 ")", (e), p, (p)->pcap_cnt); \
278 ENGINE_SET_EVENT((p), (e)); \
279 p->l4.vars.tcp.stream_pkt_flags |= STREAM_PKT_FLAG_EVENTSET; \
301#define StreamTcpSetStreamFlagAppProtoDetectionCompleted(stream) \
302 ((stream)->flags |= STREAMTCP_STREAM_FLAG_APPPROTO_DETECTION_COMPLETED)
303#define StreamTcpIsSetStreamFlagAppProtoDetectionCompleted(stream) \
304 ((stream)->flags & STREAMTCP_STREAM_FLAG_APPPROTO_DETECTION_COMPLETED)
305#define StreamTcpResetStreamFlagAppProtoDetectionCompleted(stream) \
306 ((stream)->flags &= ~STREAMTCP_STREAM_FLAG_APPPROTO_DETECTION_COMPLETED);
307#define StreamTcpDisableAppLayerReassembly(ssn) do { \
308 SCLogDebug("setting STREAMTCP_FLAG_APP_LAYER_DISABLED on ssn %p", ssn); \
309 ((ssn)->flags |= STREAMTCP_FLAG_APP_LAYER_DISABLED); \
312#define STREAM_PKT_FLAG_RETRANSMISSION BIT_U16(0)
313#define STREAM_PKT_FLAG_SPURIOUS_RETRANSMISSION BIT_U16(1)
314#define STREAM_PKT_FLAG_STATE_UPDATE BIT_U16(2)
315#define STREAM_PKT_FLAG_KEEPALIVE BIT_U16(3)
316#define STREAM_PKT_FLAG_KEEPALIVEACK BIT_U16(4)
317#define STREAM_PKT_FLAG_WINDOWUPDATE BIT_U16(5)
318#define STREAM_PKT_FLAG_EVENTSET BIT_U16(6)
319#define STREAM_PKT_FLAG_DUP_ACK BIT_U16(7)
320#define STREAM_PKT_FLAG_DSACK BIT_U16(8)
321#define STREAM_PKT_FLAG_ACK_UNSEEN_DATA BIT_U16(9)
322#define STREAM_PKT_FLAG_TCP_SESSION_REUSE BIT_U16(10)
323#define STREAM_PKT_FLAG_TCP_ZERO_WIN_PROBE BIT_U16(11)
324#define STREAM_PKT_FLAG_TCP_ZERO_WIN_PROBE_ACK BIT_U16(12)
326#define STREAM_PKT_FLAG_SET(p, f) (p)->l4.vars.tcp.stream_pkt_flags |= (f)
struct PrefilterEngineFlowbits __attribute__
DNP3 application header.
struct TcpStream_ TcpStream
struct TcpSession_ TcpSession
int TcpSegmentCompare(struct TcpSegment *a, struct TcpSegment *b)
compare function for the Segment tree
int TcpSackCompare(struct StreamTcpSackRecord *a, struct StreamTcpSackRecord *b)
struct TcpSegmentPcapHdrStorage_ TcpSegmentPcapHdrStorage
struct TcpStateQueue_ TcpStateQueue
RB_ENTRY(StreamTcpSackRecord) rb
StreamingBufferSegment sbseg
RB_ENTRY(TcpSegment) __attribute__((__packed__)) rb
TcpSegmentPcapHdrStorage * pcap_hdr_storage
uint32_t reassembly_depth
int8_t data_first_seen_dir
struct TcpStateQueue_ * next
uint32_t log_progress_rel
uint32_t min_inspect_depth
uint32_t raw_progress_rel
uint32_t app_progress_rel
#define RB_PROTOTYPE(name, type, field, cmp)
#define RB_HEAD(name, type)