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) {} |
Garrick Evans | f0ab713 | 2019-06-18 14:50:42 +0900 | [diff] [blame] | 23 | ~MockDatapath() = default; |
| 24 | |
Hugo Benichi | bf811c6 | 2020-09-07 17:30:45 +0900 | [diff] [blame] | 25 | MOCK_METHOD0(Start, void()); |
| 26 | MOCK_METHOD0(Stop, void()); |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 27 | MOCK_METHOD2(NetnsAttachName, |
| 28 | bool(const std::string& netns_name, pid_t netns_pid)); |
| 29 | MOCK_METHOD1(NetnsDeleteName, bool(const std::string& netns_name)); |
| 30 | |
Garrick Evans | 7a1a9ee | 2020-01-28 11:03:57 +0900 | [diff] [blame] | 31 | MOCK_METHOD3(AddBridge, |
| 32 | bool(const std::string& ifname, |
| 33 | uint32_t ipv4_addr, |
| 34 | uint32_t prefix_len)); |
Yuichiro Hanada | ed427fd | 2019-09-25 08:41:21 +0000 | [diff] [blame] | 35 | MOCK_METHOD1(RemoveBridge, void(const std::string& ifname)); |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 36 | MOCK_METHOD2(AddToBridge, |
| 37 | bool(const std::string& br_ifname, const std::string& ifname)); |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 38 | |
Garrick Evans | b4eb389 | 2019-11-13 12:07:07 +0900 | [diff] [blame] | 39 | MOCK_METHOD4(AddTAP, |
| 40 | std::string(const std::string& name, |
| 41 | const MacAddress* mac_addr, |
| 42 | const SubnetAddress* ipv4_addr, |
| 43 | const std::string& user)); |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 44 | MOCK_METHOD8(ConnectVethPair, |
| 45 | bool(pid_t pid, |
| 46 | const std::string& netns_name, |
Hugo Benichi | 33860d7 | 2020-07-09 16:34:01 +0900 | [diff] [blame] | 47 | const std::string& veth_ifname, |
Hugo Benichi | 82ed5cf | 2020-09-08 21:30:22 +0900 | [diff] [blame] | 48 | const std::string& peer_ifname, |
| 49 | const MacAddress& remote_mac_addr, |
| 50 | uint32_t remote_ipv4_addr, |
| 51 | uint32_t remote_ipv4_prefix_len, |
| 52 | bool remote_multicast_flag)); |
Garrick Evans | 5486162 | 2019-07-19 09:05:09 +0900 | [diff] [blame] | 53 | MOCK_METHOD1(RemoveInterface, void(const std::string& ifname)); |
Hugo Benichi | 8d622b5 | 2020-08-13 15:24:12 +0900 | [diff] [blame] | 54 | MOCK_METHOD4(StartRoutingDevice, |
| 55 | void(const std::string& ext_ifname, |
| 56 | const std::string& int_ifname, |
| 57 | uint32_t int_ipv4_addr, |
| 58 | TrafficSource source)); |
| 59 | MOCK_METHOD4(StopRoutingDevice, |
| 60 | void(const std::string& ext_ifname, |
| 61 | const std::string& int_ifname, |
| 62 | uint32_t int_ipv4_addr, |
| 63 | TrafficSource source)); |
Garrick Evans | 664a82f | 2019-12-17 12:18:05 +0900 | [diff] [blame] | 64 | MOCK_METHOD3(MaskInterfaceFlags, |
| 65 | bool(const std::string& ifname, uint16_t on, uint16_t off)); |
Taoyu Li | 90c1391 | 2019-11-26 17:56:54 +0900 | [diff] [blame] | 66 | MOCK_METHOD2(AddIPv6Forwarding, |
| 67 | bool(const std::string& ifname1, const std::string& ifname2)); |
| 68 | MOCK_METHOD2(RemoveIPv6Forwarding, |
| 69 | void(const std::string& ifname1, const std::string& ifname2)); |
Garrick Evans | 3d97a39 | 2020-02-21 15:24:37 +0900 | [diff] [blame] | 70 | 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] | 71 | |
| 72 | private: |
| 73 | DISALLOW_COPY_AND_ASSIGN(MockDatapath); |
| 74 | }; |
| 75 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 76 | } // namespace patchpanel |
Garrick Evans | f0ab713 | 2019-06-18 14:50:42 +0900 | [diff] [blame] | 77 | |
Garrick Evans | 3388a03 | 2020-03-24 11:25:55 +0900 | [diff] [blame] | 78 | #endif // PATCHPANEL_MOCK_DATAPATH_H_ |