blob: 426589354ec58fe56a36628bcfb82d13a5e09998 [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
Ben Chanc45688b2014-07-02 23:50:45 -07005#ifndef SHILL_SHILL_DAEMON_H_
6#define SHILL_SHILL_DAEMON_H_
Paul Stewart75897df2011-04-27 09:05:53 -07007
Ben Chancd477322014-10-17 14:19:30 -07008#include <memory>
mukesh agrawal8f317b62011-07-15 11:53:23 -07009#include <string>
Jason Simmons5a2097c2015-02-10 18:03:08 -080010#include <vector>
mukesh agrawal8f317b62011-07-15 11:53:23 -070011
Paul Stewartca324742014-08-29 14:41:59 -070012#include "shill/control_interface.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"
Peter Qiu1a72f542015-04-14 16:31:36 -070016
17#if !defined(DISABLE_WIFI)
Ben Chand6a8b512014-11-18 10:45:15 -080018#include "shill/wifi/callback80211_metrics.h"
Peter Qiu1a72f542015-04-14 16:31:36 -070019#endif // DISABLE_WIFI
Paul Stewart75897df2011-04-27 09:05:53 -070020
21namespace shill {
22
Darin Petkov633ac6f2011-07-08 13:56:13 -070023class Config;
Thieu Lefb46caf2012-03-08 11:57:15 -080024class DHCPProvider;
Gary Moraina9fb3252012-05-31 12:05:31 -070025class Error;
Darin Petkov887f2982011-07-14 16:10:17 -070026class GLib;
Thieu Le6c1e3bb2013-02-06 15:20:35 -080027class Metrics;
Thieu Lefb46caf2012-03-08 11:57:15 -080028class RoutingTable;
29class RTNLHandler;
Darin Petkov633ac6f2011-07-08 13:56:13 -070030
Peter Qiu1a72f542015-04-14 16:31:36 -070031#if !defined(DISABLE_WIFI)
32class NetlinkManager;
33#endif // DISABLE_WIFI
34
Paul Stewart75897df2011-04-27 09:05:53 -070035class Daemon {
36 public:
Paul Stewart1ce231c2015-06-12 19:44:22 -070037 // Run-time settings retrieved from command line.
38 struct Settings {
39 Settings()
40 : ignore_unknown_ethernet(false),
41 minimum_mtu(0),
42 passive_mode(false),
43 use_portal_list(false) {}
44 std::string accept_hostname_from;
45 std::string default_technology_order;
46 std::vector<std::string> device_blacklist;
47 std::vector<std::string> dhcpv6_enabled_devices;
48 bool ignore_unknown_ethernet;
49 int minimum_mtu;
50 bool passive_mode;
51 std::string portal_list;
52 std::string prepend_dns_servers;
53 bool use_portal_list;
54 };
55
Paul Stewart1a212a62015-06-16 13:13:10 -070056 Daemon(Config* config, ControlInterface* control);
Paul Stewart75897df2011-04-27 09:05:53 -070057 ~Daemon();
Darin Petkov633ac6f2011-07-08 13:56:13 -070058
Paul Stewart1ce231c2015-06-12 19:44:22 -070059 // Apply run-time settings to the manager.
Paul Stewart1a212a62015-06-16 13:13:10 -070060 void ApplySettings(const Settings& settings);
Peter Qiu1d499ed2015-01-30 16:01:27 -080061
Darin Petkov3c5e4dc2012-04-02 14:44:27 +020062 // Main for connection manager. Starts main process and holds event loop.
Paul Stewart75897df2011-04-27 09:05:53 -070063 void Run();
Gary Moraina9fb3252012-05-31 12:05:31 -070064
65 // Starts the termination actions in the manager.
Thieu Le1271d682011-11-02 22:48:19 +000066 void Quit();
Paul Stewart75897df2011-04-27 09:05:53 -070067
68 private:
Darin Petkov633ac6f2011-07-08 13:56:13 -070069 friend class ShillDaemonTest;
70
Ben Chana3ac0962014-06-12 01:46:18 -070071 // Called when the termination actions are completed.
Paul Stewart1a212a62015-06-16 13:13:10 -070072 void TerminationActionsCompleted(const Error& error);
Ben Chana3ac0962014-06-12 01:46:18 -070073
74 // Calls Stop() and then causes the dispatcher message loop to terminate and
75 // return to the main function which started the daemon.
76 void StopAndReturnToMain();
77
Darin Petkova7b89492011-07-27 12:48:17 -070078 void Start();
Thieu Le1271d682011-11-02 22:48:19 +000079 void Stop();
Darin Petkov633ac6f2011-07-08 13:56:13 -070080
Paul Stewart1a212a62015-06-16 13:13:10 -070081 Config* config_;
Ben Chancd477322014-10-17 14:19:30 -070082 std::unique_ptr<ControlInterface> control_;
Ben Chanb7bf2162014-06-12 02:12:28 -070083 EventDispatcher dispatcher_;
84 GLib glib_;
Ben Chancd477322014-10-17 14:19:30 -070085 std::unique_ptr<Metrics> metrics_;
Paul Stewart1a212a62015-06-16 13:13:10 -070086 RTNLHandler* rtnl_handler_;
87 RoutingTable* routing_table_;
88 DHCPProvider* dhcp_provider_;
Peter Qiu1a72f542015-04-14 16:31:36 -070089#if !defined(DISABLE_WIFI)
Paul Stewart1a212a62015-06-16 13:13:10 -070090 NetlinkManager* netlink_manager_;
Wade Guthrie5020b572012-10-12 15:51:14 -070091 Callback80211Metrics callback80211_metrics_;
Peter Qiu1a72f542015-04-14 16:31:36 -070092#endif // DISABLE_WIFI
93 std::unique_ptr<Manager> manager_;
Paul Stewart75897df2011-04-27 09:05:53 -070094};
95
96} // namespace shill
97
Ben Chanc45688b2014-07-02 23:50:45 -070098#endif // SHILL_SHILL_DAEMON_H_