blob: 8e690583ae81b08e12bdb465b0e951178e5970e3 [file] [log] [blame]
Paul Stewart75897df2011-04-27 09:05:53 -07001// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2// 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
31Daemon::Daemon(Config *config, ControlInterface *control)
32 : config_(config),
33 control_(control),
34 manager_(control_, &dispatcher_) { }
35Daemon::~Daemon() {}
36
Paul Stewart0af98bf2011-05-10 17:38:08 -070037void Daemon::Start() {
Paul Stewarta3c56f92011-05-26 07:08:52 -070038 RTNLHandler::GetInstance()->Start(&dispatcher_);
Paul Stewart0af98bf2011-05-10 17:38:08 -070039 manager_.Start();
40}
Paul Stewart75897df2011-04-27 09:05:53 -070041
42void Daemon::Run() {
Paul Stewart0af98bf2011-05-10 17:38:08 -070043 Start();
Chris Masoneb07006b2011-05-14 16:10:04 -070044 VLOG(1) << "Running main loop.";
Chris Masonec5b392e2011-05-14 16:31:01 -070045 dispatcher_.DispatchForever();
Paul Stewart75897df2011-04-27 09:05:53 -070046}
47
48
49} // namespace shill