|
|
|
@ -2638,859 +2638,6 @@ static int StreamTcpTest28(void)
|
|
|
|
|
PASS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
/**
|
|
|
|
|
* \test Test the resetting of the sesison with bad checksum packet and later
|
|
|
|
|
* send the malicious contents on the session. Engine should drop the
|
|
|
|
|
* packet with the bad checksum.
|
|
|
|
|
*
|
|
|
|
|
* \retval On success it returns 1 and on failure 0.
|
|
|
|
|
*/
|
|
|
|
|
static int StreamTcpTest29(void)
|
|
|
|
|
{
|
|
|
|
|
Packet p;
|
|
|
|
|
Flow f;
|
|
|
|
|
ThreadVars tv;
|
|
|
|
|
StreamTcpThread stt;
|
|
|
|
|
TCPHdr tcph;
|
|
|
|
|
TcpSession ssn;
|
|
|
|
|
IPV4Hdr ipv4h;
|
|
|
|
|
struct in_addr addr;
|
|
|
|
|
struct in_addr addr1;
|
|
|
|
|
TCPCache tcpc;
|
|
|
|
|
TCPVars tcpvars;
|
|
|
|
|
TcpStream server;
|
|
|
|
|
TcpStream client;
|
|
|
|
|
|
|
|
|
|
memset (&p, 0, SIZE_OF_PACKET);
|
|
|
|
|
memset (&f, 0, sizeof(Flow));
|
|
|
|
|
memset(&tv, 0, sizeof (ThreadVars));
|
|
|
|
|
memset(&stt, 0, sizeof (StreamTcpThread));
|
|
|
|
|
memset(&tcph, 0, sizeof (TCPHdr));
|
|
|
|
|
memset (&ipv4h, 0, sizeof(IPV4Hdr));
|
|
|
|
|
memset (&addr, 0, sizeof(addr));
|
|
|
|
|
memset (&addr1, 0, sizeof(addr1));
|
|
|
|
|
memset (&tcpc, 0, sizeof(tcpc));
|
|
|
|
|
memset (&tcpvars, 0, sizeof(tcpvars));
|
|
|
|
|
memset(&ssn, 0, sizeof (TcpSession));
|
|
|
|
|
memset(&server, 0, sizeof (TcpStream));
|
|
|
|
|
memset(&client, 0, sizeof (TcpStream));
|
|
|
|
|
uint8_t packet[1460] = "";
|
|
|
|
|
int result = 1;
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
StreamTcpInitConfig(true);
|
|
|
|
|
|
|
|
|
|
/* prevent L7 from kicking in */
|
|
|
|
|
|
|
|
|
|
ssn.client.os_policy = OS_POLICY_BSD;
|
|
|
|
|
p.src.family = AF_INET;
|
|
|
|
|
p.dst.family = AF_INET;
|
|
|
|
|
p.proto = IPPROTO_TCP;
|
|
|
|
|
p.flow = &f;
|
|
|
|
|
tcph.th_win = 5480;
|
|
|
|
|
p.tcph = &tcph;
|
|
|
|
|
p.payload = packet;
|
|
|
|
|
p.ip4h = &ipv4h;
|
|
|
|
|
p.tcpc = tcpc;
|
|
|
|
|
p.tcpc.level4_comp_csum = -1;
|
|
|
|
|
tcpvars.hlen = 20;
|
|
|
|
|
p.tcpvars = tcpvars;
|
|
|
|
|
ssn.state = TCP_ESTABLISHED;
|
|
|
|
|
addr.s_addr = inet_addr("10.1.3.53");
|
|
|
|
|
p.dst.address.address_un_data32[0] = addr.s_addr;
|
|
|
|
|
addr1.s_addr = inet_addr("10.1.3.7");
|
|
|
|
|
p.src.address.address_un_data32[0] = addr1.s_addr;
|
|
|
|
|
f.protoctx = &ssn;
|
|
|
|
|
stt.ra_ctx = ra_ctx;
|
|
|
|
|
ssn.server = server;
|
|
|
|
|
ssn.client = client;
|
|
|
|
|
ssn.client.isn = 10;
|
|
|
|
|
ssn.client.window = 5184;
|
|
|
|
|
ssn.client.last_ack = 10;
|
|
|
|
|
ssn.client.ra_base_seq = 10;
|
|
|
|
|
ssn.client.next_win = 5184;
|
|
|
|
|
ssn.server.isn = 119197101;
|
|
|
|
|
ssn.server.window = 5184;
|
|
|
|
|
ssn.server.next_win = 5184;
|
|
|
|
|
ssn.server.last_ack = 119197101;
|
|
|
|
|
ssn.server.ra_base_seq = 119197101;
|
|
|
|
|
|
|
|
|
|
tcph.th_flags = TH_PUSH | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
p.tcph->th_seq = htonl(11);
|
|
|
|
|
p.tcph->th_ack = htonl(119197102);
|
|
|
|
|
p.payload_len = 4;
|
|
|
|
|
p.ip4h->ip_src = addr1;
|
|
|
|
|
p.tcph->th_sum = TCPCalculateChecksum((uint16_t *)&(p.ip4h->ip_src),
|
|
|
|
|
(uint16_t *)p.tcph,
|
|
|
|
|
(p.payload_len +
|
|
|
|
|
p.tcpvars.hlen) );
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tcph.th_flags = TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
p.tcph->th_seq = htonl(119197102);
|
|
|
|
|
p.tcph->th_ack = htonl(15);
|
|
|
|
|
p.payload_len = 0;
|
|
|
|
|
p.ip4h->ip_src = addr;
|
|
|
|
|
p.tcph->th_sum = TCPCalculateChecksum((uint16_t *)&(p.ip4h->ip_src),
|
|
|
|
|
(uint16_t *)p.tcph,
|
|
|
|
|
(p.payload_len +
|
|
|
|
|
p.tcpvars.hlen) );
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tcph.th_flags = TH_RST | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
p.tcph->th_seq = htonl(15);
|
|
|
|
|
p.tcph->th_ack = htonl(119197102);
|
|
|
|
|
p.payload_len = 0;
|
|
|
|
|
p.ip4h->ip_src = addr1;
|
|
|
|
|
p.tcph->th_sum = 12345;
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ssn.state != TCP_ESTABLISHED) {
|
|
|
|
|
printf("the ssn.state should be TCP_ESTABLISHED(%"PRIu8"), not %"PRIu8""
|
|
|
|
|
"\n", TCP_ESTABLISHED, ssn.state);
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
end:
|
|
|
|
|
StreamTcpReturnStreamSegments(&ssn.client);
|
|
|
|
|
StreamTcpFreeConfig(true);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test Test the overlapping of the packet with bad checksum packet and later
|
|
|
|
|
* send the malicious contents on the session. Engine should drop the
|
|
|
|
|
* packet with the bad checksum.
|
|
|
|
|
*
|
|
|
|
|
* \retval On success it returns 1 and on failure 0.
|
|
|
|
|
*/
|
|
|
|
|
static int StreamTcpTest30(void)
|
|
|
|
|
{
|
|
|
|
|
Packet p;
|
|
|
|
|
Flow f;
|
|
|
|
|
ThreadVars tv;
|
|
|
|
|
StreamTcpThread stt;
|
|
|
|
|
TCPHdr tcph;
|
|
|
|
|
TcpSession ssn;
|
|
|
|
|
IPV4Hdr ipv4h;
|
|
|
|
|
struct in_addr addr;
|
|
|
|
|
struct in_addr addr1;
|
|
|
|
|
TCPCache tcpc;
|
|
|
|
|
TCPVars tcpvars;
|
|
|
|
|
TcpStream server;
|
|
|
|
|
TcpStream client;
|
|
|
|
|
|
|
|
|
|
memset (&p, 0, SIZE_OF_PACKET);
|
|
|
|
|
memset (&f, 0, sizeof(Flow));
|
|
|
|
|
memset(&tv, 0, sizeof (ThreadVars));
|
|
|
|
|
memset(&stt, 0, sizeof (StreamTcpThread));
|
|
|
|
|
memset(&tcph, 0, sizeof (TCPHdr));
|
|
|
|
|
memset (&ipv4h, 0, sizeof(IPV4Hdr));
|
|
|
|
|
memset (&addr, 0, sizeof(addr));
|
|
|
|
|
memset (&addr1, 0, sizeof(addr1));
|
|
|
|
|
memset (&tcpc, 0, sizeof(tcpc));
|
|
|
|
|
memset (&tcpvars, 0, sizeof(tcpvars));
|
|
|
|
|
memset(&ssn, 0, sizeof (TcpSession));
|
|
|
|
|
memset(&server, 0, sizeof (TcpStream));
|
|
|
|
|
memset(&client, 0, sizeof (TcpStream));
|
|
|
|
|
uint8_t payload[9] = "AAAAAAAAA";
|
|
|
|
|
uint8_t payload1[9] = "GET /EVIL";
|
|
|
|
|
uint8_t expected_content[9] = { 0x47, 0x45, 0x54, 0x20, 0x2f, 0x45, 0x56,
|
|
|
|
|
0x49, 0x4c };
|
|
|
|
|
int result = 1;
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
StreamTcpInitConfig(true);
|
|
|
|
|
|
|
|
|
|
/* prevent L7 from kicking in */
|
|
|
|
|
|
|
|
|
|
ssn.client.os_policy = OS_POLICY_BSD;
|
|
|
|
|
p.src.family = AF_INET;
|
|
|
|
|
p.dst.family = AF_INET;
|
|
|
|
|
p.proto = IPPROTO_TCP;
|
|
|
|
|
p.flow = &f;
|
|
|
|
|
tcph.th_win = 5480;
|
|
|
|
|
p.tcph = &tcph;
|
|
|
|
|
p.payload = payload;
|
|
|
|
|
p.ip4h = &ipv4h;
|
|
|
|
|
p.tcpc = tcpc;
|
|
|
|
|
p.tcpc.level4_comp_csum = -1;
|
|
|
|
|
p.tcpvars = tcpvars;
|
|
|
|
|
ssn.state = TCP_ESTABLISHED;
|
|
|
|
|
addr.s_addr = inet_addr("10.1.3.53");
|
|
|
|
|
p.dst.address.address_un_data32[0] = addr.s_addr;
|
|
|
|
|
addr1.s_addr = inet_addr("10.1.3.7");
|
|
|
|
|
p.src.address.address_un_data32[0] = addr1.s_addr;
|
|
|
|
|
f.protoctx = &ssn;
|
|
|
|
|
stt.ra_ctx = ra_ctx;
|
|
|
|
|
ssn.server = server;
|
|
|
|
|
ssn.client = client;
|
|
|
|
|
ssn.client.isn = 10;
|
|
|
|
|
ssn.client.window = 5184;
|
|
|
|
|
ssn.client.last_ack = 10;
|
|
|
|
|
ssn.client.ra_base_seq = 10;
|
|
|
|
|
ssn.client.next_win = 5184;
|
|
|
|
|
ssn.server.isn = 1351079940;
|
|
|
|
|
ssn.server.window = 5184;
|
|
|
|
|
ssn.server.next_win = 1351088132;
|
|
|
|
|
ssn.server.last_ack = 1351079940;
|
|
|
|
|
ssn.server.ra_base_seq = 1351079940;
|
|
|
|
|
|
|
|
|
|
tcph.th_flags = TH_PUSH | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
p.tcph->th_seq = htonl(11);
|
|
|
|
|
p.tcph->th_ack = htonl(1351079940);
|
|
|
|
|
p.payload_len = 9;
|
|
|
|
|
p.ip4h->ip_src = addr1;
|
|
|
|
|
p.tcph->th_sum = 12345;
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tcph.th_flags = TH_PUSH | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
p.tcph->th_seq = htonl(11);
|
|
|
|
|
p.tcph->th_ack = htonl(1351079940);
|
|
|
|
|
p.payload = payload1;
|
|
|
|
|
p.payload_len = 9;
|
|
|
|
|
p.ip4h->ip_src = addr1;
|
|
|
|
|
p.tcph->th_sum = TCPCalculateChecksum((uint16_t *)&(p.ip4h->ip_src),
|
|
|
|
|
(uint16_t *)p.tcph,
|
|
|
|
|
(p.payload_len +
|
|
|
|
|
p.tcpvars.hlen) );
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tcph.th_flags = TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
p.tcph->th_seq = htonl(1351079940);
|
|
|
|
|
p.tcph->th_ack = htonl(20);
|
|
|
|
|
p.payload_len = 0;
|
|
|
|
|
p.ip4h->ip_src = addr;
|
|
|
|
|
p.tcph->th_sum = TCPCalculateChecksum((uint16_t *)&(p.ip4h->ip_src),
|
|
|
|
|
(uint16_t *)p.tcph,
|
|
|
|
|
(p.payload_len +
|
|
|
|
|
p.tcpvars.hlen) );
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StreamTcpCheckStreamContents(expected_content, 9, &ssn.client) != 1) {
|
|
|
|
|
printf("the contents are not as expected(GET /EVIL), contents are: ");
|
|
|
|
|
PrintRawDataFp(stdout, ssn.client.seg_list->payload, 9);
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
end:
|
|
|
|
|
StreamTcpReturnStreamSegments(&ssn.client);
|
|
|
|
|
StreamTcpFreeConfig(true);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test Test the multiple SYN packet handling with bad checksum and timestamp
|
|
|
|
|
* value. Engine should drop the bad checksum packet and establish
|
|
|
|
|
* TCP session correctly.
|
|
|
|
|
*
|
|
|
|
|
* \retval On success it returns 1 and on failure 0.
|
|
|
|
|
*/
|
|
|
|
|
static int StreamTcpTest31(void)
|
|
|
|
|
{
|
|
|
|
|
Packet p;
|
|
|
|
|
Flow f;
|
|
|
|
|
ThreadVars tv;
|
|
|
|
|
StreamTcpThread stt;
|
|
|
|
|
TCPHdr tcph;
|
|
|
|
|
TcpSession ssn;
|
|
|
|
|
IPV4Hdr ipv4h;
|
|
|
|
|
TcpReassemblyThreadCtx *ra_ctx = StreamTcpReassembleInitThreadCtx(NULL);
|
|
|
|
|
struct in_addr addr;
|
|
|
|
|
struct in_addr addr1;
|
|
|
|
|
TCPCache tcpc;
|
|
|
|
|
TCPVars tcpvars;
|
|
|
|
|
TcpStream server;
|
|
|
|
|
TcpStream client;
|
|
|
|
|
TCPOpt tcpopt;
|
|
|
|
|
|
|
|
|
|
memset (&p, 0, SIZE_OF_PACKET);
|
|
|
|
|
memset (&f, 0, sizeof(Flow));
|
|
|
|
|
memset(&tv, 0, sizeof (ThreadVars));
|
|
|
|
|
memset(&stt, 0, sizeof (StreamTcpThread));
|
|
|
|
|
memset(&tcph, 0, sizeof (TCPHdr));
|
|
|
|
|
memset (&ipv4h, 0, sizeof(IPV4Hdr));
|
|
|
|
|
memset (&addr, 0, sizeof(addr));
|
|
|
|
|
memset (&addr1, 0, sizeof(addr1));
|
|
|
|
|
memset (&tcpc, 0, sizeof(tcpc));
|
|
|
|
|
memset (&tcpvars, 0, sizeof(tcpvars));
|
|
|
|
|
memset(&ssn, 0, sizeof (TcpSession));
|
|
|
|
|
memset(&server, 0, sizeof (TcpStream));
|
|
|
|
|
memset(&client, 0, sizeof (TcpStream));
|
|
|
|
|
memset(&tcpopt, 0, sizeof (TCPOpt));
|
|
|
|
|
int result = 1;
|
|
|
|
|
|
|
|
|
|
StreamTcpInitConfig(true);
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
/* prevent L7 from kicking in */
|
|
|
|
|
|
|
|
|
|
ssn.client.os_policy = OS_POLICY_LINUX;
|
|
|
|
|
p.src.family = AF_INET;
|
|
|
|
|
p.dst.family = AF_INET;
|
|
|
|
|
p.proto = IPPROTO_TCP;
|
|
|
|
|
p.flow = &f;
|
|
|
|
|
tcph.th_win = 5480;
|
|
|
|
|
p.tcph = &tcph;
|
|
|
|
|
p.ip4h = &ipv4h;
|
|
|
|
|
p.tcpc = tcpc;
|
|
|
|
|
p.tcpc.level4_comp_csum = -1;
|
|
|
|
|
p.tcpvars = tcpvars;
|
|
|
|
|
p.tcpvars.ts = &tcpopt;
|
|
|
|
|
addr.s_addr = inet_addr("10.1.3.53");
|
|
|
|
|
p.dst.address.address_un_data32[0] = addr.s_addr;
|
|
|
|
|
addr1.s_addr = inet_addr("10.1.3.7");
|
|
|
|
|
p.src.address.address_un_data32[0] = addr1.s_addr;
|
|
|
|
|
f.protoctx = &ssn;
|
|
|
|
|
stt.ra_ctx = ra_ctx;
|
|
|
|
|
ssn.server = server;
|
|
|
|
|
ssn.client = client;
|
|
|
|
|
ssn.client.isn = 10;
|
|
|
|
|
ssn.client.window = 5184;
|
|
|
|
|
ssn.client.last_ack = 10;
|
|
|
|
|
ssn.client.ra_base_seq = 10;
|
|
|
|
|
ssn.client.next_win = 5184;
|
|
|
|
|
ssn.server.isn = 1351079940;
|
|
|
|
|
ssn.server.window = 5184;
|
|
|
|
|
ssn.server.next_win = 1351088132;
|
|
|
|
|
ssn.server.last_ack = 1351079940;
|
|
|
|
|
ssn.server.ra_base_seq = 1351079940;
|
|
|
|
|
|
|
|
|
|
tcph.th_flags = TH_SYN;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
p.tcph->th_seq = htonl(10);
|
|
|
|
|
p.payload_len = 0;
|
|
|
|
|
p.ip4h->ip_src = addr1;
|
|
|
|
|
p.tcpc.ts1 = 100;
|
|
|
|
|
p.tcph->th_sum = 12345;
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tcph.th_flags = TH_SYN;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
p.tcph->th_seq = htonl(10);
|
|
|
|
|
p.payload_len = 0;
|
|
|
|
|
p.ip4h->ip_src = addr1;
|
|
|
|
|
p.tcpc.ts1 = 10;
|
|
|
|
|
p.tcpc.level4_comp_csum = -1;
|
|
|
|
|
p.tcph->th_sum = TCPCalculateChecksum((uint16_t *)&(p.ip4h->ip_src),
|
|
|
|
|
(uint16_t *)p.tcph,
|
|
|
|
|
(p.payload_len +
|
|
|
|
|
p.tcpvars.hlen) );
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ssn.flags |= STREAMTCP_FLAG_TIMESTAMP;
|
|
|
|
|
tcph.th_flags = TH_SYN | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
p.tcph->th_seq = htonl(1351079940);
|
|
|
|
|
p.tcph->th_ack = htonl(11);
|
|
|
|
|
p.payload_len = 0;
|
|
|
|
|
p.tcpc.ts1 = 10;
|
|
|
|
|
p.ip4h->ip_src = addr;
|
|
|
|
|
p.tcpc.level4_comp_csum = -1;
|
|
|
|
|
p.tcph->th_sum = TCPCalculateChecksum((uint16_t *)&(p.ip4h->ip_src),
|
|
|
|
|
(uint16_t *)p.tcph,
|
|
|
|
|
(p.payload_len +
|
|
|
|
|
p.tcpvars.hlen) );
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tcph.th_flags = TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
p.tcph->th_seq = htonl(11);
|
|
|
|
|
p.tcph->th_ack = htonl(1351079941);
|
|
|
|
|
p.payload_len = 0;
|
|
|
|
|
p.tcpc.ts1 = 10;
|
|
|
|
|
p.ip4h->ip_src = addr1;
|
|
|
|
|
p.tcpc.level4_comp_csum = -1;
|
|
|
|
|
p.tcph->th_sum = TCPCalculateChecksum((uint16_t *)&(p.ip4h->ip_src),
|
|
|
|
|
(uint16_t *)p.tcph,
|
|
|
|
|
(p.payload_len +
|
|
|
|
|
p.tcpvars.hlen) );
|
|
|
|
|
|
|
|
|
|
if (StreamTcp(&tv, &p, (void *)&stt, NULL, NULL) != TM_ECODE_OK) {
|
|
|
|
|
printf("failed in segment reassmebling\n");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ssn.state != TCP_ESTABLISHED) {
|
|
|
|
|
printf("the should have been changed to TCP_ESTABLISHED!!\n ");
|
|
|
|
|
result &= 0;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
end:
|
|
|
|
|
StreamTcpReturnStreamSegments(&ssn.client);
|
|
|
|
|
StreamTcpFreeConfig(true);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test Test the initialization of tcp streams with ECN & CWR flags
|
|
|
|
|
*
|
|
|
|
|
* \retval On success it returns 1 and on failure 0.
|
|
|
|
|
*/
|
|
|
|
|
static int StreamTcpTest32(void)
|
|
|
|
|
{
|
|
|
|
|
Packet p;
|
|
|
|
|
Flow f;
|
|
|
|
|
ThreadVars tv;
|
|
|
|
|
StreamTcpThread stt;
|
|
|
|
|
uint8_t payload[4];
|
|
|
|
|
TCPHdr tcph;
|
|
|
|
|
TcpReassemblyThreadCtx *ra_ctx = StreamTcpReassembleInitThreadCtx(NULL);
|
|
|
|
|
int ret = 0;
|
|
|
|
|
PacketQueueNoLock pq;
|
|
|
|
|
memset(&pq,0,sizeof(PacketQueueNoLock));
|
|
|
|
|
|
|
|
|
|
memset (&p, 0, SIZE_OF_PACKET);
|
|
|
|
|
memset (&f, 0, sizeof(Flow));
|
|
|
|
|
memset(&tv, 0, sizeof (ThreadVars));
|
|
|
|
|
memset(&stt, 0, sizeof (StreamTcpThread));
|
|
|
|
|
memset(&tcph, 0, sizeof (TCPHdr));
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
stt.ra_ctx = ra_ctx;
|
|
|
|
|
p.flow = &f;
|
|
|
|
|
tcph.th_win = htons(5480);
|
|
|
|
|
tcph.th_flags = TH_SYN | TH_CWR | TH_ECN;
|
|
|
|
|
p.tcph = &tcph;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
StreamTcpInitConfig(true);
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_SYN | TH_ACK | TH_ECN;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1 || (TcpSession *)p.flow->protoctx == NULL) {
|
|
|
|
|
printf("failed in processing packet\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_seq = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_ACK | TH_ECN | TH_CWR;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1 || (TcpSession *)p.flow->protoctx == NULL) {
|
|
|
|
|
printf("failed in processing packet\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_seq = htonl(2);
|
|
|
|
|
p.tcph->th_flags = TH_PUSH | TH_ACK | TH_ECN | TH_CWR;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
StreamTcpCreateTestPacket(payload, 0x41, 3, 4); /*AAA*/
|
|
|
|
|
p.payload = payload;
|
|
|
|
|
p.payload_len = 3;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1 || (TcpSession *)p.flow->protoctx == NULL) {
|
|
|
|
|
printf("failed in processing packet\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
p.tcph->th_flags = TH_ACK;
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1 || (TcpSession *)p.flow->protoctx == NULL) {
|
|
|
|
|
printf("failed in processing packet\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (((TcpSession *)p.flow->protoctx)->state != TCP_ESTABLISHED) {
|
|
|
|
|
printf("the TCP state should be TCP_ESTABLISEHD\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
StreamTcpSessionClear(p.flow->protoctx);
|
|
|
|
|
|
|
|
|
|
ret = 1;
|
|
|
|
|
end:
|
|
|
|
|
StreamTcpFreeConfig(true);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test Test the allocation of TCP session for a given packet when the same
|
|
|
|
|
* ports have been used to start the new session after resetting the
|
|
|
|
|
* previous session.
|
|
|
|
|
*
|
|
|
|
|
* \retval On success it returns 1 and on failure 0.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int StreamTcpTest33 (void)
|
|
|
|
|
{
|
|
|
|
|
Packet p;
|
|
|
|
|
Flow f;
|
|
|
|
|
ThreadVars tv;
|
|
|
|
|
StreamTcpThread stt;
|
|
|
|
|
TCPHdr tcph;
|
|
|
|
|
TcpReassemblyThreadCtx ra_ctx;
|
|
|
|
|
PacketQueueNoLock pq;
|
|
|
|
|
memset(&pq,0,sizeof(PacketQueueNoLock));
|
|
|
|
|
memset(&ra_ctx, 0, sizeof(TcpReassemblyThreadCtx));
|
|
|
|
|
memset (&p, 0, SIZE_OF_PACKET);
|
|
|
|
|
memset (&f, 0, sizeof(Flow));
|
|
|
|
|
memset(&tv, 0, sizeof (ThreadVars));
|
|
|
|
|
memset(&stt, 0, sizeof (StreamTcpThread));
|
|
|
|
|
memset(&tcph, 0, sizeof (TCPHdr));
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
p.flow = &f;
|
|
|
|
|
tcph.th_win = htons(5480);
|
|
|
|
|
tcph.th_flags = TH_SYN;
|
|
|
|
|
p.tcph = &tcph;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
int ret = 0;
|
|
|
|
|
stt.ra_ctx = &ra_ctx;
|
|
|
|
|
|
|
|
|
|
StreamTcpInitConfig(true);
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_SYN | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_seq = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_seq = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_RST | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
if (((TcpSession *)(p.flow->protoctx))->state != TCP_CLOSED) {
|
|
|
|
|
printf("Tcp session should have been closed\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.tcph->th_seq = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_SYN;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_seq = htonl(1);
|
|
|
|
|
p.tcph->th_ack = htonl(2);
|
|
|
|
|
p.tcph->th_flags = TH_SYN | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(2);
|
|
|
|
|
p.tcph->th_seq = htonl(2);
|
|
|
|
|
p.tcph->th_flags = TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
if (((TcpSession *)(p.flow->protoctx))->state != TCP_ESTABLISHED) {
|
|
|
|
|
printf("Tcp session should have been ESTABLISHED\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = 1;
|
|
|
|
|
end:
|
|
|
|
|
StreamTcpSessionClear(p.flow->protoctx);
|
|
|
|
|
StreamTcpFreeConfig(true);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test Test the allocation of TCP session for a given packet when the SYN
|
|
|
|
|
* packet is sent with the PUSH flag set.
|
|
|
|
|
*
|
|
|
|
|
* \retval On success it returns 1 and on failure 0.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int StreamTcpTest34 (void)
|
|
|
|
|
{
|
|
|
|
|
Packet p;
|
|
|
|
|
Flow f;
|
|
|
|
|
ThreadVars tv;
|
|
|
|
|
StreamTcpThread stt;
|
|
|
|
|
TCPHdr tcph;
|
|
|
|
|
TcpReassemblyThreadCtx ra_ctx;
|
|
|
|
|
PacketQueueNoLock pq;
|
|
|
|
|
memset(&pq,0,sizeof(PacketQueueNoLock));
|
|
|
|
|
memset(&ra_ctx, 0, sizeof(TcpReassemblyThreadCtx));
|
|
|
|
|
memset (&p, 0, SIZE_OF_PACKET);
|
|
|
|
|
memset (&f, 0, sizeof(Flow));
|
|
|
|
|
memset(&tv, 0, sizeof (ThreadVars));
|
|
|
|
|
memset(&stt, 0, sizeof (StreamTcpThread));
|
|
|
|
|
memset(&tcph, 0, sizeof (TCPHdr));
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
p.flow = &f;
|
|
|
|
|
tcph.th_win = htons(5480);
|
|
|
|
|
tcph.th_flags = TH_SYN|TH_PUSH;
|
|
|
|
|
p.tcph = &tcph;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
int ret = 0;
|
|
|
|
|
stt.ra_ctx = &ra_ctx;
|
|
|
|
|
|
|
|
|
|
StreamTcpInitConfig(true);
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_SYN | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_seq = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
if (((TcpSession *)(p.flow->protoctx))->state != TCP_ESTABLISHED) {
|
|
|
|
|
printf("Tcp session should have been establisehd\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = 1;
|
|
|
|
|
end:
|
|
|
|
|
StreamTcpSessionClear(p.flow->protoctx);
|
|
|
|
|
StreamTcpFreeConfig(true);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test Test the allocation of TCP session for a given packet when the SYN
|
|
|
|
|
* packet is sent with the URG flag set.
|
|
|
|
|
*
|
|
|
|
|
* \retval On success it returns 1 and on failure 0.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int StreamTcpTest35 (void)
|
|
|
|
|
{
|
|
|
|
|
Packet p;
|
|
|
|
|
Flow f;
|
|
|
|
|
ThreadVars tv;
|
|
|
|
|
StreamTcpThread stt;
|
|
|
|
|
TCPHdr tcph;
|
|
|
|
|
TcpReassemblyThreadCtx ra_ctx;
|
|
|
|
|
PacketQueueNoLock pq;
|
|
|
|
|
memset(&pq,0,sizeof(PacketQueueNoLock));
|
|
|
|
|
memset(&ra_ctx, 0, sizeof(TcpReassemblyThreadCtx));
|
|
|
|
|
memset (&p, 0, SIZE_OF_PACKET);
|
|
|
|
|
memset (&f, 0, sizeof(Flow));
|
|
|
|
|
memset(&tv, 0, sizeof (ThreadVars));
|
|
|
|
|
memset(&stt, 0, sizeof (StreamTcpThread));
|
|
|
|
|
memset(&tcph, 0, sizeof (TCPHdr));
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
p.flow = &f;
|
|
|
|
|
tcph.th_win = htons(5480);
|
|
|
|
|
tcph.th_flags = TH_SYN|TH_URG;
|
|
|
|
|
p.tcph = &tcph;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
int ret = 0;
|
|
|
|
|
stt.ra_ctx = &ra_ctx;
|
|
|
|
|
|
|
|
|
|
StreamTcpInitConfig(true);
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_SYN | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_seq = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
if (((TcpSession *)(p.flow->protoctx))->state != TCP_ESTABLISHED) {
|
|
|
|
|
printf("Tcp session should have been establisehd\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = 1;
|
|
|
|
|
end:
|
|
|
|
|
StreamTcpSessionClear(p.flow->protoctx);
|
|
|
|
|
StreamTcpFreeConfig(true);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test Test the processing of PSH and URG flag in tcp session.
|
|
|
|
|
*
|
|
|
|
|
* \retval On success it returns 1 and on failure 0.
|
|
|
|
|
*/
|
|
|
|
|
static int StreamTcpTest36(void)
|
|
|
|
|
{
|
|
|
|
|
Packet p;
|
|
|
|
|
Flow f;
|
|
|
|
|
ThreadVars tv;
|
|
|
|
|
StreamTcpThread stt;
|
|
|
|
|
uint8_t payload[4];
|
|
|
|
|
TCPHdr tcph;
|
|
|
|
|
TcpReassemblyThreadCtx *ra_ctx = StreamTcpReassembleInitThreadCtx(NULL);
|
|
|
|
|
int ret = 0;
|
|
|
|
|
PacketQueueNoLock pq;
|
|
|
|
|
memset(&pq,0,sizeof(PacketQueueNoLock));
|
|
|
|
|
|
|
|
|
|
memset (&p, 0, SIZE_OF_PACKET);
|
|
|
|
|
memset (&f, 0, sizeof(Flow));
|
|
|
|
|
memset(&tv, 0, sizeof (ThreadVars));
|
|
|
|
|
memset(&stt, 0, sizeof (StreamTcpThread));
|
|
|
|
|
memset(&tcph, 0, sizeof (TCPHdr));
|
|
|
|
|
|
|
|
|
|
FLOW_INITIALIZE(&f);
|
|
|
|
|
stt.ra_ctx = ra_ctx;
|
|
|
|
|
p.flow = &f;
|
|
|
|
|
tcph.th_win = htons(5480);
|
|
|
|
|
tcph.th_flags = TH_SYN;
|
|
|
|
|
p.tcph = &tcph;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
StreamTcpInitConfig(true);
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1) {
|
|
|
|
|
printf("failed in processing packet\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_SYN | TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOCLIENT;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1 || (TcpSession *)p.flow->protoctx == NULL) {
|
|
|
|
|
printf("failed in processing packet\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(1);
|
|
|
|
|
p.tcph->th_seq = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_ACK;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1 || (TcpSession *)p.flow->protoctx == NULL) {
|
|
|
|
|
printf("failed in processing packet\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (((TcpSession *)p.flow->protoctx)->state != TCP_ESTABLISHED) {
|
|
|
|
|
printf("the TCP state should be TCP_ESTABLISEHD\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.tcph->th_ack = htonl(2);
|
|
|
|
|
p.tcph->th_seq = htonl(1);
|
|
|
|
|
p.tcph->th_flags = TH_PUSH | TH_ACK | TH_URG;
|
|
|
|
|
p.flowflags = FLOW_PKT_TOSERVER;
|
|
|
|
|
|
|
|
|
|
StreamTcpCreateTestPacket(payload, 0x41, 3, 4); /*AAA*/
|
|
|
|
|
p.payload = payload;
|
|
|
|
|
p.payload_len = 3;
|
|
|
|
|
|
|
|
|
|
if (StreamTcpPacket(&tv, &p, &stt, &pq) == -1 || (TcpSession *)p.flow->protoctx == NULL) {
|
|
|
|
|
printf("failed in processing packet\n");
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (((TcpSession *)p.flow->protoctx)->client.next_seq != 4) {
|
|
|
|
|
printf("the ssn->client.next_seq should be 4, but it is %"PRIu32"\n",
|
|
|
|
|
((TcpSession *)p.flow->protoctx)->client.next_seq);
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StreamTcpSessionClear(p.flow->protoctx);
|
|
|
|
|
|
|
|
|
|
ret = 1;
|
|
|
|
|
end:
|
|
|
|
|
StreamTcpFreeConfig(true);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \test Test the processing of out of order FIN packets in tcp session.
|
|
|
|
|
*
|
|
|
|
|