} \
}
+static inline void StreamTcpCloseSsnWithReset(Packet *p, TcpSession *ssn)
+{
+ ssn->flags |= STREAMTCP_FLAG_CLOSED_BY_RST;
+ StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
+ SCLogDebug("ssn %p: (state: %s) Reset received and state changed to "
+ "TCP_CLOSED", ssn, StreamTcpStateAsString(ssn->state));
+}
+
static int StreamTcpPacketIsRetransmission(TcpStream *stream, Packet *p)
{
if (p->payload_len == 0)
{
SCLogDebug("ssn->server.flags |= STREAMTCP_STREAM_FLAG_RST_RECV");
ssn->server.flags |= STREAMTCP_STREAM_FLAG_RST_RECV;
-
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received and state changed to "
- "TCP_CLOSED", ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
}
} else {
ssn->client.flags |= STREAMTCP_STREAM_FLAG_RST_RECV;
SCLogDebug("ssn->client.flags |= STREAMTCP_STREAM_FLAG_RST_RECV");
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received and state changed to "
- "TCP_CLOSED", ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
}
/* FIN */
}
if (reset == TRUE) {
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received and state changed to "
- "TCP_CLOSED", ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
if (ssn->flags & STREAMTCP_FLAG_TIMESTAMP) {
StreamTcpHandleTimestamp(ssn, p);
return -1;
if (PKT_IS_TOSERVER(p)) {
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received and state changed to "
- "TCP_CLOSED", ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
ssn->server.next_seq = TCP_GET_ACK(p);
ssn->client.next_seq = TCP_GET_SEQ(p) + p->payload_len;
* packet will take care, otherwise the normal session
* cleanup. */
} else {
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received and state changed to "
- "TCP_CLOSED", ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
ssn->server.next_seq = TCP_GET_SEQ(p) + p->payload_len + 1;
ssn->client.next_seq = TCP_GET_ACK(p);
if (!StreamTcpValidateRst(ssn, p))
return -1;
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
- ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
if (PKT_IS_TOSERVER(p)) {
if ((p->tcph->th_flags & TH_ACK) && StreamTcpValidateAck(ssn, &ssn->server, p) == 0)
if (!StreamTcpValidateRst(ssn, p))
return -1;
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
- ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
if (PKT_IS_TOSERVER(p)) {
if ((p->tcph->th_flags & TH_ACK) && StreamTcpValidateAck(ssn, &ssn->server, p) == 0)
if (!StreamTcpValidateRst(ssn, p))
return -1;
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
- ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
if (PKT_IS_TOSERVER(p)) {
if ((p->tcph->th_flags & TH_ACK) && StreamTcpValidateAck(ssn, &ssn->server, p) == 0)
if (!StreamTcpValidateRst(ssn, p))
return -1;
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
- ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
if (PKT_IS_TOSERVER(p)) {
if ((p->tcph->th_flags & TH_ACK) && StreamTcpValidateAck(ssn, &ssn->server, p) == 0)
if (!StreamTcpValidateRst(ssn, p))
return -1;
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
- ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
if (PKT_IS_TOSERVER(p)) {
if ((p->tcph->th_flags & TH_ACK) && StreamTcpValidateAck(ssn, &ssn->server, p) == 0)
if (!StreamTcpValidateRst(ssn, p))
return -1;
- StreamTcpPacketSetState(p, ssn, TCP_CLOSED);
- SCLogDebug("ssn %p: Reset received state changed to TCP_CLOSED",
- ssn);
+ StreamTcpCloseSsnWithReset(p, ssn);
if (PKT_IS_TOSERVER(p)) {
if ((p->tcph->th_flags & TH_ACK) && StreamTcpValidateAck(ssn, &ssn->server, p) == 0)
SCLogDebug("regular packet %"PRIu64" from same sender as "
"the previous RST. Looks like it injected!", p->pcap_cnt);
ostream->flags &= ~STREAMTCP_STREAM_FLAG_RST_RECV;
+ ssn->flags &= ~STREAMTCP_FLAG_CLOSED_BY_RST;
StreamTcpSetEvent(p, STREAM_SUSPECTED_RST_INJECT);
return;
}