1 // Copyright 2015 The Chromium 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.
5 #ifndef CHROMEOS_NETWORK_FIREWALL_HOLE_H_
6 #define CHROMEOS_NETWORK_FIREWALL_HOLE_H_
11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chromeos/chromeos_export.h"
14 #include "dbus/file_descriptor.h"
18 // This class works with the Chrome OS permission broker to open a port in the
19 // system firewall. It is closed on destruction.
20 class CHROMEOS_EXPORT FirewallHole
{
27 typedef base::Callback
<void(scoped_ptr
<FirewallHole
>)> OpenCallback
;
29 // Opens a port on the system firewall for the given network interface (or all
30 // interfaces if |interface| is ""). The hole will be closed when the object
31 // provided to the callback is destroyed.
32 static void Open(PortType type
,
34 const std::string
& interface
,
35 const OpenCallback
& callback
);
40 static void RequestPortAccess(PortType type
,
42 const std::string
& interface
,
43 dbus::ScopedFileDescriptor lifeline_local
,
44 dbus::ScopedFileDescriptor lifeline_remote
,
45 const OpenCallback
& callback
);
47 static void PortAccessGranted(PortType type
,
49 const std::string
& interface
,
50 dbus::ScopedFileDescriptor lifeline_fd
,
51 const FirewallHole::OpenCallback
& callback
,
54 FirewallHole(PortType type
,
56 const std::string
& interface
,
57 dbus::ScopedFileDescriptor lifeline_fd
);
61 const std::string interface_
;
63 // A file descriptor used by firewalld to track the lifetime of this process.
64 dbus::ScopedFileDescriptor lifeline_fd_
;
67 } // namespace chromeos
69 #endif // CHROMEOS_NETWORK_FIREWALL_HOLE_H_