blob: fda116bf9ec6f4ee1c46b8bce3f7c4b8c6ad6a2c [file] [log] [blame]
Alexander Afanasyev31367922015-02-09 20:51:10 -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_RIB_NRD_HPP
27#define NFD_RIB_NRD_HPP
28
29#include "common.hpp"
30#include "core/config-file.hpp"
31#include "rib-manager.hpp"
32
33#include <ndn-cxx/face.hpp>
34#include <ndn-cxx/security/key-chain.hpp>
35#include <ndn-cxx/transport/transport.hpp>
36
37namespace nfd {
38namespace rib {
39
40/**
41 * \brief Class representing NRD (NFD RIB Manager) instance
42 * This class can be used to initialize all components of NRD
43 */
44class Nrd : noncopyable
45{
46public:
47 class Error : public std::runtime_error
48 {
49 public:
50 explicit
51 Error(const std::string& what)
52 : std::runtime_error(what)
53 {
54 }
55 };
56
57 /**
58 * \brief Create NRD instance using absolute or relative path to \p configFile
59 */
60 Nrd(const std::string& configFile, ndn::KeyChain& keyChain);
61
62 /**
63 * \brief Create NRD instance using a parsed ConfigSection \p config
64 * This version of the constructor is more appropriate for integrated environments,
65 * such as NS-3 or android.
66 * \note When using this version of the constructor, error messages will include
67 * "internal://nfd.conf" when referring to configuration errors.
68 */
69 Nrd(const ConfigSection& config, ndn::KeyChain& keyChain);
70
71 /**
72 * \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
78private:
79 void
80 initializeLogging();
81
82 /**
83 * \brief Look into the config file and construct appropriate transport to communicate with NFD
84 * If NRD instance was initialized with config file, INFO format is assumed
85 */
86 shared_ptr<ndn::Transport>
87 getLocalNfdTransport();
88
89private:
90 std::string m_configFile;
91 ConfigSection m_configSection;
92
93 ndn::KeyChain& m_keyChain;
94 unique_ptr<ndn::Face> m_face;
95 unique_ptr<RibManager> m_ribManager;
96};
97
98} // namespace rib
99} // namespace nfd
100
101#endif // NFD_RIB_NRD_HPP