blob: 0d8743dbab3d7285a16e0438bdd402b022f9d072 [file] [log] [blame]
Alexander Afanasyev31367922015-02-09 20:51:10 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Yanbiao Licf0db022016-01-29 00:54:25 -08003 * Copyright (c) 2014-2016, Regents of the University of California,
Alexander Afanasyev31367922015-02-09 20:51:10 -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_RIB_NRD_HPP
27#define NFD_RIB_NRD_HPP
28
29#include "common.hpp"
30#include "core/config-file.hpp"
Alexander Afanasyev31367922015-02-09 20:51:10 -080031
32#include <ndn-cxx/face.hpp>
33#include <ndn-cxx/security/key-chain.hpp>
34#include <ndn-cxx/transport/transport.hpp>
Yanbiao Licf0db022016-01-29 00:54:25 -080035#include <ndn-cxx/mgmt/dispatcher.hpp>
Alexander Afanasyev31367922015-02-09 20:51:10 -080036
37namespace nfd {
38namespace rib {
39
Alexander Afanasyevc3ea5a72015-02-12 20:14:16 -080040class RibManager;
41
Alexander Afanasyev31367922015-02-09 20:51:10 -080042/**
43 * \brief Class representing NRD (NFD RIB Manager) instance
44 * This class can be used to initialize all components of NRD
45 */
46class Nrd : noncopyable
47{
48public:
49 class Error : public std::runtime_error
50 {
51 public:
52 explicit
53 Error(const std::string& what)
54 : std::runtime_error(what)
55 {
56 }
57 };
58
59 /**
60 * \brief Create NRD instance using absolute or relative path to \p configFile
61 */
62 Nrd(const std::string& configFile, ndn::KeyChain& keyChain);
63
64 /**
65 * \brief Create NRD instance using a parsed ConfigSection \p config
66 * This version of the constructor is more appropriate for integrated environments,
67 * such as NS-3 or android.
68 * \note When using this version of the constructor, error messages will include
69 * "internal://nfd.conf" when referring to configuration errors.
70 */
71 Nrd(const ConfigSection& config, ndn::KeyChain& keyChain);
72
73 /**
Alexander Afanasyevc3ea5a72015-02-12 20:14:16 -080074 * \brief Destructor
75 */
76 ~Nrd();
77
78 /**
Alexander Afanasyev31367922015-02-09 20:51:10 -080079 * \brief Perform initialization of NFD instance
80 * After initialization, NFD instance can be started by invoking run on globalIoService
81 */
82 void
83 initialize();
84
85private:
86 void
87 initializeLogging();
88
89 /**
90 * \brief Look into the config file and construct appropriate transport to communicate with NFD
91 * If NRD instance was initialized with config file, INFO format is assumed
92 */
93 shared_ptr<ndn::Transport>
94 getLocalNfdTransport();
95
96private:
97 std::string m_configFile;
98 ConfigSection m_configSection;
99
100 ndn::KeyChain& m_keyChain;
101 unique_ptr<ndn::Face> m_face;
Yanbiao Licf0db022016-01-29 00:54:25 -0800102 unique_ptr<ndn::mgmt::Dispatcher> m_dispatcher;
Alexander Afanasyev31367922015-02-09 20:51:10 -0800103 unique_ptr<RibManager> m_ribManager;
104};
105
106} // namespace rib
107} // namespace nfd
108
109#endif // NFD_RIB_NRD_HPP