blob: 58403f891c0d0d013fb3afc480732354fb7f89b4 [file] [log] [blame]
Junxiao Shi7357ef22016-09-07 02:39:37 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Davide Pesavento25e3d8c2017-02-08 22:17:46 -05003 * Copyright (c) 2013-2017 Regents of the University of California.
Junxiao Shi7357ef22016-09-07 02:39:37 +00004 *
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#ifndef NDN_MGMT_NFD_FORWARDER_STATUS_HPP
23#define NDN_MGMT_NFD_FORWARDER_STATUS_HPP
24
25#include "../../encoding/block.hpp"
26#include "../../util/time.hpp"
27
28namespace ndn {
29namespace nfd {
30
31/**
32 * \ingroup management
Davide Pesavento25e3d8c2017-02-08 22:17:46 -050033 * \brief represents NFD General Status dataset
34 * \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +000035 */
36class ForwarderStatus
37{
38public:
39 class Error : public tlv::Error
40 {
41 public:
42 explicit
43 Error(const std::string& what)
44 : tlv::Error(what)
45 {
46 }
47 };
48
49 ForwarderStatus();
50
51 explicit
52 ForwarderStatus(const Block& payload);
53
54 /** \brief prepend ForwarderStatus as a Content block to the encoder
55 *
Davide Pesavento25e3d8c2017-02-08 22:17:46 -050056 * The outermost Content element isn't part of ForwarderStatus structure.
Junxiao Shi7357ef22016-09-07 02:39:37 +000057 */
58 template<encoding::Tag TAG>
59 size_t
60 wireEncode(EncodingImpl<TAG>& encoder) const;
61
62 /** \brief encode ForwarderStatus as a Content block
63 *
Davide Pesavento25e3d8c2017-02-08 22:17:46 -050064 * The outermost Content element isn't part of ForwarderStatus structure.
Junxiao Shi7357ef22016-09-07 02:39:37 +000065 */
66 const Block&
67 wireEncode() const;
68
69 /** \brief decode ForwarderStatus from a Content block
70 *
Davide Pesavento25e3d8c2017-02-08 22:17:46 -050071 * The outermost Content element isn't part of ForwarderStatus structure.
Junxiao Shi7357ef22016-09-07 02:39:37 +000072 */
73 void
74 wireDecode(const Block& wire);
75
76public: // getters & setters
77 const std::string&
78 getNfdVersion() const
79 {
80 return m_nfdVersion;
81 }
82
83 ForwarderStatus&
84 setNfdVersion(const std::string& nfdVersion);
85
86 const time::system_clock::TimePoint&
87 getStartTimestamp() const
88 {
89 return m_startTimestamp;
90 }
91
92 ForwarderStatus&
93 setStartTimestamp(const time::system_clock::TimePoint& startTimestamp);
94
95 const time::system_clock::TimePoint&
96 getCurrentTimestamp() const
97 {
98 return m_currentTimestamp;
99 }
100
101 ForwarderStatus&
102 setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp);
103
104 size_t
105 getNNameTreeEntries() const
106 {
107 return m_nNameTreeEntries;
108 }
109
110 ForwarderStatus&
111 setNNameTreeEntries(size_t nNameTreeEntries);
112
113 size_t
114 getNFibEntries() const
115 {
116 return m_nFibEntries;
117 }
118
119 ForwarderStatus&
120 setNFibEntries(size_t nFibEntries);
121
122 size_t
123 getNPitEntries() const
124 {
125 return m_nPitEntries;
126 }
127
128 ForwarderStatus&
129 setNPitEntries(size_t nPitEntries);
130
131 size_t
132 getNMeasurementsEntries() const
133 {
134 return m_nMeasurementsEntries;
135 }
136
137 ForwarderStatus&
138 setNMeasurementsEntries(size_t nMeasurementsEntries);
139
140 size_t
141 getNCsEntries() const
142 {
143 return m_nCsEntries;
144 }
145
146 ForwarderStatus&
147 setNCsEntries(size_t nCsEntries);
148
149 uint64_t
150 getNInInterests() const
151 {
152 return m_nInInterests;
153 }
154
155 ForwarderStatus&
156 setNInInterests(uint64_t nInInterests);
157
158 uint64_t
Junxiao Shi9a53d782017-04-04 20:09:57 +0000159 getNInData() const
Junxiao Shi7357ef22016-09-07 02:39:37 +0000160 {
Junxiao Shi9a53d782017-04-04 20:09:57 +0000161 return m_nInData;
162 }
163
164 DEPRECATED(
165 uint64_t
166 getNInDatas() const)
167 {
168 return getNInData();
Junxiao Shi7357ef22016-09-07 02:39:37 +0000169 }
170
171 ForwarderStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000172 setNInData(uint64_t nInData);
173
174 DEPRECATED(
175 ForwarderStatus&
176 setNInDatas(uint64_t nInData))
177 {
178 return setNInData(nInData);
179 }
Junxiao Shi7357ef22016-09-07 02:39:37 +0000180
181 uint64_t
182 getNInNacks() const
183 {
184 return m_nInNacks;
185 }
186
187 ForwarderStatus&
188 setNInNacks(uint64_t nInNacks);
189
190 uint64_t
191 getNOutInterests() const
192 {
193 return m_nOutInterests;
194 }
195
196 ForwarderStatus&
197 setNOutInterests(uint64_t nOutInterests);
198
199 uint64_t
Junxiao Shi9a53d782017-04-04 20:09:57 +0000200 getNOutData() const
Junxiao Shi7357ef22016-09-07 02:39:37 +0000201 {
Junxiao Shi9a53d782017-04-04 20:09:57 +0000202 return m_nOutData;
203 }
204
205 DEPRECATED(
206 uint64_t
207 getNOutDatas() const)
208 {
209 return getNOutData();
Junxiao Shi7357ef22016-09-07 02:39:37 +0000210 }
211
212 ForwarderStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000213 setNOutData(uint64_t nOutData);
214
215 DEPRECATED(
216 ForwarderStatus&
217 setNOutDatas(uint64_t nOutData))
218 {
219 return setNOutData(nOutData);
220 }
Junxiao Shi7357ef22016-09-07 02:39:37 +0000221
222 uint64_t
223 getNOutNacks() const
224 {
225 return m_nOutNacks;
226 }
227
228 ForwarderStatus&
229 setNOutNacks(uint64_t nOutNacks);
230
231private:
232 std::string m_nfdVersion;
233 time::system_clock::TimePoint m_startTimestamp;
234 time::system_clock::TimePoint m_currentTimestamp;
235 size_t m_nNameTreeEntries;
236 size_t m_nFibEntries;
237 size_t m_nPitEntries;
238 size_t m_nMeasurementsEntries;
239 size_t m_nCsEntries;
240 uint64_t m_nInInterests;
Junxiao Shi9a53d782017-04-04 20:09:57 +0000241 uint64_t m_nInData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000242 uint64_t m_nInNacks;
243 uint64_t m_nOutInterests;
Junxiao Shi9a53d782017-04-04 20:09:57 +0000244 uint64_t m_nOutData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000245 uint64_t m_nOutNacks;
246
247 mutable Block m_wire;
248};
249
Davide Pesavento25e3d8c2017-02-08 22:17:46 -0500250bool
251operator==(const ForwarderStatus& a, const ForwarderStatus& b);
252
253inline bool
254operator!=(const ForwarderStatus& a, const ForwarderStatus& b)
255{
256 return !(a == b);
257}
258
259std::ostream&
260operator<<(std::ostream& os, const ForwarderStatus& status);
261
Junxiao Shi7357ef22016-09-07 02:39:37 +0000262} // namespace nfd
263} // namespace ndn
264
265#endif // NDN_MGMT_NFD_FORWARDER_STATUS_HPP