blob: a39b4b9ee4059ef73ddf673d61aeb61c4b2d0177 [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
Paul Stewart0af98bf2011-05-10 17:38:08 -070037void Daemon::Start() {
Darin Petkov633ac6f2011-07-08 13:56:13 -070038 RTNLHandler::GetInstance()->Start(&dispatcher_, &sockets_);
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