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-2019 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& 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>(std::move(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>(std::move(payload));
128 }
129 
131  : StatusDataset("fib/list")
132 {
133 }
134 
137 {
138  return parseDatasetVector<FibEntry>(std::move(payload));
139 }
140 
142  : StatusDataset("cs/info")
143 {
144 }
145 
148 {
149  return CsInfo(Block(std::move(payload)));
150 }
151 
153  : StatusDataset("strategy-choice/list")
154 {
155 }
156 
159 {
160  return parseDatasetVector<StrategyChoice>(std::move(payload));
161 }
162 
164  : StatusDataset("rib/list")
165 {
166 }
167 
170 {
171  return parseDatasetVector<RibEntry>(std::move(payload));
172 }
173 
174 } // namespace nfd
175 } // namespace ndn
ndn::nfd::ChannelDataset::ChannelDataset
ChannelDataset()
Definition: status-dataset.cpp:119
ndn::nfd::StrategyChoiceDataset::StrategyChoiceDataset
StrategyChoiceDataset()
Definition: status-dataset.cpp:152
ndn::nfd::StatusDataset
base class of NFD StatusDataset
Definition: status-dataset.hpp:44
nonstd::optional_lite::std11::move
T & move(T &t)
Definition: optional.hpp:421
ndn::nfd::CsInfoDataset::CsInfoDataset
CsInfoDataset()
Definition: status-dataset.cpp:141
ndn::nfd::StatusDataset::~StatusDataset
virtual ~StatusDataset()
ndn::nfd::parseDatasetVector
static std::vector< T > parseDatasetVector(ConstBufferPtr payload)
parses elements into a vector of T
Definition: status-dataset.cpp:58
ndn::nfd::StatusDataset::StatusDataset
StatusDataset(const PartialName &datasetName)
constructs a StatusDataset instance with given sub-prefix
Definition: status-dataset.cpp:28
concepts.hpp
ndn::nfd::StatusDataset::ParseResultError
indicates reassembled payload cannot be parsed as ResultType
Definition: status-dataset.hpp:76
ndn::nfd::FibDataset::parseResult
ResultType parseResult(ConstBufferPtr payload) const
Definition: status-dataset.cpp:136
ndn::nfd::CsInfo
represents the CS Information dataset
Definition: cs-info.hpp:38
ndn::nfd::FaceQueryFilter::wireEncode
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend FaceQueryFilter to the encoder
Definition: face-query-filter.cpp:45
ndn::WireDecodable
a concept check for TLV abstraction with .wireDecode method and constructible from Block
Definition: concepts.hpp:81
ndn::nfd::StatusDataset::getDatasetPrefix
Name getDatasetPrefix(const Name &prefix) const
constructs a name prefix for the dataset
Definition: status-dataset.cpp:36
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
ndn::Block::fromBuffer
static NDN_CXX_NODISCARD std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to parse Block from a wire buffer.
Definition: block.cpp:194
ndn::tlv::nfd::CsInfo
@ CsInfo
Definition: tlv-nfd.hpp:90
ndn::nfd::FaceDatasetBase::FaceDatasetBase
FaceDatasetBase(const PartialName &datasetName)
Definition: status-dataset.cpp:91
ndn::nfd::RibDataset::ResultType
std::vector< RibEntry > ResultType
Definition: status-dataset.hpp:250
ndn::nfd::FaceDataset::FaceDataset
FaceDataset()
Definition: status-dataset.cpp:102
ndn::nfd::RibDataset::RibDataset
RibDataset()
Definition: status-dataset.cpp:163
NDN_THROW
#define NDN_THROW(e)
Definition: exception.hpp:61
status-dataset.hpp
ndn::nfd::StrategyChoiceDataset::parseResult
ResultType parseResult(ConstBufferPtr payload) const
Definition: status-dataset.cpp:158
ndn::nfd::FibDataset::ResultType
std::vector< FibEntry > ResultType
Definition: status-dataset.hpp:202
ndn::nfd::StrategyChoiceDataset::ResultType
std::vector< StrategyChoice > ResultType
Definition: status-dataset.hpp:234
ndn::nfd::ForwarderGeneralStatusDataset::parseResult
ResultType parseResult(ConstBufferPtr payload) const
Definition: status-dataset.cpp:86
ndn::nfd::ChannelDataset::ResultType
std::vector< ChannelStatus > ResultType
Definition: status-dataset.hpp:186
ndn::nfd::FaceDatasetBase
provides common functionality among FaceDataset and FaceQueryDataset
Definition: status-dataset.hpp:132
ndn::nfd::FaceQueryDataset::FaceQueryDataset
FaceQueryDataset(const FaceQueryFilter &filter)
Definition: status-dataset.cpp:107
ndn::Block
Represents a TLV element of NDN packet format.
Definition: block.hpp:43
ndn::Block::size
size_t size() const
Return the size of the encoded wire, i.e.
Definition: block.cpp:290
ndn::name
Definition: name-component-types.hpp:33
ndn::nfd::FaceDatasetBase::parseResult
ResultType parseResult(ConstBufferPtr payload) const
Definition: status-dataset.cpp:97
ndn::nfd::ChannelDataset::parseResult
ResultType parseResult(ConstBufferPtr payload) const
Definition: status-dataset.cpp:125
ndn::nfd::RibDataset::parseResult
ResultType parseResult(ConstBufferPtr payload) const
Definition: status-dataset.cpp:169
ndn::nfd::ForwarderGeneralStatusDataset::ForwarderGeneralStatusDataset
ForwarderGeneralStatusDataset()
Definition: status-dataset.cpp:80
ndn::nfd::FaceDatasetBase::ResultType
std::vector< FaceStatus > ResultType
Definition: status-dataset.hpp:134
ndn::ConstBufferPtr
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:126
ndn::nfd::ForwarderStatus
represents NFD General Status dataset
Definition: forwarder-status.hpp:37
ndn::nfd::FaceQueryFilter
represents Face Query Filter
Definition: face-query-filter.hpp:37
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::nfd::CsInfoDataset::parseResult
ResultType parseResult(ConstBufferPtr payload) const
Definition: status-dataset.cpp:147
ndn::tlv::Content
@ Content
Definition: tlv.hpp:79
ndn::nfd::FibDataset::FibDataset
FibDataset()
Definition: status-dataset.cpp:130