blob: 28d8a714972dd044bbe28b67baa12935fe599b43 [file] [log] [blame]
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08001
2from vpp_interface import VppInterface
3import socket
Ole Troan7f991832018-12-06 17:35:12 +01004from vpp_mac import mactobinary
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)
23 cmac = mactobinary(self.client_mac)
24 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)
33 cmac = mactobinary(self.client_mac)
34 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)