blob: 9a8b8699328ef92a7dd17d55b114aecb1cb32d31 [file] [log] [blame]
Hongjun Ni62f9cdd2017-07-04 20:11:57 +08001
2from vpp_interface import VppInterface
3import socket
4from util import ppp, ppc, mactobinary
5
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 """
15 self._sw_if_index = 0
16 super(VppPppoeInterface, self).__init__(test)
17 self._test = test
18 self.client_ip = client_ip
19 self.client_mac = client_mac
20 self.session_id = session_id
21 self.decap_vrf_id = decap_vrf_id
22
23 def add_vpp_config(self):
24 cip = socket.inet_pton(socket.AF_INET, self.client_ip)
25 cmac = mactobinary(self.client_mac)
26 r = self.test.vapi.pppoe_add_del_session(
27 cip, cmac,
28 session_id=self.session_id,
29 decap_vrf_id=self.decap_vrf_id)
30 self._sw_if_index = r.sw_if_index
31 self.generate_remote_hosts()
32
33 def remove_vpp_config(self):
34 cip = socket.inet_pton(socket.AF_INET, self.client_ip)
35 cmac = mactobinary(self.client_mac)
36 self.unconfig()
37 r = self.test.vapi.pppoe_add_del_session(
38 cip, cmac,
39 session_id=self.session_id,
40 decap_vrf_id=self.decap_vrf_id,
41 is_add=0)
42
43
44class VppPppoe6Interface(VppInterface):
45 """
46 VPP Pppoe IPv6 interface
47 """
48
49 def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, is_teb=0):
50 """ Create VPP PPPoE6 interface """
51 self._sw_if_index = 0
52 super(VppPppoe6Interface, self).__init__(test)
53 self._test = test
54 self.client_ip = client_ip
55 self.client_mac = client_mac
56 self.session_id = session_id
57 self.decap_vrf_id = decap_vrf_id
58
59 def add_vpp_config(self):
60 cip = socket.inet_pton(socket.AF_INET6, self.client_ip)
61 cmac = mactobinary(self.client_mac)
62 r = self.test.vapi.pppoe_add_del_session(
63 cip, cmac,
64 session_id=self.session_id,
65 decap_vrf_id=self.decap_vrf_id,
66 is_ip6=1)
67 self._sw_if_index = r.sw_if_index
68 self.generate_remote_hosts()
69
70 def remove_vpp_config(self):
71 cip = socket.inet_pton(socket.AF_INET6, self.client_ip)
72 cmac = mactobinary(self.client_mac)
73 self.unconfig()
74 r = self.test.vapi.pppoe_add_del_session(
75 cip, cmac,
76 session_id=self.session_id,
77 decap_vrf_id=self.decap_vrf_id,
78 is_add=0,
79 is_ip6=1)