NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
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("strategy-choice/list")
143 {
144 }
145 
148 {
149  return parseDatasetVector<StrategyChoice>(payload);
150 }
151 
153  : StatusDataset("rib/list")
154 {
155 }
156 
159 {
160  return parseDatasetVector<RibEntry>(payload);
161 }
162 
163 } // namespace nfd
164 } // namespace ndn
provides common functionality among FaceDataset and FaceQueryDataset
indicates reassembled payload cannot be parsed as ResultType
represents NFD General Status dataset
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend FaceQueryFilter to the encoder
Copyright (c) 2011-2015 Regents of the University of California.
ResultType parseResult(ConstBufferPtr payload) const
static std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to parse Block from a wire buffer.
Definition: block.cpp:195
ResultType parseResult(ConstBufferPtr payload) const
FaceDatasetBase(const PartialName &datasetName)
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
ResultType parseResult(ConstBufferPtr payload) const
base class of NFD StatusDataset
Name & append(const Component &component)
Append a component.
Definition: name.hpp:256
std::vector< FaceStatus > ResultType
ResultType parseResult(ConstBufferPtr payload) const
size_t size() const
Get size of encoded wire, including Type-Length-Value.
Definition: block.cpp:299
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
StatusDataset(const PartialName &datasetName)
constructs a StatusDataset instance with given sub-prefix
Name getDatasetPrefix(const Name &prefix) const
constructs a name prefix for the dataset
Represents an absolute name.
Definition: name.hpp:42
std::vector< FibEntry > ResultType
represents Face Query Filter
ResultType parseResult(ConstBufferPtr payload) const
std::vector< ChannelStatus > ResultType
std::vector< StrategyChoice > ResultType
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
std::vector< RibEntry > ResultType
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:89