from vpp_interface import VppInterface
import socket
from vpp_papi import mac_pton


class VppPppoeInterface(VppInterface):
    """
    VPP Pppoe interface
    """

    def __init__(self, test, client_ip, client_mac, session_id, decap_vrf_id=0):
        """Create VPP PPPoE4 interface"""
        super(VppPppoeInterface, self).__init__(test)
        self.client_ip = client_ip
        self.client_mac = client_mac
        self.session_id = session_id
        self.decap_vrf_id = decap_vrf_id
        self.vpp_sw_if_index = -1

    def add_vpp_config(self):
        r = self.test.vapi.pppoe_add_del_session(
            self.client_ip,
            self.client_mac,
            session_id=self.session_id,
            decap_vrf_id=self.decap_vrf_id,
        )
        self.set_sw_if_index(r.sw_if_index)
        self.vpp_sw_if_index = r.sw_if_index
        self.generate_remote_hosts()

    def remove_vpp_config(self):
        self.unconfig()
        self.test.vapi.pppoe_add_del_session(
            self.client_ip,
            self.client_mac,
            session_id=self.session_id,
            decap_vrf_id=self.decap_vrf_id,
            is_add=0,
        )

    def set_unnumbered(self, swif_iface):
        self.test.vapi.sw_interface_set_unnumbered(swif_iface, self.vpp_sw_if_index)
