Home | History | Annotate | Download | only in firewalld
      1 // Copyright 2014 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 FIREWALLD_FIREWALL_SERVICE_H_
     16 #define FIREWALLD_FIREWALL_SERVICE_H_
     17 
     18 #include <base/callback.h>
     19 #include <base/macros.h>
     20 #include <base/memory/scoped_ptr.h>
     21 #include <base/memory/weak_ptr.h>
     22 #include <brillo/dbus/dbus_object.h>
     23 
     24 #include "dbus_bindings/org.chromium.Firewalld.h"
     25 #if !defined(__ANDROID__)
     26 # include "permission_broker/dbus-proxies.h"
     27 #endif  // __ANDROID__
     28 
     29 #include "iptables.h"
     30 
     31 using CompletionAction =
     32     brillo::dbus_utils::AsyncEventSequencer::CompletionAction;
     33 
     34 namespace firewalld {
     35 
     36 class FirewallService : public org::chromium::FirewalldAdaptor {
     37  public:
     38   explicit FirewallService(
     39       brillo::dbus_utils::ExportedObjectManager* object_manager);
     40   virtual ~FirewallService() = default;
     41 
     42   // Connects to D-Bus system bus and exports methods.
     43   void RegisterAsync(const CompletionAction& callback);
     44 
     45  private:
     46 #if !defined(__ANDROID__)
     47   void OnPermissionBrokerRemoved(const dbus::ObjectPath& path);
     48 #endif  // __ANDROID__
     49 
     50   brillo::dbus_utils::DBusObject dbus_object_;
     51 #if !defined(__ANDROID__)
     52   std::unique_ptr<org::chromium::PermissionBroker::ObjectManagerProxy>
     53       permission_broker_;
     54 #endif  // __ANDROID__
     55   IpTables iptables_;
     56 
     57   base::WeakPtrFactory<FirewallService> weak_ptr_factory_{this};
     58   DISALLOW_COPY_AND_ASSIGN(FirewallService);
     59 };
     60 
     61 }  // namespace firewalld
     62 
     63 #endif  // FIREWALLD_FIREWALL_SERVICE_H_
     64