Add test case: inject IPv4 based TCP RST packet after recv Sub-ACK

This commit is contained in:
luwenpeng
2024-05-15 15:07:27 +08:00
parent b33dafff53
commit bb55ea68e0
5 changed files with 35 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
#include "packet_injector_test_frame.h" #include "packet_injector_test_frame.h"
#if 1
TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_SYN_ACK) TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_SYN_ACK)
{ {
struct packet_injector_case test = { struct packet_injector_case test = {
@@ -31,6 +32,39 @@ TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_SYN_ACK)
packet_injector_test_frame_run(&test); packet_injector_test_frame_run(&test);
} }
#endif
#if 1
TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_SUB_ACK)
{
struct packet_injector_case test = {
// descriptor
.finish_clean_work_dir = 1,
.descriptor = "Inject IPv4 based TCP RST after receiving SUB-ACK packet.",
.work_dir = "/tmp/inject_ipv4_based_tcp_rst_after_recv_sub_ack/", // user defined work directory
// prefix
.input_prefix = "pcap/inject_ipv4_based_tcp_rst_after_recv_sub_ack/test/",
.output_prefix = "/tmp/",
// input pcap
.input_pcap = "input.pcap",
// compare
.c2s_expect_pcap = "expect-192.0.2.211:42242-192.0.2.110:80-1.pcap",
.c2s_output_pcap = "inject-192.0.2.211:42242-192.0.2.110:80-1.pcap",
.s2c_expect_pcap = "expect-192.0.2.110:80-192.0.2.211:42242-2.pcap",
.s2c_output_pcap = "inject-192.0.2.110:80-192.0.2.211:42242-2.pcap",
// packet injector command
.packet_injector_cmd = "./packet_injector -t tcp-rst -c c2s-packet -n 2",
.diff_skip_pattern = "-I frame.time -I frame.time_epoch -I ip.id -I ip.ttl -I ip.checksum -I tcp.checksum -I tcp.window_size",
};
packet_injector_test_frame_run(&test);
}
#endif
int main(int argc, char **argv) int main(int argc, char **argv)
{ {

View File

@@ -175,9 +175,7 @@ void packet_injector_test_frame_run(struct packet_injector_case *test)
EXPECT_TRUE(replace_file_string(config_file_abs_path, "dumpfile_dir = \"/tmp/dumpfile/\"", temp) == 0); EXPECT_TRUE(replace_file_string(config_file_abs_path, "dumpfile_dir = \"/tmp/dumpfile/\"", temp) == 0);
// run packet injector // run packet injector
chdir(test->work_dir); system_cmd("cd %s && %s && cd ..", test->work_dir, test->packet_injector_cmd);
system_cmd(test->packet_injector_cmd);
chdir("../");
// compare pcap // compare pcap
if (test->c2s_output_pcap && test->c2s_expect_pcap) if (test->c2s_output_pcap && test->c2s_expect_pcap)