"""
Check README file
"""
import Queue

from oftest import config
import inspect
import logging
import oftest.base_tests as base_tests
import ofp
from oftest.testutils import *
from accton_util import *


class PacketInUDP(base_tests.SimpleDataPlane):
    """
    Verify a ACL rule that matches on IP_PROTO 2 will not match a UDP packet.
    Next it verify a rule that matches on IP_PROTO 17 WILL match a UDP packet.
    """

    def runTest(self):
        try:
            parsed_vlan_pkt = simple_udp_packet(pktlen=104,
                                                vlan_vid=0x1001,
                                                dl_vlan_enable=True)
            vlan_pkt = str(parsed_vlan_pkt)
            # create match
            match = ofp.match()
            match.oxm_list.append(ofp.oxm.eth_type(0x0800))
            match.oxm_list.append(ofp.oxm.ip_proto(2))
            request = ofp.message.flow_add(
                    table_id=60,
                    cookie=42,
                    match=match,
                    instructions=[
                        ofp.instruction.apply_actions(
                                actions=[
                                    ofp.action.output(
                                            port=ofp.OFPP_CONTROLLER,
                                            max_len=ofp.OFPCML_NO_BUFFER)]), ],
                    buffer_id=ofp.OFP_NO_BUFFER,
                    priority=1)
            logging.info("Inserting packet in flow to controller")
            self.controller.message_send(request)

            for of_port in config["port_map"].keys():
                logging.info("PacketInMiss test, port %d", of_port)
                self.dataplane.send(of_port, vlan_pkt)

                verify_no_packet_in(self, vlan_pkt, of_port)
            delete_all_flows(self.controller)
            do_barrier(self.controller)

            match = ofp.match()
            match.oxm_list.append(ofp.oxm.eth_type(0x0800))
            match.oxm_list.append(ofp.oxm.ip_proto(17))
            request = ofp.message.flow_add(
                    table_id=60,
                    cookie=42,
                    match=match,
                    instructions=[
                        ofp.instruction.apply_actions(
                                actions=[
                                    ofp.action.output(
                                            port=ofp.OFPP_CONTROLLER,
                                            max_len=ofp.OFPCML_NO_BUFFER)]), ],
                    buffer_id=ofp.OFP_NO_BUFFER,
                    priority=1)
            logging.info("Inserting packet in flow to controller")
            self.controller.message_send(request)
            do_barrier(self.controller)

            for of_port in config["port_map"].keys():
                logging.info("PacketInMiss test, port %d", of_port)
                self.dataplane.send(of_port, vlan_pkt)

                verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)

                verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_all_groups(self.controller)


