NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
status-dataset.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2022 Regents of the University of California.
4  *
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 
24 
25 namespace ndn {
26 namespace nfd {
27 
29  : m_datasetName(datasetName)
30 {
31 }
32 
34 
35 Name
37 {
38  Name name;
39  name.append(prefix).append(m_datasetName);
40  this->addParameters(name);
41  return name;
42 }
43 
44 void
45 StatusDataset::addParameters(Name&) const
46 {
47 }
48 
56 template<typename T>
57 static std::vector<T>
59 {
60  BOOST_CONCEPT_ASSERT((WireDecodable<T>));
61 
62  std::vector<T> result;
63 
64  size_t offset = 0;
65  while (offset < payload->size()) {
66  bool isOk = false;
67  Block block;
68  std::tie(isOk, block) = Block::fromBuffer(payload, offset);
69  if (!isOk) {
70  NDN_THROW(StatusDataset::ParseResultError("cannot decode Block"));
71  }
72 
73  offset += block.size();
74  result.emplace_back(block);
75  }
76 
77  return result;
78 }
79 
81  : StatusDataset("status/general")
82 {
83 }
84 
87 {
88  return ForwarderStatus(Block(tlv::Content, std::move(payload)));
89 }
90 
92  : StatusDataset(datasetName)
93 {
94 }
95 
98 {
99  return parseDatasetVector<FaceStatus>(payload);
100 }
101 
103  : FaceDatasetBase("faces/list")
104 {
105 }
106 
108  : FaceDatasetBase("faces/query")
109  , m_filter(filter)
110 {
111 }
112 
113 void
114 FaceQueryDataset::addParameters(Name& name) const
115 {
116  name.append(m_filter.wireEncode());
117 }
118 
120  : StatusDataset("faces/channels")
121 {
122 }
123 
126 {
127  return parseDatasetVector<ChannelStatus>(payload);
128 }
129 
131  : StatusDataset("fib/list")
132 {
133 }
134 
137 {
138  return parseDatasetVector<FibEntry>(payload);
139 }
140 
142  : StatusDataset("cs/info")
143 {
144 }
145 
148 {
149  return CsInfo(Block(payload));
150 }
151 
153  : StatusDataset("strategy-choice/list")
154 {
155 }
156 
159 {
160  return parseDatasetVector<StrategyChoice>(payload);
161 }
162 
164  : StatusDataset("rib/list")
165 {
166 }
167 
170 {
171  return parseDatasetVector<RibEntry>(payload);
172 }
173 
174 } // namespace nfd
175 } // namespace ndn
ResultType parseResult(ConstBufferPtr payload) const
provides common functionality among FaceDataset and FaceQueryDataset
indicates reassembled payload cannot be parsed as ResultType
static NDN_CXX_NODISCARD std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset=0)
Try to parse Block from a wire buffer.
Definition: block.cpp:162
represents NFD General Status dataset
Copyright (c) 2011-2015 Regents of the University of California.
FaceDatasetBase(const PartialName &datasetName)
Represents a TLV element of the NDN packet format.
Definition: block.hpp:44
std::vector< ChannelStatus > ResultType
std::vector< StrategyChoice > ResultType
ResultType parseResult(ConstBufferPtr payload) const
base class of NFD StatusDataset
Name getDatasetPrefix(const Name &prefix) const
constructs a name prefix for the dataset
Name & append(const Component &component)
Append a component.
Definition: name.hpp:275
#define NDN_THROW(e)
Definition: exception.hpp:61
ResultType parseResult(ConstBufferPtr payload) const
size_t size() const
Return the size of the encoded wire, i.e., of the whole TLV.
Definition: block.cpp:294
std::vector< FibEntry > ResultType
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:39
std::vector< RibEntry > ResultType
std::vector< FaceStatus > ResultType
StatusDataset(const PartialName &datasetName)
constructs a StatusDataset instance with given sub-prefix
static std::vector< T > parseDatasetVector(const ConstBufferPtr &payload)
parses elements into a vector of T
ResultType parseResult(ConstBufferPtr payload) const
Represents an absolute name.
Definition: name.hpp:41
represents the CS Information dataset
Definition: cs-info.hpp:37
ResultType parseResult(ConstBufferPtr payload) const
represents Face Query Filter
ResultType parseResult(ConstBufferPtr payload) const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend FaceQueryFilter to the encoder
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span-lite.hpp:1535
FaceQueryDataset(const FaceQueryFilter &filter)
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
Definition: concepts.hpp:80
ResultType parseResult(ConstBufferPtr payload) const
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:139