blob: 0efa02db51f0f36e8afe3a0f267e37d77625d756 [file] [log] [blame]
Steve DiBenedetto3a4f83d2014-06-02 14:58:54 -06001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014, 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#include "tables-config-section.hpp"
27
28#include "common.hpp"
29#include "core/logger.hpp"
30#include "core/config-file.hpp"
31
32namespace nfd {
33
34NFD_LOG_INIT("TablesConfigSection");
35
36TablesConfigSection::TablesConfigSection(Cs& cs,
37 Pit& pit,
38 Fib& fib,
39 StrategyChoice& strategyChoice,
40 Measurements& measurements)
41 : m_cs(cs)
42 // , m_pit(pit)
43 // , m_fib(fib)
44 // , m_strategyChoice(strategyChoice)
45 // , m_measurements(measurements)
46{
47
48}
49
50void
51TablesConfigSection::onConfig(const ConfigSection& configSection,
52 bool isDryRun,
53 const std::string& filename)
54{
55 // tables
56 // {
57 // cs_max_packets 65536
58 // }
59
60 boost::optional<const ConfigSection&> csMaxPacketsNode =
61 configSection.get_child_optional("cs_max_packets");
62
63 if (csMaxPacketsNode)
64 {
65 boost::optional<size_t> valCsMaxPackets =
66 configSection.get_optional<size_t>("cs_max_packets");
67
68 if (!valCsMaxPackets)
69 {
70 throw ConfigFile::Error("Invalid value for option \"cs_max_packets\""
71 " in \"tables\" section");
72 }
73 else if (!isDryRun)
74 {
75 m_cs.setLimit(*valCsMaxPackets);
76 }
77 }
78}
79
80void
81TablesConfigSection::setConfigFile(ConfigFile& configFile)
82{
83 configFile.addSectionHandler("tables",
84 bind(&TablesConfigSection::onConfig, this, _1, _2, _3));
85}
86
87} // namespace nfd