blob: acd30967185455b9b0a8b1d9ec7ff1756234fd82 [file] [log] [blame]
Alexander Afanasyev31c781e2015-02-09 17:39:59 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2015, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#ifndef NFD_DAEMON_NFD_HPP
27#define NFD_DAEMON_NFD_HPP
28
29#include "common.hpp"
30#include "core/config-file.hpp"
Alexander Afanasyev3f41ade2015-06-29 18:31:22 -070031#include "core/scheduler.hpp"
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080032
33#include <ndn-cxx/security/key-chain.hpp>
Alexander Afanasyev3f41ade2015-06-29 18:31:22 -070034#include <ndn-cxx/util/network-monitor.hpp>
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080035
36namespace nfd {
37
38class Forwarder;
39class InternalFace;
40class FibManager;
41class FaceManager;
42class StrategyChoiceManager;
43class StatusServer;
44
45/**
46 * \brief Class representing NFD instance
47 * This class can be used to initialize all components of NFD
48 */
49class Nfd : noncopyable
50{
51public:
52 /**
53 * \brief Create NFD instance using absolute or relative path to \p configFile
54 */
55 Nfd(const std::string& configFile, ndn::KeyChain& keyChain);
56
57 /**
58 * \brief Create NFD instance using a parsed ConfigSection \p config
59 * This version of the constructor is more appropriate for integrated environments,
60 * such as NS-3 or android.
61 * \note When using this version of the constructor, error messages will include
62 * "internal://nfd.conf" when referring to configuration errors.
63 */
64 Nfd(const ConfigSection& config, ndn::KeyChain& keyChain);
65
66 /**
Alexander Afanasyev2bda6f82015-02-10 14:17:19 -080067 * \brief Destructor
68 */
69 ~Nfd();
70
71 /**
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080072 * \brief Perform initialization of NFD instance
73 * After initialization, NFD instance can be started by invoking run on globalIoService
74 */
75 void
76 initialize();
77
78 /**
79 * \brief Reload configuration file and apply update (if any)
80 */
81 void
82 reloadConfigFile();
83
84private:
85 void
86 initializeLogging();
87
88 void
89 initializeManagement();
90
Alexander Afanasyev3f41ade2015-06-29 18:31:22 -070091 void
92 reloadConfigFileFaceSection();
93
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080094private:
95 std::string m_configFile;
96 ConfigSection m_configSection;
97
Alexander Afanasyev2bda6f82015-02-10 14:17:19 -080098 unique_ptr<Forwarder> m_forwarder;
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080099
100 shared_ptr<InternalFace> m_internalFace;
Yanbiao Li36f35002015-08-19 16:30:16 -0700101 // unique_ptr<FibManager> m_fibManager;
102 // unique_ptr<FaceManager> m_faceManager;
103 // unique_ptr<StrategyChoiceManager> m_strategyChoiceManager;
104 // unique_ptr<StatusServer> m_statusServer;
Alexander Afanasyev31c781e2015-02-09 17:39:59 -0800105
Yanbiao Li36f35002015-08-19 16:30:16 -0700106 // ndn::KeyChain& m_keyChain;
Alexander Afanasyev3f41ade2015-06-29 18:31:22 -0700107
108 ndn::util::NetworkMonitor m_networkMonitor;
109 scheduler::ScopedEventId m_reloadConfigEvent;
Alexander Afanasyev31c781e2015-02-09 17:39:59 -0800110};
111
112} // namespace nfd
113
114#endif // NFD_DAEMON_NFD_HPP