@disabled
class ArpNL2(base_tests.SimpleDataPlane):
    def runTest(self):
        delete_all_flows(self.controller)
        delete_all_groups(self.controller)

        ports = sorted(config["port_map"].keys())
        match = ofp.match()
        match.oxm_list.append(ofp.oxm.eth_type(0x0806))
        request = ofp.message.flow_add(
                table_id=60,
                cookie=42,
                match=match,
                instructions=[
                    ofp.instruction.apply_actions(
                            actions=[
                                ofp.action.output(
                                        port=ofp.OFPP_CONTROLLER,
                                        max_len=ofp.OFPCML_NO_BUFFER)]),
                ],
                buffer_id=ofp.OFP_NO_BUFFER,
                priority=40000)
        self.controller.message_send(request)
        for port in ports:
            add_one_l2_interface_group(self.controller, port, 1, False, False)
            add_one_vlan_table_flow(self.controller, port, 1,
                                    flag=VLAN_TABLE_FLAG_ONLY_BOTH)
            group_id = encode_l2_interface_group_id(1, port)
            add_bridge_flow(self.controller,
                            [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id,
                            True)
        do_barrier(self.controller)
        parsed_arp_pkt = simple_arp_packet()
        arp_pkt = str(parsed_arp_pkt)

        for out_port in ports:
            self.dataplane.send(out_port, arp_pkt)
            verify_packet_in(self, arp_pkt, out_port, ofp.OFPR_ACTION)
            # change dest based on port number
            mac_dst = '00:12:34:56:78:%02X' % out_port
            for in_port in ports:
                if in_port == out_port:
                    continue
                # change source based on port number to avoid packet-ins from learning
                mac_src = '00:12:34:56:78:%02X' % in_port
                parsed_pkt = simple_tcp_packet(eth_dst=mac_dst, eth_src=mac_src)
                pkt = str(parsed_pkt)
                self.dataplane.send(in_port, pkt)

                for ofport in ports:
                    if ofport in [out_port]:
                        verify_packet(self, pkt, ofport)
                    else:
                        verify_no_packet(self, pkt, ofport)

                verify_no_other_packets(self)


class PacketInArp(base_tests.SimpleDataPlane):
    """
    Verify an ACL rule matching on ethertyper 0x806 will result in a packet-in
    """

    def runTest(self):
        try:
            parsed_arp_pkt = simple_arp_packet()
            arp_pkt = str(parsed_arp_pkt)
            # create match
            match = ofp.match()
            match.oxm_list.append(ofp.oxm.eth_type(0x0806))
            request = ofp.message.flow_add(
                    table_id=60,
                    cookie=42,
                    match=match,
                    instructions=[
                        ofp.instruction.apply_actions(
                                actions=[
                                    ofp.action.output(
                                            port=ofp.OFPP_CONTROLLER,
                                            max_len=ofp.OFPCML_NO_BUFFER)]),
                    ],
                    buffer_id=ofp.OFP_NO_BUFFER,
                    priority=1)

            logging.info("Inserting packet in flow to controller")
            self.controller.message_send(request)
            do_barrier(self.controller)

            for of_port in config["port_map"].keys():
                logging.info("PacketInMiss test, port %d", of_port)
                self.dataplane.send(of_port, arp_pkt)

                verify_packet_in(self, arp_pkt, of_port, ofp.OFPR_ACTION)

                verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_all_groups(self.controller)

class PacketInIPTable(base_tests.SimpleDataPlane):
    """
    Test packet in function on IPTABLE
    Send a packet to each dataplane port and verify that a packet
    in message is received from the controller for each
    #todo verify you stop receiving after adding rule
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip=0xc0a80001
            ports = sorted(config["port_map"].keys())

            for port in ports:
                #add l2 interface group
                vlan_id=port
                add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False)
                dst_mac[5]=vlan_id
                l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
                #add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,  flag=VLAN_TABLE_FLAG_ONLY_TAG)
                #add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
                #add unicast routing flow
                dst_ip = dip + (vlan_id<<8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id, send_ctrl=True)
                Groups.put(l3_msg.group_id)

            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                mac_src='00:00:00:22:22:%02X' % in_port
                ip_src='192.168.%02d.1' % in_port
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst='192.168.%02d.1' % out_port
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
                                                   eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt=str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    verify_packet_in(self, pkt, in_port, ofp.OFPR_ACTION)
                    #verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class L2FloodQinQ(base_tests.SimpleDataPlane):
    """
    Verify a tagged frame can be flooded based on its outer vlan
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            ports = sorted(config["port_map"].keys())
            vlan_id = 1

            for port in ports:
                L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
                                                          vlan_id, True, False)
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                Groups.put(L2gid)

            msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
            Groups.put(msg.group_id)
            add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
            do_barrier(self.controller)

            # verify flood
            for ofport in ports:
                # change dest based on port number
                mac_src = '00:12:34:56:78:%02X' % ofport
                parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108,
                                                        out_dl_vlan_enable=True,
                                                        out_vlan_vid=vlan_id,
                                                        in_dl_vlan_enable=True,
                                                        in_vlan_vid=10,
                                                        eth_dst='00:12:34:56:78:9a',
                                                        eth_src=mac_src)
                pkt = str(parsed_pkt)
                self.dataplane.send(ofport, pkt)
                # self won't rx packet
                verify_no_packet(self, pkt, ofport)
                # others will rx packet
                tmp_ports = list(ports)
                tmp_ports.remove(ofport)
                verify_packets(self, pkt, tmp_ports)

            verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

@disabled
class L2FloodTagged(base_tests.SimpleDataPlane):
    """
    Test L2 flood to a vlan
    Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
    """

    def runTest(self):
        # Hashes Test Name and uses it as id for installing unique groups
        vlan_id = abs(hash(inspect.stack()[0][3])) % (256)
        print vlan_id

        ports = sorted(config["port_map"].keys())

        delete_all_flows(self.controller)
        delete_all_groups(self.controller)

        # Installing flows to avoid packet-in
        for port in ports:
            add_one_l2_interface_group(self.controller, port, vlan_id, True,
                                       False)
            add_one_vlan_table_flow(self.controller, port, vlan_id,
                                    flag=VLAN_TABLE_FLAG_ONLY_TAG)
        msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
        add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
        do_barrier(self.controller)

        # verify flood
        for ofport in ports:
            # change dest based on port number
            pkt = str(simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,
                                        eth_dst='00:12:34:56:78:9a'))
            self.dataplane.send(ofport, pkt)
            # self won't rx packet
            verify_no_packet(self, pkt, ofport)
            # others will rx packet
            tmp_ports = list(ports)
            tmp_ports.remove(ofport)
            verify_packets(self, pkt, tmp_ports)
        verify_no_other_packets(self)


