Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 1 | |
| 2 | from vpp_interface import VppInterface |
| 3 | import socket |
| 4 | from util import ppp, ppc, mactobinary |
| 5 | |
| 6 | |
| 7 | class 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 | |
| 44 | class 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) |