blob: fbb78bcc55f200806554b0e0c3c65bd7cb2296e2 [file] [log] [blame]
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08001
2from vpp_interface import VppInterface
3import socket
Hongjun Ni2629c842018-03-08 00:25:56 +08004from util 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 """
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080015 self._test = test
16 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)
28 self._sw_if_index = r.sw_if_index
Hongjun Ni2629c842018-03-08 00:25:56 +080029 super(VppPppoeInterface, self).__init__(self._test)
Hongjun Ni62f9cdd2017-07-04 20:11:57 +080030 self.generate_remote_hosts()
31
32 def remove_vpp_config(self):
33 cip = socket.inet_pton(socket.AF_INET, self.client_ip)
34 cmac = mactobinary(self.client_mac)
35 self.unconfig()
36 r = self.test.vapi.pppoe_add_del_session(
37 cip, cmac,
38 session_id=self.session_id,
39 decap_vrf_id=self.decap_vrf_id,
40 is_add=0)