class L2UnicastTagged(base_tests.SimpleDataPlane):
    """
    Verify L2 forwarding works
    """

    def runTest(self):

        Groups = Queue.LifoQueue()
        try:
            ports = sorted(config["port_map"].keys())
            vlan_id = 1;
            for port in ports:
                L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
                                                          vlan_id, True, False)
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                Groups.put(L2gid)
                add_bridge_flow(self.controller,
                                [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id,
                                L2gid, True)
            do_barrier(self.controller)

            for out_port in ports:
                # change dest based on port number
                mac_dst = '00:12:34:56:78:%02X' % out_port
                for in_port in ports:
                    if in_port == out_port:
                        continue
                    pkt = str(
                            simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,
                                              eth_dst=mac_dst))
                    self.dataplane.send(in_port, pkt)
                    for ofport in ports:
                        if ofport in [out_port]:
                            verify_packet(self, pkt, ofport)
                        else:
                            verify_no_packet(self, pkt, ofport)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class Mtu1500(base_tests.SimpleDataPlane):
    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            ports = sorted(config["port_map"].keys())
            vlan_id = 18
            for port in ports:
                L2gid, msg = add_one_l2_interface_group(self.controller, port,
                                                        vlan_id, True, False)
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                Groups.put(L2gid)
                add_bridge_flow(self.controller,
                                [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id,
                                L2gid, True)
            do_barrier(self.controller)

            for out_port in ports:
                # change dest based on port number
                mac_dst = '00:12:34:56:78:%02X' % out_port
                for in_port in ports:
                    if in_port == out_port:
                        continue
                    pkt = str(simple_tcp_packet(pktlen=1500, dl_vlan_enable=True,
                                                vlan_vid=vlan_id, eth_dst=mac_dst))
                    self.dataplane.send(in_port, pkt)
                    for ofport in ports:
                        if ofport in [out_port]:
                            verify_packet(self, pkt, ofport)
                        else:
                            verify_no_packet(self, pkt, ofport)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _32UcastTagged(base_tests.SimpleDataPlane):
    """
    Verify a IP forwarding works for a /32 rule to L3 Unicast Interface
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            test_id = 26
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return

            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip = 0xc0a80001
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                vlan_id = port + test_id
                l2gid, msg = add_one_l2_interface_group(self.controller, port,
                                                        vlan_id=vlan_id,
                                                        is_tagged=True,
                                                        send_barrier=False)
                dst_mac[5] = vlan_id
                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
                                              id=vlan_id, src_mac=intf_src_mac,
                                              dst_mac=dst_mac)
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                     vlan_id)
                # add unicast routing flow
                dst_ip = dip + (vlan_id << 8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                         0xffffffff, l3_msg.group_id)
                Groups.put(l2gid)
                Groups.put(l3_msg.group_id)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                mac_src = '00:00:00:22:32:%02X' % (test_id + in_port)
                ip_src = '192.168.%02d.1' % (test_id + in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (test_id + out_port)
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                   vlan_vid=(test_id + in_port),
                                                   eth_dst=switch_mac,
                                                   eth_src=mac_src, ip_ttl=64,
                                                   ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expected packet
                    mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                vlan_vid=(test_id + out_port),
                                                eth_dst=mac_dst, eth_src=switch_mac,
                                                ip_ttl=63,
                                                ip_src=ip_src, ip_dst=ip_dst)
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _32VPN(base_tests.SimpleDataPlane):
    """
            Insert IP packet
            Receive MPLS packet
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return

            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip = 0xc0a80001
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                id = port
                vlan_id = port
                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
                                                            vlan_id, True, True)
                dst_mac[5] = vlan_id
                # add MPLS interface group
                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
                                                         dst_mac, intf_src_mac,
                                                         vlan_id, id)
                # add MPLS L3 VPN group
                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
                        self.controller,
                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
                        index=id, ref_gid=mpls_gid, push_mpls_header=True,
                        set_mpls_label=port, set_bos=1, set_ttl=32)
                # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
                do_barrier(self.controller)
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                     vlan_id)
                # add routing flow
                dst_ip = dip + (vlan_id << 8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                         0xffffffff, mpls_label_gid,vrf=2)
                Groups._put(l2_gid)
                Groups._put(mpls_gid)
                Groups._put(mpls_label_gid)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                ip_src = '192.168.%02d.1' % (in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (out_port)
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                   vlan_vid=(in_port),
                                                   eth_dst=switch_mac, ip_ttl=64,
                                                   ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expect packet
                    mac_dst = '00:00:00:22:22:%02X' % (out_port)
                    label = (out_port, 0, 1, 32)
                    exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
                                          vlan_vid=(out_port), ip_ttl=63,
                                          ip_src=ip_src,
                                          ip_dst=ip_dst, eth_dst=mac_dst,
                                          eth_src=switch_mac, label=[label])
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _32EcmpVpn(base_tests.SimpleDataPlane):
    """
            Insert IP packet
            Receive MPLS packet
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return

            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip = 0xc0a80001
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                id = port
                vlan_id = port
                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
                                                            vlan_id, True, True)
                dst_mac[5] = vlan_id
                # add MPLS interface group
                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
                                                         dst_mac, intf_src_mac,
                                                         vlan_id, id)
                # add MPLS L3 VPN group
                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
                        self.controller,
                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
                        index=id, ref_gid=mpls_gid, push_mpls_header=True,
                        set_mpls_label=port, set_bos=1, set_ttl=32)
                ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
                do_barrier(self.controller)
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                     vlan_id)
                # add routing flow
                dst_ip = dip + (vlan_id << 8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                         0xffffffff, ecmp_msg.group_id)
                Groups._put(l2_gid)
                Groups._put(mpls_gid)
                Groups._put(mpls_label_gid)
                Groups._put(ecmp_msg.group_id)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                ip_src = '192.168.%02d.1' % (in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (out_port)
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                   vlan_vid=(in_port),
                                                   eth_dst=switch_mac, ip_ttl=64,
                                                   ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expect packet
                    mac_dst = '00:00:00:22:22:%02X' % (out_port)
                    label = (out_port, 0, 1, 32)
                    exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
                                          vlan_vid=(out_port), ip_ttl=63,
                                          ip_src=ip_src,
                                          ip_dst=ip_dst, eth_dst=mac_dst,
                                          eth_src=switch_mac, label=[label])
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _32ECMPL3(base_tests.SimpleDataPlane):
    """
        Insert IP packet
        Receive IP packet
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return

            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip = 0xc0a80001
            # Hashes Test Name and uses it as id for installing unique groups
            ports = config["port_map"].keys()
            for port in ports:
                vlan_id = port
                id = port
                # add l2 interface group
                l2_gid, msg = add_one_l2_interface_group(self.controller, port,
                                                         vlan_id=vlan_id,
                                                         is_tagged=True,
                                                         send_barrier=False)
                dst_mac[5] = vlan_id
                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
                                              id=id, src_mac=intf_src_mac,
                                              dst_mac=dst_mac)
                ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                     vlan_id)
                # add unicast routing flow
                dst_ip = dip + (vlan_id << 8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                         0xffffffff, ecmp_msg.group_id)
                Groups._put(l2_gid)
                Groups._put(l3_msg.group_id)
                Groups._put(ecmp_msg.group_id)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                mac_src = '00:00:00:22:22:%02X' % in_port
                ip_src = '192.168.%02d.1' % in_port
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % out_port
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                   vlan_vid=in_port,
                                                   eth_dst=switch_mac,
                                                   eth_src=mac_src, ip_ttl=64,
                                                   ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expected packet
                    mac_dst = '00:00:00:22:22:%02X' % out_port
                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                vlan_vid=out_port,
                                                eth_dst=mac_dst, eth_src=switch_mac,
                                                ip_ttl=63,
                                                ip_src=ip_src, ip_dst=ip_dst)
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _24VPN(base_tests.SimpleDataPlane):
    """
            Insert IP packet
            Receive MPLS packet
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return

            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip = 0xc0a80001
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                id = port
                vlan_id = port
                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
                dst_mac[5] = vlan_id
                # add MPLS interface group
                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, id)
                # add MPLS L3 VPN group
                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
                        self.controller,
                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
                        index=id, ref_gid=mpls_gid, push_mpls_header=True,
                        set_mpls_label=port, set_bos=1, set_ttl=32)
                # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
                do_barrier(self.controller)
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                     vlan_id)
                # add routing flow
                dst_ip = dip + (vlan_id << 8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                         0xffffff00, mpls_label_gid)
                Groups._put(l2_gid)
                Groups._put(mpls_gid)
                Groups._put(mpls_label_gid)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                ip_src = '192.168.%02d.1' % (in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (out_port)
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                   vlan_vid=(in_port),
                                                   eth_dst=switch_mac, ip_ttl=64,
                                                   ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expect packet
                    mac_dst = '00:00:00:22:22:%02X' % (out_port)
                    label = (out_port, 0, 1, 32)
                    exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
                                          vlan_vid=(out_port), ip_ttl=63,
                                          ip_src=ip_src,
                                          ip_dst=ip_dst, eth_dst=mac_dst,
                                          eth_src=switch_mac, label=[label])
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _24EcmpVpn(base_tests.SimpleDataPlane):
    """
	    Insert IP packet
	    Receive MPLS packet
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return
            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip = 0xc0a80001
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                id = port
                vlan_id = id
                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
                                                            vlan_id, True, True)
                dst_mac[5] = vlan_id
                # add MPLS interface group
                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
                                                         dst_mac, intf_src_mac,
                                                         vlan_id, id)
                # add MPLS L3 VPN group
                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
                        self.controller,
                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
                        index=id, ref_gid=mpls_gid, push_mpls_header=True,
                        set_mpls_label=port, set_bos=1, set_ttl=32)
                ecmp_msg = add_l3_ecmp_group(self.controller, id, [mpls_label_gid])
                do_barrier(self.controller)
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                     vlan_id)
                # add routing flow
                dst_ip = dip + (vlan_id << 8)
                # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                         0xffffff00, ecmp_msg.group_id, vrf=0)
                Groups._put(l2_gid)
                Groups._put(mpls_gid)
                Groups._put(mpls_label_gid)
                Groups._put(ecmp_msg.group_id)

            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                mac_src = '00:00:00:22:22:%02X' % (in_port)
                ip_src = '192.168.%02d.1' % (in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (out_port)
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                   vlan_vid=(in_port),
                                                   eth_dst=switch_mac,
                                                   eth_src=mac_src, ip_ttl=64,
                                                   ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expect packet
                    mac_dst = '00:00:00:22:22:%02X' % out_port
                    label = (out_port, 0, 1, 32)
                    exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
                                          vlan_vid=(out_port), ip_ttl=63,
                                          ip_src=ip_src,
                                          ip_dst=ip_dst, eth_dst=mac_dst,
                                          eth_src=switch_mac, label=[label])
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _24ECMPL3(base_tests.SimpleDataPlane):
    """
        Insert IP packet
        Receive IP packet
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return

            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip = 0xc0a80001
            # Hashes Test Name and uses it as id for installing unique groups
            ports = config["port_map"].keys()
            for port in ports:
                vlan_id = port
                id = port
                # add l2 interface group
                l2_gid, msg = add_one_l2_interface_group(self.controller, port,
                                                         vlan_id=vlan_id,
                                                         is_tagged=True,
                                                         send_barrier=False)
                dst_mac[5] = vlan_id
                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
                                              id=id, src_mac=intf_src_mac,
                                              dst_mac=dst_mac)
                ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                     vlan_id)
                # add unicast routing flow
                dst_ip = dip + (vlan_id << 8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                         0xffffff00, ecmp_msg.group_id)
                Groups._put(l2_gid)
                Groups._put(l3_msg.group_id)
                Groups._put(ecmp_msg.group_id)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                mac_src = '00:00:00:22:22:%02X' % in_port
                ip_src = '192.168.%02d.1' % in_port
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % out_port
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                   vlan_vid=in_port,
                                                   eth_dst=switch_mac,
                                                   eth_src=mac_src, ip_ttl=64,
                                                   ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expected packet
                    mac_dst = '00:00:00:22:22:%02X' % out_port
                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                vlan_vid=out_port,
                                                eth_dst=mac_dst, eth_src=switch_mac,
                                                ip_ttl=63,
                                                ip_src=ip_src, ip_dst=ip_dst)
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

@disabled
class MPLSBUG(base_tests.SimpleDataPlane):
    def runTest(self):
        if len(config["port_map"]) < 2:
            logging.info("Port count less than 2, can't run this case")
            return
        intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
        dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
        dip = 0xc0a80001
        Groups = Queue.LifoQueue()
        ports = config["port_map"].keys()
        for port in ports:
            # add l2 interface group
            vlan_id = port
            l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
                                                        vlan_id, True, False)
            dst_mac[5] = vlan_id
            # add L3 Unicast  group
            l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
                                          id=vlan_id, src_mac=intf_src_mac,
                                          dst_mac=dst_mac)
            # add vlan flow table
            add_one_vlan_table_flow(self.controller, port, vlan_id,
                                    flag=VLAN_TABLE_FLAG_ONLY_BOTH)
            # add termination flow
            add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
                                 vlan_id, goto_table=24)
            # add mpls flow
            add_mpls_flow(self.controller, l3_msg.group_id, port)
            # add termination flow
            add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                 vlan_id)
            # add unicast routing flow
            dst_ip = dip + (vlan_id << 8)
            add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                     0xffffffff, l3_msg.group_id)
            Groups._put(l2_gid)
            Groups._put(l3_msg.group_id)
        do_barrier(self.controller)

        switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
        for in_port in ports:
            mac_src = '00:00:00:22:22:%02X' % in_port
            ip_src = '192.168.%02d.1' % in_port
            for out_port in ports:
                if in_port == out_port:
                    continue
                ip_dst = '192.168.%02d.1' % out_port
                switch_mac = "00:00:00:cc:cc:cc"
                label = (out_port, 0, 1, 32)
                parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
                                         vlan_vid=in_port, ip_src=ip_src,
                                         ip_dst=ip_dst, eth_dst=switch_mac,
                                         eth_src=mac_src, label=[label])
                pkt = str(parsed_pkt)
                self.dataplane.send(in_port, pkt)

                # build expect packet
                mac_dst = '00:00:00:22:22:%02X' % out_port
                exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                            vlan_vid=out_port,
                                            eth_dst=mac_dst, eth_src=switch_mac,
                                            ip_ttl=31, ip_src=ip_src,
                                            ip_dst=ip_dst)
                pkt = str(exp_pkt)
                verify_packet(self, pkt, out_port)
                verify_no_other_packets(self)

                parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                               vlan_vid=in_port,
                                               eth_dst=switch_mac,
                                               eth_src=mac_src, ip_ttl=64,
                                               ip_src=ip_src,
                                               ip_dst=ip_dst)
                pkt = str(parsed_pkt)
                self.dataplane.send(in_port, pkt)
                # build expected packet
                mac_dst = '00:00:00:22:22:%02X' % out_port
                exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                            vlan_vid=out_port,
                                            eth_dst=mac_dst, eth_src=switch_mac,
                                            ip_ttl=63,
                                            ip_src=ip_src, ip_dst=ip_dst)
                pkt = str(exp_pkt)
                verify_packet(self, pkt, out_port)
                verify_no_other_packets(self)
        delete_all_flows(self.controller)
        delete_groups(self.controller, Groups)

class L3McastToL2(base_tests.SimpleDataPlane):
    """
    Mcast routing to L2
    """

    def runTest(self):
        """
        port1 (vlan 300)-> All Ports (vlan 300)
        """
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 3:
                logging.info("Port count less than 3, can't run this case")
                assert (False)
                return
            vlan_id = 300
            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac])
            dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
            dst_mac_str = ':'.join(['%02X' % x for x in dst_mac])
            port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
            port1_mac_str = ':'.join(['%02X' % x for x in port1_mac])
            src_ip = 0xc0a80101
            src_ip_str = "192.168.1.1"
            dst_ip = 0xe0010101
            dst_ip_str = "224.1.1.1"

            port1 = config["port_map"].keys()[0]
            port2 = config["port_map"].keys()[1]

            switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00]

            # add l2 interface group
            l2_intf_group_list = []
            for port in config["port_map"].keys():
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                if port == port2:
                    continue
                l2_intf_gid, msg = add_one_l2_interface_group(self.controller, port,
                                                              vlan_id=vlan_id,
                                                              is_tagged=True,
                                                              send_barrier=False)
                l2_intf_group_list.append(l2_intf_gid)
                Groups.put(l2_intf_gid)

                # add termination flow
            add_termination_flow(self.controller, port1, 0x0800, switch_mac,
                                 vlan_id)

            # add l3 interface group
            mcat_group_msg = add_l3_mcast_group(self.controller, vlan_id, 2,
                                                l2_intf_group_list)
            add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip,
                                    mcat_group_msg.group_id)
            Groups._put(mcat_group_msg.group_id)

            parsed_pkt = simple_udp_packet(pktlen=100,
                                           dl_vlan_enable=True,
                                           vlan_vid=vlan_id,
                                           eth_dst=dst_mac_str,
                                           eth_src=port1_mac_str,
                                           ip_ttl=64,
                                           ip_src=src_ip_str,
                                           ip_dst=dst_ip_str)
            pkt = str(parsed_pkt)
            self.dataplane.send(port1, pkt)
            for port in config["port_map"].keys():
                if port == port2 or port == port1:
                    verify_no_packet(self, pkt, port)
                    continue
                verify_packet(self, pkt, port)
            verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class L3McastToL3(base_tests.SimpleDataPlane):
    """
    Mcast routing
    """

    def runTest(self):
        """
        port1 (vlan 1)-> port 2 (vlan 2)
        """
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 3:
                logging.info("Port count less than 3, can't run this case")
                assert (False)
                return

            vlan_id = 1
            port2_out_vlan = 2
            port3_out_vlan = 3
            in_vlan = 1  # macast group vid shall use input vlan diffe from l3 interface use output vlan
            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac])
            dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
            dst_mac_str = ':'.join(['%02X' % x for x in dst_mac])
            port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
            port1_mac_str = ':'.join(['%02X' % x for x in port1_mac])
            src_ip = 0xc0a80101
            src_ip_str = "192.168.1.1"
            dst_ip = 0xe0010101
            dst_ip_str = "224.1.1.1"

            port1 = config["port_map"].keys()[0]
            port2 = config["port_map"].keys()[1]
            port3 = config["port_map"].keys()[2]

            # add l2 interface group
            for port in config["port_map"].keys():
                l2gid, msg = add_one_l2_interface_group(self.controller, port,
                                                        vlan_id=vlan_id,
                                                        is_tagged=False,
                                                        send_barrier=False)
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                vlan_id += 1
                Groups._put(l2gid)

                # add termination flow
            add_termination_flow(self.controller, port1, 0x0800,
                                 [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)

            # add l3 interface group
            port2_ucast_msg = add_l3_interface_group(self.controller, port2,
                                                     port2_out_vlan, 2,
                                                     intf_src_mac)
            port3_ucast_msg = add_l3_interface_group(self.controller, port3,
                                                     port3_out_vlan, 3,
                                                     intf_src_mac)
            mcat_group_msg = add_l3_mcast_group(self.controller, in_vlan, 2,
                                                [port2_ucast_msg.group_id,
                                                 port3_ucast_msg.group_id])
            add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip,
                                    mcat_group_msg.group_id)
            Groups._put(port2_ucast_msg.group_id)
            Groups._put(port3_ucast_msg.group_id)
            Groups._put(mcat_group_msg.group_id)
            parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
                                           vlan_vid=1,
                                           eth_dst=dst_mac_str,
                                           eth_src=port1_mac_str,
                                           ip_ttl=64,
                                           ip_src=src_ip_str,
                                           ip_dst=dst_ip_str)
            pkt = str(parsed_pkt)
            self.dataplane.send(port1, pkt)
            parsed_pkt = simple_udp_packet(pktlen=96,
                                           eth_dst=dst_mac_str,
                                           eth_src=intf_src_mac_str,
                                           ip_ttl=63,
                                           ip_src=src_ip_str,
                                           ip_dst=dst_ip_str)
            pkt = str(parsed_pkt)
            verify_packet(self, pkt, port2)
            verify_packet(self, pkt, port3)
            verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)
@disabled
class _MplsFwd(base_tests.SimpleDataPlane):
    """
        Insert MPLS packet
        Receive MPLS packet
    """
    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return
            dip = 0xc0a80001
            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                id = port
                vlan_id = id
                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
                                                            vlan_id, True, False)
                dst_mac[5] = vlan_id
                mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
                                                         dst_mac, intf_src_mac,
                                                         vlan_id, id)
                mpls_label_gid, mpls_label_msg = add_mpls_label_group(
                        self.controller,
                        subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL,
                        index=id, ref_gid=mpls_gid, push_mpls_header=False,
                        set_mpls_label=port, set_bos=1)
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
                                     vlan_id, goto_table=24)
                add_mpls_flow(self.controller, mpls_label_gid, port, goto_table=29)
                dst_ip = dip + (vlan_id << 8)
                Groups._put(l2_gid)
                Groups._put(mpls_gid)
                Groups._put(mpls_label_gid)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                ip_src = '192.168.%02d.1' % (in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (out_port)

                    label = (out_port, 0, 1, 32)
                    parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
                                             vlan_vid=(in_port), ip_src=ip_src,
                                             ip_dst=ip_dst, eth_dst=switch_mac,
                                             label=[label])
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)

                    # build expect packet
                    mac_dst = '00:00:00:22:22:%02X' % (out_port)
                    label = (out_port, 0, 1, 31)
                    exp_pkt =  mpls_packet(pktlen=104, dl_vlan_enable=True,
                                             vlan_vid=(out_port), ip_src=ip_src,
                                             ip_dst=ip_dst, eth_src=switch_mac,
                                             eth_dst=mac_dst,label=[label])
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _MplsTermination(base_tests.SimpleDataPlane):
    """
        Insert MPLS packet
        Receive IP packet
    """
    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return
            dip = 0xc0a80001
            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                vlan_id, id, dst_mac[5] = port, port, port
                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
                                                            vlan_id, True, False)
                # add L3 Unicast  group
                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
                                              id=id, src_mac=intf_src_mac,dst_mac=dst_mac)
                # add L3 ecmp group
                ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
                                     vlan_id, goto_table=24)
                #add_mpls_flow(self.controller, ecmp_msg.group_id, port)
                add_mpls_flow(self.controller, label=port)
                dst_ip = dip + (vlan_id << 8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
                                         ecmp_msg.group_id, 1)
                Groups._put(l2_gid)
                Groups._put(l3_msg.group_id)
                Groups._put(ecmp_msg.group_id)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                ip_src = '192.168.%02d.1' % (in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (out_port)
                    label = (out_port, 0, 1, 32)
                    parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,vlan_vid=(in_port),
                                             ip_src=ip_src,ip_dst=ip_dst, eth_dst=switch_mac,label=[label])
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expect packet
                    mac_dst = '00:00:00:22:22:%02X' % (out_port)
                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                vlan_vid=(out_port),
                                                eth_dst=mac_dst, eth_src=switch_mac,
                                                ip_ttl=31, ip_src=ip_src,
                                                ip_dst=ip_dst)
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _MplsVpnFwd(base_tests.SimpleDataPlane):
    """
        Insert MPLS packet
        Receive IP packet
    """
    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return
            dip = 0xc0a80001
            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                vlan_id, id, dst_mac[5] = port, port, port
                l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
                                                            vlan_id, True, False)
                # add L3 Unicast  group
                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
                                              id=id, src_mac=intf_src_mac,dst_mac=dst_mac)
                # add L3 ecmp group
                ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
                                     vlan_id, goto_table=24)
                add_mpls_flow(self.controller, ecmp_msg.group_id, port)
                #add_mpls_flow(self.controller, label=port)
                dst_ip = dip + (vlan_id << 8)
                #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
                #                         ecmp_msg.group_id, 1)
                Groups._put(l2_gid)
                Groups._put(l3_msg.group_id)
                Groups._put(ecmp_msg.group_id)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                ip_src = '192.168.%02d.1' % (in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (out_port)
                    label = (out_port, 0, 1, 32)
                    parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,vlan_vid=(in_port),
                                             ip_src=ip_src,ip_dst=ip_dst, eth_dst=switch_mac,label=[label])
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expect packet
                    mac_dst = '00:00:00:22:22:%02X' % (out_port)
                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                vlan_vid=(out_port),
                                                eth_dst=mac_dst, eth_src=switch_mac,
                                                ip_ttl=31, ip_src=ip_src,
                                                ip_dst=ip_dst)
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _24UcastTagged(base_tests.SimpleDataPlane):
    """
    Verify a IP forwarding works for a /32 rule to L3 Unicast Interface
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            test_id = 26
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return
            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip = 0xc0a80001
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                vlan_id = port + test_id
                l2gid, msg = add_one_l2_interface_group(self.controller, port,
                                                        vlan_id=vlan_id,
                                                        is_tagged=True,
                                                        send_barrier=False)
                dst_mac[5] = vlan_id
                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
                                              id=vlan_id, src_mac=intf_src_mac,
                                              dst_mac=dst_mac)
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                     vlan_id)
                # add unicast routing flow
                dst_ip = dip + (vlan_id << 8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                         0xffffff00, l3_msg.group_id)
                Groups.put(l2gid)
                Groups.put(l3_msg.group_id)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
                ip_src = '192.168.%02d.1' % (test_id + in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (test_id + out_port)
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                   vlan_vid=(test_id + in_port),
                                                   eth_dst=switch_mac,
                                                   eth_src=mac_src, ip_ttl=64,
                                                   ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expected packet
                    mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                vlan_vid=(test_id + out_port),
                                                eth_dst=mac_dst, eth_src=switch_mac,
                                                ip_ttl=63,
                                                ip_src=ip_src, ip_dst=ip_dst)
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class _0Ucast(base_tests.SimpleDataPlane):
    """
    Verify a IP forwarding works for a /0 rule to L3 Unicast Interface
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            if len(config["port_map"]) < 2:
                logging.info("Port count less than 2, can't run this case")
                return

            intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
            dip = 0xc0a80001
            ports = config["port_map"].keys()
            for port in ports:
                # add l2 interface group
                vlan_id = port
                l2gid, msg = add_one_l2_interface_group(self.controller, port,
                                                        vlan_id=vlan_id+1,
                                                        is_tagged=True,
                                                        send_barrier=False)
                dst_mac[5] = vlan_id
                l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id+1,
                                              id=vlan_id, src_mac=intf_src_mac,
                                              dst_mac=dst_mac)
                # add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id,
                                        flag=VLAN_TABLE_FLAG_ONLY_TAG)
                # add termination flow
                add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
                                     vlan_id)
                # add unicast routing flow
                dst_ip = dip + (vlan_id << 8)
                add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
                                         0xffffffff, l3_msg.group_id)
                Groups.put(l2gid)
                Groups.put(l3_msg.group_id)
            l3_gid = encode_l3_unicast_group_id(ports[0])
            dst_ip = 0x0
            add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, l3_gid)
            do_barrier(self.controller)

            switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
            for in_port in ports:
                mac_src = '00:00:00:22:22:%02X' % (in_port)
                ip_src = '192.168.%02d.1' % (in_port)
                for out_port in ports:
                    if in_port == out_port:
                        continue
                    ip_dst = '192.168.%02d.1' % (out_port)
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                   vlan_vid=(in_port),
                                                   eth_dst=switch_mac,
                                                   eth_src=mac_src, ip_ttl=64,
                                                   ip_src=ip_src,
                                                   ip_dst=ip_dst)
                    pkt = str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    # build expected packet
                    mac_dst = '00:00:00:22:22:%02X' % (out_port)
                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
                                                vlan_vid=(out_port+1),
                                                eth_dst=mac_dst, eth_src=switch_mac,
                                                ip_ttl=63,
                                                ip_src=ip_src, ip_dst=ip_dst)
                    pkt = str(exp_pkt)
                    verify_packet(self, pkt, out_port)
                    verify_no_other_packets(self)
                    ip_dst='1.168.%02d.1' % ports[0]
                    parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
                                                   eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst)
                    pkt=str(parsed_pkt)
                    self.dataplane.send(in_port, pkt)
                    #build expect packet
                    mac_dst='00:00:00:22:22:%02X' % ports[0]
                    exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0]+1, ip_ttl=63, ip_src=ip_src,
                                          ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac)
                    pkt=str(exp_pkt)
                    verify_packet(self, pkt, ports[0])
                    verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_groups(self.controller, Groups)
            delete_all_groups(self.controller)

class Unfiltered(base_tests.SimpleDataPlane):
    """
    Testing addition of unfiltered groups
    """

    def runTest(self):
        try:
            ports = sorted(config["port_map"].keys())
            vlan_id = 1;
            for port in ports:
                add_l2_unfiltered_group(self.controller, [port], False)
            do_barrier(self.controller)
        finally:
            delete_all_flows(self.controller)
            delete_all_groups(self.controller)

class L3McastToVPN(base_tests.SimpleDataPlane):
    """
    Mcast routing
    """
    def runTest(self):
        """
        port1 (vlan 1)-> port 2 (vlan 2)
        """
        try:
            delete_all_flows(self.controller)
            delete_all_groups(self.controller)

            if len(config["port_map"]) <3:
                logging.info("Port count less than 3, can't run this case")
                assert(False)
                return

            vlan_id =1
            port2_out_vlan=2
            port3_out_vlan=3
            in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
            intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
            intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
            dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
            dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
            port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
            port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
            src_ip=0xc0a80101
            src_ip_str="192.168.1.1"
            dst_ip=0xe0010101
            dst_ip_str="224.1.1.1"

            port1=config["port_map"].keys()[0]
            port2=config["port_map"].keys()[1]
            #port3=config["port_map"].keys()[2]

            #add l2 interface group
            for port in config["port_map"].keys():
                add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
                #add vlan flow table
                add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
                vlan_id +=1

                #add termination flow
            add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)

            #add MPLS interface group
            l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2)
            mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2)
            #l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
            #mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
            #add L3VPN groups
            mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
                                                                   index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True)
            #mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
            #                                                       index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True)

            mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan,  2, [mpls_label_gid2])
            add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)

            parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
                                           eth_dst=dst_mac_str,
                                           eth_src=port1_mac_str,
                                           ip_ttl=64,
                                           ip_src=src_ip_str,
                                           ip_dst=dst_ip_str)
            pkt=str(parsed_pkt)
            self.dataplane.send(port1, pkt)
            label = (12, 0, 1, 63)
            exp_pkt = mpls_packet(pktlen=100,
                                  eth_dst=dst_mac_str,
                                  eth_src=intf_src_mac_str,
                                  ip_ttl=64,
                                  ip_src=src_ip_str, label= [label],
                                  ip_dst=dst_ip_str)
            pkt=str(exp_pkt)
            verify_packet(self, pkt, port2)
            #verify_packet(self, pkt, port3)
            verify_no_other_packets(self)
            delete_all_groups(self.controller)
        finally:
            delete_all_flows(self.controller)
            delete_all_groups(self.controller)


class PacketInSrcMacMiss(base_tests.SimpleDataPlane):
    """
    Test packet in function on a src-mac miss
    Send a packet to each dataplane port and verify that a packet
    in message is received from the controller for each
    #todo verify you stop receiving after adding rule
    """

    def runTest(self):
        Groups = Queue.LifoQueue()
        try:
            ports = sorted(config["port_map"].keys())

            Groups = Queue.LifoQueue()
            for port in ports:
                L2gid, l2msg = add_one_l2_interface_group(self.controller, port, 1, True, False)
                add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
                Groups.put(L2gid)
            parsed_vlan_pkt = simple_tcp_packet(pktlen=104,
                                                vlan_vid=0x1001, dl_vlan_enable=True)
            vlan_pkt = str(parsed_vlan_pkt)
            for of_port in config["port_map"].keys():
                logging.info("PacketInMiss test, port %d", of_port)
                self.dataplane.send(of_port, vlan_pkt)
                verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH)
                verify_no_other_packets(self)
        finally:
            delete_all_flows(self.controller)
            delete_all_groups(self.controller)
