blob: c86155fdc9871b534c02e3e58618436b76c5bbef [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/*
Junxiao Shi68b53852018-07-25 13:56:38 -06003 * Copyright (c) 2013-2018 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:
Junxiao Shi68b53852018-07-25 13:56:38 -060078 using tlv::Error::Error;
Junxiao Shi7357ef22016-09-07 02:39:37 +000079 };
80
81#ifdef DOXYGEN
82 /**
83 * \brief parses a result from reassembled payload
84 * \param payload reassembled payload
85 * \throw tlv::Error cannot parse payload
86 */
87 ResultType
88 parseResult(ConstBufferPtr payload) const;
89#endif
90
91protected:
92 /**
93 * \brief constructs a StatusDataset instance with given sub-prefix
94 * \param datasetName dataset name after top-level prefix, such as faces/list
95 */
96 explicit
97 StatusDataset(const PartialName& datasetName);
98
99private:
100 /**
101 * \brief appends parameters to the dataset name prefix
102 * \param[in,out] the dataset name prefix onto which parameter components can be appended
103 */
104 virtual void
105 addParameters(Name& name) const;
106
107private:
108 PartialName m_datasetName;
109};
110
Junxiao Shi7357ef22016-09-07 02:39:37 +0000111/**
112 * \ingroup management
113 * \brief represents a status/general dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800114 * \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000115 */
116class ForwarderGeneralStatusDataset : public StatusDataset
117{
118public:
119 ForwarderGeneralStatusDataset();
120
Junxiao Shi7f012472017-12-07 20:40:47 +0000121 using ResultType = ForwarderStatus;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000122
123 ResultType
124 parseResult(ConstBufferPtr payload) const;
125};
126
Junxiao Shi7357ef22016-09-07 02:39:37 +0000127/**
128 * \ingroup management
129 * \brief provides common functionality among FaceDataset and FaceQueryDataset
130 */
131class FaceDatasetBase : public StatusDataset
132{
133public:
Junxiao Shi7f012472017-12-07 20:40:47 +0000134 using ResultType = std::vector<FaceStatus>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000135
136 ResultType
137 parseResult(ConstBufferPtr payload) const;
138
139protected:
140 explicit
141 FaceDatasetBase(const PartialName& datasetName);
142};
143
Junxiao Shi7357ef22016-09-07 02:39:37 +0000144/**
145 * \ingroup management
146 * \brief represents a faces/list dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800147 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000148 */
149class FaceDataset : public FaceDatasetBase
150{
151public:
152 FaceDataset();
153};
154
Junxiao Shi7357ef22016-09-07 02:39:37 +0000155/**
156 * \ingroup management
157 * \brief represents a faces/query dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800158 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Query-Operation
Junxiao Shi7357ef22016-09-07 02:39:37 +0000159 */
160class FaceQueryDataset : public FaceDatasetBase
161{
162public:
Junxiao Shi7f012472017-12-07 20:40:47 +0000163 using ParamType = FaceQueryFilter;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000164
165 explicit
166 FaceQueryDataset(const FaceQueryFilter& filter);
167
168private:
Davide Pesavento57c07df2016-12-11 18:41:45 -0500169 void
Junxiao Shi7357ef22016-09-07 02:39:37 +0000170 addParameters(Name& name) const override;
171
172private:
173 FaceQueryFilter m_filter;
174};
175
Junxiao Shi7357ef22016-09-07 02:39:37 +0000176/**
177 * \ingroup management
178 * \brief represents a faces/channels dataset
179 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset
180 */
181class ChannelDataset : public StatusDataset
182{
183public:
184 ChannelDataset();
185
Junxiao Shi7f012472017-12-07 20:40:47 +0000186 using ResultType = std::vector<ChannelStatus>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000187
188 ResultType
189 parseResult(ConstBufferPtr payload) const;
190};
191
Junxiao Shi7357ef22016-09-07 02:39:37 +0000192/**
193 * \ingroup management
194 * \brief represents a fib/list dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800195 * \sa https://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000196 */
197class FibDataset : public StatusDataset
198{
199public:
200 FibDataset();
201
Junxiao Shi7f012472017-12-07 20:40:47 +0000202 using ResultType = std::vector<FibEntry>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000203
204 ResultType
205 parseResult(ConstBufferPtr payload) const;
206};
207
Junxiao Shi7f012472017-12-07 20:40:47 +0000208/**
209 * \ingroup management
210 * \brief represents a cs/info dataset
211 * \sa https://redmine.named-data.net/projects/nfd/wiki/CsMgmt#CS-Information-Dataset
212 */
213class CsInfoDataset : public StatusDataset
214{
215public:
216 CsInfoDataset();
217
218 using ResultType = CsInfo;
219
220 ResultType
221 parseResult(ConstBufferPtr payload) const;
222};
Junxiao Shi7357ef22016-09-07 02:39:37 +0000223
224/**
225 * \ingroup management
226 * \brief represents a strategy-choice/list dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800227 * \sa https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy-Choice-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000228 */
229class StrategyChoiceDataset : public StatusDataset
230{
231public:
232 StrategyChoiceDataset();
233
Junxiao Shi7f012472017-12-07 20:40:47 +0000234 using ResultType = std::vector<StrategyChoice>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000235
236 ResultType
237 parseResult(ConstBufferPtr payload) const;
238};
239
Junxiao Shi7357ef22016-09-07 02:39:37 +0000240/**
241 * \ingroup management
242 * \brief represents a rib/list dataset
Alexander Afanasyeve6835fe2017-01-19 20:05:01 -0800243 * \sa https://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +0000244 */
245class RibDataset : public StatusDataset
246{
247public:
248 RibDataset();
249
Junxiao Shi7f012472017-12-07 20:40:47 +0000250 using ResultType = std::vector<RibEntry>;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000251
252 ResultType
253 parseResult(ConstBufferPtr payload) const;
254};
255
Junxiao Shi7357ef22016-09-07 02:39:37 +0000256} // namespace nfd
257} // namespace ndn
258
259#endif // NDN_MGMT_NFD_STATUS_DATASET_HPP