blob: 33987a76b8cdf592d66d7c9ffdc104209e6ffe8d [file] [log] [blame]
Garrick Evansf0ab7132019-06-18 14:50:42 +09001// 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 Evans3388a032020-03-24 11:25:55 +09005#ifndef PATCHPANEL_MOCK_DATAPATH_H_
6#define PATCHPANEL_MOCK_DATAPATH_H_
Garrick Evansf0ab7132019-06-18 14:50:42 +09007
8#include <string>
9
10#include <base/macros.h>
11
Garrick Evans3388a032020-03-24 11:25:55 +090012#include "patchpanel/datapath.h"
13#include "patchpanel/minijailed_process_runner.h"
Garrick Evansf0ab7132019-06-18 14:50:42 +090014
Garrick Evans3388a032020-03-24 11:25:55 +090015namespace patchpanel {
Garrick Evansf0ab7132019-06-18 14:50:42 +090016
17// ARC networking data path configuration utility.
18class MockDatapath : public Datapath {
19 public:
20 explicit MockDatapath(MinijailedProcessRunner* runner) : Datapath(runner) {}
21 ~MockDatapath() = default;
22
Hugo Benichi33860d72020-07-09 16:34:01 +090023 MOCK_METHOD2(NetnsAttachName,
24 bool(const std::string& netns_name, pid_t netns_pid));
25 MOCK_METHOD1(NetnsDeleteName, bool(const std::string& netns_name));
26
Garrick Evans7a1a9ee2020-01-28 11:03:57 +090027 MOCK_METHOD3(AddBridge,
28 bool(const std::string& ifname,
29 uint32_t ipv4_addr,
30 uint32_t prefix_len));
Yuichiro Hanadaed427fd2019-09-25 08:41:21 +000031 MOCK_METHOD1(RemoveBridge, void(const std::string& ifname));
Garrick Evansb4eb3892019-11-13 12:07:07 +090032 MOCK_METHOD2(AddToBridge,
33 bool(const std::string& br_ifname, const std::string& ifname));
Hugo Benichi33860d72020-07-09 16:34:01 +090034
Garrick Evansb4eb3892019-11-13 12:07:07 +090035 MOCK_METHOD4(AddTAP,
36 std::string(const std::string& name,
37 const MacAddress* mac_addr,
38 const SubnetAddress* ipv4_addr,
39 const std::string& user));
Hugo Benichi33860d72020-07-09 16:34:01 +090040 MOCK_METHOD3(AddVirtualInterfacePair,
41 bool(const std::string& netns_name,
42 const std::string& veth_ifname,
Garrick Evans2470caa2020-03-04 14:15:41 +090043 const std::string& peer_ifname));
44 MOCK_METHOD2(ToggleInterface, bool(const std::string& ifname, bool up));
45 MOCK_METHOD6(ConfigureInterface,
46 bool(const std::string& ifname,
47 const MacAddress& mac_addr,
48 uint32_t addr,
49 uint32_t prefix_len,
50 bool up,
51 bool multicast));
Garrick Evans54861622019-07-19 09:05:09 +090052 MOCK_METHOD1(RemoveInterface, void(const std::string& ifname));
Yuichiro Hanadaed427fd2019-09-25 08:41:21 +000053 MOCK_METHOD2(AddInboundIPv4DNAT,
54 bool(const std::string& ifname, const std::string& ipv4_addr));
55 MOCK_METHOD2(RemoveInboundIPv4DNAT,
56 void(const std::string& ifname, const std::string& ipv4_addr));
57 MOCK_METHOD1(AddOutboundIPv4, bool(const std::string& ifname));
58 MOCK_METHOD1(RemoveOutboundIPv4, void(const std::string& ifname));
Garrick Evans664a82f2019-12-17 12:18:05 +090059 MOCK_METHOD3(MaskInterfaceFlags,
60 bool(const std::string& ifname, uint16_t on, uint16_t off));
Taoyu Li90c13912019-11-26 17:56:54 +090061 MOCK_METHOD2(AddIPv6Forwarding,
62 bool(const std::string& ifname1, const std::string& ifname2));
63 MOCK_METHOD2(RemoveIPv6Forwarding,
64 void(const std::string& ifname1, const std::string& ifname2));
Garrick Evans3d97a392020-02-21 15:24:37 +090065 MOCK_METHOD3(AddIPv4Route, bool(uint32_t gw, uint32_t dst, uint32_t netmask));
Garrick Evansf0ab7132019-06-18 14:50:42 +090066
67 private:
68 DISALLOW_COPY_AND_ASSIGN(MockDatapath);
69};
70
Garrick Evans3388a032020-03-24 11:25:55 +090071} // namespace patchpanel
Garrick Evansf0ab7132019-06-18 14:50:42 +090072
Garrick Evans3388a032020-03-24 11:25:55 +090073#endif // PATCHPANEL_MOCK_DATAPATH_H_