• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef WEBSERVER_WEBSERVD_FIREWALLD_FIREWALL_H_
16 #define WEBSERVER_WEBSERVD_FIREWALLD_FIREWALL_H_
17 
18 #include "webservd/firewall_interface.h"
19 
20 #include <string>
21 
22 #include <base/macros.h>
23 #include <base/memory/weak_ptr.h>
24 
25 #include "firewalld/dbus-proxies.h"
26 
27 namespace webservd {
28 
29 class FirewalldFirewall : public FirewallInterface {
30  public:
31   FirewalldFirewall() = default;
32   ~FirewalldFirewall() override = default;
33 
34   // Interface overrides.
35   void WaitForServiceAsync(dbus::Bus* bus, const base::Closure& callback)
36       override;
37   void PunchTcpHoleAsync(
38       uint16_t port, const std::string& interface_name,
39       const base::Callback<void(bool)>& success_cb,
40       const base::Callback<void(brillo::Error*)>& failure_cb) override;
41 
42  private:
43   void OnFirewalldOnline(org::chromium::FirewalldProxyInterface* proxy);
44 
45   std::unique_ptr<org::chromium::Firewalld::ObjectManagerProxy> object_manager_;
46 
47   // Proxy to the firewall DBus service. Owned by the DBus bindings module.
48   org::chromium::FirewalldProxyInterface* proxy_;
49 
50   // Callback to use when firewall service comes online.
51   base::Closure service_online_cb_;
52 
53   base::WeakPtrFactory<FirewalldFirewall> weak_ptr_factory_{this};
54   DISALLOW_COPY_AND_ASSIGN(FirewalldFirewall);
55 };
56 
57 }  // namespace webservd
58 
59 #endif  // WEBSERVER_WEBSERVD_FIREWALLD_FIREWALL_H_
60