#!/usr/bin/env python3

import unittest
import socket
import six

from framework import VppTestCase
from asfframework import VppTestRunner, tag_run_solo
from vpp_neighbor import VppNeighbor
from vpp_ip_route import find_route, VppIpTable
from util import mk_ll_addr
import scapy.compat
from scapy.layers.l2 import Ether, ARP, Dot1Q
from scapy.layers.inet import IP, UDP
from scapy.layers.inet6 import IPv6, in6_getnsmac
from scapy.layers.dhcp import DHCP, BOOTP, DHCPTypes
from scapy.layers.dhcp6 import (
    DHCP6_Solicit,
    DHCP6_RelayForward,
    DHCP6_RelayReply,
    DHCP6_Advertise,
    DHCP6OptRelayMsg,
    DHCP6OptIfaceId,
    DHCP6OptStatusCode,
    DHCP6OptVSS,
    DHCP6OptClientLinkLayerAddr,
    DHCP6_Request,
)
from socket import AF_INET, AF_INET6, inet_pton
from scapy.utils6 import in6_ptop
from vpp_papi import mac_pton, VppEnum
from vpp_sub_interface import VppDot1QSubint
from vpp_qos import VppQosEgressMap, VppQosMark
from vpp_dhcp import VppDHCPClient, VppDHCPProxy
from config import config


DHCP4_CLIENT_PORT = 68
DHCP4_SERVER_PORT = 67
DHCP6_CLIENT_PORT = 547
DHCP6_SERVER_PORT = 546


