#include <gtest/gtest.h>

#include "packet_inject_test.h"

TEST(INJECT_IPV4_BASED_TCP_RST, AFTER_RECV_S2C_FIRST_PAYLOAD)
{
    char curr_dir[1024] = {0};
    char work_dir[2048] = {0};
    char pcap_dir[2048] = {0};
    getcwd(curr_dir, sizeof(curr_dir));
    snprintf(work_dir, sizeof(work_dir), "%s/%s", curr_dir, "INJECT_IPV4_BASED_TCP_RST_AFTER_RECV_S2C_FIRST_PAYLOAD");
    snprintf(pcap_dir, sizeof(pcap_dir), "%s/%s", curr_dir, "pcap/inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload/test/");

    struct packet_inject_case test = {
        .work_dir = work_dir,
        .pcap_dir = pcap_dir,
        .input_pcap = "input.pcap",
        .compares = {
            {
                .expect_pcap = "expect-192.0.2.211:54408-192.0.2.110:80-1.pcap",
                .inject_pcap = "inject-192.0.2.211:54408-192.0.2.110:80-1.pcap",
            },
            {
                .expect_pcap = "expect-192.0.2.110:80-192.0.2.211:54408-2.pcap",
                .inject_pcap = "inject-192.0.2.110:80-192.0.2.211:54408-2.pcap",
            },
            {
                .expect_pcap = NULL,
                .inject_pcap = NULL,
            },
        },
        .plugin_config_file = "inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload.toml",
        .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_inject_test(&test);
}

int main(int argc, char **argv)
{
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
