blob: f7f7917ddc5f3570add12e70de16319a26b2c13a [file] [log] [blame]
Junxiao Shi7357ef22016-09-07 02:39:37 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi7f012472017-12-07 20:40:47 +00002/*
Davide Pesavento7f20d6e2017-01-16 14:43:58 -05003 * Copyright (c) 2013-2017 Regents of the University of California.
Junxiao Shi7357ef22016-09-07 02:39:37 +00004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 */
21
22#ifndef NDN_MGMT_NFD_STATUS_DATASET_HPP
23#define NDN_MGMT_NFD_STATUS_DATASET_HPP
24
25#include "../../name.hpp"
26#include "forwarder-status.hpp"
27#include "face-status.hpp"
28#include "face-query-filter.hpp"
29#include "channel-status.hpp"
30#include "fib-entry.hpp"
Junxiao Shi7f012472017-12-07 20:40:47 +000031#include "cs-info.hpp"
Junxiao Shi7357ef22016-09-07 02:39:37 +000032#include "strategy-choice.hpp"
33#include "rib-entry.hpp"
34
35namespace ndn {
36namespace nfd {
37
38/**
39 * \ingroup management
40 * \brief base class of NFD StatusDataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -080041 * \sa https://redmine.named-data.net/projects/nfd/wiki/StatusDataset
Junxiao Shi7357ef22016-09-07 02:39:37 +000042 */
43class StatusDataset : noncopyable
44{
45public:
Davide Pesavento7f20d6e2017-01-16 14:43:58 -050046 virtual
47 ~StatusDataset();
48
Junxiao Shi7357ef22016-09-07 02:39:37 +000049#ifdef DOXYGEN
50 /**
51 * \brief if defined, specifies constructor argument type;
52 * otherwise, constructor has no argument
53 */
Junxiao Shi7f012472017-12-07 20:40:47 +000054 using ParamType = int;
Junxiao Shi7357ef22016-09-07 02:39:37 +000055#endif
56
57 /**
58 * \brief constructs a name prefix for the dataset
59 * \param prefix top-level prefix, such as ndn:/localhost/nfd
60 * \return name prefix without version and segment components
61 */
62 Name
63 getDatasetPrefix(const Name& prefix) const;
64
65#ifdef DOXYGEN
66 /**
67 * \brief provides the result type, usually a vector
68 */
Junxiao Shi7f012472017-12-07 20:40:47 +000069 using ResultType = std::vector<int>;
Junxiao Shi7357ef22016-09-07 02:39:37 +000070#endif
71
72 /**
73 * \brief indicates reassembled payload cannot be parsed as ResultType
74 */
75 class ParseResultError : public tlv::Error
76 {
77 public:
78 explicit
79 ParseResultError(const std::string& what)
80 : tlv::Error(what)
81 {
82 }
83 };
84
85#ifdef DOXYGEN
86 /**
87 * \brief parses a result from reassembled payload
88 * \param payload reassembled payload
89 * \throw tlv::Error cannot parse payload
90 */
91 ResultType
92 parseResult(ConstBufferPtr payload) const;
93#endif
94
95protected:
96 /**
97 * \brief constructs a StatusDataset instance with given sub-prefix
98 * \param datasetName dataset name after top-level prefix, such as faces/list
99 */
100 explicit
101 StatusDataset(const PartialName& datasetName);
102
103private:
104 /**
105 * \brief appends parameters to the dataset name prefix
106 * \param[in,out] the dataset name prefix onto which parameter components can be appended
107 */
108 virtual void
109 addParameters(Name& name) const;
110
111private:
112 PartialName m_datasetName;
113};
114
Junxiao Shi7357ef22016-09-07 02:39:37 +0000115/**
116 * \ingroup management
117 * \brief represents a status/general dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800118 * \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000119 */
120class ForwarderGeneralStatusDataset : public StatusDataset
121{
122public:
123 ForwarderGeneralStatusDataset();
124
Junxiao Shi7f012472017-12-07 20:40:47 +0000125 using ResultType = ForwarderStatus;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000126
127 ResultType
128 parseResult(ConstBufferPtr payload) const;
129};
130
Junxiao Shi7357ef22016-09-07 02:39:37 +0000131/**
132 * \ingroup management
133 * \brief provides common functionality among FaceDataset and FaceQueryDataset
134 */
135class FaceDatasetBase : public StatusDataset
136{
137public:
Junxiao Shi7f012472017-12-07 20:40:47 +0000138 using ResultType = std::vector<FaceStatus>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000139
140 ResultType
141 parseResult(ConstBufferPtr payload) const;
142
143protected:
144 explicit
145 FaceDatasetBase(const PartialName& datasetName);
146};
147
Junxiao Shi7357ef22016-09-07 02:39:37 +0000148/**
149 * \ingroup management
150 * \brief represents a faces/list dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800151 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000152 */
153class FaceDataset : public FaceDatasetBase
154{
155public:
156 FaceDataset();
157};
158
Junxiao Shi7357ef22016-09-07 02:39:37 +0000159/**
160 * \ingroup management
161 * \brief represents a faces/query dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800162 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Query-Operation
Junxiao Shi7357ef22016-09-07 02:39:37 +0000163 */
164class FaceQueryDataset : public FaceDatasetBase
165{
166public:
Junxiao Shi7f012472017-12-07 20:40:47 +0000167 using ParamType = FaceQueryFilter;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000168
169 explicit
170 FaceQueryDataset(const FaceQueryFilter& filter);
171
172private:
Davide Pesavento57c07df2016-12-11 18:41:45 -0500173 void
Junxiao Shi7357ef22016-09-07 02:39:37 +0000174 addParameters(Name& name) const override;
175
176private:
177 FaceQueryFilter m_filter;
178};
179
Junxiao Shi7357ef22016-09-07 02:39:37 +0000180/**
181 * \ingroup management
182 * \brief represents a faces/channels dataset
183 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset
184 */
185class ChannelDataset : public StatusDataset
186{
187public:
188 ChannelDataset();
189
Junxiao Shi7f012472017-12-07 20:40:47 +0000190 using ResultType = std::vector<ChannelStatus>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000191
192 ResultType
193 parseResult(ConstBufferPtr payload) const;
194};
195
Junxiao Shi7357ef22016-09-07 02:39:37 +0000196/**
197 * \ingroup management
198 * \brief represents a fib/list dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800199 * \sa https://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000200 */
201class FibDataset : public StatusDataset
202{
203public:
204 FibDataset();
205
Junxiao Shi7f012472017-12-07 20:40:47 +0000206 using ResultType = std::vector<FibEntry>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000207
208 ResultType
209 parseResult(ConstBufferPtr payload) const;
210};
211
Junxiao Shi7f012472017-12-07 20:40:47 +0000212/**
213 * \ingroup management
214 * \brief represents a cs/info dataset
215 * \sa https://redmine.named-data.net/projects/nfd/wiki/CsMgmt#CS-Information-Dataset
216 */
217class CsInfoDataset : public StatusDataset
218{
219public:
220 CsInfoDataset();
221
222 using ResultType = CsInfo;
223
224 ResultType
225 parseResult(ConstBufferPtr payload) const;
226};
Junxiao Shi7357ef22016-09-07 02:39:37 +0000227
228/**
229 * \ingroup management
230 * \brief represents a strategy-choice/list dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800231 * \sa https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy-Choice-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000232 */
233class StrategyChoiceDataset : public StatusDataset
234{
235public:
236 StrategyChoiceDataset();
237
Junxiao Shi7f012472017-12-07 20:40:47 +0000238 using ResultType = std::vector<StrategyChoice>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000239
240 ResultType
241 parseResult(ConstBufferPtr payload) const;
242};
243
Junxiao Shi7357ef22016-09-07 02:39:37 +0000244/**
245 * \ingroup management
246 * \brief represents a rib/list dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800247 * \sa https://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000248 */
249class RibDataset : public StatusDataset
250{
251public:
252 RibDataset();
253
Junxiao Shi7f012472017-12-07 20:40:47 +0000254 using ResultType = std::vector<RibEntry>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000255
256 ResultType
257 parseResult(ConstBufferPtr payload) const;
258};
259
Junxiao Shi7357ef22016-09-07 02:39:37 +0000260} // namespace nfd
261} // namespace ndn
262
263#endif // NDN_MGMT_NFD_STATUS_DATASET_HPP