@tag_run_solo
@unittest.skipIf("dhcp" in config.excluded_plugins, "Exclude DHCP plugin tests")
class TestDHCP(VppTestCase):
    """DHCP Test Case"""

    @classmethod
    def setUpClass(cls):
        super(TestDHCP, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(TestDHCP, cls).tearDownClass()

    def setUp(self):
        super(TestDHCP, self).setUp()

        # create 6 pg interfaces for pg0 to pg5
        self.create_pg_interfaces(range(6))
        self.tables = []

        # pg0 to 2 are IP configured in VRF 0, 1 and 2.
        # pg3 to 5 are non IP-configured in VRF 0, 1 and 2.
        table_id = 0
        for table_id in range(1, 4):
            tbl4 = VppIpTable(self, table_id)
            tbl4.add_vpp_config()
            self.tables.append(tbl4)
            tbl6 = VppIpTable(self, table_id, is_ip6=1)
            tbl6.add_vpp_config()
            self.tables.append(tbl6)

        table_id = 0
        for i in self.pg_interfaces[:3]:
            i.admin_up()
            i.set_table_ip4(table_id)
            i.set_table_ip6(table_id)
            i.config_ip4()
            i.resolve_arp()
            i.config_ip6()
            i.resolve_ndp()
            table_id += 1

        table_id = 0
        for i in self.pg_interfaces[3:]:
            i.admin_up()
            i.set_table_ip4(table_id)
            i.set_table_ip6(table_id)
            table_id += 1

    def tearDown(self):
        for i in self.pg_interfaces[:3]:
            i.unconfig_ip4()
            i.unconfig_ip6()

        for i in self.pg_interfaces:
            i.set_table_ip4(0)
            i.set_table_ip6(0)
            i.admin_down()
        super(TestDHCP, self).tearDown()

    def verify_dhcp_has_option(self, pkt, option, value):
        dhcp = pkt[DHCP]
        found = False

        for i in dhcp.options:
            if isinstance(i, tuple):
                if i[0] == option:
                    self.assertEqual(i[1], value)
                    found = True

        self.assertTrue(found)

    def validate_relay_options(self, pkt, intf, ip_addr, vpn_id, fib_id, oui):
        dhcp = pkt[DHCP]
        found = 0
        data = []
        id_len = len(vpn_id)

        for i in dhcp.options:
            if isinstance(i, tuple):
                if i[0] == "relay_agent_information":
                    #
                    # There are two sb-options present - each of length 6.
                    #
                    data = i[1]
                    if oui != 0:
                        self.assertEqual(len(data), 24)
                    elif len(vpn_id) > 0:
                        self.assertEqual(len(data), len(vpn_id) + 17)
                    else:
                        self.assertEqual(len(data), 12)

                    #
                    # First sub-option is ID 1, len 4, then encoded
                    #  sw_if_index. This test uses low valued indicies
                    # so [2:4] are 0.
                    # The ID space is VPP internal - so no matching value
                    # scapy
                    #
                    self.assertEqual(six.byte2int(data[0:1]), 1)
                    self.assertEqual(six.byte2int(data[1:2]), 4)
                    self.assertEqual(six.byte2int(data[2:3]), 0)
                    self.assertEqual(six.byte2int(data[3:4]), 0)
                    self.assertEqual(six.byte2int(data[4:5]), 0)
                    self.assertEqual(six.byte2int(data[5:6]), intf._sw_if_index)

                    #
                    # next sub-option is the IP address of the client side
                    # interface.
                    # sub-option ID=5, length (of a v4 address)=4
                    #
                    claddr = socket.inet_pton(AF_INET, ip_addr)

                    self.assertEqual(six.byte2int(data[6:7]), 5)
                    self.assertEqual(six.byte2int(data[7:8]), 4)
                    self.assertEqual(data[8], claddr[0])
                    self.assertEqual(data[9], claddr[1])
                    self.assertEqual(data[10], claddr[2])
                    self.assertEqual(data[11], claddr[3])

                    if oui != 0:
                        # sub-option 151 encodes vss_type 1,
                        # the 3 byte oui and the 4 byte fib_id
                        self.assertEqual(id_len, 0)
                        self.assertEqual(six.byte2int(data[12:13]), 151)
                        self.assertEqual(six.byte2int(data[13:14]), 8)
                        self.assertEqual(six.byte2int(data[14:15]), 1)
                        self.assertEqual(six.byte2int(data[15:16]), 0)
                        self.assertEqual(six.byte2int(data[16:17]), 0)
                        self.assertEqual(six.byte2int(data[17:18]), oui)
                        self.assertEqual(six.byte2int(data[18:19]), 0)
                        self.assertEqual(six.byte2int(data[19:20]), 0)
                        self.assertEqual(six.byte2int(data[20:21]), 0)
                        self.assertEqual(six.byte2int(data[21:22]), fib_id)

                        # VSS control sub-option
                        self.assertEqual(six.byte2int(data[22:23]), 152)
                        self.assertEqual(six.byte2int(data[23:24]), 0)

                    if id_len > 0:
                        # sub-option 151 encode vss_type of 0
                        # followerd by vpn_id in ascii
                        self.assertEqual(oui, 0)
                        self.assertEqual(six.byte2int(data[12:13]), 151)
                        self.assertEqual(six.byte2int(data[13:14]), id_len + 1)
                        self.assertEqual(six.byte2int(data[14:15]), 0)
                        self.assertEqual(data[15 : 15 + id_len].decode("ascii"), vpn_id)

                        # VSS control sub-option
                        self.assertEqual(
                            six.byte2int(data[15 + len(vpn_id) : 16 + len(vpn_id)]), 152
                        )
                        self.assertEqual(
                            six.byte2int(data[16 + len(vpn_id) : 17 + len(vpn_id)]), 0
                        )

                    found = 1
        self.assertTrue(found)

        return data

    def verify_dhcp_msg_type(self, pkt, name):
        dhcp = pkt[DHCP]
        found = False
        for o in dhcp.options:
            if isinstance(o, tuple):
                if o[0] == "message-type" and DHCPTypes[o[1]] == name:
                    found = True
        self.assertTrue(found)

    def verify_dhcp_offer(self, pkt, intf, vpn_id="", fib_id=0, oui=0):
        ether = pkt[Ether]
        self.assertEqual(ether.dst, "ff:ff:ff:ff:ff:ff")
        self.assertEqual(ether.src, intf.local_mac)

        ip = pkt[IP]
        self.assertEqual(ip.dst, "255.255.255.255")
        self.assertEqual(ip.src, intf.local_ip4)

        udp = pkt[UDP]
        self.assertEqual(udp.dport, DHCP4_CLIENT_PORT)
        self.assertEqual(udp.sport, DHCP4_SERVER_PORT)

        self.verify_dhcp_msg_type(pkt, "offer")
        data = self.validate_relay_options(
            pkt, intf, intf.local_ip4, vpn_id, fib_id, oui
        )

    def verify_orig_dhcp_pkt(self, pkt, intf, dscp, l2_bc=True):
        ether = pkt[Ether]
        if l2_bc:
            self.assertEqual(ether.dst, "ff:ff:ff:ff:ff:ff")
        else:
            self.assertEqual(ether.dst, intf.remote_mac)
        self.assertEqual(ether.src, intf.local_mac)

        ip = pkt[IP]

        if l2_bc:
            self.assertEqual(ip.dst, "255.255.255.255")
            self.assertEqual(ip.src, "0.0.0.0")
        else:
            self.assertEqual(ip.dst, intf.remote_ip4)
            self.assertEqual(ip.src, intf.local_ip4)
        self.assertEqual(ip.tos, dscp)

        udp = pkt[UDP]
        self.assertEqual(udp.dport, DHCP4_SERVER_PORT)
        self.assertEqual(udp.sport, DHCP4_CLIENT_PORT)

    def verify_orig_dhcp_discover(
        self, pkt, intf, hostname, client_id=None, broadcast=True, dscp=0
    ):
        self.verify_orig_dhcp_pkt(pkt, intf, dscp)

        self.verify_dhcp_msg_type(pkt, "discover")
        self.verify_dhcp_has_option(pkt, "hostname", hostname.encode("ascii"))
        if client_id:
            client_id = "\x00" + client_id
            self.verify_dhcp_has_option(pkt, "client_id", client_id.encode("ascii"))
        bootp = pkt[BOOTP]
        self.assertEqual(bootp.ciaddr, "0.0.0.0")
        self.assertEqual(bootp.giaddr, "0.0.0.0")
        if broadcast:
            self.assertEqual(bootp.flags, 0x8000)
        else:
            self.assertEqual(bootp.flags, 0x0000)

    def verify_orig_dhcp_request(
        self, pkt, intf, hostname, ip, broadcast=True, l2_bc=True, dscp=0
    ):
        self.verify_orig_dhcp_pkt(pkt, intf, dscp, l2_bc=l2_bc)

        self.verify_dhcp_msg_type(pkt, "request")
        self.verify_dhcp_has_option(pkt, "hostname", hostname.encode("ascii"))
        self.verify_dhcp_has_option(pkt, "requested_addr", ip)
        bootp = pkt[BOOTP]

        if l2_bc:
            self.assertEqual(bootp.ciaddr, "0.0.0.0")
        else:
            self.assertEqual(bootp.ciaddr, intf.local_ip4)
        self.assertEqual(bootp.giaddr, "0.0.0.0")

        if broadcast:
            self.assertEqual(bootp.flags, 0x8000)
        else:
            self.assertEqual(bootp.flags, 0x0000)

    def verify_relayed_dhcp_discover(
        self,
        pkt,
        intf,
        src_intf=None,
        fib_id=0,
        oui=0,
        vpn_id="",
        dst_mac=None,
        dst_ip=None,
    ):
        if not dst_mac:
            dst_mac = intf.remote_mac
        if not dst_ip:
            dst_ip = intf.remote_ip4

        ether = pkt[Ether]
        self.assertEqual(ether.dst, dst_mac)
        self.assertEqual(ether.src, intf.local_mac)

        ip = pkt[IP]
        self.assertEqual(ip.dst, dst_ip)
        self.assertEqual(ip.src, intf.local_ip4)

        udp = pkt[UDP]
        self.assertEqual(udp.dport, DHCP4_SERVER_PORT)
        self.assertEqual(udp.sport, DHCP4_CLIENT_PORT)

        dhcp = pkt[DHCP]

        is_discover = False
        for o in dhcp.options:
            if isinstance(o, tuple):
                if o[0] == "message-type" and DHCPTypes[o[1]] == "discover":
                    is_discover = True
        self.assertTrue(is_discover)

        data = self.validate_relay_options(
            pkt, src_intf, src_intf.local_ip4, vpn_id, fib_id, oui
        )
        return data

    def verify_dhcp6_solicit(
        self,
        pkt,
        intf,
        peer_ip,
        peer_mac,
        vpn_id="",
        fib_id=0,
        oui=0,
        dst_mac=None,
        dst_ip=None,
    ):
        if not dst_mac:
            dst_mac = intf.remote_mac
        if not dst_ip:
            dst_ip = in6_ptop(intf.remote_ip6)

        ether = pkt[Ether]
        self.assertEqual(ether.dst, dst_mac)
        self.assertEqual(ether.src, intf.local_mac)

        ip = pkt[IPv6]
        self.assertEqual(in6_ptop(ip.dst), dst_ip)
        self.assertEqual(in6_ptop(ip.src), in6_ptop(intf.local_ip6))

        udp = pkt[UDP]
        self.assertEqual(udp.dport, DHCP6_CLIENT_PORT)
        self.assertEqual(udp.sport, DHCP6_SERVER_PORT)

        relay = pkt[DHCP6_RelayForward]
        self.assertEqual(in6_ptop(relay.peeraddr), in6_ptop(peer_ip))
        oid = pkt[DHCP6OptIfaceId]
        cll = pkt[DHCP6OptClientLinkLayerAddr]
        self.assertEqual(cll.optlen, 8)
        self.assertEqual(cll.lltype, 1)
        self.assertEqual(cll.clladdr, peer_mac)

        id_len = len(vpn_id)

        if fib_id != 0:
            self.assertEqual(id_len, 0)
            vss = pkt[DHCP6OptVSS]
            self.assertEqual(vss.optlen, 8)
            self.assertEqual(vss.type, 1)
            # the OUI and FIB-id are really 3 and 4 bytes resp.
            # but the tested range is small
            self.assertEqual(six.byte2int(vss.data[0:1]), 0)
            self.assertEqual(six.byte2int(vss.data[1:2]), 0)
            self.assertEqual(six.byte2int(vss.data[2:3]), oui)
            self.assertEqual(six.byte2int(vss.data[3:4]), 0)
            self.assertEqual(six.byte2int(vss.data[4:5]), 0)
            self.assertEqual(six.byte2int(vss.data[5:6]), 0)
            self.assertEqual(six.byte2int(vss.data[6:7]), fib_id)

        if id_len > 0:
            self.assertEqual(oui, 0)
            vss = pkt[DHCP6OptVSS]
            self.assertEqual(vss.optlen, id_len + 1)
            self.assertEqual(vss.type, 0)
            self.assertEqual(vss.data[0:id_len].decode("ascii"), vpn_id)

        # the relay message should be an encoded Solicit
        msg = pkt[DHCP6OptRelayMsg]
        sol = DHCP6_Solicit()
        self.assertEqual(msg.optlen, len(sol))
        self.assertEqual(sol, msg[1])

    def verify_dhcp6_advert(self, pkt, intf, peer):
        ether = pkt[Ether]
        self.assertEqual(ether.dst, "ff:ff:ff:ff:ff:ff")
        self.assertEqual(ether.src, intf.local_mac)

        ip = pkt[IPv6]
        self.assertEqual(in6_ptop(ip.dst), in6_ptop(peer))
        self.assertEqual(in6_ptop(ip.src), in6_ptop(intf.local_ip6))

        udp = pkt[UDP]
        self.assertEqual(udp.dport, DHCP6_SERVER_PORT)
        self.assertEqual(udp.sport, DHCP6_CLIENT_PORT)

        # not sure why this is not decoding
        # adv = pkt[DHCP6_Advertise]

    def wait_for_no_route(self, address, length, n_tries=50, s_time=1):
        while n_tries:
            if not find_route(self, address, length):
                return True
            n_tries = n_tries - 1
            self.sleep(s_time)

        return False

    def test_dhcp_proxy(self):
        """DHCPv4 Proxy"""

        #
        # Verify no response to DHCP request without DHCP config
        #
        p_disc_vrf0 = (
            Ether(dst="ff:ff:ff:ff:ff:ff", src=self.pg3.remote_mac)
            / IP(src="0.0.0.0", dst="255.255.255.255")
            / UDP(sport=DHCP4_CLIENT_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(options=[("message-type", "discover"), ("end")])
        )
        pkts_disc_vrf0 = [p_disc_vrf0]
        p_disc_vrf1 = (
            Ether(dst="ff:ff:ff:ff:ff:ff", src=self.pg4.remote_mac)
            / IP(src="0.0.0.0", dst="255.255.255.255")
            / UDP(sport=DHCP4_CLIENT_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(options=[("message-type", "discover"), ("end")])
        )
        pkts_disc_vrf1 = [p_disc_vrf1]
        p_disc_vrf2 = (
            Ether(dst="ff:ff:ff:ff:ff:ff", src=self.pg5.remote_mac)
            / IP(src="0.0.0.0", dst="255.255.255.255")
            / UDP(sport=DHCP4_CLIENT_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(options=[("message-type", "discover"), ("end")])
        )
        pkts_disc_vrf2 = [p_disc_vrf2]

        self.send_and_assert_no_replies(
            self.pg3, pkts_disc_vrf0, "DHCP with no configuration"
        )
        self.send_and_assert_no_replies(
            self.pg4, pkts_disc_vrf1, "DHCP with no configuration"
        )
        self.send_and_assert_no_replies(
            self.pg5, pkts_disc_vrf2, "DHCP with no configuration"
        )

        #
        # Enable DHCP proxy in VRF 0
        #
        server_addr = self.pg0.remote_ip4
        src_addr = self.pg0.local_ip4

        Proxy = VppDHCPProxy(self, server_addr, src_addr, rx_vrf_id=0)
        Proxy.add_vpp_config()

        #
        # Discover packets from the client are dropped because there is no
        # IP address configured on the client facing interface
        #
        self.send_and_assert_no_replies(
            self.pg3, pkts_disc_vrf0, "Discover DHCP no relay address"
        )

        #
        # Inject a response from the server
        #  dropped, because there is no IP addrees on the
        #  client interfce to fill in the option.
        #
        p = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(options=[("message-type", "offer"), ("end")])
        )
        pkts = [p]

        self.send_and_assert_no_replies(self.pg3, pkts, "Offer DHCP no relay address")

        #
        # configure an IP address on the client facing interface
        #
        self.pg3.config_ip4()

        #
        # Try again with a discover packet
        # Rx'd packet should be to the server address and from the configured
        # source address
        # UDP source ports are unchanged
        # we've no option 82 config so that should be absent
        #
        self.pg3.add_stream(pkts_disc_vrf0)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg0.get_capture(1)
        rx = rx[0]

        option_82 = self.verify_relayed_dhcp_discover(rx, self.pg0, src_intf=self.pg3)

        #
        # Create an DHCP offer reply from the server with a correctly formatted
        # option 82. i.e. send back what we just captured
        # The offer, sent mcast to the client, still has option 82.
        #
        p = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(
                options=[
                    ("message-type", "offer"),
                    ("relay_agent_information", option_82),
                    ("end"),
                ]
            )
        )
        pkts = [p]

        self.pg0.add_stream(pkts)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg3.get_capture(1, timeout=5)
        rx = rx[0]

        self.verify_dhcp_offer(rx, self.pg3)

        #
        # Bogus Option 82:
        #
        # 1. not our IP address = not checked by VPP? so offer is replayed
        #    to client
        bad_ip = option_82[0:8] + scapy.compat.chb(33) + option_82[9:]

        p = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(
                options=[
                    ("message-type", "offer"),
                    ("relay_agent_information", bad_ip),
                    ("end"),
                ]
            )
        )
        pkts = [p]
        self.send_and_assert_no_replies(
            self.pg0, pkts, "DHCP offer option 82 bad address"
        )

        # 2. Not a sw_if_index VPP knows
        bad_if_index = option_82[0:2] + scapy.compat.chb(33) + option_82[3:]

        p = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IP(src=self.pg0.remote_ip4, dst=self.pg0.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(
                options=[
                    ("message-type", "offer"),
                    ("relay_agent_information", bad_if_index),
                    ("end"),
                ]
            )
        )
        pkts = [p]
        self.send_and_assert_no_replies(
            self.pg0, pkts, "DHCP offer option 82 bad if index"
        )

        #
        # Send a DHCP request in VRF 1. should be dropped.
        #
        self.send_and_assert_no_replies(
            self.pg4, pkts_disc_vrf1, "DHCP with no configuration VRF 1"
        )

        #
        # Delete the DHCP config in VRF 0
        # Should now drop requests.
        #
        Proxy.remove_vpp_config()

        self.send_and_assert_no_replies(
            self.pg3, pkts_disc_vrf0, "DHCP config removed VRF 0"
        )
        self.send_and_assert_no_replies(
            self.pg4, pkts_disc_vrf1, "DHCP config removed VRF 1"
        )

        #
        # Add DHCP config for VRF 1 & 2
        #
        server_addr1 = self.pg1.remote_ip4
        src_addr1 = self.pg1.local_ip4
        Proxy1 = VppDHCPProxy(
            self, server_addr1, src_addr1, rx_vrf_id=1, server_vrf_id=1
        )
        Proxy1.add_vpp_config()

        server_addr2 = self.pg2.remote_ip4
        src_addr2 = self.pg2.local_ip4
        Proxy2 = VppDHCPProxy(
            self, server_addr2, src_addr2, rx_vrf_id=2, server_vrf_id=2
        )
        Proxy2.add_vpp_config()

        #
        # Confim DHCP requests ok in VRF 1 & 2.
        #  - dropped on IP config on client interface
        #
        self.send_and_assert_no_replies(
            self.pg4, pkts_disc_vrf1, "DHCP config removed VRF 1"
        )
        self.send_and_assert_no_replies(
            self.pg5, pkts_disc_vrf2, "DHCP config removed VRF 2"
        )

        #
        # configure an IP address on the client facing interface
        #
        self.pg4.config_ip4()
        self.pg4.add_stream(pkts_disc_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()
        rx = self.pg1.get_capture(1)
        rx = rx[0]
        self.verify_relayed_dhcp_discover(rx, self.pg1, src_intf=self.pg4)

        self.pg5.config_ip4()
        self.pg5.add_stream(pkts_disc_vrf2)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()
        rx = self.pg2.get_capture(1)
        rx = rx[0]
        self.verify_relayed_dhcp_discover(rx, self.pg2, src_intf=self.pg5)

        #
        # Add VSS config
        #  table=1, vss_type=1, vpn_index=1, oui=4
        #  table=2, vss_type=0, vpn_id = "ip4-table-2"
        self.vapi.dhcp_proxy_set_vss(tbl_id=1, vss_type=1, vpn_index=1, oui=4, is_add=1)
        self.vapi.dhcp_proxy_set_vss(
            tbl_id=2, vss_type=0, vpn_ascii_id="ip4-table-2", is_add=1
        )

        self.pg4.add_stream(pkts_disc_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(1)
        rx = rx[0]
        self.verify_relayed_dhcp_discover(
            rx, self.pg1, src_intf=self.pg4, fib_id=1, oui=4
        )

        self.pg5.add_stream(pkts_disc_vrf2)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg2.get_capture(1)
        rx = rx[0]
        self.verify_relayed_dhcp_discover(
            rx, self.pg2, src_intf=self.pg5, vpn_id="ip4-table-2"
        )

        #
        # Add a second DHCP server in VRF 1
        #  expect clients messages to be relay to both configured servers
        #
        self.pg1.generate_remote_hosts(2)
        server_addr12 = self.pg1.remote_hosts[1].ip4

        Proxy12 = VppDHCPProxy(
            self, server_addr12, src_addr, rx_vrf_id=1, server_vrf_id=1
        )
        Proxy12.add_vpp_config()

        #
        # We'll need an ARP entry for the server to send it packets
        #
        arp_entry = VppNeighbor(
            self,
            self.pg1.sw_if_index,
            self.pg1.remote_hosts[1].mac,
            self.pg1.remote_hosts[1].ip4,
        )
        arp_entry.add_vpp_config()

        #
        # Send a discover from the client. expect two relayed messages
        # The frist packet is sent to the second server
        # We're not enforcing that here, it's just the way it is.
        #
        self.pg4.add_stream(pkts_disc_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(2)

        option_82 = self.verify_relayed_dhcp_discover(
            rx[0],
            self.pg1,
            src_intf=self.pg4,
            dst_mac=self.pg1.remote_hosts[1].mac,
            dst_ip=self.pg1.remote_hosts[1].ip4,
            fib_id=1,
            oui=4,
        )
        self.verify_relayed_dhcp_discover(
            rx[1], self.pg1, src_intf=self.pg4, fib_id=1, oui=4
        )

        #
        # Send both packets back. Client gets both.
        #
        p1 = (
            Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac)
            / IP(src=self.pg1.remote_ip4, dst=self.pg1.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(
                options=[
                    ("message-type", "offer"),
                    ("relay_agent_information", option_82),
                    ("end"),
                ]
            )
        )
        p2 = (
            Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac)
            / IP(src=self.pg1.remote_hosts[1].ip4, dst=self.pg1.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(
                options=[
                    ("message-type", "offer"),
                    ("relay_agent_information", option_82),
                    ("end"),
                ]
            )
        )
        pkts = [p1, p2]

        self.pg1.add_stream(pkts)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg4.get_capture(2)

        self.verify_dhcp_offer(rx[0], self.pg4, fib_id=1, oui=4)
        self.verify_dhcp_offer(rx[1], self.pg4, fib_id=1, oui=4)

        #
        # Ensure offers from non-servers are dropeed
        #
        p2 = (
            Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac)
            / IP(src="8.8.8.8", dst=self.pg1.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(
                options=[
                    ("message-type", "offer"),
                    ("relay_agent_information", option_82),
                    ("end"),
                ]
            )
        )
        self.send_and_assert_no_replies(self.pg1, p2, "DHCP offer from non-server")

        #
        # Ensure only the discover is sent to multiple servers
        #
        p_req_vrf1 = (
            Ether(dst="ff:ff:ff:ff:ff:ff", src=self.pg4.remote_mac)
            / IP(src="0.0.0.0", dst="255.255.255.255")
            / UDP(sport=DHCP4_CLIENT_PORT, dport=DHCP4_SERVER_PORT)
            / BOOTP(op=1)
            / DHCP(options=[("message-type", "request"), ("end")])
        )

        self.pg4.add_stream(p_req_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(1)

        #
        # Remove the second DHCP server
        #
        Proxy12.remove_vpp_config()

        #
        # Test we can still relay with the first
        #
        self.pg4.add_stream(pkts_disc_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(1)
        rx = rx[0]
        self.verify_relayed_dhcp_discover(
            rx, self.pg1, src_intf=self.pg4, fib_id=1, oui=4
        )

        #
        # Remove the VSS config
        #  relayed DHCP has default vlaues in the option.
        #
        self.vapi.dhcp_proxy_set_vss(tbl_id=1, is_add=0)
        self.vapi.dhcp_proxy_set_vss(tbl_id=2, is_add=0)

        self.pg4.add_stream(pkts_disc_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(1)
        rx = rx[0]
        self.verify_relayed_dhcp_discover(rx, self.pg1, src_intf=self.pg4)

        #
        # remove DHCP config to cleanup
        #
        Proxy1.remove_vpp_config()
        Proxy2.remove_vpp_config()

        self.send_and_assert_no_replies(self.pg3, pkts_disc_vrf0, "DHCP cleanup VRF 0")
        self.send_and_assert_no_replies(self.pg4, pkts_disc_vrf1, "DHCP cleanup VRF 1")
        self.send_and_assert_no_replies(self.pg5, pkts_disc_vrf2, "DHCP cleanup VRF 2")

        self.pg3.unconfig_ip4()
        self.pg4.unconfig_ip4()
        self.pg5.unconfig_ip4()

    def test_dhcp6_proxy(self):
        """DHCPv6 Proxy"""
        #
        # Verify no response to DHCP request without DHCP config
        #
        dhcp_solicit_dst = "ff02::1:2"
        dhcp_solicit_src_vrf0 = mk_ll_addr(self.pg3.remote_mac)
        dhcp_solicit_src_vrf1 = mk_ll_addr(self.pg4.remote_mac)
        dhcp_solicit_src_vrf2 = mk_ll_addr(self.pg5.remote_mac)
        server_addr_vrf0 = self.pg0.remote_ip6
        src_addr_vrf0 = self.pg0.local_ip6
        server_addr_vrf1 = self.pg1.remote_ip6
        src_addr_vrf1 = self.pg1.local_ip6
        server_addr_vrf2 = self.pg2.remote_ip6
        src_addr_vrf2 = self.pg2.local_ip6

        dmac = in6_getnsmac(inet_pton(socket.AF_INET6, dhcp_solicit_dst))
        p_solicit_vrf0 = (
            Ether(dst=dmac, src=self.pg3.remote_mac)
            / IPv6(src=dhcp_solicit_src_vrf0, dst=dhcp_solicit_dst)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_CLIENT_PORT)
            / DHCP6_Solicit()
        )
        p_solicit_vrf1 = (
            Ether(dst=dmac, src=self.pg4.remote_mac)
            / IPv6(src=dhcp_solicit_src_vrf1, dst=dhcp_solicit_dst)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_CLIENT_PORT)
            / DHCP6_Solicit()
        )
        p_solicit_vrf2 = (
            Ether(dst=dmac, src=self.pg5.remote_mac)
            / IPv6(src=dhcp_solicit_src_vrf2, dst=dhcp_solicit_dst)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_CLIENT_PORT)
            / DHCP6_Solicit()
        )

        self.send_and_assert_no_replies(
            self.pg3, p_solicit_vrf0, "DHCP with no configuration"
        )
        self.send_and_assert_no_replies(
            self.pg4, p_solicit_vrf1, "DHCP with no configuration"
        )
        self.send_and_assert_no_replies(
            self.pg5, p_solicit_vrf2, "DHCP with no configuration"
        )

        #
        # DHCPv6 config in VRF 0.
        # Packets still dropped because the client facing interface has no
        # IPv6 config
        #
        Proxy = VppDHCPProxy(
            self, server_addr_vrf0, src_addr_vrf0, rx_vrf_id=0, server_vrf_id=0
        )
        Proxy.add_vpp_config()

        self.send_and_assert_no_replies(
            self.pg3, p_solicit_vrf0, "DHCP with no configuration"
        )
        self.send_and_assert_no_replies(
            self.pg4, p_solicit_vrf1, "DHCP with no configuration"
        )

        #
        # configure an IP address on the client facing interface
        #
        self.pg3.config_ip6()

        #
        # Now the DHCP requests are relayed to the server
        #
        self.pg3.add_stream(p_solicit_vrf0)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg0.get_capture(1)

        self.verify_dhcp6_solicit(
            rx[0], self.pg0, dhcp_solicit_src_vrf0, self.pg3.remote_mac
        )

        #
        # Exception cases for rejected relay responses
        #

        # 1 - not a relay reply
        p_adv_vrf0 = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_Advertise()
        )
        self.send_and_assert_no_replies(self.pg3, p_adv_vrf0, "DHCP6 not a relay reply")

        # 2 - no relay message option
        p_adv_vrf0 = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_RelayReply()
            / DHCP6_Advertise()
        )
        self.send_and_assert_no_replies(
            self.pg3, p_adv_vrf0, "DHCP not a relay message"
        )

        # 3 - no circuit ID
        p_adv_vrf0 = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_RelayReply()
            / DHCP6OptRelayMsg(optlen=0)
            / DHCP6_Advertise()
        )
        self.send_and_assert_no_replies(self.pg3, p_adv_vrf0, "DHCP6 no circuit ID")
        # 4 - wrong circuit ID
        p_adv_vrf0 = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_RelayReply()
            / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05")
            / DHCP6OptRelayMsg(optlen=0)
            / DHCP6_Advertise()
        )
        self.send_and_assert_no_replies(self.pg3, p_adv_vrf0, "DHCP6 wrong circuit ID")

        #
        # Send the relay response (the advertisement)
        #   - no peer address
        p_adv_vrf0 = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_RelayReply()
            / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x04")
            / DHCP6OptRelayMsg(optlen=0)
            / DHCP6_Advertise(trid=1)
            / DHCP6OptStatusCode(statuscode=0)
        )
        pkts_adv_vrf0 = [p_adv_vrf0]

        self.pg0.add_stream(pkts_adv_vrf0)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg3.get_capture(1)

        self.verify_dhcp6_advert(rx[0], self.pg3, "::")

        #
        # Send the relay response (the advertisement)
        #   - with peer address
        p_adv_vrf0 = (
            Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac)
            / IPv6(dst=self.pg0.local_ip6, src=self.pg0.remote_ip6)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf0)
            / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x04")
            / DHCP6OptRelayMsg(optlen=0)
            / DHCP6_Advertise(trid=1)
            / DHCP6OptStatusCode(statuscode=0)
        )
        pkts_adv_vrf0 = [p_adv_vrf0]

        self.pg0.add_stream(pkts_adv_vrf0)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg3.get_capture(1)

        self.verify_dhcp6_advert(rx[0], self.pg3, dhcp_solicit_src_vrf0)

        #
        # Add all the config for VRF 1 & 2
        #
        Proxy1 = VppDHCPProxy(
            self, server_addr_vrf1, src_addr_vrf1, rx_vrf_id=1, server_vrf_id=1
        )
        Proxy1.add_vpp_config()
        self.pg4.config_ip6()

        Proxy2 = VppDHCPProxy(
            self, server_addr_vrf2, src_addr_vrf2, rx_vrf_id=2, server_vrf_id=2
        )
        Proxy2.add_vpp_config()
        self.pg5.config_ip6()

        #
        # VRF 1 solicit
        #
        self.pg4.add_stream(p_solicit_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(1)

        self.verify_dhcp6_solicit(
            rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac
        )

        #
        # VRF 2 solicit
        #
        self.pg5.add_stream(p_solicit_vrf2)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg2.get_capture(1)

        self.verify_dhcp6_solicit(
            rx[0], self.pg2, dhcp_solicit_src_vrf2, self.pg5.remote_mac
        )

        #
        # VRF 1 Advert
        #
        p_adv_vrf1 = (
            Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac)
            / IPv6(dst=self.pg1.local_ip6, src=self.pg1.remote_ip6)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf1)
            / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05")
            / DHCP6OptRelayMsg(optlen=0)
            / DHCP6_Advertise(trid=1)
            / DHCP6OptStatusCode(statuscode=0)
        )
        pkts_adv_vrf1 = [p_adv_vrf1]

        self.pg1.add_stream(pkts_adv_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg4.get_capture(1)

        self.verify_dhcp6_advert(rx[0], self.pg4, dhcp_solicit_src_vrf1)

        #
        # Add VSS config
        #
        self.vapi.dhcp_proxy_set_vss(
            tbl_id=1, vss_type=1, oui=4, vpn_index=1, is_ipv6=1, is_add=1
        )
        self.vapi.dhcp_proxy_set_vss(
            tbl_id=2, vss_type=0, vpn_ascii_id="IPv6-table-2", is_ipv6=1, is_add=1
        )

        self.pg4.add_stream(p_solicit_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(1)

        self.verify_dhcp6_solicit(
            rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac, fib_id=1, oui=4
        )

        self.pg5.add_stream(p_solicit_vrf2)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg2.get_capture(1)

        self.verify_dhcp6_solicit(
            rx[0],
            self.pg2,
            dhcp_solicit_src_vrf2,
            self.pg5.remote_mac,
            vpn_id="IPv6-table-2",
        )

        #
        # Remove the VSS config
        #  relayed DHCP has default vlaues in the option.
        #
        self.vapi.dhcp_proxy_set_vss(tbl_id=1, is_ipv6=1, is_add=0)

        self.pg4.add_stream(p_solicit_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(1)

        self.verify_dhcp6_solicit(
            rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac
        )

        #
        # Add a second DHCP server in VRF 1
        #  expect clients messages to be relay to both configured servers
        #
        self.pg1.generate_remote_hosts(2)
        server_addr12 = self.pg1.remote_hosts[1].ip6

        Proxy12 = VppDHCPProxy(
            self, server_addr12, src_addr_vrf1, rx_vrf_id=1, server_vrf_id=1
        )
        Proxy12.add_vpp_config()

        #
        # We'll need an ND entry for the server to send it packets
        #
        nd_entry = VppNeighbor(
            self,
            self.pg1.sw_if_index,
            self.pg1.remote_hosts[1].mac,
            self.pg1.remote_hosts[1].ip6,
        )
        nd_entry.add_vpp_config()

        #
        # Send a discover from the client. expect two relayed messages
        # The frist packet is sent to the second server
        # We're not enforcing that here, it's just the way it is.
        #
        self.pg4.add_stream(p_solicit_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(2)

        self.verify_dhcp6_solicit(
            rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac
        )
        self.verify_dhcp6_solicit(
            rx[1],
            self.pg1,
            dhcp_solicit_src_vrf1,
            self.pg4.remote_mac,
            dst_mac=self.pg1.remote_hosts[1].mac,
            dst_ip=self.pg1.remote_hosts[1].ip6,
        )

        #
        # Send both packets back. Client gets both.
        #
        p1 = (
            Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac)
            / IPv6(dst=self.pg1.local_ip6, src=self.pg1.remote_ip6)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf1)
            / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05")
            / DHCP6OptRelayMsg(optlen=0)
            / DHCP6_Advertise(trid=1)
            / DHCP6OptStatusCode(statuscode=0)
        )
        p2 = (
            Ether(dst=self.pg1.local_mac, src=self.pg1.remote_hosts[1].mac)
            / IPv6(dst=self.pg1.local_ip6, src=self.pg1._remote_hosts[1].ip6)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf1)
            / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05")
            / DHCP6OptRelayMsg(optlen=0)
            / DHCP6_Advertise(trid=1)
            / DHCP6OptStatusCode(statuscode=0)
        )

        pkts = [p1, p2]

        self.pg1.add_stream(pkts)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg4.get_capture(2)

        self.verify_dhcp6_advert(rx[0], self.pg4, dhcp_solicit_src_vrf1)
        self.verify_dhcp6_advert(rx[1], self.pg4, dhcp_solicit_src_vrf1)

        #
        # Ensure only solicit messages are duplicated
        #
        p_request_vrf1 = (
            Ether(dst=dmac, src=self.pg4.remote_mac)
            / IPv6(src=dhcp_solicit_src_vrf1, dst=dhcp_solicit_dst)
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_CLIENT_PORT)
            / DHCP6_Request()
        )

        self.pg4.add_stream(p_request_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(1)

        #
        # Test we drop DHCP packets from addresses that are not configured as
        # DHCP servers
        #
        p2 = (
            Ether(dst=self.pg1.local_mac, src=self.pg1.remote_hosts[1].mac)
            / IPv6(dst=self.pg1.local_ip6, src="3001::1")
            / UDP(sport=DHCP6_SERVER_PORT, dport=DHCP6_SERVER_PORT)
            / DHCP6_RelayReply(peeraddr=dhcp_solicit_src_vrf1)
            / DHCP6OptIfaceId(optlen=4, ifaceid="\x00\x00\x00\x05")
            / DHCP6OptRelayMsg(optlen=0)
            / DHCP6_Advertise(trid=1)
            / DHCP6OptStatusCode(statuscode=0)
        )
        self.send_and_assert_no_replies(self.pg1, p2, "DHCP6 not from server")

        #
        # Remove the second DHCP server
        #
        Proxy12.remove_vpp_config()

        #
        # Test we can still relay with the first
        #
        self.pg4.add_stream(p_solicit_vrf1)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg1.get_capture(1)

        self.verify_dhcp6_solicit(
            rx[0], self.pg1, dhcp_solicit_src_vrf1, self.pg4.remote_mac
        )

        #
        # Cleanup
        #
        Proxy.remove_vpp_config()
        Proxy1.remove_vpp_config()
        Proxy2.remove_vpp_config()

        self.pg3.unconfig_ip6()
        self.pg4.unconfig_ip6()
        self.pg5.unconfig_ip6()

    def test_dhcp_client(self):
        """DHCP Client"""

        vdscp = VppEnum.vl_api_ip_dscp_t
        hostname = "universal-dp"

        self.pg_enable_capture(self.pg_interfaces)

        #
        # Configure DHCP client on PG3 and capture the discover sent
        #
        Client = VppDHCPClient(self, self.pg3.sw_if_index, hostname)
        Client.add_vpp_config()
        self.assertTrue(Client.query_vpp_config())

        rx = self.pg3.get_capture(1)

        self.verify_orig_dhcp_discover(rx[0], self.pg3, hostname)

        #
        # Send back on offer, expect the request
        #
        p_offer = (
            Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac)
            / IP(src=self.pg3.remote_ip4, dst="255.255.255.255")
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT)
            / BOOTP(
                op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac)
            )
            / DHCP(
                options=[
                    ("message-type", "offer"),
                    ("server_id", self.pg3.remote_ip4),
                    "end",
                ]
            )
        )

        self.pg3.add_stream(p_offer)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg3.get_capture(1)
        self.verify_orig_dhcp_request(rx[0], self.pg3, hostname, self.pg3.local_ip4)

        #
        # Send an acknowledgment
        #
        p_ack = (
            Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac)
            / IP(src=self.pg3.remote_ip4, dst="255.255.255.255")
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT)
            / BOOTP(
                op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac)
            )
            / DHCP(
                options=[
                    ("message-type", "ack"),
                    ("subnet_mask", "255.255.255.0"),
                    ("router", self.pg3.remote_ip4),
                    ("server_id", self.pg3.remote_ip4),
                    ("lease_time", 43200),
                    "end",
                ]
            )
        )

        self.pg3.add_stream(p_ack)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        #
        # We'll get an ARP request for the router address
        #
        rx = self.pg3.get_capture(1)

        self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4)
        self.pg_enable_capture(self.pg_interfaces)

        #
        # At the end of this procedure there should be a connected route
        # in the FIB
        #
        self.assertTrue(find_route(self, self.pg3.local_ip4, 24))
        self.assertTrue(find_route(self, self.pg3.local_ip4, 32))

        #
        # remove the DHCP config
        #
        Client.remove_vpp_config()

        #
        # and now the route should be gone
        #
        self.assertFalse(find_route(self, self.pg3.local_ip4, 32))
        self.assertFalse(find_route(self, self.pg3.local_ip4, 24))

        #
        # Start the procedure again. this time have VPP send the client-ID
        # and set the DSCP value
        #
        self.pg3.admin_down()
        self.sleep(1)
        self.pg3.admin_up()
        Client.set_client(
            self.pg3.sw_if_index,
            hostname,
            id=self.pg3.local_mac,
            dscp=vdscp.IP_API_DSCP_EF,
        )
        Client.add_vpp_config()

        rx = self.pg3.get_capture(1)

        self.verify_orig_dhcp_discover(
            rx[0], self.pg3, hostname, self.pg3.local_mac, dscp=vdscp.IP_API_DSCP_EF
        )

        # TODO: VPP DHCP client should not accept DHCP OFFER message with
        # the XID (Transaction ID) not matching the XID of the most recent
        # DHCP DISCOVERY message.
        # Such DHCP OFFER message must be silently discarded - RFC2131.
        # Reported in Jira ticket: VPP-99
        self.pg3.add_stream(p_offer)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg3.get_capture(1)
        self.verify_orig_dhcp_request(
            rx[0], self.pg3, hostname, self.pg3.local_ip4, dscp=vdscp.IP_API_DSCP_EF
        )

        #
        # unicast the ack to the offered address
        #
        p_ack = (
            Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac)
            / IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT)
            / BOOTP(
                op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac)
            )
            / DHCP(
                options=[
                    ("message-type", "ack"),
                    ("subnet_mask", "255.255.255.0"),
                    ("router", self.pg3.remote_ip4),
                    ("server_id", self.pg3.remote_ip4),
                    ("lease_time", 43200),
                    "end",
                ]
            )
        )

        self.pg3.add_stream(p_ack)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        #
        # We'll get an ARP request for the router address
        #
        rx = self.pg3.get_capture(1)

        self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4)
        self.pg_enable_capture(self.pg_interfaces)

        #
        # At the end of this procedure there should be a connected route
        # in the FIB
        #
        self.assertTrue(find_route(self, self.pg3.local_ip4, 32))
        self.assertTrue(find_route(self, self.pg3.local_ip4, 24))

        #
        # remove the DHCP config
        #
        Client.remove_vpp_config()

        self.assertFalse(find_route(self, self.pg3.local_ip4, 32))
        self.assertFalse(find_route(self, self.pg3.local_ip4, 24))

        #
        # Rince and repeat, this time with VPP configured not to set
        # the braodcast flag in the discover and request messages,
        # and for the server to unicast the responses.
        #
        # Configure DHCP client on PG3 and capture the discover sent
        #
        Client.set_client(self.pg3.sw_if_index, hostname, set_broadcast_flag=False)
        Client.add_vpp_config()

        rx = self.pg3.get_capture(1)

        self.verify_orig_dhcp_discover(rx[0], self.pg3, hostname, broadcast=False)

        #
        # Send back on offer, unicasted to the offered address.
        # Expect the request.
        #
        p_offer = (
            Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac)
            / IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT)
            / BOOTP(
                op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac)
            )
            / DHCP(
                options=[
                    ("message-type", "offer"),
                    ("server_id", self.pg3.remote_ip4),
                    "end",
                ]
            )
        )

        self.pg3.add_stream(p_offer)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg3.get_capture(1)
        self.verify_orig_dhcp_request(
            rx[0], self.pg3, hostname, self.pg3.local_ip4, broadcast=False
        )

        #
        # Send an acknowledgment, the lease renewal time is 2 seconds
        # so we should expect the renew straight after
        #
        p_ack = (
            Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac)
            / IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT)
            / BOOTP(
                op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac)
            )
            / DHCP(
                options=[
                    ("message-type", "ack"),
                    ("subnet_mask", "255.255.255.0"),
                    ("router", self.pg3.remote_ip4),
                    ("server_id", self.pg3.remote_ip4),
                    ("lease_time", 43200),
                    ("renewal_time", 2),
                    "end",
                ]
            )
        )

        self.pg3.add_stream(p_ack)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        #
        # We'll get an ARP request for the router address
        #
        rx = self.pg3.get_capture(1)

        self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4)
        self.pg_enable_capture(self.pg_interfaces)

        #
        # At the end of this procedure there should be a connected route
        # in the FIB
        #
        self.assertTrue(find_route(self, self.pg3.local_ip4, 24))
        self.assertTrue(find_route(self, self.pg3.local_ip4, 32))

        #
        # read the DHCP client details from a dump
        #
        clients = self.vapi.dhcp_client_dump()

        self.assertEqual(clients[0].client.sw_if_index, self.pg3.sw_if_index)
        self.assertEqual(clients[0].lease.sw_if_index, self.pg3.sw_if_index)
        self.assertEqual(clients[0].client.hostname, hostname)
        self.assertEqual(clients[0].lease.hostname, hostname)
        # 0 = DISCOVER, 1 = REQUEST, 2 = BOUND
        self.assertEqual(clients[0].lease.state, 2)
        self.assertEqual(clients[0].lease.mask_width, 24)
        self.assertEqual(str(clients[0].lease.router_address), self.pg3.remote_ip4)
        self.assertEqual(str(clients[0].lease.host_address), self.pg3.local_ip4)

        #
        # wait for the unicasted renewal
        #  the first attempt will be an ARP packet, since we have not yet
        #  responded to VPP's request
        #
        self.logger.info(self.vapi.cli("sh dhcp client intfc pg3 verbose"))
        rx = self.pg3.get_capture(1, timeout=10)

        self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4)

        # respond to the arp
        p_arp = Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac) / ARP(
            op="is-at",
            hwdst=self.pg3.local_mac,
            hwsrc=self.pg3.remote_mac,
            pdst=self.pg3.local_ip4,
            psrc=self.pg3.remote_ip4,
        )
        self.pg3.add_stream(p_arp)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        # the next packet is the unicasted renewal
        rx = self.pg3.get_capture(1, timeout=10)
        self.verify_orig_dhcp_request(
            rx[0], self.pg3, hostname, self.pg3.local_ip4, l2_bc=False, broadcast=False
        )

        # send an ACK with different data from the original offer *
        self.pg3.generate_remote_hosts(4)
        p_ack = (
            Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac)
            / IP(src=self.pg3.remote_ip4, dst=self.pg3.local_ip4)
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT)
            / BOOTP(
                op=1,
                yiaddr=self.pg3.remote_hosts[3].ip4,
                chaddr=mac_pton(self.pg3.local_mac),
            )
            / DHCP(
                options=[
                    ("message-type", "ack"),
                    ("subnet_mask", "255.255.255.0"),
                    ("router", self.pg3.remote_hosts[1].ip4),
                    ("server_id", self.pg3.remote_hosts[2].ip4),
                    ("lease_time", 43200),
                    ("renewal_time", 2),
                    "end",
                ]
            )
        )

        self.pg3.add_stream(p_ack)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        #
        # read the DHCP client details from a dump
        #
        clients = self.vapi.dhcp_client_dump()

        self.assertEqual(clients[0].client.sw_if_index, self.pg3.sw_if_index)
        self.assertEqual(clients[0].lease.sw_if_index, self.pg3.sw_if_index)
        self.assertEqual(clients[0].client.hostname, hostname)
        self.assertEqual(clients[0].lease.hostname, hostname)
        # 0 = DISCOVER, 1 = REQUEST, 2 = BOUND
        self.assertEqual(clients[0].lease.state, 2)
        self.assertEqual(clients[0].lease.mask_width, 24)
        self.assertEqual(
            str(clients[0].lease.router_address), self.pg3.remote_hosts[1].ip4
        )
        self.assertEqual(
            str(clients[0].lease.host_address), self.pg3.remote_hosts[3].ip4
        )

        #
        # remove the DHCP config
        #
        Client.remove_vpp_config()

        #
        # and now the route should be gone
        #
        self.assertFalse(find_route(self, self.pg3.local_ip4, 32))
        self.assertFalse(find_route(self, self.pg3.local_ip4, 24))

        #
        # Start the procedure again. Use requested lease time option.
        # this time wait for the lease to expire and the client to
        # self-destruct
        #
        hostname += "-2"
        self.pg3.admin_down()
        self.sleep(1)
        self.pg3.admin_up()
        self.pg_enable_capture(self.pg_interfaces)
        Client.set_client(self.pg3.sw_if_index, hostname)
        Client.add_vpp_config()

        rx = self.pg3.get_capture(1)

        self.verify_orig_dhcp_discover(rx[0], self.pg3, hostname)

        #
        # Send back on offer with requested lease time, expect the request
        #
        lease_time = 1
        p_offer = (
            Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac)
            / IP(src=self.pg3.remote_ip4, dst="255.255.255.255")
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT)
            / BOOTP(
                op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac)
            )
            / DHCP(
                options=[
                    ("message-type", "offer"),
                    ("server_id", self.pg3.remote_ip4),
                    ("lease_time", lease_time),
                    "end",
                ]
            )
        )

        self.pg3.add_stream(p_offer)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        rx = self.pg3.get_capture(1)
        self.verify_orig_dhcp_request(rx[0], self.pg3, hostname, self.pg3.local_ip4)

        #
        # Send an acknowledgment
        #
        p_ack = (
            Ether(dst=self.pg3.local_mac, src=self.pg3.remote_mac)
            / IP(src=self.pg3.remote_ip4, dst="255.255.255.255")
            / UDP(sport=DHCP4_SERVER_PORT, dport=DHCP4_CLIENT_PORT)
            / BOOTP(
                op=1, yiaddr=self.pg3.local_ip4, chaddr=mac_pton(self.pg3.local_mac)
            )
            / DHCP(
                options=[
                    ("message-type", "ack"),
                    ("subnet_mask", "255.255.255.0"),
                    ("router", self.pg3.remote_ip4),
                    ("server_id", self.pg3.remote_ip4),
                    ("lease_time", lease_time),
                    "end",
                ]
            )
        )

        self.pg3.add_stream(p_ack)
        self.pg_enable_capture(self.pg_interfaces)
        self.pg_start()

        #
        # We'll get an ARP request for the router address
        #
        rx = self.pg3.get_capture(1)

        self.assertEqual(rx[0][ARP].pdst, self.pg3.remote_ip4)

        #
        # At the end of this procedure there should be a connected route
        # in the FIB
        #
        self.assertTrue(find_route(self, self.pg3.local_ip4, 32))
        self.assertTrue(find_route(self, self.pg3.local_ip4, 24))

        #
        # the route should be gone after the lease expires
        #
        self.assertTrue(self.wait_for_no_route(self.pg3.local_ip4, 32))
        self.assertTrue(self.wait_for_no_route(self.pg3.local_ip4, 24))

        #
        # remove the DHCP config
        #
        Client.remove_vpp_config()

    def test_dhcp_client_vlan(self):
        """DHCP Client w/ VLAN"""

        vdscp = VppEnum.vl_api_ip_dscp_t
        vqos = VppEnum.vl_api_qos_source_t
        hostname = "universal-dp"

        self.pg_enable_capture(self.pg_interfaces)

        vlan_100 = VppDot1QSubint(self, self.pg3, 100)
        vlan_100.admin_up()

        output = [scapy.compat.chb(4)] * 256
        os = b"".join(output)
        rows = [{"outputs": os}, {"outputs": os}, {"outputs": os}, {"outputs": os}]

        qem1 = VppQosEgressMap(self, 1, rows).add_vpp_config()
        qm1 = VppQosMark(
            self, vlan_100, qem1, vqos.QOS_API_SOURCE_VLAN
        ).add_vpp_config()

        #
        # Configure DHCP client on PG3 and capture the discover sent
        #
        Client = VppDHCPClient(
            self, vlan_100.sw_if_index, hostname, dscp=vdscp.IP_API_DSCP_EF
        )
        Client.add_vpp_config()

        rx = self.pg3.get_capture(1)

        self.assertEqual(rx[0][Dot1Q].vlan, 100)
        self.assertEqual(rx[0][Dot1Q].prio, 2)

        self.verify_orig_dhcp_discover(
            rx[0], self.pg3, hostname, dscp=vdscp.IP_API_DSCP_EF
        )


if __name__ == "__main__":
    unittest.main(testRunner=VppTestRunner)
