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-2024, 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 "common/config-file.hpp"
30 
31 #include <ndn-cxx/net/network-address.hpp>
32 #include <ndn-cxx/net/network-interface.hpp>
33 #include <ndn-cxx/net/network-monitor.hpp>
34 
35 #include <map>
36 #include <set>
37 
38 namespace nfd {
39 
40 class FaceTable;
41 
42 namespace face {
43 
44 class NetdevBound;
45 class ProtocolFactory;
46 struct ProtocolFactoryCtorParams;
47 
54 class FaceSystem : noncopyable
55 {
56 public:
57  FaceSystem(FaceTable& faceTable, shared_ptr<ndn::net::NetworkMonitor> netmon);
58 
60 
64  [[nodiscard]] std::set<const ProtocolFactory*>
65  listProtocolFactories() const;
66 
71  getFactoryById(const std::string& id) const;
72 
77  getFactoryByScheme(const std::string& scheme) const;
78 
79  bool
80  hasFactoryForScheme(const std::string& scheme) const;
81 
82  FaceTable&
84  {
85  return m_faceTable;
86  }
87 
90  void
91  setConfigFile(ConfigFile& configFile);
92 
96  {
97  bool wantCongestionMarking = true;
98  };
99 
102  class ConfigContext : noncopyable
103  {
104  public:
106  bool isDryRun;
107  };
108 
111  makePFCtorParams();
112 
113 private:
114  void
115  processConfig(const ConfigSection& configSection, bool isDryRun,
116  const std::string& filename);
117 
121  std::map<std::string, unique_ptr<ProtocolFactory>> m_factories;
122  unique_ptr<NetdevBound> m_netdevBound;
123 
124 private:
129  std::map<std::string, ProtocolFactory*> m_factoryByScheme;
130 
131  FaceTable& m_faceTable;
132  shared_ptr<ndn::net::NetworkMonitor> m_netmon;
133 };
134 
135 } // namespace face
136 
137 using face::FaceSystem;
138 
139 } // namespace nfd
140 
141 #endif // NFD_DAEMON_FACE_FACE_SYSTEM_HPP
Configuration file parsing utility.
Definition: config-file.hpp:66
Container of all faces.
Definition: face-table.hpp:42
Context for processing a config section in ProtocolFactory.
Entry point of NFD's face system.
Definition: face-system.hpp:55
std::set< const ProtocolFactory * > listProtocolFactories() const
Returns all ProtocolFactory objects owned by the face system.
Definition: face-system.cpp:63
ProtocolFactory * getFactoryById(const std::string &id) const
Definition: face-system.cpp:73
FaceSystem(FaceTable &faceTable, shared_ptr< ndn::net::NetworkMonitor > netmon)
Definition: face-system.cpp:40
FaceTable & getFaceTable()
Definition: face-system.hpp:83
bool hasFactoryForScheme(const std::string &scheme) const
Definition: face-system.cpp:87
ProtocolFactory * getFactoryByScheme(const std::string &scheme) const
Definition: face-system.cpp:80
void setConfigFile(ConfigFile &configFile)
Register handler for the face_system section of NFD's configuration file.
Definition: face-system.cpp:93
Provides support for an underlying protocol.
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
-status-http-server
Definition: common.hpp:71
boost::property_tree::ptree ConfigSection
A configuration file section.
Definition: config-file.hpp:41
Configuration options from general section.
Definition: face-system.hpp:96
Parameters to ProtocolFactory constructor.