Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 1 | /* -*- 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 Afanasyev | 3f41ade | 2015-06-29 18:31:22 -0700 | [diff] [blame] | 31 | #include "core/scheduler.hpp" |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 32 | |
| 33 | #include <ndn-cxx/security/key-chain.hpp> |
Alexander Afanasyev | 3f41ade | 2015-06-29 18:31:22 -0700 | [diff] [blame] | 34 | #include <ndn-cxx/util/network-monitor.hpp> |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 35 | |
Yanbiao Li | 698f4fe | 2015-08-19 16:30:16 -0700 | [diff] [blame] | 36 | namespace ndn { |
Junxiao Shi | 6535f1e | 2015-10-08 13:02:18 -0700 | [diff] [blame] | 37 | |
| 38 | class Face; |
| 39 | |
Yanbiao Li | 698f4fe | 2015-08-19 16:30:16 -0700 | [diff] [blame] | 40 | namespace mgmt { |
| 41 | |
| 42 | class Dispatcher; |
| 43 | |
| 44 | } |
| 45 | } |
| 46 | |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 47 | namespace nfd { |
| 48 | |
Junxiao Shi | 6535f1e | 2015-10-08 13:02:18 -0700 | [diff] [blame] | 49 | class Face; |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 50 | class Forwarder; |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 51 | class FibManager; |
| 52 | class FaceManager; |
| 53 | class StrategyChoiceManager; |
Yanbiao Li | 7cec7ea | 2015-08-19 16:30:16 -0700 | [diff] [blame] | 54 | class ForwarderStatusManager; |
Yanbiao Li | 698f4fe | 2015-08-19 16:30:16 -0700 | [diff] [blame] | 55 | class CommandValidator; |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * \brief Class representing NFD instance |
| 59 | * This class can be used to initialize all components of NFD |
| 60 | */ |
| 61 | class Nfd : noncopyable |
| 62 | { |
| 63 | public: |
| 64 | /** |
| 65 | * \brief Create NFD instance using absolute or relative path to \p configFile |
| 66 | */ |
| 67 | Nfd(const std::string& configFile, ndn::KeyChain& keyChain); |
| 68 | |
| 69 | /** |
| 70 | * \brief Create NFD instance using a parsed ConfigSection \p config |
| 71 | * This version of the constructor is more appropriate for integrated environments, |
| 72 | * such as NS-3 or android. |
| 73 | * \note When using this version of the constructor, error messages will include |
| 74 | * "internal://nfd.conf" when referring to configuration errors. |
| 75 | */ |
| 76 | Nfd(const ConfigSection& config, ndn::KeyChain& keyChain); |
| 77 | |
| 78 | /** |
Alexander Afanasyev | 2bda6f8 | 2015-02-10 14:17:19 -0800 | [diff] [blame] | 79 | * \brief Destructor |
| 80 | */ |
| 81 | ~Nfd(); |
| 82 | |
| 83 | /** |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 84 | * \brief Perform initialization of NFD instance |
| 85 | * After initialization, NFD instance can be started by invoking run on globalIoService |
| 86 | */ |
| 87 | void |
| 88 | initialize(); |
| 89 | |
| 90 | /** |
| 91 | * \brief Reload configuration file and apply update (if any) |
| 92 | */ |
| 93 | void |
| 94 | reloadConfigFile(); |
| 95 | |
| 96 | private: |
| 97 | void |
| 98 | initializeLogging(); |
| 99 | |
| 100 | void |
| 101 | initializeManagement(); |
| 102 | |
Alexander Afanasyev | 3f41ade | 2015-06-29 18:31:22 -0700 | [diff] [blame] | 103 | void |
| 104 | reloadConfigFileFaceSection(); |
| 105 | |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 106 | private: |
| 107 | std::string m_configFile; |
| 108 | ConfigSection m_configSection; |
| 109 | |
Alexander Afanasyev | 2bda6f8 | 2015-02-10 14:17:19 -0800 | [diff] [blame] | 110 | unique_ptr<Forwarder> m_forwarder; |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 111 | |
Junxiao Shi | 6535f1e | 2015-10-08 13:02:18 -0700 | [diff] [blame] | 112 | ndn::KeyChain& m_keyChain; |
| 113 | shared_ptr<Face> m_internalFace; |
| 114 | shared_ptr<ndn::Face> m_internalClientFace; |
| 115 | unique_ptr<CommandValidator> m_validator; |
Yanbiao Li | 698f4fe | 2015-08-19 16:30:16 -0700 | [diff] [blame] | 116 | |
Yanbiao Li | 7cec7ea | 2015-08-19 16:30:16 -0700 | [diff] [blame] | 117 | unique_ptr<ndn::mgmt::Dispatcher> m_dispatcher; |
| 118 | unique_ptr<FibManager> m_fibManager; |
| 119 | unique_ptr<FaceManager> m_faceManager; |
Yanbiao Li | 6704a4a | 2015-08-19 16:30:16 -0700 | [diff] [blame] | 120 | unique_ptr<StrategyChoiceManager> m_strategyChoiceManager; |
Yanbiao Li | 7cec7ea | 2015-08-19 16:30:16 -0700 | [diff] [blame] | 121 | unique_ptr<ForwarderStatusManager> m_forwarderStatusManager; |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 122 | |
Alexander Afanasyev | 441ba21 | 2015-09-10 23:41:07 -0700 | [diff] [blame] | 123 | unique_ptr<ndn::util::NetworkMonitor> m_networkMonitor; |
| 124 | scheduler::ScopedEventId m_reloadConfigEvent; |
Alexander Afanasyev | 31c781e | 2015-02-09 17:39:59 -0800 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | } // namespace nfd |
| 128 | |
| 129 | #endif // NFD_DAEMON_NFD_HPP |