blob: e861422c296fe0f23190dcbd25f97918e3c26479 [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"
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>
35
36namespace nfd {
37namespace rib {
38
Alexander Afanasyevc3ea5a72015-02-12 20:14:16 -080039class RibManager;
40
Alexander Afanasyev31367922015-02-09 20:51:10 -080041/**
42 * \brief Class representing NRD (NFD RIB Manager) instance
43 * This class can be used to initialize all components of NRD
44 */
45class Nrd : noncopyable
46{
47public:
48 class Error : public std::runtime_error
49 {
50 public:
51 explicit
52 Error(const std::string& what)
53 : std::runtime_error(what)
54 {
55 }
56 };
57
58 /**
59 * \brief Create NRD instance using absolute or relative path to \p configFile
60 */
61 Nrd(const std::string& configFile, ndn::KeyChain& keyChain);
62
63 /**
64 * \brief Create NRD instance using a parsed ConfigSection \p config
65 * This version of the constructor is more appropriate for integrated environments,
66 * such as NS-3 or android.
67 * \note When using this version of the constructor, error messages will include
68 * "internal://nfd.conf" when referring to configuration errors.
69 */
70 Nrd(const ConfigSection& config, ndn::KeyChain& keyChain);
71
72 /**
Alexander Afanasyevc3ea5a72015-02-12 20:14:16 -080073 * \brief Destructor
74 */
75 ~Nrd();
76
77 /**
Alexander Afanasyev31367922015-02-09 20:51:10 -080078 * \brief Perform initialization of NFD instance
79 * After initialization, NFD instance can be started by invoking run on globalIoService
80 */
81 void
82 initialize();
83
84private:
85 void
86 initializeLogging();
87
88 /**
89 * \brief Look into the config file and construct appropriate transport to communicate with NFD
90 * If NRD instance was initialized with config file, INFO format is assumed
91 */
92 shared_ptr<ndn::Transport>
93 getLocalNfdTransport();
94
95private:
96 std::string m_configFile;
97 ConfigSection m_configSection;
98
99 ndn::KeyChain& m_keyChain;
100 unique_ptr<ndn::Face> m_face;
101 unique_ptr<RibManager> m_ribManager;
102};
103
104} // namespace rib
105} // namespace nfd
106
107#endif // NFD_RIB_NRD_HPP