face-system.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2022, 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_FACE_FACE_SYSTEM_HPP
27 #define NFD_DAEMON_FACE_FACE_SYSTEM_HPP
28 
29 #include "network-predicate.hpp"
30 #include "common/config-file.hpp"
31 
32 #include <ndn-cxx/net/network-address.hpp>
33 #include <ndn-cxx/net/network-interface.hpp>
34 #include <ndn-cxx/net/network-monitor.hpp>
35 
36 namespace nfd {
37 
38 class FaceTable;
39 
40 namespace face {
41 
42 class NetdevBound;
43 class ProtocolFactory;
44 struct ProtocolFactoryCtorParams;
45 
52 class FaceSystem : noncopyable
53 {
54 public:
55  FaceSystem(FaceTable& faceTable, shared_ptr<ndn::net::NetworkMonitor> netmon);
56 
58 
62  [[nodiscard]] std::set<const ProtocolFactory*>
63  listProtocolFactories() const;
64 
68  getFactoryById(const std::string& id);
69 
73  getFactoryByScheme(const std::string& scheme);
74 
75  bool
76  hasFactoryForScheme(const std::string& scheme) const;
77 
78  FaceTable&
80  {
81  return m_faceTable;
82  }
83 
86  void
87  setConfigFile(ConfigFile& configFile);
88 
92  {
93  bool wantCongestionMarking = true;
94  };
95 
98  class ConfigContext : noncopyable
99  {
100  public:
102  bool isDryRun;
103  };
104 
107  makePFCtorParams();
108 
109 private:
110  void
111  processConfig(const ConfigSection& configSection, bool isDryRun,
112  const std::string& filename);
113 
117  std::map<std::string, unique_ptr<ProtocolFactory>> m_factories;
118  unique_ptr<NetdevBound> m_netdevBound;
119 
120 private:
125  std::map<std::string, ProtocolFactory*> m_factoryByScheme;
126 
127  FaceTable& m_faceTable;
128  shared_ptr<ndn::net::NetworkMonitor> m_netmon;
129 };
130 
131 } // namespace face
132 
133 using face::FaceSystem;
134 
135 } // namespace nfd
136 
137 #endif // NFD_DAEMON_FACE_FACE_SYSTEM_HPP
Configuration file parsing utility.
Definition: config-file.hpp:63
Container of all faces.
Definition: face-table.hpp:40
Context for processing a config section in ProtocolFactory.
Definition: face-system.hpp:99
Entry point of NFD's face system.
Definition: face-system.hpp:53
std::set< const ProtocolFactory * > listProtocolFactories() const
Returns all ProtocolFactory objects owned by the face system.
Definition: face-system.cpp:64
FaceSystem(FaceTable &faceTable, shared_ptr< ndn::net::NetworkMonitor > netmon)
Definition: face-system.cpp:41
FaceTable & getFaceTable()
Definition: face-system.hpp:79
bool hasFactoryForScheme(const std::string &scheme) const
Definition: face-system.cpp:88
void setConfigFile(ConfigFile &configFile)
Register handler for the face_system section of NFD's configuration file.
Definition: face-system.cpp:94
ProtocolFactory * getFactoryById(const std::string &id)
Definition: face-system.cpp:74
ProtocolFactory * getFactoryByScheme(const std::string &scheme)
Definition: face-system.cpp:81
Provides support for an underlying protocol.
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
Definition: common.hpp:77
boost::property_tree::ptree ConfigSection
A configuration file section.
Definition: config-file.hpp:38
Configuration options from general section.
Definition: face-system.hpp:92
Parameters to ProtocolFactory constructor.