Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 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 | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 5 | #include "shill/shill_daemon.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 6 | |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 7 | #include <stdio.h> |
| 8 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 9 | #include <string> |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 10 | |
Chris Masone | ee929b7 | 2011-05-10 10:02:18 -0700 | [diff] [blame] | 11 | #include <base/logging.h> |
| 12 | |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 13 | #include "shill/dhcp_provider.h" |
Paul Stewart | a3c56f9 | 2011-05-26 07:08:52 -0700 | [diff] [blame] | 14 | #include "shill/rtnl_handler.h" |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 15 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 16 | using std::string; |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 17 | |
| 18 | namespace shill { |
| 19 | |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 20 | // Daemon: Main for connection manager. Starts main process and holds event |
| 21 | // loop. |
| 22 | |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 23 | Daemon::Daemon(Config *config, ControlInterface *control) |
| 24 | : config_(config), |
| 25 | control_(control), |
| 26 | manager_(control_, &dispatcher_, &glib_) { } |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 27 | Daemon::~Daemon() {} |
| 28 | |
mukesh agrawal | 8f317b6 | 2011-07-15 11:53:23 -0700 | [diff] [blame] | 29 | void Daemon::AddDeviceToBlackList(const string &device_name) { |
| 30 | manager_.AddDeviceToBlackList(device_name); |
| 31 | } |
| 32 | |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 33 | void Daemon::Start() { |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 34 | glib_.TypeInit(); |
| 35 | proxy_factory_.Init(); |
| 36 | ProxyFactory::set_factory(&proxy_factory_); |
Darin Petkov | 633ac6f | 2011-07-08 13:56:13 -0700 | [diff] [blame] | 37 | RTNLHandler::GetInstance()->Start(&dispatcher_, &sockets_); |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 38 | DHCPProvider::GetInstance()->Init(control_, &dispatcher_, &glib_); |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 39 | manager_.Start(); |
| 40 | } |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 41 | |
| 42 | void Daemon::Run() { |
Paul Stewart | 0af98bf | 2011-05-10 17:38:08 -0700 | [diff] [blame] | 43 | Start(); |
Chris Masone | b07006b | 2011-05-14 16:10:04 -0700 | [diff] [blame] | 44 | VLOG(1) << "Running main loop."; |
Chris Masone | c5b392e | 2011-05-14 16:31:01 -0700 | [diff] [blame] | 45 | dispatcher_.DispatchForever(); |
Paul Stewart | 75897df | 2011-04-27 09:05:53 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | |
| 49 | } // namespace shill |