blob: 9be92327dcf550efd1ccc1a5b07703254c35dc55 [file] [log] [blame]
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08001
2from vpp_interface import VppInterface
3import socket
Ole Troan8006c6a2018-12-17 12:02:26 +01004from vpp_papi import mac_pton
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08005
6
7class VppPppoeInterface(VppInterface):
8 """
9 VPP Pppoe interface
10 """
11
12 def __init__(self, test, client_ip, client_mac,
13 session_id, decap_vrf_id=0):
14 """ Create VPP PPPoE4 interface """
Klement Sekerab9ef2732018-06-24 22:49:33 +020015 super(VppPppoeInterface, self).__init__(test)
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080016 self.client_ip = client_ip
17 self.client_mac = client_mac
18 self.session_id = session_id
19 self.decap_vrf_id = decap_vrf_id
20
21 def add_vpp_config(self):
22 cip = socket.inet_pton(socket.AF_INET, self.client_ip)
Ole Troan8006c6a2018-12-17 12:02:26 +010023 cmac = mac_pton(self.client_mac)
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080024 r = self.test.vapi.pppoe_add_del_session(
25 cip, cmac,
26 session_id=self.session_id,
27 decap_vrf_id=self.decap_vrf_id)
Klement Sekerab9ef2732018-06-24 22:49:33 +020028 self.set_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):
32 cip = socket.inet_pton(socket.AF_INET, self.client_ip)
Ole Troan8006c6a2018-12-17 12:02:26 +010033 cmac = mac_pton(self.client_mac)
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080034 self.unconfig()
Klement Sekerab9ef2732018-06-24 22:49:33 +020035 self.test.vapi.pppoe_add_del_session(
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080036 cip, cmac,
37 session_id=self.session_id,
38 decap_vrf_id=self.decap_vrf_id,
39 is_add=0)