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 
33 Name
35 {
36  Name name;
37  name.append(prefix).append(m_datasetName);
38  this->addParameters(name);
39  return name;
40 }
41 
42 void
43 StatusDataset::addParameters(Name& name) const
44 {
45 }
46 
54 template<typename T>
55 static std::vector<T>
57 {
58  BOOST_CONCEPT_ASSERT((WireDecodable<T>));
59 
60  std::vector<T> result;
61 
62  size_t offset = 0;
63  while (offset < payload->size()) {
64  bool isOk = false;
65  Block block;
66  std::tie(isOk, block) = Block::fromBuffer(payload, offset);
67  if (!isOk) {
68  BOOST_THROW_EXCEPTION(StatusDataset::ParseResultError("cannot decode Block"));
69  }
70 
71  offset += block.size();
72  result.emplace_back(block);
73  }
74 
75  return result;
76 }
77 
79  : StatusDataset("status/general")
80 {
81 }
82 
85 {
86  return ForwarderStatus(Block(tlv::Content, payload));
87 }
88 
90  : StatusDataset(datasetName)
91 {
92 }
93 
96 {
97  return parseDatasetVector<FaceStatus>(payload);
98 }
99 
101  : FaceDatasetBase("faces/list")
102 {
103 }
104 
106  : FaceDatasetBase("faces/query")
107  , m_filter(filter)
108 {
109 }
110 
111 void
112 FaceQueryDataset::addParameters(Name& name) const
113 {
114  name.append(m_filter.wireEncode());
115 }
116 
118  : StatusDataset("faces/channels")
119 {
120 }
121 
124 {
125  return parseDatasetVector<ChannelStatus>(payload);
126 }
127 
129  : StatusDataset("fib/list")
130 {
131 }
132 
135 {
136  return parseDatasetVector<FibEntry>(payload);
137 }
138 
140  : StatusDataset("strategy-choice/list")
141 {
142 }
143 
146 {
147  return parseDatasetVector<StrategyChoice>(payload);
148 }
149 
151  : StatusDataset("rib/list")
152 {
153 }
154 
157 {
158  return parseDatasetVector<RibEntry>(payload);
159 }
160 
161 } // namespace nfd
162 } // namespace ndn
ResultType parseResult(ConstBufferPtr payload) const
provides common functionality among FaceDataset and FaceQueryDataset
indicates reassembled payload cannot be parsed as ResultType
represents NFD Forwarder Status
Copyright (c) 2011-2015 Regents of the University of California.
static std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to construct block from Buffer.
Definition: block.cpp:253
FaceDatasetBase(const PartialName &datasetName)
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
ResultType parseResult(ConstBufferPtr payload) const
base class of NFD StatusDataset
Name getDatasetPrefix(const Name &prefix) const
constructs a name prefix for the dataset
std::vector< FaceStatus > ResultType
ResultType parseResult(ConstBufferPtr payload) const
size_t size() const
Definition: block.cpp:504
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
ResultType parseResult(ConstBufferPtr payload) const
Name abstraction to represent an absolute name.
Definition: name.hpp:46
ResultType parseResult(ConstBufferPtr payload) const
std::vector< FibEntry > ResultType
represents Face Query Filter
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend FaceQueryFilter to the encoder
std::vector< ChannelStatus > ResultType
Name & append(const uint8_t *value, size_t valueLength)
Append a new component, copying from value of length valueLength.
Definition: name.hpp:140
std::vector< StrategyChoice > ResultType
static std::vector< T > parseDatasetVector(ConstBufferPtr payload)
parses elements into a vector of T
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:33
FaceQueryDataset(const FaceQueryFilter &filter)
a concept check for TLV abstraction with .wireDecode method and constructible from Block ...
Definition: concepts.hpp:70
ResultType parseResult(ConstBufferPtr payload) const
std::vector< RibEntry > ResultType