Garrick Evans | f0ab713 | 2019-06-18 14:50:42 +0900 | [diff] [blame] | 1 | // Copyright 2019 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_MOCK_DATAPATH_H_ |
| 6 | #define PATCHPANEL_MOCK_DATAPATH_H_ |
Garrick Evans | f0ab713 | 2019-06-18 14:50:42 +0900 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/macros.h> |
| 11 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 12 | #include "patchpanel/datapath.h" |
Jason Jeremy Iman | a7273a3 | 2020-08-04 11:25:31 +0900 | [diff] [blame] | 13 | #include "patchpanel/firewall.h" |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 14 | #include "patchpanel/minijailed_process_runner.h" |
Garrick Evans | f0ab713 | 2019-06-18 14:50:42 +0900 | [diff] [blame] | 15 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 16 | namespace patchpanel { |
Garrick Evans | f0ab713 | 2019-06-18 14:50:42 +0900 | [diff] [blame] | 17 | |
| 18 | // ARC networking data path configuration utility. |
| 19 | class MockDatapath : public Datapath { |
| 20 | public: |
Jason Jeremy Iman | a7273a3 | 2020-08-04 11:25:31 +0900 | [diff] [blame] | 21 | explicit MockDatapath(MinijailedProcessRunner* runner, Firewall* firewall) |
| 22 | : Datapath(runner, firewall) {} |
Qijiang Fan | 6bc59e1 | 2020-11-11 02:51:06 +0900 | [diff] [blame] | 23 | MockDatapath(const MockDatapath&) = delete; |
| 24 | MockDatapath& operator=(const MockDatapath&) = delete; |
| 25 | |
Garrick Evans | f0ab713 | 2019-06-18 14:50:42 +0900 | [diff] [blame] | 26 | ~MockDatapath() = default; |
| 27 | |
Hugo Benichi | bf811c6 | 2020-09-07 17:30:45 +0900 | [diff] [blame] | 28 | MOCK_METHOD0(Start, void()); |
| 29 | MOCK_METHOD0(Stop, void()); |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 30 | MOCK_METHOD2(NetnsAttachName, |
| 31 | bool(const std::string& netns_name, pid_t netns_pid)); |
| 32 | MOCK_METHOD1(NetnsDeleteName, bool(const std::string& netns_name)); |
| 33 | |
Garrick Evans | 7a1a9ee | 2020-01-28 11:03:57 +0900 | [diff] [blame] | 34 | MOCK_METHOD3(AddBridge, |
| 35 | bool(const std::string& ifname, |
| 36 | uint32_t ipv4_addr, |
| 37 | uint32_t prefix_len)); |
Yuichiro Hanada | ed427fd | 2019-09-25 08:41:21 +0000 | [diff] [blame] | 38 | MOCK_METHOD1(RemoveBridge, void(const std::string& ifname)); |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 39 | MOCK_METHOD2(AddToBridge, |
| 40 | bool(const std::string& br_ifname, const std::string& ifname)); |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 41 | |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 42 | MOCK_METHOD4(AddTAP, |
| 43 | std::string(const std::string& name, |
| 44 | const MacAddress* mac_addr, |
| 45 | const SubnetAddress* ipv4_addr, |
| 46 | const std::string& user)); |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 47 | MOCK_METHOD8(ConnectVethPair, |
| 48 | bool(pid_t pid, |
| 49 | const std::string& netns_name, |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 50 | const std::string& veth_ifname, |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 51 | const std::string& peer_ifname, |
| 52 | const MacAddress& remote_mac_addr, |
| 53 | uint32_t remote_ipv4_addr, |
| 54 | uint32_t remote_ipv4_prefix_len, |
| 55 | bool remote_multicast_flag)); |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 56 | MOCK_METHOD1(RemoveInterface, void(const std::string& ifname)); |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 57 | MOCK_METHOD5(StartRoutingDevice, |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 58 | void(const std::string& ext_ifname, |
| 59 | const std::string& int_ifname, |
| 60 | uint32_t int_ipv4_addr, |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 61 | TrafficSource source, |
| 62 | bool route_on_vpn)); |
| 63 | MOCK_METHOD5(StopRoutingDevice, |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 64 | void(const std::string& ext_ifname, |
| 65 | const std::string& int_ifname, |
| 66 | uint32_t int_ipv4_addr, |
Hugo Benichi | 93306e5 | 2020-12-04 16:08:00 +0900 | [diff] [blame] | 67 | TrafficSource source, |
| 68 | bool route_on_vpn)); |
Garrick Evans | 664a82f | 2019-12-17 12:18:05 +0900 | [diff] [blame] | 69 | MOCK_METHOD3(MaskInterfaceFlags, |
| 70 | bool(const std::string& ifname, uint16_t on, uint16_t off)); |
Taoyu Li | 90c1391 | 2019-11-26 17:56:54 +0900 | [diff] [blame] | 71 | MOCK_METHOD2(AddIPv6Forwarding, |
| 72 | bool(const std::string& ifname1, const std::string& ifname2)); |
| 73 | MOCK_METHOD2(RemoveIPv6Forwarding, |
| 74 | void(const std::string& ifname1, const std::string& ifname2)); |
Garrick Evans | 3d97a39 | 2020-02-21 15:24:37 +0900 | [diff] [blame] | 75 | MOCK_METHOD3(AddIPv4Route, bool(uint32_t gw, uint32_t dst, uint32_t netmask)); |
Garrick Evans | f0ab713 | 2019-06-18 14:50:42 +0900 | [diff] [blame] | 76 | }; |
| 77 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 78 | } // namespace patchpanel |
Garrick Evans | f0ab713 | 2019-06-18 14:50:42 +0900 | [diff] [blame] | 79 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 80 | #endif // PATCHPANEL_MOCK_DATAPATH_H_ |