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