blob: f222f80e2222153acc89e4361bb1cd4091f82a24 [file] [log] [blame]
Junxiao Shi7357ef22016-09-07 02:39:37 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento88a0d812017-08-19 21:31:42 -04002/*
Junxiao Shi643b7f52018-07-18 08:05:01 -06003 * Copyright (c) 2013-2018 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:
Junxiao Shi68b53852018-07-25 13:56:38 -060042 using tlv::Error::Error;
Junxiao Shi7357ef22016-09-07 02:39:37 +000043 };
44
45 ForwarderStatus();
46
47 explicit
48 ForwarderStatus(const Block& payload);
49
50 /** \brief prepend ForwarderStatus as a Content block to the encoder
51 *
Davide Pesavento25e3d8c2017-02-08 22:17:46 -050052 * The outermost Content element isn't part of ForwarderStatus structure.
Junxiao Shi7357ef22016-09-07 02:39:37 +000053 */
54 template<encoding::Tag TAG>
55 size_t
56 wireEncode(EncodingImpl<TAG>& encoder) const;
57
58 /** \brief encode ForwarderStatus as a Content block
59 *
Davide Pesavento25e3d8c2017-02-08 22:17:46 -050060 * The outermost Content element isn't part of ForwarderStatus structure.
Junxiao Shi7357ef22016-09-07 02:39:37 +000061 */
62 const Block&
63 wireEncode() const;
64
65 /** \brief decode ForwarderStatus from a Content block
66 *
Davide Pesavento25e3d8c2017-02-08 22:17:46 -050067 * The outermost Content element isn't part of ForwarderStatus structure.
Junxiao Shi7357ef22016-09-07 02:39:37 +000068 */
69 void
70 wireDecode(const Block& wire);
71
72public: // getters & setters
73 const std::string&
74 getNfdVersion() const
75 {
76 return m_nfdVersion;
77 }
78
79 ForwarderStatus&
80 setNfdVersion(const std::string& nfdVersion);
81
82 const time::system_clock::TimePoint&
83 getStartTimestamp() const
84 {
85 return m_startTimestamp;
86 }
87
88 ForwarderStatus&
89 setStartTimestamp(const time::system_clock::TimePoint& startTimestamp);
90
91 const time::system_clock::TimePoint&
92 getCurrentTimestamp() const
93 {
94 return m_currentTimestamp;
95 }
96
97 ForwarderStatus&
98 setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp);
99
Junxiao Shi643b7f52018-07-18 08:05:01 -0600100 uint64_t
Junxiao Shi7357ef22016-09-07 02:39:37 +0000101 getNNameTreeEntries() const
102 {
103 return m_nNameTreeEntries;
104 }
105
106 ForwarderStatus&
Junxiao Shi643b7f52018-07-18 08:05:01 -0600107 setNNameTreeEntries(uint64_t nNameTreeEntries);
Junxiao Shi7357ef22016-09-07 02:39:37 +0000108
Junxiao Shi643b7f52018-07-18 08:05:01 -0600109 uint64_t
Junxiao Shi7357ef22016-09-07 02:39:37 +0000110 getNFibEntries() const
111 {
112 return m_nFibEntries;
113 }
114
115 ForwarderStatus&
Junxiao Shi643b7f52018-07-18 08:05:01 -0600116 setNFibEntries(uint64_t nFibEntries);
Junxiao Shi7357ef22016-09-07 02:39:37 +0000117
Junxiao Shi643b7f52018-07-18 08:05:01 -0600118 uint64_t
Junxiao Shi7357ef22016-09-07 02:39:37 +0000119 getNPitEntries() const
120 {
121 return m_nPitEntries;
122 }
123
124 ForwarderStatus&
Junxiao Shi643b7f52018-07-18 08:05:01 -0600125 setNPitEntries(uint64_t nPitEntries);
Junxiao Shi7357ef22016-09-07 02:39:37 +0000126
Junxiao Shi643b7f52018-07-18 08:05:01 -0600127 uint64_t
Junxiao Shi7357ef22016-09-07 02:39:37 +0000128 getNMeasurementsEntries() const
129 {
130 return m_nMeasurementsEntries;
131 }
132
133 ForwarderStatus&
Junxiao Shi643b7f52018-07-18 08:05:01 -0600134 setNMeasurementsEntries(uint64_t nMeasurementsEntries);
Junxiao Shi7357ef22016-09-07 02:39:37 +0000135
Junxiao Shi643b7f52018-07-18 08:05:01 -0600136 uint64_t
Junxiao Shi7357ef22016-09-07 02:39:37 +0000137 getNCsEntries() const
138 {
139 return m_nCsEntries;
140 }
141
142 ForwarderStatus&
Junxiao Shi643b7f52018-07-18 08:05:01 -0600143 setNCsEntries(uint64_t nCsEntries);
Junxiao Shi7357ef22016-09-07 02:39:37 +0000144
145 uint64_t
146 getNInInterests() const
147 {
148 return m_nInInterests;
149 }
150
151 ForwarderStatus&
152 setNInInterests(uint64_t nInInterests);
153
154 uint64_t
Junxiao Shi9a53d782017-04-04 20:09:57 +0000155 getNInData() const
Junxiao Shi7357ef22016-09-07 02:39:37 +0000156 {
Junxiao Shi9a53d782017-04-04 20:09:57 +0000157 return m_nInData;
158 }
159
Junxiao Shi7357ef22016-09-07 02:39:37 +0000160 ForwarderStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000161 setNInData(uint64_t nInData);
162
Junxiao Shi7357ef22016-09-07 02:39:37 +0000163 uint64_t
164 getNInNacks() const
165 {
166 return m_nInNacks;
167 }
168
169 ForwarderStatus&
170 setNInNacks(uint64_t nInNacks);
171
172 uint64_t
173 getNOutInterests() const
174 {
175 return m_nOutInterests;
176 }
177
178 ForwarderStatus&
179 setNOutInterests(uint64_t nOutInterests);
180
181 uint64_t
Junxiao Shi9a53d782017-04-04 20:09:57 +0000182 getNOutData() const
Junxiao Shi7357ef22016-09-07 02:39:37 +0000183 {
Junxiao Shi9a53d782017-04-04 20:09:57 +0000184 return m_nOutData;
185 }
186
Junxiao Shi7357ef22016-09-07 02:39:37 +0000187 ForwarderStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000188 setNOutData(uint64_t nOutData);
189
Junxiao Shi7357ef22016-09-07 02:39:37 +0000190 uint64_t
191 getNOutNacks() const
192 {
193 return m_nOutNacks;
194 }
195
196 ForwarderStatus&
197 setNOutNacks(uint64_t nOutNacks);
198
199private:
200 std::string m_nfdVersion;
201 time::system_clock::TimePoint m_startTimestamp;
202 time::system_clock::TimePoint m_currentTimestamp;
Junxiao Shi643b7f52018-07-18 08:05:01 -0600203 uint64_t m_nNameTreeEntries;
204 uint64_t m_nFibEntries;
205 uint64_t m_nPitEntries;
206 uint64_t m_nMeasurementsEntries;
207 uint64_t m_nCsEntries;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000208 uint64_t m_nInInterests;
Junxiao Shi9a53d782017-04-04 20:09:57 +0000209 uint64_t m_nInData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000210 uint64_t m_nInNacks;
211 uint64_t m_nOutInterests;
Junxiao Shi9a53d782017-04-04 20:09:57 +0000212 uint64_t m_nOutData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000213 uint64_t m_nOutNacks;
214
215 mutable Block m_wire;
216};
217
Davide Pesavento88a0d812017-08-19 21:31:42 -0400218NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ForwarderStatus);
219
Davide Pesavento25e3d8c2017-02-08 22:17:46 -0500220bool
221operator==(const ForwarderStatus& a, const ForwarderStatus& b);
222
223inline bool
224operator!=(const ForwarderStatus& a, const ForwarderStatus& b)
225{
226 return !(a == b);
227}
228
229std::ostream&
230operator<<(std::ostream& os, const ForwarderStatus& status);
231
Junxiao Shi7357ef22016-09-07 02:39:37 +0000232} // namespace nfd
233} // namespace ndn
234
235#endif // NDN_MGMT_NFD_FORWARDER_STATUS_HPP