Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 1 | from vpp_interface import VppInterface |
| 2 | import socket |
Ole Troan | 8006c6a | 2018-12-17 12:02:26 +0100 | [diff] [blame] | 3 | from vpp_papi import mac_pton |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 4 | |
| 5 | |
| 6 | class VppPppoeInterface(VppInterface): |
| 7 | """ |
| 8 | VPP Pppoe interface |
| 9 | """ |
| 10 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 11 | def __init__(self, test, client_ip, client_mac, session_id, decap_vrf_id=0): |
| 12 | """Create VPP PPPoE4 interface""" |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 13 | super(VppPppoeInterface, self).__init__(test) |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 14 | self.client_ip = client_ip |
| 15 | self.client_mac = client_mac |
| 16 | self.session_id = session_id |
| 17 | self.decap_vrf_id = decap_vrf_id |
Stanislav Zaikin | 938af5e | 2020-12-03 19:09:53 +0000 | [diff] [blame] | 18 | self.vpp_sw_if_index = -1 |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 19 | |
| 20 | def add_vpp_config(self): |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 21 | r = self.test.vapi.pppoe_add_del_session( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 22 | self.client_ip, |
| 23 | self.client_mac, |
| 24 | session_id=self.session_id, |
| 25 | decap_vrf_id=self.decap_vrf_id, |
| 26 | ) |
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( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 34 | self.client_ip, |
| 35 | self.client_mac, |
| 36 | session_id=self.session_id, |
| 37 | decap_vrf_id=self.decap_vrf_id, |
| 38 | is_add=0, |
| 39 | ) |
Stanislav Zaikin | 938af5e | 2020-12-03 19:09:53 +0000 | [diff] [blame] | 40 | |
| 41 | def set_unnumbered(self, swif_iface): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 42 | self.test.vapi.sw_interface_set_unnumbered(swif_iface, self.vpp_sw_if_index) |