Feature #225 ยป 0001-added-the-counter-for-tcp.segment_memcap_drop-to-sho.patch
src/stream-tcp-reassemble.c | ||
---|---|---|
static uint32_t stream_reassembly_memuse_max;
|
||
/* prototypes */
|
||
static int HandleSegmentStartsBeforeListSegment(TcpStream *, TcpSegment *,
|
||
TcpSegment *);
|
||
static int HandleSegmentStartsAtSameListSegment(TcpStream *, TcpSegment *,
|
||
TcpSegment *);
|
||
static int HandleSegmentStartsAfterListSegment(TcpStream *, TcpSegment *,
|
||
TcpSegment *);
|
||
static int HandleSegmentStartsBeforeListSegment(ThreadVars *, TcpReassemblyThreadCtx *,
|
||
TcpStream *, TcpSegment *, TcpSegment *);
|
||
static int HandleSegmentStartsAtSameListSegment(ThreadVars *, TcpReassemblyThreadCtx *,
|
||
TcpStream *, TcpSegment *, TcpSegment *);
|
||
static int HandleSegmentStartsAfterListSegment(ThreadVars *, TcpReassemblyThreadCtx *,
|
||
TcpStream *, TcpSegment *, TcpSegment *);
|
||
void StreamTcpSegmentDataReplace(TcpSegment *, TcpSegment *, uint32_t, uint16_t);
|
||
void StreamTcpSegmentDataCopy(TcpSegment *, TcpSegment *);
|
||
TcpSegment* StreamTcpGetSegment(uint16_t);
|
||
TcpSegment* StreamTcpGetSegment(ThreadVars *tv, TcpReassemblyThreadCtx *, uint16_t);
|
||
void StreamTcpSegmentReturntoPool(TcpSegment *);
|
||
void StreamTcpCreateTestPacket(uint8_t *, uint8_t, uint8_t, uint8_t);
|
||
... | ... | |
* \retval -1 error
|
||
*/
|
||
static int ReassembleInsertSegment(TcpStream *stream, TcpSegment *seg, Packet *p)
|
||
static int ReassembleInsertSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
|
||
TcpStream *stream, TcpSegment *seg, Packet *p)
|
||
{
|
||
SCEnter();
|
||
... | ... | |
goto end;
|
||
/* seg overlap with next seg(s) */
|
||
} else {
|
||
ret_value = HandleSegmentStartsBeforeListSegment(stream, list_seg, seg);
|
||
ret_value = HandleSegmentStartsBeforeListSegment(tv, ra_ctx, stream, list_seg, seg);
|
||
if (ret_value == 1) {
|
||
ret_value = 0;
|
||
return_seg = TRUE;
|
||
... | ... | |
}
|
||
/* seg starts at same sequence number as list_seg */
|
||
} else if (SEQ_EQ(seg->seq, list_seg->seq)) {
|
||
ret_value = HandleSegmentStartsAtSameListSegment(stream, list_seg, seg);
|
||
ret_value = HandleSegmentStartsAtSameListSegment(tv, ra_ctx, stream, list_seg, seg);
|
||
if (ret_value == 1) {
|
||
ret_value = 0;
|
||
return_seg = TRUE;
|
||
... | ... | |
goto end;
|
||
}
|
||
} else {
|
||
ret_value = HandleSegmentStartsAfterListSegment(stream, list_seg, seg);
|
||
ret_value = HandleSegmentStartsAfterListSegment(tv, ra_ctx, stream, list_seg, seg);
|
||
if (ret_value == 1) {
|
||
ret_value = 0;
|
||
return_seg = TRUE;
|
||
... | ... | |
* \retval -1 error
|
||
*/
|
||
static int HandleSegmentStartsBeforeListSegment(TcpStream *stream,
|
||
TcpSegment *list_seg,
|
||
TcpSegment *seg)
|
||
static int HandleSegmentStartsBeforeListSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
|
||
TcpStream *stream, TcpSegment *list_seg, TcpSegment *seg)
|
||
{
|
||
SCEnter();
|
||
... | ... | |
" %" PRIu32 ", list->payload_len %" PRIu32 "",
|
||
packet_length, seg->payload_len, list_seg->payload_len);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(packet_length);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length);
|
||
if (new_seg == NULL) {
|
||
SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]);
|
||
SCReturnInt(-1);
|
||
... | ... | |
(list_seg->prev->seq + list_seg->prev->payload_len));
|
||
}
|
||
TcpSegment *new_seg = StreamTcpGetSegment(packet_length);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length);
|
||
if (new_seg == NULL) {
|
||
SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]);
|
||
SCReturnInt(-1);
|
||
... | ... | |
packet_length += (seg->seq + seg->payload_len) -
|
||
(list_seg->seq + list_seg->payload_len);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(packet_length);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length);
|
||
if (new_seg == NULL) {
|
||
SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]);
|
||
SCReturnInt(-1);
|
||
... | ... | |
packet_length += (seg->seq + seg->payload_len) -
|
||
(list_seg->seq + list_seg->payload_len);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(packet_length);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length);
|
||
if (new_seg == NULL) {
|
||
SCLogDebug("segment_pool[%"PRIu16"] is empty",
|
||
segment_pool_idx[packet_length]);
|
||
... | ... | |
* \retval -1 error
|
||
*/
|
||
static int HandleSegmentStartsAtSameListSegment(TcpStream *stream,
|
||
TcpSegment *list_seg,
|
||
TcpSegment *seg)
|
||
static int HandleSegmentStartsAtSameListSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
|
||
TcpStream *stream, TcpSegment *list_seg, TcpSegment *seg)
|
||
{
|
||
uint16_t overlap = 0;
|
||
uint16_t packet_length;
|
||
... | ... | |
SCLogDebug("packet_length %"PRIu16"", packet_length);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(packet_length);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length);
|
||
if (new_seg == NULL) {
|
||
SCLogDebug("egment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]);
|
||
return -1;
|
||
... | ... | |
* \retval -1 error
|
||
*/
|
||
static int HandleSegmentStartsAfterListSegment(TcpStream *stream,
|
||
TcpSegment *list_seg,
|
||
TcpSegment *seg)
|
||
static int HandleSegmentStartsAfterListSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
|
||
TcpStream *stream, TcpSegment *list_seg, TcpSegment *seg)
|
||
{
|
||
SCEnter();
|
||
uint16_t overlap = 0;
|
||
... | ... | |
}
|
||
SCLogDebug("packet_length %"PRIu16"", packet_length);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(packet_length);
|
||
TcpSegment *new_seg = StreamTcpGetSegment(tv, ra_ctx, packet_length);
|
||
if (new_seg == NULL) {
|
||
SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[packet_length]);
|
||
SCReturnInt(-1);
|
||
... | ... | |
SCReturnInt(ret);
|
||
}
|
||
int StreamTcpReassembleHandleSegmentHandleData(TcpSession *ssn,
|
||
TcpStream *stream, Packet *p)
|
||
int StreamTcpReassembleHandleSegmentHandleData(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
|
||
TcpSession *ssn, TcpStream *stream, Packet *p)
|
||
{
|
||
SCEnter();
|
||
... | ... | |
SCReturnInt(0);
|
||
}
|
||
TcpSegment *seg = StreamTcpGetSegment(p->payload_len);
|
||
TcpSegment *seg = StreamTcpGetSegment(tv, ra_ctx, p->payload_len);
|
||
if (seg == NULL) {
|
||
SCLogDebug("segment_pool[%"PRIu16"] is empty", segment_pool_idx[p->payload_len]);
|
||
SCReturnInt(-1);
|
||
... | ... | |
seg->prev = NULL;
|
||
stream->reassembly_depth += p->payload_len;
|
||
if (ReassembleInsertSegment(stream, seg, p) != 0) {
|
||
if (ReassembleInsertSegment(tv, ra_ctx, stream, seg, p) != 0) {
|
||
SCLogDebug("ReassembleInsertSegment failed");
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
SCReturnInt(r);
|
||
}
|
||
int StreamTcpReassembleHandleSegment(TcpReassemblyThreadCtx *ra_ctx,
|
||
int StreamTcpReassembleHandleSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx,
|
||
TcpSession *ssn, TcpStream *stream,
|
||
Packet *p)
|
||
{
|
||
... | ... | |
{
|
||
SCLogDebug("calling StreamTcpReassembleHandleSegmentHandleData");
|
||
if (StreamTcpReassembleHandleSegmentHandleData(ssn, stream, p) != 0) {
|
||
if (StreamTcpReassembleHandleSegmentHandleData(tv, ra_ctx, ssn, stream, p) != 0) {
|
||
SCLogDebug("StreamTcpReassembleHandleSegmentHandleData error");
|
||
SCReturnInt(-1);
|
||
}
|
||
... | ... | |
* \param len Length which tells the required size of needed segment.
|
||
*/
|
||
TcpSegment* StreamTcpGetSegment(uint16_t len)
|
||
TcpSegment* StreamTcpGetSegment(ThreadVars *tv, TcpReassemblyThreadCtx *ra_ctx, uint16_t len)
|
||
{
|
||
uint16_t idx = segment_pool_idx[len];
|
||
SCLogDebug("segment_pool_idx %" PRIu32 " for payload_len %" PRIu32 "",
|
||
... | ... | |
SCLogDebug("segment_pool[%u]->empty_list_size %u, "
|
||
"alloc %u", idx, segment_pool[idx]->empty_list_size,
|
||
segment_pool[idx]->allocated);
|
||
/* Increment the counter to show that we are not able to serve the
|
||
segment request due to memcap limit */
|
||
SCPerfCounterIncr(ra_ctx->counter_tcp_segment_memcap, tv->sc_perf_pca);
|
||
} else {
|
||
#ifdef DEBUG
|
||
SCMutexLock(&segment_pool_cnt_mutex);
|
||
... | ... | |
memset(&p, 0, sizeof (Packet));
|
||
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x42, 2, 4); /*BB*/
|
||
p.tcph->th_seq = htonl(16);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x43, 3, 4); /*CCC*/
|
||
p.tcph->th_seq = htonl(18);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x44, 1, 4); /*D*/
|
||
p.tcph->th_seq = htonl(22);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x45, 2, 4); /*EE*/
|
||
p.tcph->th_seq = htonl(25);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x46, 3, 4); /*FFF*/
|
||
p.tcph->th_seq = htonl(27);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x47, 2, 4); /*GG*/
|
||
p.tcph->th_seq = htonl(30);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x48, 2, 4); /*HH*/
|
||
p.tcph->th_seq = htonl(32);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x49, 1, 4); /*I*/
|
||
p.tcph->th_seq = htonl(34);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4a, 4, 4); /*JJJJ*/
|
||
p.tcph->th_seq = htonl(13);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 4;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4b, 3, 4); /*KKK*/
|
||
p.tcph->th_seq = htonl(18);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4c, 3, 4); /*LLL*/
|
||
p.tcph->th_seq = htonl(21);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4d, 3, 4); /*MMM*/
|
||
p.tcph->th_seq = htonl(24);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4e, 1, 4); /*N*/
|
||
p.tcph->th_seq = htonl(28);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4f, 1, 4); /*O*/
|
||
p.tcph->th_seq = htonl(31);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x50, 1, 4); /*P*/
|
||
p.tcph->th_seq = htonl(32);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x51, 2, 4); /*QQ*/
|
||
p.tcph->th_seq = htonl(34);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x30, 1, 4); /*0*/
|
||
p.tcph->th_seq = htonl(11);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpReassembleFreeThreadCtx(ra_ctx);
|
||
... | ... | |
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x44, 1, 4); /*D*/
|
||
p.tcph->th_seq = htonl(22);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x45, 2, 4); /*EE*/
|
||
p.tcph->th_seq = htonl(25);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x41, 2, 4); /*AA*/
|
||
p.tcph->th_seq = htonl(15);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4a, 4, 4); /*JJJJ*/
|
||
p.tcph->th_seq = htonl(14);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 4;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4c, 3, 4); /*LLL*/
|
||
p.tcph->th_seq = htonl(21);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4d, 3, 4); /*MMM*/
|
||
p.tcph->th_seq = htonl(24);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
return 1;
|
||
... | ... | |
memset(&p, 0, sizeof (Packet));
|
||
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x48, 2, 4); /*HH*/
|
||
p.tcph->th_seq = htonl(32);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x49, 1, 4); /*I*/
|
||
p.tcph->th_seq = htonl(34);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4b, 3, 4); /*KKK*/
|
||
p.tcph->th_seq = htonl(18);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4c, 4, 4); /*LLLL*/
|
||
p.tcph->th_seq = htonl(18);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 4;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x50, 1, 4); /*P*/
|
||
p.tcph->th_seq = htonl(32);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x51, 2, 4); /*QQ*/
|
||
p.tcph->th_seq = htonl(34);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
return 1;
|
||
... | ... | |
memset(&p, 0, sizeof (Packet));
|
||
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x46, 3, 4); /*FFF*/
|
||
p.tcph->th_seq = htonl(27);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 3;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x47, 2, 4); /*GG*/
|
||
p.tcph->th_seq = htonl(30);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4a, 2, 4); /*JJ*/
|
||
p.tcph->th_seq = htonl(13);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 2;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4f, 1, 4); /*O*/
|
||
p.tcph->th_seq = htonl(31);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpCreateTestPacket(payload, 0x4e, 1, 4); /*N*/
|
||
p.tcph->th_seq = htonl(28);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload = payload;
|
||
p.payload_len = 1;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, stream, &p) == -1)
|
||
return 0;
|
||
return 1;
|
||
... | ... | |
memset(&tcph, 0, sizeof (TCPHdr));
|
||
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
inet_pton(AF_INET, "1.2.3.4", &in);
|
||
... | ... | |
s = &ssn->client;
|
||
}
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, ssn, s, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, ssn, s, &p) == -1)
|
||
return -1;
|
||
return 0;
|
||
... | ... | |
memset(&p, 0, sizeof (Packet));
|
||
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
p.payload_len = 10;
|
||
StreamTcpCreateTestPacket(payload, 0x41, 10, 20); /*AA*/
|
||
p.payload = payload;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
goto end;
|
||
p.tcph->th_seq = htonl(20);
|
||
... | ... | |
p.payload_len = 10;
|
||
StreamTcpCreateTestPacket(payload, 0x42, 10, 20); /*BB*/
|
||
p.payload = payload;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
goto end;
|
||
p.tcph->th_seq = htonl(40);
|
||
... | ... | |
p.payload_len = 10;
|
||
StreamTcpCreateTestPacket(payload, 0x43, 10, 20); /*CC*/
|
||
p.payload = payload;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
goto end;
|
||
p.tcph->th_seq = htonl(5);
|
||
... | ... | |
p.payload_len = 20;
|
||
StreamTcpCreateTestPacket(payload, 0x41, 20, 20); /*AA*/
|
||
p.payload = payload;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
goto end;
|
||
if (StreamTcpCheckStreamContents(check_contents, 35, &stream) != 0) {
|
||
... | ... | |
memset(&p, 0, sizeof (Packet));
|
||
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
p.tcph->th_ack = htonl(31);
|
||
p.payload_len = 10;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(20);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload_len = 10;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(40);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload_len = 10;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(5);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload_len = 30;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpFreeConfig(TRUE);
|
||
... | ... | |
memset(&p, 0, sizeof (Packet));
|
||
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
p.tcph->th_ack = htonl(31);
|
||
p.payload_len = 304;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(857961534);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload_len = 1460;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(857963582);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload_len = 1460;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(857960946);
|
||
p.tcph->th_ack = htonl(31);
|
||
p.payload_len = 1460;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpFreeConfig(TRUE);
|
||
... | ... | |
memset(&p, 0, sizeof (Packet));
|
||
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
stream.last_ack = 2257022285UL;
|
||
stream.ra_base_seq = 2257022172UL;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(2257022285UL);
|
||
... | ... | |
stream.last_ack = 2257022285UL;
|
||
stream.ra_base_seq = 2257022172UL;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpFreeConfig(TRUE);
|
||
... | ... | |
memset(&p, 0, sizeof (Packet));
|
||
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
stream.last_ack = 1549589007;
|
||
stream.ra_base_seq = 1549589101;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(1549589007);
|
||
... | ... | |
stream.last_ack = 1549589007;
|
||
stream.ra_base_seq = 1549589101;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpFreeConfig(TRUE);
|
||
... | ... | |
memset(&p, 0, sizeof (Packet));
|
||
memset(&f, 0, sizeof (Flow));
|
||
memset(&tcph, 0, sizeof (TCPHdr));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
f.protoctx = &ssn;
|
||
p.src.family = AF_INET;
|
||
... | ... | |
stream.last_ack = 3061091137UL;
|
||
stream.ra_base_seq = 3061091309UL;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(3061089928UL);
|
||
... | ... | |
stream.last_ack = 3061091137UL;
|
||
stream.ra_base_seq = 3061091309UL;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
p.tcph->th_seq = htonl(3061091319UL);
|
||
... | ... | |
stream.last_ack = 3061091137UL;
|
||
stream.ra_base_seq = 3061091309UL;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx,&ssn, &stream, &p) == -1)
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx,&ssn, &stream, &p) == -1)
|
||
return 0;
|
||
StreamTcpFreeConfig(TRUE);
|
||
... | ... | |
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
memset(&ssn, 0, sizeof(TcpSession));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
/* prevent L7 from kicking in */
|
||
StreamMsgQueueSetMinInitChunkLen(FLOW_PKT_TOSERVER, 0);
|
||
... | ... | |
TcpStream *s = NULL;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(55);
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_seq = htonl(55);
|
||
tcph.th_ack = htonl(53);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_seq = htonl(53);
|
||
tcph.th_ack = htonl(100);
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(53);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
memset(&ssn, 0, sizeof(TcpSession));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
StreamTcpInitConfig(TRUE);
|
||
... | ... | |
TcpStream *s = NULL;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(55);
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_seq = htonl(55);
|
||
tcph.th_ack = htonl(53);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_seq = htonl(53);
|
||
tcph.th_ack = htonl(100);
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_seq = htonl(100);
|
||
tcph.th_ack = htonl(96);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
memset(&ssn, 0, sizeof(TcpSession));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
StreamTcpInitConfig(TRUE);
|
||
... | ... | |
TcpStream *s = NULL;
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
s = &ssn.server;
|
||
ssn.server.last_ack = 11;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
s = &ssn.client;
|
||
ssn.client.last_ack = 55;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
s = &ssn.server;
|
||
ssn.server.last_ack = 12;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
s = &ssn.client;
|
||
ssn.client.last_ack = 100;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
s = &ssn.server;
|
||
ssn.server.last_ack = 13;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
s = &ssn.client;
|
||
ssn.client.last_ack = 145;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
s = &ssn.server;
|
||
ssn.server.last_ack = 16;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
memset(&ssn, 0, sizeof(TcpSession));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
StreamTcpInitConfig(TRUE);
|
||
... | ... | |
TcpStream *s = NULL;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet: ");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(55);
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet: ");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(100);
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet: ");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(522);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet: ");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(522);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet: ");
|
||
goto end;
|
||
}
|
||
... | ... | |
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
memset(&ssn, 0, sizeof(TcpSession));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
StreamTcpInitConfig(TRUE);
|
||
... | ... | |
TcpStream *s = NULL;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(55);
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(53);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(53);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
memset(&ssn, 0, sizeof(TcpSession));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
FLOW_INITIALIZE(&f);
|
||
StreamTcpInitConfig(TRUE);
|
||
... | ... | |
TcpStream *s = NULL;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(55);
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(44);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(100);
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
tcph.th_ack = htonl(53);
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
memset(&ssn, 0, sizeof(TcpSession));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
uint8_t httpbuf1[] = "/ HTTP/1.0\r\nUser-Agent: Victor/1.0";
|
||
... | ... | |
TcpStream *s = NULL;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toclient packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
p.payload_len = httplen1;
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
p.payload_len = httplen1;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
memset(&ssn, 0, sizeof(TcpSession));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
uint8_t httpbuf1[] = "/ HTTP/1.0\r\nUser-Agent: Victor/1.0";
|
||
... | ... | |
TcpStream *s = NULL;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toclient packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
p.payload_len = httplen1;
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
p.payload_len = httplen1;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver packet\n");
|
||
goto end;
|
||
}
|
||
... | ... | |
memset(&src, 0, sizeof(Address));
|
||
memset(&dst, 0, sizeof(Address));
|
||
memset(&ssn, 0, sizeof(TcpSession));
|
||
ThreadVars tv;
|
||
memset(&tv, 0, sizeof (ThreadVars));
|
||
/* prevent L7 from kicking in */
|
||
StreamMsgQueueSetMinInitChunkLen(FLOW_PKT_TOSERVER, 0);
|
||
... | ... | |
p.payload_len = 1;
|
||
s = &ssn.client;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver "
|
||
"packet\n");
|
||
goto end;
|
||
... | ... | |
p.tcph = &tcph;
|
||
s = &ssn.server;
|
||
if (StreamTcpReassembleHandleSegment(ra_ctx, &ssn, s, &p) == -1) {
|
||
if (StreamTcpReassembleHandleSegment(&tv, ra_ctx, &ssn, s, &p) == -1) {
|
||
printf("failed in segments reassembly, while processing toserver "
|
||
"packet\n");
|
||
goto end;
|
src/stream-tcp-reassemble.h | ||
---|---|---|
typedef struct TcpReassemblyThreadCtx_ {
|
||
StreamMsgQueue *stream_q;
|
||
AlpProtoDetectThreadCtx dp_ctx; /**< proto detection thread data */
|
||
/** TCP segments which are not being reassembled due to memcap was reached */
|
||
uint16_t counter_tcp_segment_memcap;
|
||
} TcpReassemblyThreadCtx;
|
||
#define OS_POLICY_DEFAULT OS_POLICY_BSD
|
||
int StreamTcpReassembleHandleSegment(TcpReassemblyThreadCtx *, TcpSession *, TcpStream *, Packet *);
|
||
int StreamTcpReassembleHandleSegment(ThreadVars *, TcpReassemblyThreadCtx *, TcpSession *, TcpStream *, Packet *);
|
||
int StreamTcpReassembleInit(char);
|
||
void StreamTcpReassembleFree(char);
|
||
void StreamTcpReassembleRegisterTests(void);
|
src/stream-tcp.c | ||
---|---|---|
TmEcode StreamTcpThreadDeinit(ThreadVars *, void *);
|
||
void StreamTcpExitPrintStats(ThreadVars *, void *);
|
||
static int ValidReset(TcpSession * , Packet *);
|
||
static int StreamTcpHandleFin(StreamTcpThread *, TcpSession *, Packet *);
|
||
static int StreamTcpHandleFin(ThreadVars *tv, StreamTcpThread *, TcpSession *, Packet *);
|
||
void StreamTcpRegisterTests (void);
|
||
void StreamTcpReturnStreamSegments (TcpStream *);
|
||
void StreamTcpInitConfig(char);
|
||
... | ... | |
ssn->client.last_ts = 0;
|
||
}
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn, &ssn->client, p);
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn, &ssn->client, p);
|
||
break;
|
||
case TH_RST:
|
||
... | ... | |
ssn->client.next_win = ssn->client.last_ack +
|
||
ssn->client.window;
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn,
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
|
||
&ssn->server, p);
|
||
} else {
|
||
SCLogDebug("ssn %p: 4WHS wrong seq nr on packet", ssn);
|
||
... | ... | |
ssn->client.wscale = TCP_WSCALE_MAX;
|
||
}
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn,
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
|
||
&ssn->client, p);
|
||
/* If asynchronous stream handling is allowed then set the session,
|
||
... | ... | |
, ssn, TCP_GET_SEQ(p), p->payload_len, TCP_GET_SEQ(p)
|
||
+ p->payload_len, ssn->server.next_seq);
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn,
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
|
||
&ssn->server, p);
|
||
/* Upon receiving the packet with correct seq number and wrong
|
||
ACK number, it causes the other end to send RST. But some target
|
||
... | ... | |
return -1;
|
||
}
|
||
if((StreamTcpHandleFin(stt, ssn, p)) == -1)
|
||
if((StreamTcpHandleFin(tv, stt, ssn, p)) == -1)
|
||
return -1;
|
||
break;
|
||
default:
|
||
... | ... | |
/**
|
||
* \brief Function to handle the TCP_ESTABLISHED state packets, which are
|
||
* sent by the client to server. The function handles
|
||
* ACK packets and call StreamTcpReassembleHandleSegment() to handle
|
||
* ACK packets and call StreamTcpReassembleHandleSegment(tv, ) to handle
|
||
* the reassembling.
|
||
*
|
||
* \param tv Thread Variable containig input/output queue, cpu affinity etc.
|
||
* \param ssn Pointer to the current TCP session
|
||
* \param p Packet which has to be handled in this TCP state.
|
||
* \param stt Strean Thread module registered to handle the stream handling
|
||
*/
|
||
static int HandleEstablishedPacketToServer(TcpSession *ssn, Packet *p,
|
||
static int HandleEstablishedPacketToServer(ThreadVars *tv, TcpSession *ssn, Packet *p,
|
||
StreamTcpThread *stt)
|
||
{
|
||
SCLogDebug("ssn %p: =+ pkt (%" PRIu32 ") is to server: SEQ %" PRIu32 ","
|
||
... | ... | |
ssn->server.next_win, ssn->server.window);
|
||
}
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn, &ssn->client, p);
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn, &ssn->client, p);
|
||
} else {
|
||
SCLogDebug("ssn %p: toserver => SEQ out of window, packet SEQ "
|
||
"%" PRIu32 ", payload size %" PRIu32 " (%" PRIu32 "),"
|
||
... | ... | |
/**
|
||
* \brief Function to handle the TCP_ESTABLISHED state packets, which are
|
||
* sent by the server to client. The function handles
|
||
* ACK packets and call StreamTcpReassembleHandleSegment() to handle
|
||
* ACK packets and call StreamTcpReassembleHandleSegment(tv, ) to handle
|
||
* the reassembling.
|
||
*
|
||
* \param tv Thread Variable containig input/output queue, cpu affinity etc.
|
||
* \param ssn Pointer to the current TCP session
|
||
* \param p Packet which has to be handled in this TCP state.
|
||
* \param stt Strean Thread module registered to handle the stream handling
|
||
*/
|
||
static int HandleEstablishedPacketToClient(TcpSession *ssn, Packet *p,
|
||
static int HandleEstablishedPacketToClient(ThreadVars *tv, TcpSession *ssn, Packet *p,
|
||
StreamTcpThread *stt)
|
||
{
|
||
SCLogDebug("ssn %p: =+ pkt (%" PRIu32 ") is to client: SEQ %" PRIu32 ","
|
||
... | ... | |
TCP_GET_SEQ(p),ssn->client.next_win, ssn->client.window);
|
||
}
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn, &ssn->server, p);
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn, &ssn->server, p);
|
||
} else {
|
||
SCLogDebug("ssn %p: client => SEQ out of window, packet SEQ"
|
||
"%" PRIu32 ", payload size %" PRIu32 " (%" PRIu32 "),"
|
||
... | ... | |
* \brief Function to handle the TCP_ESTABLISHED state. The function handles
|
||
* ACK, FIN, RST packets and correspondingly changes the connection
|
||
* state. The function handles the data inside packets and call
|
||
* StreamTcpReassembleHandleSegment() to handle the reassembling.
|
||
* StreamTcpReassembleHandleSegment(tv, ) to handle the reassembling.
|
||
*
|
||
* \param tv Thread Variable containig input/output queue, cpu affinity etc.
|
||
* \param p Packet which has to be handled in this TCP state.
|
||
... | ... | |
if (PKT_IS_TOSERVER(p)) {
|
||
/* Process the received packet to server */
|
||
HandleEstablishedPacketToServer(ssn, p, stt);
|
||
HandleEstablishedPacketToServer(tv, ssn, p, stt);
|
||
SCLogDebug("ssn %p: next SEQ %" PRIu32 ", last ACK %" PRIu32 ","
|
||
" next win %" PRIu32 ", win %" PRIu32 "", ssn,
|
||
... | ... | |
} else { /* implied to client */
|
||
/* Process the received packet to client */
|
||
HandleEstablishedPacketToClient(ssn, p, stt);
|
||
HandleEstablishedPacketToClient(tv, ssn, p, stt);
|
||
SCLogDebug("ssn %p: next SEQ %" PRIu32 ", last ACK %" PRIu32 ","
|
||
" next win %" PRIu32 ", win %" PRIu32 "", ssn,
|
||
... | ... | |
ssn->client.last_ack, ssn->server.next_win,
|
||
ssn->server.window);
|
||
if((StreamTcpHandleFin(stt, ssn, p)) == -1)
|
||
if((StreamTcpHandleFin(tv, stt, ssn, p)) == -1)
|
||
return -1;
|
||
break;
|
||
case TH_RST:
|
||
... | ... | |
if (SEQ_GT(TCP_GET_ACK(p),ssn->server.last_ack))
|
||
ssn->server.last_ack = TCP_GET_ACK(p);
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn,
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
|
||
&ssn->client, p);
|
||
SCLogDebug("ssn %p: =+ next SEQ %" PRIu32 ", last ACK "
|
||
"%" PRIu32 "", ssn, ssn->client.next_seq,
|
||
... | ... | |
if (SEQ_GT(TCP_GET_ACK(p),ssn->client.last_ack))
|
||
ssn->client.last_ack = TCP_GET_ACK(p);
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn,
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
|
||
&ssn->server, p);
|
||
SCLogDebug("ssn %p: =+ next SEQ %" PRIu32 ", last ACK "
|
||
"%" PRIu32 "", ssn, ssn->server.next_seq,
|
||
... | ... | |
* \param stt Strean Thread module registered to handle the stream handling
|
||
*/
|
||
static int StreamTcpHandleFin(StreamTcpThread *stt, TcpSession *ssn, Packet *p)
|
||
static int StreamTcpHandleFin(ThreadVars *tv, StreamTcpThread *stt, TcpSession *ssn, Packet *p)
|
||
{
|
||
if (PKT_IS_TOSERVER(p)) {
|
||
... | ... | |
if (SEQ_GT(TCP_GET_ACK(p),ssn->server.last_ack))
|
||
ssn->server.last_ack = TCP_GET_ACK(p);
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn, &ssn->client, p);
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn, &ssn->client, p);
|
||
SCLogDebug("ssn %p: =+ next SEQ %" PRIu32 ", last ACK %" PRIu32 "",
|
||
ssn, ssn->client.next_seq, ssn->server.last_ack);
|
||
... | ... | |
if (SEQ_GT(TCP_GET_ACK(p),ssn->client.last_ack))
|
||
ssn->client.last_ack = TCP_GET_ACK(p);
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn, &ssn->server, p);
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn, &ssn->server, p);
|
||
SCLogDebug("ssn %p: =+ next SEQ %" PRIu32 ", last ACK %" PRIu32 "",
|
||
ssn, ssn->server.next_seq, ssn->client.last_ack);
|
||
... | ... | |
if (SEQ_GT(TCP_GET_ACK(p),ssn->server.last_ack))
|
||
ssn->server.last_ack = TCP_GET_ACK(p);
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn,
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
|
||
&ssn->client, p);
|
||
if (SEQ_EQ(ssn->client.next_seq, TCP_GET_SEQ(p))) {
|
||
... | ... | |
if (SEQ_GT(TCP_GET_ACK(p),ssn->client.last_ack))
|
||
ssn->client.last_ack = TCP_GET_ACK(p);
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn,
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
|
||
&ssn->server, p);
|
||
if (SEQ_EQ(ssn->server.next_seq, TCP_GET_SEQ(p))) {
|
||
... | ... | |
if (SEQ_GT(TCP_GET_ACK(p),ssn->server.last_ack))
|
||
ssn->server.last_ack = TCP_GET_ACK(p);
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn,
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
|
||
&ssn->client, p);
|
||
if (SEQ_EQ(ssn->client.next_seq, TCP_GET_SEQ(p))) {
|
||
... | ... | |
if (SEQ_GT(TCP_GET_ACK(p),ssn->client.last_ack))
|
||
ssn->client.last_ack = TCP_GET_ACK(p);
|
||
StreamTcpReassembleHandleSegment(stt->ra_ctx, ssn,
|
||
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
|
||
&ssn->server, p);
|
||
if (SEQ_EQ(ssn->server.next_seq, TCP_GET_SEQ(p))) {
|