blob: dc74eb13f2c7ed46e48994596f1a952b710d13eb [file] [log] [blame]
Junxiao Shi13e637f2014-07-16 19:20:40 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi5d75fd92017-08-08 18:09:20 +00002/*
Eric Newberry07d05c92018-01-22 16:08:01 -07003 * Copyright (c) 2013-2018 Regents of the University of California.
Junxiao Shi13e637f2014-07-16 19:20:40 -07004 *
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
Junxiao Shi7357ef22016-09-07 02:39:37 +000022#include "face-status.hpp"
Junxiao Shi65f1a712014-11-20 14:59:36 -070023#include "encoding/block-helpers.hpp"
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050024#include "encoding/encoding-buffer.hpp"
25#include "encoding/tlv-nfd.hpp"
Junxiao Shi65f1a712014-11-20 14:59:36 -070026#include "util/concepts.hpp"
Davide Pesaventoe78eeca2017-02-23 23:22:32 -050027#include "util/string-helper.hpp"
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050028
Junxiao Shi13e637f2014-07-16 19:20:40 -070029namespace ndn {
30namespace nfd {
31
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050032BOOST_CONCEPT_ASSERT((StatusDatasetItem<FaceStatus>));
Junxiao Shi65f1a712014-11-20 14:59:36 -070033
Junxiao Shi13e637f2014-07-16 19:20:40 -070034FaceStatus::FaceStatus()
Eric Newberryd567aab2018-01-27 16:38:24 -070035 : m_nInInterests(0)
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050036 , m_nInData(0)
Eric Newberry95bd96a2015-09-04 23:34:22 -070037 , m_nInNacks(0)
Junxiao Shi13e637f2014-07-16 19:20:40 -070038 , m_nOutInterests(0)
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050039 , m_nOutData(0)
Eric Newberry95bd96a2015-09-04 23:34:22 -070040 , m_nOutNacks(0)
Junxiao Shi13e637f2014-07-16 19:20:40 -070041 , m_nInBytes(0)
42 , m_nOutBytes(0)
43{
44}
45
Chengyu Fan36dca992014-09-25 13:42:03 -060046FaceStatus::FaceStatus(const Block& block)
47{
48 this->wireDecode(block);
49}
50
Alexander Afanasyev74633892015-02-08 18:08:46 -080051template<encoding::Tag TAG>
Junxiao Shi13e637f2014-07-16 19:20:40 -070052size_t
Alexander Afanasyev74633892015-02-08 18:08:46 -080053FaceStatus::wireEncode(EncodingImpl<TAG>& encoder) const
Junxiao Shi13e637f2014-07-16 19:20:40 -070054{
55 size_t totalLength = 0;
56
Junxiao Shi9a53d782017-04-04 20:09:57 +000057 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Flags, m_flags);
58 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutBytes, m_nOutBytes);
59 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInBytes, m_nInBytes);
60 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutNacks, m_nOutNacks);
61 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutData, m_nOutData);
62 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutInterests, m_nOutInterests);
63 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInNacks, m_nInNacks);
64 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInData, m_nInData);
65 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInInterests, m_nInInterests);
Eric Newberry3c9bc042018-06-02 17:58:10 -070066 if (m_mtu) {
67 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::Mtu, *m_mtu);
68 }
Eric Newberryd567aab2018-01-27 16:38:24 -070069 if (m_defaultCongestionThreshold) {
70 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::DefaultCongestionThreshold,
71 *m_defaultCongestionThreshold);
72 }
73 if (m_baseCongestionMarkingInterval) {
74 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::BaseCongestionMarkingInterval,
75 m_baseCongestionMarkingInterval->count());
76 }
Junxiao Shi9a53d782017-04-04 20:09:57 +000077 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::LinkType, m_linkType);
78 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FacePersistency, m_facePersistency);
79 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceScope, m_faceScope);
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -050080 if (m_expirationPeriod) {
Junxiao Shi5d75fd92017-08-08 18:09:20 +000081 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::ExpirationPeriod,
82 m_expirationPeriod->count());
Junxiao Shi13e637f2014-07-16 19:20:40 -070083 }
Junxiao Shi5d75fd92017-08-08 18:09:20 +000084 totalLength += prependStringBlock(encoder, tlv::nfd::LocalUri, m_localUri);
85 totalLength += prependStringBlock(encoder, tlv::nfd::Uri, m_remoteUri);
86 totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::FaceId, m_faceId);
Junxiao Shi13e637f2014-07-16 19:20:40 -070087
88 totalLength += encoder.prependVarNumber(totalLength);
89 totalLength += encoder.prependVarNumber(tlv::nfd::FaceStatus);
90 return totalLength;
91}
92
Davide Pesavento88a0d812017-08-19 21:31:42 -040093NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(FaceStatus);
Junxiao Shi13e637f2014-07-16 19:20:40 -070094
95const Block&
96FaceStatus::wireEncode() const
97{
98 if (m_wire.hasWire())
99 return m_wire;
100
101 EncodingEstimator estimator;
102 size_t estimatedSize = wireEncode(estimator);
103
104 EncodingBuffer buffer(estimatedSize, 0);
105 wireEncode(buffer);
106
107 m_wire = buffer.block();
108 return m_wire;
109}
110
111void
112FaceStatus::wireDecode(const Block& block)
113{
114 if (block.type() != tlv::nfd::FaceStatus) {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700115 BOOST_THROW_EXCEPTION(Error("expecting FaceStatus block"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700116 }
117 m_wire = block;
118 m_wire.parse();
119 Block::element_const_iterator val = m_wire.elements_begin();
120
121 if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceId) {
122 m_faceId = readNonNegativeInteger(*val);
123 ++val;
124 }
125 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700126 BOOST_THROW_EXCEPTION(Error("missing required FaceId field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700127 }
128
129 if (val != m_wire.elements_end() && val->type() == tlv::nfd::Uri) {
Junxiao Shi5d75fd92017-08-08 18:09:20 +0000130 m_remoteUri = readString(*val);
Junxiao Shi13e637f2014-07-16 19:20:40 -0700131 ++val;
132 }
133 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700134 BOOST_THROW_EXCEPTION(Error("missing required Uri field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700135 }
136
137 if (val != m_wire.elements_end() && val->type() == tlv::nfd::LocalUri) {
Junxiao Shi5d75fd92017-08-08 18:09:20 +0000138 m_localUri = readString(*val);
Junxiao Shi13e637f2014-07-16 19:20:40 -0700139 ++val;
140 }
141 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700142 BOOST_THROW_EXCEPTION(Error("missing required LocalUri field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700143 }
144
145 if (val != m_wire.elements_end() && val->type() == tlv::nfd::ExpirationPeriod) {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500146 m_expirationPeriod.emplace(readNonNegativeInteger(*val));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700147 ++val;
148 }
149 else {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500150 m_expirationPeriod = nullopt;
Junxiao Shi13e637f2014-07-16 19:20:40 -0700151 }
152
Chengyu Fan36dca992014-09-25 13:42:03 -0600153 if (val != m_wire.elements_end() && val->type() == tlv::nfd::FaceScope) {
Junxiao Shi5d75fd92017-08-08 18:09:20 +0000154 m_faceScope = readNonNegativeIntegerAs<FaceScope>(*val);
Junxiao Shi13e637f2014-07-16 19:20:40 -0700155 ++val;
156 }
157 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700158 BOOST_THROW_EXCEPTION(Error("missing required FaceScope field"));
Chengyu Fan36dca992014-09-25 13:42:03 -0600159 }
160
161 if (val != m_wire.elements_end() && val->type() == tlv::nfd::FacePersistency) {
Junxiao Shi5d75fd92017-08-08 18:09:20 +0000162 m_facePersistency = readNonNegativeIntegerAs<FacePersistency>(*val);
Chengyu Fan36dca992014-09-25 13:42:03 -0600163 ++val;
164 }
165 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700166 BOOST_THROW_EXCEPTION(Error("missing required FacePersistency field"));
Chengyu Fan36dca992014-09-25 13:42:03 -0600167 }
168
169 if (val != m_wire.elements_end() && val->type() == tlv::nfd::LinkType) {
Junxiao Shi5d75fd92017-08-08 18:09:20 +0000170 m_linkType = readNonNegativeIntegerAs<LinkType>(*val);
Chengyu Fan36dca992014-09-25 13:42:03 -0600171 ++val;
172 }
173 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700174 BOOST_THROW_EXCEPTION(Error("missing required LinkType field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700175 }
176
Eric Newberry07d05c92018-01-22 16:08:01 -0700177 if (val != m_wire.elements_end() && val->type() == tlv::nfd::BaseCongestionMarkingInterval) {
Eric Newberryd567aab2018-01-27 16:38:24 -0700178 m_baseCongestionMarkingInterval.emplace(readNonNegativeInteger(*val));
Eric Newberry07d05c92018-01-22 16:08:01 -0700179 ++val;
180 }
181 else {
Eric Newberryd567aab2018-01-27 16:38:24 -0700182 m_baseCongestionMarkingInterval = nullopt;
Eric Newberry07d05c92018-01-22 16:08:01 -0700183 }
184
185 if (val != m_wire.elements_end() && val->type() == tlv::nfd::DefaultCongestionThreshold) {
186 m_defaultCongestionThreshold = readNonNegativeInteger(*val);
187 ++val;
188 }
189 else {
Eric Newberryd567aab2018-01-27 16:38:24 -0700190 m_defaultCongestionThreshold = nullopt;
Eric Newberry07d05c92018-01-22 16:08:01 -0700191 }
192
Eric Newberry3c9bc042018-06-02 17:58:10 -0700193 if (val != m_wire.elements_end() && val->type() == tlv::nfd::Mtu) {
194 m_mtu = readNonNegativeInteger(*val);
195 ++val;
196 }
197 else {
198 m_mtu = nullopt;
199 }
200
Junxiao Shi13e637f2014-07-16 19:20:40 -0700201 if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) {
202 m_nInInterests = readNonNegativeInteger(*val);
203 ++val;
204 }
205 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700206 BOOST_THROW_EXCEPTION(Error("missing required NInInterests field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700207 }
208
Junxiao Shi9a53d782017-04-04 20:09:57 +0000209 if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInData) {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500210 m_nInData = readNonNegativeInteger(*val);
Junxiao Shi13e637f2014-07-16 19:20:40 -0700211 ++val;
212 }
213 else {
Junxiao Shi9a53d782017-04-04 20:09:57 +0000214 BOOST_THROW_EXCEPTION(Error("missing required NInData field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700215 }
216
Eric Newberry95bd96a2015-09-04 23:34:22 -0700217 if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInNacks) {
218 m_nInNacks = readNonNegativeInteger(*val);
219 ++val;
220 }
221 else {
222 BOOST_THROW_EXCEPTION(Error("missing required NInNacks field"));
223 }
224
Junxiao Shi13e637f2014-07-16 19:20:40 -0700225 if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutInterests) {
226 m_nOutInterests = readNonNegativeInteger(*val);
227 ++val;
228 }
229 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700230 BOOST_THROW_EXCEPTION(Error("missing required NOutInterests field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700231 }
232
Junxiao Shi9a53d782017-04-04 20:09:57 +0000233 if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutData) {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500234 m_nOutData = readNonNegativeInteger(*val);
Junxiao Shi13e637f2014-07-16 19:20:40 -0700235 ++val;
236 }
237 else {
Junxiao Shi9a53d782017-04-04 20:09:57 +0000238 BOOST_THROW_EXCEPTION(Error("missing required NOutData field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700239 }
240
Eric Newberry95bd96a2015-09-04 23:34:22 -0700241 if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutNacks) {
242 m_nOutNacks = readNonNegativeInteger(*val);
243 ++val;
244 }
245 else {
246 BOOST_THROW_EXCEPTION(Error("missing required NOutNacks field"));
247 }
248
Junxiao Shi13e637f2014-07-16 19:20:40 -0700249 if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInBytes) {
250 m_nInBytes = readNonNegativeInteger(*val);
251 ++val;
252 }
253 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700254 BOOST_THROW_EXCEPTION(Error("missing required NInBytes field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700255 }
256
257 if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutBytes) {
258 m_nOutBytes = readNonNegativeInteger(*val);
259 ++val;
260 }
261 else {
Spyridon Mastorakis0d2ed2e2015-07-27 19:09:12 -0700262 BOOST_THROW_EXCEPTION(Error("missing required NOutBytes field"));
Junxiao Shi13e637f2014-07-16 19:20:40 -0700263 }
Eric Newberry1ce8ab22016-09-24 11:57:21 -0700264
265 if (val != m_wire.elements_end() && val->type() == tlv::nfd::Flags) {
266 m_flags = readNonNegativeInteger(*val);
267 ++val;
268 }
269 else {
270 BOOST_THROW_EXCEPTION(Error("missing required Flags field"));
271 }
Junxiao Shi13e637f2014-07-16 19:20:40 -0700272}
273
Chengyu Fan36dca992014-09-25 13:42:03 -0600274FaceStatus&
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500275FaceStatus::setExpirationPeriod(time::milliseconds expirationPeriod)
Chengyu Fan36dca992014-09-25 13:42:03 -0600276{
277 m_wire.reset();
278 m_expirationPeriod = expirationPeriod;
Chengyu Fan36dca992014-09-25 13:42:03 -0600279 return *this;
280}
281
282FaceStatus&
Davide Pesavento156c1ea2017-03-19 16:09:33 -0400283FaceStatus::unsetExpirationPeriod()
284{
285 m_wire.reset();
286 m_expirationPeriod = nullopt;
287 return *this;
288}
289
290FaceStatus&
Eric Newberry07d05c92018-01-22 16:08:01 -0700291FaceStatus::setBaseCongestionMarkingInterval(time::nanoseconds interval)
292{
293 m_wire.reset();
294 m_baseCongestionMarkingInterval = interval;
295 return *this;
296}
297
298FaceStatus&
Eric Newberryd567aab2018-01-27 16:38:24 -0700299FaceStatus::unsetBaseCongestionMarkingInterval()
300{
301 m_wire.reset();
302 m_baseCongestionMarkingInterval = nullopt;
303 return *this;
304}
305
306FaceStatus&
Eric Newberry07d05c92018-01-22 16:08:01 -0700307FaceStatus::setDefaultCongestionThreshold(uint64_t threshold)
308{
309 m_wire.reset();
310 m_defaultCongestionThreshold = threshold;
311 return *this;
312}
313
314FaceStatus&
Eric Newberryd567aab2018-01-27 16:38:24 -0700315FaceStatus::unsetDefaultCongestionThreshold()
316{
317 m_wire.reset();
318 m_defaultCongestionThreshold = nullopt;
319 return *this;
320}
321
322FaceStatus&
Eric Newberry3c9bc042018-06-02 17:58:10 -0700323FaceStatus::setMtu(uint64_t mtu)
324{
325 m_wire.reset();
326 m_mtu = mtu;
327 return *this;
328}
329
330FaceStatus&
331FaceStatus::unsetMtu()
332{
333 m_wire.reset();
334 m_mtu = nullopt;
335 return *this;
336}
337
338FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600339FaceStatus::setNInInterests(uint64_t nInInterests)
340{
341 m_wire.reset();
342 m_nInInterests = nInInterests;
343 return *this;
344}
345
346FaceStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000347FaceStatus::setNInData(uint64_t nInData)
Chengyu Fan36dca992014-09-25 13:42:03 -0600348{
349 m_wire.reset();
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500350 m_nInData = nInData;
Chengyu Fan36dca992014-09-25 13:42:03 -0600351 return *this;
352}
353
354FaceStatus&
Eric Newberry95bd96a2015-09-04 23:34:22 -0700355FaceStatus::setNInNacks(uint64_t nInNacks)
356{
357 m_wire.reset();
358 m_nInNacks = nInNacks;
359 return *this;
360}
361
362FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600363FaceStatus::setNOutInterests(uint64_t nOutInterests)
364{
365 m_wire.reset();
366 m_nOutInterests = nOutInterests;
367 return *this;
368}
369
370FaceStatus&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000371FaceStatus::setNOutData(uint64_t nOutData)
Chengyu Fan36dca992014-09-25 13:42:03 -0600372{
373 m_wire.reset();
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500374 m_nOutData = nOutData;
Chengyu Fan36dca992014-09-25 13:42:03 -0600375 return *this;
376}
377
378FaceStatus&
Eric Newberry95bd96a2015-09-04 23:34:22 -0700379FaceStatus::setNOutNacks(uint64_t nOutNacks)
380{
381 m_wire.reset();
382 m_nOutNacks = nOutNacks;
383 return *this;
384}
385
386FaceStatus&
Chengyu Fan36dca992014-09-25 13:42:03 -0600387FaceStatus::setNInBytes(uint64_t nInBytes)
388{
389 m_wire.reset();
390 m_nInBytes = nInBytes;
391 return *this;
392}
393
394FaceStatus&
395FaceStatus::setNOutBytes(uint64_t nOutBytes)
396{
397 m_wire.reset();
398 m_nOutBytes = nOutBytes;
399 return *this;
400}
401
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500402bool
403operator==(const FaceStatus& a, const FaceStatus& b)
404{
405 return a.getFaceId() == b.getFaceId() &&
406 a.getRemoteUri() == b.getRemoteUri() &&
407 a.getLocalUri() == b.getLocalUri() &&
408 a.getFaceScope() == b.getFaceScope() &&
409 a.getFacePersistency() == b.getFacePersistency() &&
410 a.getLinkType() == b.getLinkType() &&
411 a.getFlags() == b.getFlags() &&
412 a.hasExpirationPeriod() == b.hasExpirationPeriod() &&
413 (!a.hasExpirationPeriod() || a.getExpirationPeriod() == b.getExpirationPeriod()) &&
Eric Newberryd567aab2018-01-27 16:38:24 -0700414 a.hasBaseCongestionMarkingInterval() == b.hasBaseCongestionMarkingInterval() &&
415 (!a.hasBaseCongestionMarkingInterval() ||
416 a.getBaseCongestionMarkingInterval() == b.getBaseCongestionMarkingInterval()) &&
417 a.hasDefaultCongestionThreshold() == b.hasDefaultCongestionThreshold() &&
418 (!a.hasDefaultCongestionThreshold() ||
419 a.getDefaultCongestionThreshold() == b.getDefaultCongestionThreshold()) &&
Eric Newberry3c9bc042018-06-02 17:58:10 -0700420 a.hasMtu() == b.hasMtu() &&
421 (!a.hasMtu() || a.getMtu() == b.getMtu()) &&
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500422 a.getNInInterests() == b.getNInInterests() &&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000423 a.getNInData() == b.getNInData() &&
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500424 a.getNInNacks() == b.getNInNacks() &&
425 a.getNOutInterests() == b.getNOutInterests() &&
Junxiao Shi9a53d782017-04-04 20:09:57 +0000426 a.getNOutData() == b.getNOutData() &&
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500427 a.getNOutNacks() == b.getNOutNacks() &&
428 a.getNInBytes() == b.getNInBytes() &&
429 a.getNOutBytes() == b.getNOutBytes();
430}
431
Junxiao Shi13e637f2014-07-16 19:20:40 -0700432std::ostream&
433operator<<(std::ostream& os, const FaceStatus& status)
434{
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500435 os << "Face(FaceId: " << status.getFaceId() << ",\n"
436 << " RemoteUri: " << status.getRemoteUri() << ",\n"
437 << " LocalUri: " << status.getLocalUri() << ",\n";
Junxiao Shi13e637f2014-07-16 19:20:40 -0700438
439 if (status.hasExpirationPeriod()) {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500440 os << " ExpirationPeriod: " << status.getExpirationPeriod() << ",\n";
Junxiao Shi13e637f2014-07-16 19:20:40 -0700441 }
442 else {
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500443 os << " ExpirationPeriod: infinite,\n";
Junxiao Shi13e637f2014-07-16 19:20:40 -0700444 }
445
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500446 os << " FaceScope: " << status.getFaceScope() << ",\n"
447 << " FacePersistency: " << status.getFacePersistency() << ",\n"
Eric Newberryd567aab2018-01-27 16:38:24 -0700448 << " LinkType: " << status.getLinkType() << ",\n";
449
450 if (status.hasBaseCongestionMarkingInterval()) {
451 os << " BaseCongestionMarkingInterval: " << status.getBaseCongestionMarkingInterval() << ",\n";
452 }
453
454 if (status.hasDefaultCongestionThreshold()) {
455 os << " DefaultCongestionThreshold: " << status.getDefaultCongestionThreshold() << " bytes,\n";
456 }
457
Eric Newberry3c9bc042018-06-02 17:58:10 -0700458 if (status.hasMtu()) {
459 os << " Mtu: " << status.getMtu() << " bytes,\n";
460 }
461
Eric Newberryd567aab2018-01-27 16:38:24 -0700462 os << " Flags: " << AsHex{status.getFlags()} << ",\n"
Davide Pesaventoe78eeca2017-02-23 23:22:32 -0500463 << " Counters: {Interests: {in: " << status.getNInInterests() << ", "
Junxiao Shi13e637f2014-07-16 19:20:40 -0700464 << "out: " << status.getNOutInterests() << "},\n"
Junxiao Shi9a53d782017-04-04 20:09:57 +0000465 << " Data: {in: " << status.getNInData() << ", "
466 << "out: " << status.getNOutData() << "},\n"
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500467 << " Nacks: {in: " << status.getNInNacks() << ", "
Eric Newberry95bd96a2015-09-04 23:34:22 -0700468 << "out: " << status.getNOutNacks() << "},\n"
Davide Pesavento4ec7a5a2017-02-07 23:13:39 -0500469 << " bytes: {in: " << status.getNInBytes() << ", "
470 << "out: " << status.getNOutBytes() << "}}\n";
471
472 return os << " )";
Junxiao Shi13e637f2014-07-16 19:20:40 -0700473}
474
475} // namespace nfd
476} // namespace ndn