blob: f3aae4252b4785591279e009b6c8e4b95ce5d178 [file] [log] [blame]
Thieu Le3426c8f2012-01-11 17:35:11 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Paul Stewart75897df2011-04-27 09:05:53 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Darin Petkov633ac6f2011-07-08 13:56:13 -07005#ifndef SHILL_DAEMON_H_
6#define SHILL_DAEMON_H_
Paul Stewart75897df2011-04-27 09:05:53 -07007
mukesh agrawal8f317b62011-07-15 11:53:23 -07008#include <string>
9
Thieu Lefb46caf2012-03-08 11:57:15 -080010#include <base/memory/scoped_ptr.h>
11
Ben Chanb7bf2162014-06-12 02:12:28 -070012#include "shill/callback80211_metrics.h"
Paul Stewart26b327e2011-10-19 11:38:09 -070013#include "shill/event_dispatcher.h"
Darin Petkova7b89492011-07-27 12:48:17 -070014#include "shill/glib.h"
Paul Stewart75897df2011-04-27 09:05:53 -070015#include "shill/manager.h"
Darin Petkov633ac6f2011-07-08 13:56:13 -070016#include "shill/sockets.h"
Paul Stewart75897df2011-04-27 09:05:53 -070017
18namespace shill {
19
Darin Petkov633ac6f2011-07-08 13:56:13 -070020class Config;
21class ControlInterface;
Thieu Lefb46caf2012-03-08 11:57:15 -080022class DHCPProvider;
Gary Moraina9fb3252012-05-31 12:05:31 -070023class Error;
Darin Petkov887f2982011-07-14 16:10:17 -070024class GLib;
Thieu Le6c1e3bb2013-02-06 15:20:35 -080025class Metrics;
Wade Guthriebb9fca22013-04-10 17:21:42 -070026class NetlinkManager;
Darin Petkov3c5e4dc2012-04-02 14:44:27 +020027class NSS;
Thieu Lefb46caf2012-03-08 11:57:15 -080028class ProxyFactory;
29class RoutingTable;
30class RTNLHandler;
Darin Petkov633ac6f2011-07-08 13:56:13 -070031
Paul Stewart75897df2011-04-27 09:05:53 -070032class Daemon {
33 public:
Darin Petkova7b89492011-07-27 12:48:17 -070034 Daemon(Config *config, ControlInterface *control);
Paul Stewart75897df2011-04-27 09:05:53 -070035 ~Daemon();
Darin Petkov633ac6f2011-07-08 13:56:13 -070036
mukesh agrawal8f317b62011-07-15 11:53:23 -070037 void AddDeviceToBlackList(const std::string &device_name);
Paul Stewart10e9e4e2012-04-26 19:46:28 -070038 void SetStartupPortalList(const std::string &portal_list);
Darin Petkov3c5e4dc2012-04-02 14:44:27 +020039 // Main for connection manager. Starts main process and holds event loop.
Paul Stewart75897df2011-04-27 09:05:53 -070040 void Run();
Gary Moraina9fb3252012-05-31 12:05:31 -070041
42 // Starts the termination actions in the manager.
Thieu Le1271d682011-11-02 22:48:19 +000043 void Quit();
Paul Stewart75897df2011-04-27 09:05:53 -070044
45 private:
Darin Petkov633ac6f2011-07-08 13:56:13 -070046 friend class ShillDaemonTest;
47
Ben Chana3ac0962014-06-12 01:46:18 -070048 // Called when the termination actions are completed.
Gary Moraina9fb3252012-05-31 12:05:31 -070049 void TerminationActionsCompleted(const Error &error);
Ben Chana3ac0962014-06-12 01:46:18 -070050
51 // Calls Stop() and then causes the dispatcher message loop to terminate and
52 // return to the main function which started the daemon.
53 void StopAndReturnToMain();
54
Darin Petkova7b89492011-07-27 12:48:17 -070055 void Start();
Thieu Le1271d682011-11-02 22:48:19 +000056 void Stop();
Darin Petkov633ac6f2011-07-08 13:56:13 -070057
Paul Stewart75897df2011-04-27 09:05:53 -070058 Config *config_;
59 ControlInterface *control_;
Ben Chanb7bf2162014-06-12 02:12:28 -070060 EventDispatcher dispatcher_;
61 GLib glib_;
62 Sockets sockets_;
Thieu Le6c1e3bb2013-02-06 15:20:35 -080063 scoped_ptr<Metrics> metrics_;
Darin Petkov3c5e4dc2012-04-02 14:44:27 +020064 NSS *nss_;
Thieu Lefb46caf2012-03-08 11:57:15 -080065 ProxyFactory *proxy_factory_;
66 RTNLHandler *rtnl_handler_;
67 RoutingTable *routing_table_;
68 DHCPProvider *dhcp_provider_;
Wade Guthriebb9fca22013-04-10 17:21:42 -070069 NetlinkManager *netlink_manager_;
Thieu Lefb46caf2012-03-08 11:57:15 -080070 scoped_ptr<Manager> manager_;
Wade Guthrie5020b572012-10-12 15:51:14 -070071 Callback80211Metrics callback80211_metrics_;
Paul Stewart75897df2011-04-27 09:05:53 -070072};
73
74} // namespace shill
75
Darin Petkov633ac6f2011-07-08 13:56:13 -070076#endif // SHILL_DAEMON_H_