blob: ae2577fd96404d85f80c3356ca29fda604b75fff [file] [log] [blame]
Darin Petkov633ac6f2011-07-08 13:56:13 -07001// Copyright (c) 2011 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
5#include <stdio.h>
6#include <glib.h>
7
8#include <algorithm>
9#include <string>
10#include <vector>
11
Chris Masoneee929b72011-05-10 10:02:18 -070012#include <base/logging.h>
13
Paul Stewart75897df2011-04-27 09:05:53 -070014#include "shill/shill_daemon.h"
15#include "shill/control_interface.h"
16#include "shill/dbus_control.h"
Paul Stewarta3c56f92011-05-26 07:08:52 -070017#include "shill/rtnl_handler.h"
Paul Stewart75897df2011-04-27 09:05:53 -070018
19using std::max;
20using std::min;
21using std::string;
22using std::vector;
23
24namespace shill {
25
26static const char kTaggedFilePath[] = "/var/lib/shill";
27
28// Daemon: Main for connection manager. Starts main process and holds event
29// loop.
30
Darin Petkov887f2982011-07-14 16:10:17 -070031Daemon::Daemon(Config *config, ControlInterface *control, GLib *glib)
Paul Stewart75897df2011-04-27 09:05:53 -070032 : config_(config),
33 control_(control),
Darin Petkov887f2982011-07-14 16:10:17 -070034 manager_(control_, &dispatcher_, glib) { }
Paul Stewart75897df2011-04-27 09:05:53 -070035Daemon::~Daemon() {}
36
mukesh agrawal8f317b62011-07-15 11:53:23 -070037void Daemon::AddDeviceToBlackList(const string &device_name) {
38 manager_.AddDeviceToBlackList(device_name);
39}
40
Paul Stewart0af98bf2011-05-10 17:38:08 -070041void Daemon::Start() {
Darin Petkov633ac6f2011-07-08 13:56:13 -070042 RTNLHandler::GetInstance()->Start(&dispatcher_, &sockets_);
Paul Stewart0af98bf2011-05-10 17:38:08 -070043 manager_.Start();
44}
Paul Stewart75897df2011-04-27 09:05:53 -070045
46void Daemon::Run() {
Paul Stewart0af98bf2011-05-10 17:38:08 -070047 Start();
Chris Masoneb07006b2011-05-14 16:10:04 -070048 VLOG(1) << "Running main loop.";
Chris Masonec5b392e2011-05-14 16:31:01 -070049 dispatcher_.DispatchForever();
Paul Stewart75897df2011-04-27 09:05:53 -070050}
51
52
53} // namespace shill