blob: 8082bf3137bc9b260d8f143255736b29efe6c9a8 [file] [log] [blame]
Alexander Afanasyev31c781e2015-02-09 17:39:59 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shiea47bde2017-01-26 17:49:16 +00003 * Copyright (c) 2014-2017, Regents of the University of California,
Alexander Afanasyev31c781e2015-02-09 17:39:59 -08004 * 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
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080029#include "core/config-file.hpp"
Alexander Afanasyev3f41ade2015-06-29 18:31:22 -070030#include "core/scheduler.hpp"
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080031
32#include <ndn-cxx/security/key-chain.hpp>
Alexander Afanasyev3f41ade2015-06-29 18:31:22 -070033#include <ndn-cxx/util/network-monitor.hpp>
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080034
Yanbiao Li698f4fe2015-08-19 16:30:16 -070035namespace ndn {
Junxiao Shi6535f1e2015-10-08 13:02:18 -070036class Face;
Yanbiao Li698f4fe2015-08-19 16:30:16 -070037namespace mgmt {
Yanbiao Li698f4fe2015-08-19 16:30:16 -070038class Dispatcher;
Junxiao Shicde37ad2015-12-24 01:02:05 -070039} // namespace mgmt
40} // namespace ndn
Yanbiao Li698f4fe2015-08-19 16:30:16 -070041
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080042namespace nfd {
43
44class Forwarder;
Junxiao Shi9ddf1b52016-08-22 03:58:55 +000045class CommandAuthenticator;
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080046class FibManager;
47class FaceManager;
48class StrategyChoiceManager;
Yanbiao Li7cec7ea2015-08-19 16:30:16 -070049class ForwarderStatusManager;
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080050
Junxiao Shicde37ad2015-12-24 01:02:05 -070051namespace face {
52class Face;
Junxiao Shiea47bde2017-01-26 17:49:16 +000053class FaceSystem;
Junxiao Shicde37ad2015-12-24 01:02:05 -070054} // namespace face
55
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080056/**
57 * \brief Class representing NFD instance
58 * This class can be used to initialize all components of NFD
59 */
60class Nfd : noncopyable
61{
62public:
63 /**
64 * \brief Create NFD instance using absolute or relative path to \p configFile
65 */
66 Nfd(const std::string& configFile, ndn::KeyChain& keyChain);
67
68 /**
69 * \brief Create NFD instance using a parsed ConfigSection \p config
70 * This version of the constructor is more appropriate for integrated environments,
71 * such as NS-3 or android.
72 * \note When using this version of the constructor, error messages will include
73 * "internal://nfd.conf" when referring to configuration errors.
74 */
75 Nfd(const ConfigSection& config, ndn::KeyChain& keyChain);
76
77 /**
Alexander Afanasyev2bda6f82015-02-10 14:17:19 -080078 * \brief Destructor
79 */
80 ~Nfd();
81
82 /**
Alexander Afanasyev31c781e2015-02-09 17:39:59 -080083 * \brief Perform initialization of NFD instance
84 * After initialization, NFD instance can be started by invoking run on globalIoService
85 */
86 void
87 initialize();
88
89 /**
90 * \brief Reload configuration file and apply update (if any)
91 */
92 void
93 reloadConfigFile();
94
95private:
96 void
97 initializeLogging();
98
99 void
100 initializeManagement();
101
Alexander Afanasyev3f41ade2015-06-29 18:31:22 -0700102 void
103 reloadConfigFileFaceSection();
104
Alexander Afanasyev31c781e2015-02-09 17:39:59 -0800105private:
106 std::string m_configFile;
107 ConfigSection m_configSection;
108
Alexander Afanasyev2bda6f82015-02-10 14:17:19 -0800109 unique_ptr<Forwarder> m_forwarder;
Junxiao Shiea47bde2017-01-26 17:49:16 +0000110 unique_ptr<face::FaceSystem> m_faceSystem;
Alexander Afanasyev31c781e2015-02-09 17:39:59 -0800111
Junxiao Shi9ddf1b52016-08-22 03:58:55 +0000112 ndn::KeyChain& m_keyChain;
113 shared_ptr<face::Face> m_internalFace;
114 shared_ptr<ndn::Face> m_internalClientFace;
115 unique_ptr<ndn::mgmt::Dispatcher> m_dispatcher;
116 shared_ptr<CommandAuthenticator> m_authenticator;
Yanbiao Li7cec7ea2015-08-19 16:30:16 -0700117 unique_ptr<ForwarderStatusManager> m_forwarderStatusManager;
Junxiao Shi9ddf1b52016-08-22 03:58:55 +0000118 unique_ptr<FaceManager> m_faceManager;
119 unique_ptr<FibManager> m_fibManager;
120 unique_ptr<StrategyChoiceManager> m_strategyChoiceManager;
Alexander Afanasyev31c781e2015-02-09 17:39:59 -0800121
Alexander Afanasyev441ba212015-09-10 23:41:07 -0700122 unique_ptr<ndn::util::NetworkMonitor> m_networkMonitor;
Junxiao Shi9ddf1b52016-08-22 03:58:55 +0000123 scheduler::ScopedEventId m_reloadConfigEvent;
Alexander Afanasyev31c781e2015-02-09 17:39:59 -0800124};
125
126} // namespace nfd
127
128#endif // NFD_DAEMON_NFD_HPP