blob: 22b2a1402eb2ec9dbc32813ce197f5fbc1136b2d [file] [log] [blame]
Junxiao Shib8590312016-12-29 21:22:25 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2016, 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 "core/config-file.hpp"
30#include "protocol-factory.hpp"
31
32namespace nfd {
33
34class FaceTable;
35class NetworkInterfaceInfo;
36
37namespace face {
38
39/** \brief entry point of the face system
40 *
41 * FaceSystem class is the entry point of NFD's face system.
42 * It owns ProtocolFactory objects that are created from face_system section of NFD configuration file.
43 */
44class FaceSystem : noncopyable
45{
46public:
47 explicit
48 FaceSystem(FaceTable& faceTable);
49
50 /** \return ProtocolFactory objects owned by the FaceSystem
51 */
52 std::set<const ProtocolFactory*>
53 listProtocolFactories() const;
54
55 /** \return ProtocolFactory for specified protocol scheme, or nullptr if not found
56 */
57 ProtocolFactory*
58 getProtocolFactory(const std::string& scheme);
59
60 /** \brief register handler for face_system section of NFD configuration file
61 */
62 void
63 setConfigFile(ConfigFile& configFile);
64
65private:
66 void
67 processConfig(const ConfigSection& configSection, bool isDryRun,
68 const std::string& filename);
69
70 void
71 processSectionUnix(const ConfigSection& configSection, bool isDryRun);
72
73 void
74 processSectionTcp(const ConfigSection& configSection, bool isDryRun);
75
76 void
77 processSectionUdp(const ConfigSection& configSection, bool isDryRun,
78 const std::vector<NetworkInterfaceInfo>& nicList);
79
80 void
81 processSectionEther(const ConfigSection& configSection, bool isDryRun,
82 const std::vector<NetworkInterfaceInfo>& nicList);
83
84 void
85 processSectionWebSocket(const ConfigSection& configSection, bool isDryRun);
86
87PUBLIC_WITH_TESTS_ELSE_PRIVATE:
88 /** \brief scheme => protocol factory
89 *
90 * The same protocol factory may be available under multiple schemes.
91 */
92 std::map<std::string, shared_ptr<ProtocolFactory>> m_factories;
93
94 FaceTable& m_faceTable;
95};
96
97} // namespace face
98
99using face::FaceSystem;
100
101} // namespace nfd
102
103#endif // NFD_DAEMON_FACE_FACE_SYSTEM_HPP