blob: 0d5516eab603e9e2c132bad0f210becf93183830 [file] [log] [blame]
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08001from vpp_interface import VppInterface
2import socket
Ole Troan8006c6a2018-12-17 12:02:26 +01003from vpp_papi import mac_pton
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08004
5
6class VppPppoeInterface(VppInterface):
7 """
8 VPP Pppoe interface
9 """
10
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020011 def __init__(self, test, client_ip, client_mac, session_id, decap_vrf_id=0):
12 """Create VPP PPPoE4 interface"""
Klement Sekerab9ef2732018-06-24 22:49:33 +020013 super(VppPppoeInterface, self).__init__(test)
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080014 self.client_ip = client_ip
15 self.client_mac = client_mac
16 self.session_id = session_id
17 self.decap_vrf_id = decap_vrf_id
Stanislav Zaikin938af5e2020-12-03 19:09:53 +000018 self.vpp_sw_if_index = -1
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080019
20 def add_vpp_config(self):
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080021 r = self.test.vapi.pppoe_add_del_session(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020022 self.client_ip,
23 self.client_mac,
24 session_id=self.session_id,
25 decap_vrf_id=self.decap_vrf_id,
26 )
Klement Sekerab9ef2732018-06-24 22:49:33 +020027 self.set_sw_if_index(r.sw_if_index)
Stanislav Zaikin938af5e2020-12-03 19:09:53 +000028 self.vpp_sw_if_index = r.sw_if_index
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080029 self.generate_remote_hosts()
30
31 def remove_vpp_config(self):
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080032 self.unconfig()
Klement Sekerab9ef2732018-06-24 22:49:33 +020033 self.test.vapi.pppoe_add_del_session(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020034 self.client_ip,
35 self.client_mac,
36 session_id=self.session_id,
37 decap_vrf_id=self.decap_vrf_id,
38 is_add=0,
39 )
Stanislav Zaikin938af5e2020-12-03 19:09:53 +000040
41 def set_unnumbered(self, swif_iface):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020042 self.test.vapi.sw_interface_set_unnumbered(swif_iface, self.vpp_sw_if_index)