Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Chavoosh Ghasemi | 32e7609 | 2018-09-10 14:51:33 -0700 | [diff] [blame] | 2 | /* |
Davide Pesavento | 2cae8ca | 2019-04-18 20:48:05 -0400 | [diff] [blame^] | 3 | * Copyright (c) 2014-2019, Regents of the University of California, |
Vince Lehman | 63ab1bb | 2015-09-04 17:06:58 -0500 | [diff] [blame] | 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. |
Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 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 | |
Davide Pesavento | 2cae8ca | 2019-04-18 20:48:05 -0400 | [diff] [blame^] | 26 | #ifndef NFD_DAEMON_MGMT_TABLES_CONFIG_SECTION_HPP |
| 27 | #define NFD_DAEMON_MGMT_TABLES_CONFIG_SECTION_HPP |
Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 28 | |
Davide Pesavento | 2cae8ca | 2019-04-18 20:48:05 -0400 | [diff] [blame^] | 29 | #include "common/config-file.hpp" |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 30 | #include "fw/forwarder.hpp" |
Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 31 | |
| 32 | namespace nfd { |
| 33 | |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 34 | /** \brief handles 'tables' config section |
Vince Lehman | 63ab1bb | 2015-09-04 17:06:58 -0500 | [diff] [blame] | 35 | * |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 36 | * This class recognizes a config section that looks like |
| 37 | * \code{.unparsed} |
| 38 | * tables |
| 39 | * { |
| 40 | * cs_max_packets 65536 |
Chavoosh Ghasemi | 32e7609 | 2018-09-10 14:51:33 -0700 | [diff] [blame] | 41 | * cs_policy lru |
Junxiao Shi | 9685cc5 | 2016-08-29 12:47:05 +0000 | [diff] [blame] | 42 | * cs_unsolicited_policy drop-all |
| 43 | * |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 44 | * strategy_choice |
| 45 | * { |
| 46 | * / /localhost/nfd/strategy/best-route |
| 47 | * /localhost /localhost/nfd/strategy/multicast |
| 48 | * /localhost/nfd /localhost/nfd/strategy/best-route |
| 49 | * /ndn/broadcast /localhost/nfd/strategy/multicast |
| 50 | * } |
| 51 | * |
| 52 | * network_region |
| 53 | * { |
| 54 | * /example/region1 |
| 55 | * /example/region2 |
| 56 | * } |
| 57 | * } |
| 58 | * \endcode |
Junxiao Shi | 9685cc5 | 2016-08-29 12:47:05 +0000 | [diff] [blame] | 59 | * |
| 60 | * During a configuration reload, |
Junxiao Shi | b4a5acd | 2016-12-07 19:59:18 +0000 | [diff] [blame] | 61 | * \li cs_max_packets, cs_policy, and cs_unsolicited_policy are applied; |
Junxiao Shi | 9685cc5 | 2016-08-29 12:47:05 +0000 | [diff] [blame] | 62 | * defaults are used if an option is omitted. |
| 63 | * \li strategy_choice entries are inserted, but old entries are not deleted. |
| 64 | * \li network_region is applied; it's kept unchanged if the section is omitted. |
| 65 | * |
| 66 | * It's necessary to call \p ensureConfigured() after initial configuration and |
| 67 | * configuration reload, so that the correct defaults are applied in case |
| 68 | * tables section is omitted. |
Vince Lehman | 63ab1bb | 2015-09-04 17:06:58 -0500 | [diff] [blame] | 69 | */ |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 70 | class TablesConfigSection : noncopyable |
Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 71 | { |
| 72 | public: |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 73 | explicit |
| 74 | TablesConfigSection(Forwarder& forwarder); |
Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 75 | |
| 76 | void |
| 77 | setConfigFile(ConfigFile& configFile); |
| 78 | |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 79 | /** \brief apply default configuration, if tables section was omitted in configuration file |
| 80 | */ |
Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 81 | void |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 82 | ensureConfigured(); |
Steve DiBenedetto | 9bcc88f | 2014-07-08 09:52:13 -0600 | [diff] [blame] | 83 | |
| 84 | private: |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 85 | void |
| 86 | processConfig(const ConfigSection& section, bool isDryRun); |
Steve DiBenedetto | 9bcc88f | 2014-07-08 09:52:13 -0600 | [diff] [blame] | 87 | |
| 88 | void |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 89 | processStrategyChoiceSection(const ConfigSection& section, bool isDryRun); |
Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 90 | |
Steve DiBenedetto | c0640f5 | 2014-11-03 15:55:43 -0700 | [diff] [blame] | 91 | void |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 92 | processNetworkRegionSection(const ConfigSection& section, bool isDryRun); |
Vince Lehman | 63ab1bb | 2015-09-04 17:06:58 -0500 | [diff] [blame] | 93 | |
Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 94 | private: |
Steve DiBenedetto | 9bcc88f | 2014-07-08 09:52:13 -0600 | [diff] [blame] | 95 | static const size_t DEFAULT_CS_MAX_PACKETS; |
Junxiao Shi | 0cc125c | 2016-08-25 21:50:04 +0000 | [diff] [blame] | 96 | |
| 97 | Forwarder& m_forwarder; |
| 98 | |
| 99 | bool m_isConfigured; |
Steve DiBenedetto | 3a4f83d | 2014-06-02 14:58:54 -0600 | [diff] [blame] | 100 | }; |
| 101 | |
| 102 | } // namespace nfd |
| 103 | |
Davide Pesavento | 2cae8ca | 2019-04-18 20:48:05 -0400 | [diff] [blame^] | 104 | #endif // NFD_DAEMON_MGMT_TABLES_CONFIG_SECTION_HPP |