blob: 2f9d46cc246a98e9141ccd121233139dfbb20dec [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
5#ifndef ARC_NETWORK_MOCK_DATAPATH_H_
6#define ARC_NETWORK_MOCK_DATAPATH_H_
7
8#include <string>
9
10#include <base/macros.h>
11
Garrick Evansb4eb3892019-11-13 12:07:07 +090012#include "arc/network/datapath.h"
Garrick Evansf0ab7132019-06-18 14:50:42 +090013#include "arc/network/minijailed_process_runner.h"
14
15namespace arc_networkd {
16
17// ARC networking data path configuration utility.
18class MockDatapath : public Datapath {
19 public:
20 explicit MockDatapath(MinijailedProcessRunner* runner) : Datapath(runner) {}
21 ~MockDatapath() = default;
22
Garrick Evans7a1a9ee2020-01-28 11:03:57 +090023 MOCK_METHOD3(AddBridge,
24 bool(const std::string& ifname,
25 uint32_t ipv4_addr,
26 uint32_t prefix_len));
Yuichiro Hanadaed427fd2019-09-25 08:41:21 +000027 MOCK_METHOD1(RemoveBridge, void(const std::string& ifname));
Garrick Evansb4eb3892019-11-13 12:07:07 +090028 MOCK_METHOD2(AddToBridge,
29 bool(const std::string& br_ifname, const std::string& ifname));
30 MOCK_METHOD4(AddTAP,
31 std::string(const std::string& name,
32 const MacAddress* mac_addr,
33 const SubnetAddress* ipv4_addr,
34 const std::string& user));
Garrick Evans54861622019-07-19 09:05:09 +090035 MOCK_METHOD3(AddVirtualBridgedInterface,
36 std::string(const std::string& ifname,
37 const std::string& mac_addr,
38 const std::string& br_ifname));
39 MOCK_METHOD1(RemoveInterface, void(const std::string& ifname));
Garrick Evans7a1a9ee2020-01-28 11:03:57 +090040 MOCK_METHOD6(AddInterfaceToContainer,
Garrick Evans54861622019-07-19 09:05:09 +090041 bool(int ns,
42 const std::string& src_ifname,
43 const std::string& dst_ifname,
Garrick Evans7a1a9ee2020-01-28 11:03:57 +090044 const uint32_t dst_ipv4_addr,
45 const uint32_t dst_prefix_len,
Garrick Evans54861622019-07-19 09:05:09 +090046 bool fwd_multicast));
Yuichiro Hanadaed427fd2019-09-25 08:41:21 +000047 MOCK_METHOD1(AddLegacyIPv4DNAT, bool(const std::string& ipv4_addr));
48 MOCK_METHOD0(RemoveLegacyIPv4DNAT, void());
Garrick Evansb4eb3892019-11-13 12:07:07 +090049 MOCK_METHOD1(AddLegacyIPv4InboundDNAT, bool(const std::string& ifname));
50 MOCK_METHOD0(RemoveLegacyIPv4InboundDNAT, void());
Yuichiro Hanadaed427fd2019-09-25 08:41:21 +000051 MOCK_METHOD2(AddInboundIPv4DNAT,
52 bool(const std::string& ifname, const std::string& ipv4_addr));
53 MOCK_METHOD2(RemoveInboundIPv4DNAT,
54 void(const std::string& ifname, const std::string& ipv4_addr));
55 MOCK_METHOD1(AddOutboundIPv4, bool(const std::string& ifname));
56 MOCK_METHOD1(RemoveOutboundIPv4, void(const std::string& ifname));
Garrick Evans664a82f2019-12-17 12:18:05 +090057 MOCK_METHOD3(MaskInterfaceFlags,
58 bool(const std::string& ifname, uint16_t on, uint16_t off));
Taoyu Li90c13912019-11-26 17:56:54 +090059 MOCK_METHOD2(AddIPv6Forwarding,
60 bool(const std::string& ifname1, const std::string& ifname2));
61 MOCK_METHOD2(RemoveIPv6Forwarding,
62 void(const std::string& ifname1, const std::string& ifname2));
Garrick Evans3d97a392020-02-21 15:24:37 +090063 MOCK_METHOD3(AddIPv4Route, bool(uint32_t gw, uint32_t dst, uint32_t netmask));
Garrick Evansf0ab7132019-06-18 14:50:42 +090064
65 private:
66 DISALLOW_COPY_AND_ASSIGN(MockDatapath);
67};
68
69} // namespace arc_networkd
70
71#endif // ARC_NETWORK_MOCK_DATAPATH_H_