blob: b749b82788b3e533f66b04561733cad53f692564 [file] [log] [blame]
Jie Jiang81c84db2020-09-29 17:40:16 +09001// 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
5#include "patchpanel/dbus/fake_client.h"
6
7namespace patchpanel {
8
Garrick Evansd0a646e2020-11-25 21:08:32 +09009void FakeClient::RegisterOnAvailableCallback(
10 base::RepeatingCallback<void(bool)> callback) {}
11
Garrick Evans6a062012021-02-15 09:25:44 +090012void FakeClient::RegisterProcessChangedCallback(
13 base::RepeatingCallback<void(bool)> callback) {}
14
Jie Jiang81c84db2020-09-29 17:40:16 +090015bool FakeClient::NotifyArcStartup(pid_t) {
16 return true;
17}
18
19bool FakeClient::NotifyArcShutdown() {
20 return true;
21}
22
23std::vector<NetworkDevice> FakeClient::NotifyArcVmStartup(uint32_t cid) {
24 return {};
25}
26
27bool FakeClient::NotifyArcVmShutdown(uint32_t cid) {
28 return true;
29}
30
31bool FakeClient::NotifyTerminaVmStartup(uint32_t cid,
32 NetworkDevice* device,
33 IPv4Subnet* container_subnet) {
34 return true;
35}
36
37bool FakeClient::NotifyTerminaVmShutdown(uint32_t cid) {
38 return true;
39}
40
41bool FakeClient::NotifyPluginVmStartup(uint64_t vm_id,
42 int subnet_index,
43 NetworkDevice* device) {
44 return true;
45}
46
47bool FakeClient::NotifyPluginVmShutdown(uint64_t vm_id) {
48 return true;
49}
50
51bool FakeClient::DefaultVpnRouting(int socket) {
52 return true;
53}
54
55bool FakeClient::RouteOnVpn(int socket) {
56 return true;
57}
58
59bool FakeClient::BypassVpn(int socket) {
60 return true;
61}
62
63std::pair<base::ScopedFD, patchpanel::ConnectNamespaceResponse>
64FakeClient::ConnectNamespace(pid_t pid,
65 const std::string& outbound_ifname,
Garrick Evans58697022020-12-03 12:41:13 +090066 bool forward_user_traffic,
67 bool route_on_vpn,
68 TrafficCounter::Source traffic_source) {
Jie Jiang81c84db2020-09-29 17:40:16 +090069 return {};
70}
71
72void FakeClient::GetTrafficCounters(const std::set<std::string>& devices,
73 GetTrafficCountersCallback callback) {
74 if (devices.size() == 0) {
75 std::move(callback).Run(
76 {stored_traffic_counters_.begin(), stored_traffic_counters_.end()});
77 return;
78 }
79
80 std::vector<TrafficCounter> return_counters;
81 for (const auto& counter : stored_traffic_counters_) {
82 if (devices.find(counter.device()) != devices.end())
83 return_counters.push_back(counter);
84 }
85
86 std::move(callback).Run({return_counters.begin(), return_counters.end()});
87}
88
89bool FakeClient::ModifyPortRule(
90 patchpanel::ModifyPortRuleRequest::Operation op,
91 patchpanel::ModifyPortRuleRequest::RuleType type,
92 patchpanel::ModifyPortRuleRequest::Protocol proto,
93 const std::string& input_ifname,
94 const std::string& input_dst_ip,
95 uint32_t input_dst_port,
96 const std::string& dst_ip,
97 uint32_t dst_port) {
98 return true;
99}
100
Hugo Benichi007abcc2021-05-14 10:44:45 +0900101bool FakeClient::SetVpnLockdown(bool enable) {
102 return true;
103}
104
Garrick Evans9e637982020-11-30 11:59:27 +0900105std::vector<NetworkDevice> FakeClient::GetDevices() {
106 return {};
107}
108
Garrick Evansf04f0442020-12-01 12:36:44 +0900109void FakeClient::RegisterNetworkDeviceChangedSignalHandler(
110 NetworkDeviceChangedSignalHandler handler) {
111 network_device_changed_handler_ = handler;
112}
113
Jie Jiang25c1b972020-11-12 15:42:53 +0900114void FakeClient::RegisterNeighborReachabilityEventHandler(
115 NeighborReachabilityEventHandler handler) {
Jie Jiang81c84db2020-09-29 17:40:16 +0900116 neighbor_handlers_.push_back(handler);
117}
118
Jie Jiang25c1b972020-11-12 15:42:53 +0900119void FakeClient::TriggerNeighborReachabilityEvent(
120 const NeighborReachabilityEventSignal& signal) {
Jie Jiang81c84db2020-09-29 17:40:16 +0900121 for (const auto& handler : neighbor_handlers_)
122 handler.Run(signal);
123}
124
125} // namespace patchpanel