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-2017 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 
22 #include "status-dataset.hpp"
23 #include "../../util/concepts.hpp"
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  BOOST_THROW_EXCEPTION(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, 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
represents NFD General Status dataset
Copyright (c) 2011-2015 Regents of the University of California.
static std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to parse Block from a wire buffer.
Definition: block.cpp:196
FaceDatasetBase(const PartialName &datasetName)
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
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
ResultType parseResult(ConstBufferPtr payload) const
size_t size() const
Get size of encoded wire, including Type-Length-Value.
Definition: block.cpp:300
std::vector< FibEntry > ResultType
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
std::vector< RibEntry > ResultType
std::vector< FaceStatus > ResultType
StatusDataset(const PartialName &datasetName)
constructs a StatusDataset instance with given sub-prefix
ResultType parseResult(ConstBufferPtr payload) const
Represents an absolute name.
Definition: name.hpp:42
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
static std::vector< T > parseDatasetVector(ConstBufferPtr payload)
parses elements into a vector of T
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:89