Garrick Evans | 6e4eb3b | 2020-03-09 07:18:31 +0900 | [diff] [blame] | 1 | // Copyright 2020 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 5 | #ifndef PATCHPANEL_TRAFFIC_FORWARDER_H_ |
| 6 | #define PATCHPANEL_TRAFFIC_FORWARDER_H_ |
Garrick Evans | 6e4eb3b | 2020-03-09 07:18:31 +0900 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 10 | namespace patchpanel { |
Garrick Evans | 6e4eb3b | 2020-03-09 07:18:31 +0900 | [diff] [blame] | 11 | |
| 12 | // Interface to encapsulate traffic forwarding behaviors so individual services |
| 13 | // are not exposed to dependents. |
| 14 | class TrafficForwarder { |
| 15 | public: |
| 16 | virtual ~TrafficForwarder() = default; |
| 17 | |
Taoyu Li | 7dca19a | 2020-03-16 16:27:07 +0900 | [diff] [blame] | 18 | // Start forwarding between a pair of physical and virtual (guest-facing) |
| 19 | // interfaces. |
Garrick Evans | 6e4eb3b | 2020-03-09 07:18:31 +0900 | [diff] [blame] | 20 | virtual void StartForwarding(const std::string& ifname_physical, |
| 21 | const std::string& ifname_virtual, |
Garrick Evans | 6e4eb3b | 2020-03-09 07:18:31 +0900 | [diff] [blame] | 22 | bool ipv6, |
| 23 | bool multicast) = 0; |
| 24 | |
Taoyu Li | 7dca19a | 2020-03-16 16:27:07 +0900 | [diff] [blame] | 25 | // Stop forwarding between a interface pair. If |ifname_virtual| is empty, |
| 26 | // stop all forwarding from/to |ifname_physical| instead. |
Garrick Evans | 6e4eb3b | 2020-03-09 07:18:31 +0900 | [diff] [blame] | 27 | virtual void StopForwarding(const std::string& ifname_physical, |
| 28 | const std::string& ifname_virtual, |
| 29 | bool ipv6, |
| 30 | bool multicast) = 0; |
| 31 | |
| 32 | protected: |
| 33 | TrafficForwarder() = default; |
| 34 | }; |
| 35 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 36 | } // namespace patchpanel |
Garrick Evans | 6e4eb3b | 2020-03-09 07:18:31 +0900 | [diff] [blame] | 37 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 38 | #endif // PATCHPANEL_TRAFFIC_FORWARDER_H_ |