Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 1 | |
| 2 | from vpp_interface import VppInterface |
| 3 | import socket |
Ole Troan | 8006c6a | 2018-12-17 12:02:26 +0100 | [diff] [blame] | 4 | from vpp_papi import mac_pton |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 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 """ |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 15 | super(VppPppoeInterface, self).__init__(test) |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 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 |
Stanislav Zaikin | 938af5e | 2020-12-03 19:09:53 +0000 | [diff] [blame] | 20 | self.vpp_sw_if_index = -1 |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 21 | |
| 22 | def add_vpp_config(self): |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 23 | r = self.test.vapi.pppoe_add_del_session( |
Ole Troan | 04338e8 | 2019-12-06 14:23:10 +0100 | [diff] [blame] | 24 | self.client_ip, self.client_mac, |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 25 | session_id=self.session_id, |
| 26 | decap_vrf_id=self.decap_vrf_id) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 27 | self.set_sw_if_index(r.sw_if_index) |
Stanislav Zaikin | 938af5e | 2020-12-03 19:09:53 +0000 | [diff] [blame] | 28 | self.vpp_sw_if_index = r.sw_if_index |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 29 | self.generate_remote_hosts() |
| 30 | |
| 31 | def remove_vpp_config(self): |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 32 | self.unconfig() |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 33 | self.test.vapi.pppoe_add_del_session( |
Ole Troan | 04338e8 | 2019-12-06 14:23:10 +0100 | [diff] [blame] | 34 | self.client_ip, self.client_mac, |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 35 | session_id=self.session_id, |
| 36 | decap_vrf_id=self.decap_vrf_id, |
| 37 | is_add=0) |
Stanislav Zaikin | 938af5e | 2020-12-03 19:09:53 +0000 | [diff] [blame] | 38 | |
| 39 | def set_unnumbered(self, swif_iface): |
| 40 | self.test.vapi.sw_interface_set_unnumbered( |
| 41 | swif_iface, |
| 42 | self.vpp_sw_if_index) |