# vi:syntax=python
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
# -*- mode: python -*-
# TEST_INT=VF

TCCL(
    include = [
        "../../../config-templates/tc/template_tc_filtertest_soc_tcpv4_q_in_q_megafilter_test_setup.config",
    ],

    test_setup = [
    ],

    test_teardown = [
    ],

    traffic_generators = [
        CustomTrafficGenerator(
            title="soc_IPv4_proto_testcase",
            source=Ref("traffic_dut"),
            destination=Ref("traffic_partner"),
            source_interface=Ref("HOST1_DEV_PF0_VF0"),
            destination_interface=Ref("HOST2_DEV_PF0"),
            duration=10,
            analyzer=[
                Pass(),
                Fail(),
                Fail()
            ],
            skip_layers="Raw",
            packet=[
                """
                Ether(
                    src={HOST1_PF0_VF0_MAC},
                    dst={HOST2_PF0_VF0_MAC},
                    type=0x800
                ) /
                IP(
                    version=4,
                    ihl=5,
                    len=1450,
                    id=10843,
                    frag=0,
                    ttl=64,
                    proto={proto},
                    chksum=0x758c,
                    src={HOST1_p},
                    dst={HOST2_p},
                    tos=0,
                    flags=2
                ) /
                TCP(
                    sport=35347,
                    dport=39517,
                    seq=1656527237,
                    ack=1628882447,
                    dataofs=8,
                    reserved=0,
                    flags=0x010,
                    window=221,
                    chksum=0xfb02,
                    urgptr=0,
                    options=[('NOP', None), ('NOP', None), ('Timestamp', (2475470151, 1001023071))]
                )
                """,
            ],
            expected=[
                """
                Ether(
                    src={HOST1_PF0_VF0_MAC},
                    dst={HOST2_PF0_VF0_MAC},
                    type=0x8100
                ) /
                Dot1Q(
                    prio=0,
                    id=0,
                    vlan=100,
                    type=0x8100
                ) /
                Dot1Q(
                    prio=0,
                    id=0,
                    vlan=200,
                    type=0x800
                ) /
                IP(
                    version=4,
                    ihl=5,
                    len=1450,
                    id=10843,
                    frag=0,
                    ttl=64,
                    proto={proto},
                    chksum=0x758c,
                    src={HOST1_p},
                    dst={HOST2_p},
                    tos=0,
                    flags=2
                ) /
                TCP(
                    sport=35347,
                    dport=39517,
                    seq=1656527237,
                    ack=1628882447,
                    dataofs=8,
                    reserved=0,
                    flags=0x010,
                    window=221,
                    chksum=0xfb02,
                    urgptr=0,
                    options=[('NOP', None), ('NOP', None), ('Timestamp', (2475470151, 1001023071))]
                )
                """,
            ],
            packet_arguments={
                "OVS_HOST1_PF0_MAC": MacAddress(
                    client=Ref("admin_dut"),
                    network="l",
                ),
                "OVS_HOST2_PF0_MAC": MacAddress(
                    client=Ref("admin_partner"),
                    network="l",
                ),
                "OVS_HOST1_6l": IpAddress(
                    client=Ref("admin_dut"),
                    network="6l",
                ),
                "OVS_HOST2_6l": IpAddress(
                    client=Ref("admin_partner"),
                    network="6l",
                ),
                "HOST1_PF0_VF0_MAC": MacAddress(
                    client=Ref("x86_dut"),
                    network="p",
                ),
                "HOST2_PF0_VF0_MAC": MacAddress(
                    client=Ref("x86_partner"),
                    network="p",
                ),
                "HOST1_p": IpAddress(
                    client=Ref("x86_dut"),
                    network="p",
                ),
                "HOST2_p": IpAddress(
                    client=Ref("x86_partner"),
                    network="p",
                ),
                "proto": [
                    6,
                    17,
                    2,
                ],
            },
        ),
    ],
)

