|
|
|
|
@ -1263,11 +1263,15 @@ static int StreamTcpPacketStateSynSent(ThreadVars *tv, Packet *p,
|
|
|
|
|
SEQ_EQ(TCP_GET_ACK(p), (ssn->client.isn + 1)))
|
|
|
|
|
{
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received and state changed to "
|
|
|
|
|
"TCP_CLOSED", ssn);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received and state changed to "
|
|
|
|
|
"TCP_CLOSED", ssn);
|
|
|
|
|
}
|
|
|
|
|
@ -1577,6 +1581,8 @@ static int StreamTcpPacketStateSynRecv(ThreadVars *tv, Packet *p,
|
|
|
|
|
|
|
|
|
|
if (reset == TRUE) {
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received and state changed to "
|
|
|
|
|
"TCP_CLOSED", ssn);
|
|
|
|
|
|
|
|
|
|
@ -2036,6 +2042,8 @@ static int StreamTcpPacketStateEstablished(ThreadVars *tv, Packet *p,
|
|
|
|
|
|
|
|
|
|
if(PKT_IS_TOSERVER(p)) {
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received and state changed to "
|
|
|
|
|
"TCP_CLOSED", ssn);
|
|
|
|
|
|
|
|
|
|
@ -2066,6 +2074,8 @@ static int StreamTcpPacketStateEstablished(ThreadVars *tv, Packet *p,
|
|
|
|
|
* cleanup. */
|
|
|
|
|
} else {
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received and state changed to "
|
|
|
|
|
"TCP_CLOSED", ssn);
|
|
|
|
|
|
|
|
|
|
@ -2146,6 +2156,7 @@ static int StreamTcpHandleFin(ThreadVars *tv, StreamTcpThread *stt,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSE_WAIT);
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: state changed to TCP_CLOSE_WAIT", ssn);
|
|
|
|
|
|
|
|
|
|
if (SEQ_EQ(TCP_GET_SEQ(p), ssn->client.next_seq))
|
|
|
|
|
@ -2193,6 +2204,7 @@ static int StreamTcpHandleFin(ThreadVars *tv, StreamTcpThread *stt,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_FIN_WAIT1);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: state changed to TCP_FIN_WAIT1", ssn);
|
|
|
|
|
|
|
|
|
|
if (SEQ_EQ(TCP_GET_SEQ(p), ssn->server.next_seq))
|
|
|
|
|
@ -2414,6 +2426,7 @@ static int StreamTcpPacketStateFinWait1(ThreadVars *tv, Packet *p,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_TIME_WAIT);
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: state changed to TCP_TIME_WAIT", ssn);
|
|
|
|
|
|
|
|
|
|
ssn->server.window = TCP_GET_WINDOW(p) << ssn->server.wscale;
|
|
|
|
|
@ -2463,6 +2476,7 @@ static int StreamTcpPacketStateFinWait1(ThreadVars *tv, Packet *p,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_TIME_WAIT);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: state changed to TCP_TIME_WAIT", ssn);
|
|
|
|
|
|
|
|
|
|
ssn->client.window = TCP_GET_WINDOW(p) << ssn->client.wscale;
|
|
|
|
|
@ -2504,6 +2518,8 @@ static int StreamTcpPacketStateFinWait1(ThreadVars *tv, Packet *p,
|
|
|
|
|
SCPerfCounterIncr(stt->counter_tcp_pseudo, tv->sc_perf_pca);
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
|
|
|
|
|
ssn);
|
|
|
|
|
|
|
|
|
|
@ -2689,6 +2705,8 @@ static int StreamTcpPacketStateFinWait2(ThreadVars *tv, Packet *p,
|
|
|
|
|
SCPerfCounterIncr(stt->counter_tcp_pseudo, tv->sc_perf_pca);
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
|
|
|
|
|
ssn);
|
|
|
|
|
|
|
|
|
|
@ -2759,6 +2777,7 @@ static int StreamTcpPacketStateFinWait2(ThreadVars *tv, Packet *p,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_TIME_WAIT);
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: state changed to TCP_TIME_WAIT", ssn);
|
|
|
|
|
|
|
|
|
|
ssn->server.window = TCP_GET_WINDOW(p) << ssn->server.wscale;
|
|
|
|
|
@ -2804,6 +2823,7 @@ static int StreamTcpPacketStateFinWait2(ThreadVars *tv, Packet *p,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_TIME_WAIT);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: state changed to TCP_TIME_WAIT", ssn);
|
|
|
|
|
|
|
|
|
|
ssn->client.window = TCP_GET_WINDOW(p) << ssn->client.wscale;
|
|
|
|
|
@ -2956,6 +2976,8 @@ static int StreamTcpPacketStateClosing(ThreadVars *tv, Packet *p,
|
|
|
|
|
SCPerfCounterIncr(stt->counter_tcp_pseudo, tv->sc_perf_pca);
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
|
|
|
|
|
ssn);
|
|
|
|
|
|
|
|
|
|
@ -3060,6 +3082,7 @@ static int StreamTcpPacketStateCloseWait(ThreadVars *tv, Packet *p,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_LAST_ACK);
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: state changed to TCP_LAST_ACK", ssn);
|
|
|
|
|
|
|
|
|
|
ssn->server.window = TCP_GET_WINDOW(p) << ssn->server.wscale;
|
|
|
|
|
@ -3102,6 +3125,7 @@ static int StreamTcpPacketStateCloseWait(ThreadVars *tv, Packet *p,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_LAST_ACK);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: state changed to TCP_LAST_ACK", ssn);
|
|
|
|
|
|
|
|
|
|
ssn->client.window = TCP_GET_WINDOW(p) << ssn->client.wscale;
|
|
|
|
|
@ -3232,6 +3256,8 @@ static int StreamTcpPacketStateCloseWait(ThreadVars *tv, Packet *p,
|
|
|
|
|
SCPerfCounterIncr(stt->counter_tcp_pseudo, tv->sc_perf_pca);
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
|
|
|
|
|
ssn);
|
|
|
|
|
|
|
|
|
|
@ -3355,6 +3381,8 @@ static int StreamTcpPakcetStateLastAck(ThreadVars *tv, Packet *p,
|
|
|
|
|
SCPerfCounterIncr(stt->counter_tcp_pseudo, tv->sc_perf_pca);
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
|
|
|
|
|
ssn);
|
|
|
|
|
|
|
|
|
|
@ -3522,6 +3550,8 @@ static int StreamTcpPacketStateTimeWait(ThreadVars *tv, Packet *p,
|
|
|
|
|
SCPerfCounterIncr(stt->counter_tcp_pseudo, tv->sc_perf_pca);
|
|
|
|
|
|
|
|
|
|
StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
|
|
|
|
|
ssn->server.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
ssn->client.flags |= STREAMTCP_STREAM_FLAG_CLOSE_INITIATED;
|
|
|
|
|
SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
|
|
|
|
|
ssn);
|
|
|
|
|
|
|
|
|
|
@ -3715,8 +3745,13 @@ static int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt,
|
|
|
|
|
if (ssn->state >= TCP_ESTABLISHED) {
|
|
|
|
|
p->flags |= PKT_STREAM_EST;
|
|
|
|
|
}
|
|
|
|
|
if (ssn->state > TCP_ESTABLISHED) {
|
|
|
|
|
p->flags |= PKT_STREAM_EOF;
|
|
|
|
|
|
|
|
|
|
if (PKT_IS_TOSERVER(p)) {
|
|
|
|
|
if (ssn->client.flags & STREAMTCP_STREAM_FLAG_CLOSE_INITIATED)
|
|
|
|
|
p->flags |= PKT_STREAM_EOF;
|
|
|
|
|
} else {
|
|
|
|
|
if (ssn->server.flags & STREAMTCP_STREAM_FLAG_CLOSE_INITIATED)
|
|
|
|
|
p->flags |= PKT_STREAM_EOF;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|