blob: 4aff010aae1091cc45eee89f4bd8ea2a42961691 [file] [log] [blame]
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shi0cc125c2016-08-25 21:50:04 +00003 * Copyright (c) 2014-2016, Regents of the University of California,
Vince Lehman63ab1bb2015-09-04 17:06:58 -05004 * 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.
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -060010 *
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_MGMT_TABLES_CONFIG_SECTION_HPP
27#define NFD_MGMT_TABLES_CONFIG_SECTION_HPP
28
Junxiao Shi0cc125c2016-08-25 21:50:04 +000029#include "fw/forwarder.hpp"
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -060030#include "core/config-file.hpp"
31
32namespace nfd {
33
Junxiao Shi0cc125c2016-08-25 21:50:04 +000034/** \brief handles 'tables' config section
Vince Lehman63ab1bb2015-09-04 17:06:58 -050035 *
Junxiao Shi0cc125c2016-08-25 21:50:04 +000036 * This class recognizes a config section that looks like
37 * \code{.unparsed}
38 * tables
39 * {
40 * cs_max_packets 65536
41 *
42 * strategy_choice
43 * {
44 * / /localhost/nfd/strategy/best-route
45 * /localhost /localhost/nfd/strategy/multicast
46 * /localhost/nfd /localhost/nfd/strategy/best-route
47 * /ndn/broadcast /localhost/nfd/strategy/multicast
48 * }
49 *
50 * network_region
51 * {
52 * /example/region1
53 * /example/region2
54 * }
55 * }
56 * \endcode
Vince Lehman63ab1bb2015-09-04 17:06:58 -050057 */
Junxiao Shi0cc125c2016-08-25 21:50:04 +000058class TablesConfigSection : noncopyable
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -060059{
60public:
Junxiao Shi0cc125c2016-08-25 21:50:04 +000061 explicit
62 TablesConfigSection(Forwarder& forwarder);
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -060063
64 void
65 setConfigFile(ConfigFile& configFile);
66
Junxiao Shi0cc125c2016-08-25 21:50:04 +000067 /** \brief apply default configuration, if tables section was omitted in configuration file
68 */
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -060069 void
Junxiao Shi0cc125c2016-08-25 21:50:04 +000070 ensureConfigured();
Steve DiBenedetto9bcc88f2014-07-08 09:52:13 -060071
72private:
Junxiao Shi0cc125c2016-08-25 21:50:04 +000073 void
74 processConfig(const ConfigSection& section, bool isDryRun);
Steve DiBenedetto9bcc88f2014-07-08 09:52:13 -060075
76 void
Junxiao Shi0cc125c2016-08-25 21:50:04 +000077 processStrategyChoiceSection(const ConfigSection& section, bool isDryRun);
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -060078
Steve DiBenedettoc0640f52014-11-03 15:55:43 -070079 void
Junxiao Shi0cc125c2016-08-25 21:50:04 +000080 processNetworkRegionSection(const ConfigSection& section, bool isDryRun);
Vince Lehman63ab1bb2015-09-04 17:06:58 -050081
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -060082private:
Steve DiBenedetto9bcc88f2014-07-08 09:52:13 -060083private:
Steve DiBenedetto9bcc88f2014-07-08 09:52:13 -060084 static const size_t DEFAULT_CS_MAX_PACKETS;
Junxiao Shi0cc125c2016-08-25 21:50:04 +000085
86 Forwarder& m_forwarder;
87
88 bool m_isConfigured;
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -060089};
90
91} // namespace nfd
92
93#endif // NFD_MGMT_TABLES_CONFIG_SECTION_HPP