37450d19c2de03e0abce8f9ab8f976b798c24187
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / container / service.h
1 /*
2  * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3, as published
6  * by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranties of
10  * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11  * PURPOSE.  See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17
18 #ifndef ANBOX_CONTAINER_SERVICE_H_
19 #define ANBOX_CONTAINER_SERVICE_H_
20
21 #include "anbox/common/dispatcher.h"
22 #include "anbox/container/container.h"
23 #include "anbox/network/connections.h"
24 #include "anbox/network/credentials.h"
25 #include "anbox/network/published_socket_connector.h"
26 #include "anbox/network/socket_connection.h"
27 #include "anbox/runtime.h"
28
29 namespace anbox {
30 namespace container {
31 class Service : public std::enable_shared_from_this<Service> {
32  public:
33   struct Configuration {
34     bool privileged = false;
35     bool rootfs_overlay = true;
36     std::string container_network_address;
37     std::string container_network_gateway;
38     std::vector<std::string> container_network_dns_servers;
39   };
40
41   static std::shared_ptr<Service> create(const std::shared_ptr<Runtime> &rt,
42                                          const Configuration &config);
43
44   ~Service();
45
46  private:
47   Service(const std::shared_ptr<Runtime> &rt, const Configuration &config);
48
49   int next_id();
50   void new_client(std::shared_ptr<
51                   boost::asio::local::stream_protocol::socket> const &socket);
52
53   std::shared_ptr<common::Dispatcher> dispatcher_;
54   std::shared_ptr<network::PublishedSocketConnector> connector_;
55   std::atomic<int> next_connection_id_;
56   std::shared_ptr<network::Connections<network::SocketConnection>> connections_;
57   std::shared_ptr<Container> backend_;
58   Configuration config_;
59 };
60 }  // namespace container
61 }  // namespace anbox
62
63 #endif