blob: 30a97f507bbe917a71e59b491060150aae562498 [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/*
Eric Newberry07d05c92018-01-22 16:08:01 -07003 * 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_FACE_STATUS_HPP
23#define NDN_MGMT_NFD_FACE_STATUS_HPP
24
Davide Pesavento7f20d6e2017-01-16 14:43:58 -050025#include "face-traits.hpp"
Junxiao Shi7357ef22016-09-07 02:39:37 +000026#include "../../util/time.hpp"
27
28namespace ndn {
29namespace nfd {
30
31/**
32 * \ingroup management
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050033 * \brief represents an item in NFD Face dataset
34 * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset
Junxiao Shi7357ef22016-09-07 02:39:37 +000035 */
36class FaceStatus : public FaceTraits<FaceStatus>
37{
38public:
39 FaceStatus();
40
41 explicit
42 FaceStatus(const Block& block);
43
44 /** \brief prepend FaceStatus to the encoder
45 */
46 template<encoding::Tag TAG>
47 size_t
48 wireEncode(EncodingImpl<TAG>& encoder) const;
49
50 /** \brief encode FaceStatus
51 */
52 const Block&
53 wireEncode() const;
54
55 /** \brief decode FaceStatus
56 */
57 void
58 wireDecode(const Block& wire);
59
60public: // getters & setters
61 bool
62 hasExpirationPeriod() const
63 {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050064 return !!m_expirationPeriod;
Junxiao Shi7357ef22016-09-07 02:39:37 +000065 }
66
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050067 time::milliseconds
Junxiao Shi7357ef22016-09-07 02:39:37 +000068 getExpirationPeriod() const
69 {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050070 BOOST_ASSERT(hasExpirationPeriod());
71 return *m_expirationPeriod;
Junxiao Shi7357ef22016-09-07 02:39:37 +000072 }
73
74 FaceStatus&
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050075 setExpirationPeriod(time::milliseconds expirationPeriod);
Junxiao Shi7357ef22016-09-07 02:39:37 +000076
Davide Pesavento156c1ea2017-03-19 16:09:33 -040077 FaceStatus&
78 unsetExpirationPeriod();
79
Eric Newberryd567aab2018-01-27 16:38:24 -070080 bool
81 hasBaseCongestionMarkingInterval() const
82 {
83 return !!m_baseCongestionMarkingInterval;
84 }
85
Eric Newberry07d05c92018-01-22 16:08:01 -070086 time::nanoseconds
87 getBaseCongestionMarkingInterval() const
88 {
Eric Newberryd567aab2018-01-27 16:38:24 -070089 BOOST_ASSERT(hasBaseCongestionMarkingInterval());
90 return *m_baseCongestionMarkingInterval;
Eric Newberry07d05c92018-01-22 16:08:01 -070091 }
92
93 FaceStatus&
94 setBaseCongestionMarkingInterval(time::nanoseconds interval);
95
Eric Newberryd567aab2018-01-27 16:38:24 -070096 FaceStatus&
97 unsetBaseCongestionMarkingInterval();
98
99 bool
100 hasDefaultCongestionThreshold() const
101 {
102 return !!m_defaultCongestionThreshold;
103 }
104
Eric Newberry07d05c92018-01-22 16:08:01 -0700105 /** \brief get default congestion threshold (measured in bytes)
106 */
107 uint64_t
108 getDefaultCongestionThreshold() const
109 {
Eric Newberryd567aab2018-01-27 16:38:24 -0700110 BOOST_ASSERT(hasDefaultCongestionThreshold());
111 return *m_defaultCongestionThreshold;
Eric Newberry07d05c92018-01-22 16:08:01 -0700112 }
113
114 /** \brief set default congestion threshold (measured in bytes)
115 */
116 FaceStatus&
117 setDefaultCongestionThreshold(uint64_t threshold);
118
Eric Newberryd567aab2018-01-27 16:38:24 -0700119 FaceStatus&
120 unsetDefaultCongestionThreshold();
121
Junxiao Shi7357ef22016-09-07 02:39:37 +0000122 uint64_t
123 getNInInterests() const
124 {
125 return m_nInInterests;
126 }
127
128 FaceStatus&
129 setNInInterests(uint64_t nInInterests);
130
131 uint64_t
Junxiao Shi9a53d782017-04-04 20:09:57 +0000132 getNInData() const
Junxiao Shi7357ef22016-09-07 02:39:37 +0000133 {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500134 return m_nInData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000135 }
136
137 FaceStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000138 setNInData(uint64_t nInData);
139
Junxiao Shi7357ef22016-09-07 02:39:37 +0000140 uint64_t
141 getNInNacks() const
142 {
143 return m_nInNacks;
144 }
145
146 FaceStatus&
147 setNInNacks(uint64_t nInNacks);
148
149 uint64_t
150 getNOutInterests() const
151 {
152 return m_nOutInterests;
153 }
154
155 FaceStatus&
156 setNOutInterests(uint64_t nOutInterests);
157
158 uint64_t
Junxiao Shi9a53d782017-04-04 20:09:57 +0000159 getNOutData() const
Junxiao Shi7357ef22016-09-07 02:39:37 +0000160 {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500161 return m_nOutData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000162 }
163
164 FaceStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000165 setNOutData(uint64_t nOutData);
166
Junxiao Shi7357ef22016-09-07 02:39:37 +0000167 uint64_t
168 getNOutNacks() const
169 {
170 return m_nOutNacks;
171 }
172
173 FaceStatus&
174 setNOutNacks(uint64_t nOutNacks);
175
176 uint64_t
177 getNInBytes() const
178 {
179 return m_nInBytes;
180 }
181
182 FaceStatus&
183 setNInBytes(uint64_t nInBytes);
184
185 uint64_t
186 getNOutBytes() const
187 {
188 return m_nOutBytes;
189 }
190
191 FaceStatus&
192 setNOutBytes(uint64_t nOutBytes);
193
Junxiao Shi7357ef22016-09-07 02:39:37 +0000194private:
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500195 optional<time::milliseconds> m_expirationPeriod;
Eric Newberryd567aab2018-01-27 16:38:24 -0700196 optional<time::nanoseconds> m_baseCongestionMarkingInterval;
197 optional<uint64_t> m_defaultCongestionThreshold;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000198 uint64_t m_nInInterests;
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500199 uint64_t m_nInData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000200 uint64_t m_nInNacks;
201 uint64_t m_nOutInterests;
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500202 uint64_t m_nOutData;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000203 uint64_t m_nOutNacks;
204 uint64_t m_nInBytes;
205 uint64_t m_nOutBytes;
Junxiao Shi7357ef22016-09-07 02:39:37 +0000206};
207
Davide Pesavento88a0d812017-08-19 21:31:42 -0400208NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(FaceStatus);
209
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500210bool
211operator==(const FaceStatus& a, const FaceStatus& b);
212
213inline bool
214operator!=(const FaceStatus& a, const FaceStatus& b)
215{
216 return !(a == b);
217}
218
Junxiao Shi7357ef22016-09-07 02:39:37 +0000219std::ostream&
220operator<<(std::ostream& os, const FaceStatus& status);
221
222} // namespace nfd
223} // namespace ndn
224
225#endif // NDN_MGMT_NFD_FACE_STATUS_HPP