Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 1 | |
| 2 | from vpp_interface import VppInterface |
| 3 | import socket |
Ole Troan | 7f99183 | 2018-12-06 17:35:12 +0100 | [diff] [blame] | 4 | from vpp_mac import mactobinary |
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 |
| 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) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 28 | self.set_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): |
| 32 | cip = socket.inet_pton(socket.AF_INET, self.client_ip) |
| 33 | cmac = mactobinary(self.client_mac) |
| 34 | self.unconfig() |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 35 | self.test.vapi.pppoe_add_del_session( |
Hongjun Ni | 62f9cdd | 2017-07-04 20:11:57 +0800 | [diff] [blame] | 36 | cip, cmac, |
| 37 | session_id=self.session_id, |
| 38 | decap_vrf_id=self.decap_vrf_id, |
| 39 | is_add=0) |