Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 5 | #ifndef SHILL_DAEMON_H_ |
| 6 | #define SHILL_DAEMON_H_ |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 7 | |
mukesh agrawal | 8f317b6 | 2011-07-15 11:53:23 -0700 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Thieu Le | fb46caf | 2012-03-08 11:57:15 -0800 | [diff] [blame] | 10 | #include <base/memory/scoped_ptr.h> |
| 11 | |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 12 | #include "shill/event_dispatcher.h" |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 13 | #include "shill/glib.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 14 | #include "shill/manager.h" |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 15 | #include "shill/metrics.h" |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 16 | #include "shill/sockets.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 17 | |
| 18 | namespace shill { |
| 19 | |
Wade Guthrie | 64b4c14 | 2012-08-20 15:21:01 -0700 | [diff] [blame] | 20 | class Callback80211Object; |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 21 | class Config; |
Wade Guthrie | 64b4c14 | 2012-08-20 15:21:01 -0700 | [diff] [blame] | 22 | class Config80211; |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 23 | class ControlInterface; |
Thieu Le | fb46caf | 2012-03-08 11:57:15 -0800 | [diff] [blame] | 24 | class DHCPProvider; |
Gary Morain | a9fb325 | 2012-05-31 12:05:31 -0700 | [diff] [blame] | 25 | class Error; |
Darin Petkov | 887f298 | 2011-07-14 16:10:17 -0700 | [diff] [blame] | 26 | class GLib; |
Darin Petkov | 3c5e4dc | 2012-04-02 14:44:27 +0200 | [diff] [blame] | 27 | class NSS; |
Thieu Le | fb46caf | 2012-03-08 11:57:15 -0800 | [diff] [blame] | 28 | class ProxyFactory; |
| 29 | class RoutingTable; |
| 30 | class RTNLHandler; |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 31 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 32 | class Daemon { |
| 33 | public: |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 34 | Daemon(Config *config, ControlInterface *control); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 35 | ~Daemon(); |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 36 | |
mukesh agrawal | 8f317b6 | 2011-07-15 11:53:23 -0700 | [diff] [blame] | 37 | void AddDeviceToBlackList(const std::string &device_name); |
Gaurav Shah | 7135476 | 2011-11-28 19:22:49 -0800 | [diff] [blame] | 38 | void SetStartupProfiles(const std::vector<std::string> &profile_path); |
Paul Stewart | 10e9e4e | 2012-04-26 19:46:28 -0700 | [diff] [blame] | 39 | void SetStartupPortalList(const std::string &portal_list); |
Darin Petkov | 3c5e4dc | 2012-04-02 14:44:27 +0200 | [diff] [blame] | 40 | // Main for connection manager. Starts main process and holds event loop. |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 41 | void Run(); |
Gary Morain | a9fb325 | 2012-05-31 12:05:31 -0700 | [diff] [blame] | 42 | |
| 43 | // Starts the termination actions in the manager. |
Thieu Le | 1271d68 | 2011-11-02 22:48:19 +0000 | [diff] [blame] | 44 | void Quit(); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 45 | |
| 46 | private: |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 47 | friend class ShillDaemonTest; |
| 48 | |
Gary Morain | a9fb325 | 2012-05-31 12:05:31 -0700 | [diff] [blame] | 49 | // Time to wait for termination actions to complete. |
| 50 | static const int kTerminationActionsTimeout; // ms |
| 51 | |
| 52 | // Causes the dispatcher message loop to terminate, calls Stop(), and returns |
| 53 | // to the main function which started the daemon. Called when the termination |
| 54 | // actions are completed. |
| 55 | void TerminationActionsCompleted(const Error &error); |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 56 | void Start(); |
Thieu Le | 1271d68 | 2011-11-02 22:48:19 +0000 | [diff] [blame] | 57 | void Stop(); |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 58 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 59 | Config *config_; |
| 60 | ControlInterface *control_; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 61 | Metrics metrics_; |
Darin Petkov | 3c5e4dc | 2012-04-02 14:44:27 +0200 | [diff] [blame] | 62 | NSS *nss_; |
Thieu Le | fb46caf | 2012-03-08 11:57:15 -0800 | [diff] [blame] | 63 | ProxyFactory *proxy_factory_; |
| 64 | RTNLHandler *rtnl_handler_; |
| 65 | RoutingTable *routing_table_; |
| 66 | DHCPProvider *dhcp_provider_; |
Wade Guthrie | 0d43853 | 2012-05-18 14:18:50 -0700 | [diff] [blame] | 67 | Config80211 *config80211_; |
| 68 | Callback80211Object *callback80211_; |
Thieu Le | fb46caf | 2012-03-08 11:57:15 -0800 | [diff] [blame] | 69 | scoped_ptr<Manager> manager_; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 70 | EventDispatcher dispatcher_; |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 71 | Sockets sockets_; |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 72 | GLib glib_; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | } // namespace shill |
| 76 | |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 77 | #endif // SHILL_DAEMON_H_ |