Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 4 | * |
| 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 Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 22 | #include "forwarder-status.hpp" |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 23 | #include "encoding/block-helpers.hpp" |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 24 | #include "encoding/encoding-buffer.hpp" |
| 25 | #include "encoding/tlv-nfd.hpp" |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 26 | #include "util/concepts.hpp" |
| 27 | |
| 28 | namespace ndn { |
| 29 | namespace nfd { |
| 30 | |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 31 | BOOST_CONCEPT_ASSERT((StatusDatasetItem<ForwarderStatus>)); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 32 | |
| 33 | ForwarderStatus::ForwarderStatus() |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 34 | : m_nNameTreeEntries(0) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 35 | , m_nFibEntries(0) |
| 36 | , m_nPitEntries(0) |
| 37 | , m_nMeasurementsEntries(0) |
| 38 | , m_nCsEntries(0) |
| 39 | , m_nInInterests(0) |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 40 | , m_nInData(0) |
Eric Newberry | 95bd96a | 2015-09-04 23:34:22 -0700 | [diff] [blame] | 41 | , m_nInNacks(0) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 42 | , m_nOutInterests(0) |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 43 | , m_nOutData(0) |
Eric Newberry | 95bd96a | 2015-09-04 23:34:22 -0700 | [diff] [blame] | 44 | , m_nOutNacks(0) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 45 | { |
| 46 | } |
| 47 | |
| 48 | ForwarderStatus::ForwarderStatus(const Block& payload) |
| 49 | { |
| 50 | this->wireDecode(payload); |
| 51 | } |
| 52 | |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 53 | template<encoding::Tag TAG> |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 54 | size_t |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 55 | ForwarderStatus::wireEncode(EncodingImpl<TAG>& encoder) const |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 56 | { |
| 57 | size_t totalLength = 0; |
| 58 | |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 59 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutNacks, m_nOutNacks); |
| 60 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutData, m_nOutData); |
| 61 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutInterests, m_nOutInterests); |
| 62 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInNacks, m_nInNacks); |
| 63 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInData, m_nInData); |
| 64 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInInterests, m_nInInterests); |
| 65 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NCsEntries, m_nCsEntries); |
| 66 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NMeasurementsEntries, m_nMeasurementsEntries); |
| 67 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NPitEntries, m_nPitEntries); |
| 68 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NFibEntries, m_nFibEntries); |
| 69 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NNameTreeEntries, m_nNameTreeEntries); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 70 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::CurrentTimestamp, |
| 71 | time::toUnixTimestamp(m_currentTimestamp).count()); |
| 72 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::StartTimestamp, |
| 73 | time::toUnixTimestamp(m_startTimestamp).count()); |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 74 | totalLength += encoder.prependByteArrayBlock(tlv::nfd::NfdVersion, |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 75 | reinterpret_cast<const uint8_t*>(m_nfdVersion.data()), |
| 76 | m_nfdVersion.size()); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 77 | |
| 78 | totalLength += encoder.prependVarNumber(totalLength); |
| 79 | totalLength += encoder.prependVarNumber(tlv::Content); |
| 80 | return totalLength; |
| 81 | } |
| 82 | |
| 83 | template size_t |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 84 | ForwarderStatus::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>&) const; |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 85 | |
| 86 | template size_t |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 87 | ForwarderStatus::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>&) const; |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 88 | |
| 89 | const Block& |
| 90 | ForwarderStatus::wireEncode() const |
| 91 | { |
| 92 | if (m_wire.hasWire()) |
| 93 | return m_wire; |
| 94 | |
| 95 | EncodingEstimator estimator; |
| 96 | size_t estimatedSize = wireEncode(estimator); |
| 97 | |
| 98 | EncodingBuffer buffer(estimatedSize, 0); |
| 99 | wireEncode(buffer); |
| 100 | |
| 101 | m_wire = buffer.block(); |
| 102 | return m_wire; |
| 103 | } |
| 104 | |
| 105 | void |
| 106 | ForwarderStatus::wireDecode(const Block& block) |
| 107 | { |
| 108 | if (block.type() != tlv::Content) { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 109 | BOOST_THROW_EXCEPTION(Error("expecting Content block for Status payload")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 110 | } |
| 111 | m_wire = block; |
| 112 | m_wire.parse(); |
| 113 | Block::element_const_iterator val = m_wire.elements_begin(); |
| 114 | |
| 115 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NfdVersion) { |
Hila Ben Abraham | 23f9e78 | 2014-12-02 02:21:34 -0600 | [diff] [blame] | 116 | m_nfdVersion.assign(reinterpret_cast<const char*>(val->value()), val->value_size()); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 117 | ++val; |
| 118 | } |
| 119 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 120 | BOOST_THROW_EXCEPTION(Error("missing required NfdVersion field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::StartTimestamp) { |
| 124 | m_startTimestamp = time::fromUnixTimestamp(time::milliseconds(readNonNegativeInteger(*val))); |
| 125 | ++val; |
| 126 | } |
| 127 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 128 | BOOST_THROW_EXCEPTION(Error("missing required StartTimestamp field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::CurrentTimestamp) { |
| 132 | m_currentTimestamp = time::fromUnixTimestamp(time::milliseconds(readNonNegativeInteger(*val))); |
| 133 | ++val; |
| 134 | } |
| 135 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 136 | BOOST_THROW_EXCEPTION(Error("missing required CurrentTimestamp field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NNameTreeEntries) { |
| 140 | m_nNameTreeEntries = static_cast<size_t>(readNonNegativeInteger(*val)); |
| 141 | ++val; |
| 142 | } |
| 143 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 144 | BOOST_THROW_EXCEPTION(Error("missing required NNameTreeEntries field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NFibEntries) { |
| 148 | m_nFibEntries = static_cast<size_t>(readNonNegativeInteger(*val)); |
| 149 | ++val; |
| 150 | } |
| 151 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 152 | BOOST_THROW_EXCEPTION(Error("missing required NFibEntries field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NPitEntries) { |
| 156 | m_nPitEntries = static_cast<size_t>(readNonNegativeInteger(*val)); |
| 157 | ++val; |
| 158 | } |
| 159 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 160 | BOOST_THROW_EXCEPTION(Error("missing required NPitEntries field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NMeasurementsEntries) { |
| 164 | m_nMeasurementsEntries = static_cast<size_t>(readNonNegativeInteger(*val)); |
| 165 | ++val; |
| 166 | } |
| 167 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 168 | BOOST_THROW_EXCEPTION(Error("missing required NMeasurementsEntries field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NCsEntries) { |
| 172 | m_nCsEntries = static_cast<size_t>(readNonNegativeInteger(*val)); |
| 173 | ++val; |
| 174 | } |
| 175 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 176 | BOOST_THROW_EXCEPTION(Error("missing required NCsEntries field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInInterests) { |
| 180 | m_nInInterests = static_cast<uint64_t>(readNonNegativeInteger(*val)); |
| 181 | ++val; |
| 182 | } |
| 183 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 184 | BOOST_THROW_EXCEPTION(Error("missing required NInInterests field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 187 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInData) { |
| 188 | m_nInData = static_cast<uint64_t>(readNonNegativeInteger(*val)); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 189 | ++val; |
| 190 | } |
| 191 | else { |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 192 | BOOST_THROW_EXCEPTION(Error("missing required NInData field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 193 | } |
| 194 | |
Eric Newberry | 95bd96a | 2015-09-04 23:34:22 -0700 | [diff] [blame] | 195 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NInNacks) { |
| 196 | m_nInNacks = static_cast<uint64_t>(readNonNegativeInteger(*val)); |
| 197 | ++val; |
| 198 | } |
| 199 | else { |
| 200 | BOOST_THROW_EXCEPTION(Error("missing required NInNacks field")); |
| 201 | } |
| 202 | |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 203 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutInterests) { |
| 204 | m_nOutInterests = static_cast<uint64_t>(readNonNegativeInteger(*val)); |
| 205 | ++val; |
| 206 | } |
| 207 | else { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 208 | BOOST_THROW_EXCEPTION(Error("missing required NOutInterests field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 211 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutData) { |
| 212 | m_nOutData = static_cast<uint64_t>(readNonNegativeInteger(*val)); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 213 | ++val; |
| 214 | } |
| 215 | else { |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 216 | BOOST_THROW_EXCEPTION(Error("missing required NOutData field")); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 217 | } |
Eric Newberry | 95bd96a | 2015-09-04 23:34:22 -0700 | [diff] [blame] | 218 | |
| 219 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NOutNacks) { |
| 220 | m_nOutNacks = static_cast<uint64_t>(readNonNegativeInteger(*val)); |
| 221 | ++val; |
| 222 | } |
| 223 | else { |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 224 | BOOST_THROW_EXCEPTION(Error("missing required NOutNacks field")); |
Eric Newberry | 95bd96a | 2015-09-04 23:34:22 -0700 | [diff] [blame] | 225 | } |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | ForwarderStatus& |
Hila Ben Abraham | 23f9e78 | 2014-12-02 02:21:34 -0600 | [diff] [blame] | 229 | ForwarderStatus::setNfdVersion(const std::string& nfdVersion) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 230 | { |
| 231 | m_wire.reset(); |
| 232 | m_nfdVersion = nfdVersion; |
| 233 | return *this; |
| 234 | } |
| 235 | |
| 236 | ForwarderStatus& |
| 237 | ForwarderStatus::setStartTimestamp(const time::system_clock::TimePoint& startTimestamp) |
| 238 | { |
| 239 | m_wire.reset(); |
| 240 | m_startTimestamp = startTimestamp; |
| 241 | return *this; |
| 242 | } |
| 243 | |
| 244 | ForwarderStatus& |
| 245 | ForwarderStatus::setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp) |
| 246 | { |
| 247 | m_wire.reset(); |
| 248 | m_currentTimestamp = currentTimestamp; |
| 249 | return *this; |
| 250 | } |
| 251 | |
| 252 | ForwarderStatus& |
| 253 | ForwarderStatus::setNNameTreeEntries(size_t nNameTreeEntries) |
| 254 | { |
| 255 | m_wire.reset(); |
| 256 | m_nNameTreeEntries = nNameTreeEntries; |
| 257 | return *this; |
| 258 | } |
| 259 | |
| 260 | ForwarderStatus& |
| 261 | ForwarderStatus::setNFibEntries(size_t nFibEntries) |
| 262 | { |
| 263 | m_wire.reset(); |
| 264 | m_nFibEntries = nFibEntries; |
| 265 | return *this; |
| 266 | } |
| 267 | |
| 268 | ForwarderStatus& |
| 269 | ForwarderStatus::setNPitEntries(size_t nPitEntries) |
| 270 | { |
| 271 | m_wire.reset(); |
| 272 | m_nPitEntries = nPitEntries; |
| 273 | return *this; |
| 274 | } |
| 275 | |
| 276 | ForwarderStatus& |
| 277 | ForwarderStatus::setNMeasurementsEntries(size_t nMeasurementsEntries) |
| 278 | { |
| 279 | m_wire.reset(); |
| 280 | m_nMeasurementsEntries = nMeasurementsEntries; |
| 281 | return *this; |
| 282 | } |
| 283 | |
| 284 | ForwarderStatus& |
| 285 | ForwarderStatus::setNCsEntries(size_t nCsEntries) |
| 286 | { |
| 287 | m_wire.reset(); |
| 288 | m_nCsEntries = nCsEntries; |
| 289 | return *this; |
| 290 | } |
| 291 | |
| 292 | ForwarderStatus& |
| 293 | ForwarderStatus::setNInInterests(uint64_t nInInterests) |
| 294 | { |
| 295 | m_wire.reset(); |
| 296 | m_nInInterests = nInInterests; |
| 297 | return *this; |
| 298 | } |
| 299 | |
| 300 | ForwarderStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 301 | ForwarderStatus::setNInData(uint64_t nInData) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 302 | { |
| 303 | m_wire.reset(); |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 304 | m_nInData = nInData; |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 305 | return *this; |
| 306 | } |
| 307 | |
| 308 | ForwarderStatus& |
Eric Newberry | 95bd96a | 2015-09-04 23:34:22 -0700 | [diff] [blame] | 309 | ForwarderStatus::setNInNacks(uint64_t nInNacks) |
| 310 | { |
| 311 | m_wire.reset(); |
| 312 | m_nInNacks = nInNacks; |
| 313 | return *this; |
| 314 | } |
| 315 | |
| 316 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 317 | ForwarderStatus::setNOutInterests(uint64_t nOutInterests) |
| 318 | { |
| 319 | m_wire.reset(); |
| 320 | m_nOutInterests = nOutInterests; |
| 321 | return *this; |
| 322 | } |
| 323 | |
| 324 | ForwarderStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 325 | ForwarderStatus::setNOutData(uint64_t nOutData) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 326 | { |
| 327 | m_wire.reset(); |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 328 | m_nOutData = nOutData; |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 329 | return *this; |
| 330 | } |
| 331 | |
Eric Newberry | 95bd96a | 2015-09-04 23:34:22 -0700 | [diff] [blame] | 332 | ForwarderStatus& |
| 333 | ForwarderStatus::setNOutNacks(uint64_t nOutNacks) |
| 334 | { |
| 335 | m_wire.reset(); |
| 336 | m_nOutNacks = nOutNacks; |
| 337 | return *this; |
| 338 | } |
| 339 | |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 340 | bool |
| 341 | operator==(const ForwarderStatus& a, const ForwarderStatus& b) |
| 342 | { |
| 343 | return a.getNfdVersion() == b.getNfdVersion() && |
| 344 | a.getStartTimestamp() == b.getStartTimestamp() && |
| 345 | a.getCurrentTimestamp() == b.getCurrentTimestamp() && |
| 346 | a.getNNameTreeEntries() == b.getNNameTreeEntries() && |
| 347 | a.getNFibEntries() == b.getNFibEntries() && |
| 348 | a.getNPitEntries() == b.getNPitEntries() && |
| 349 | a.getNMeasurementsEntries() == b.getNMeasurementsEntries() && |
| 350 | a.getNCsEntries() == b.getNCsEntries() && |
| 351 | a.getNInInterests() == b.getNInInterests() && |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 352 | a.getNInData() == b.getNInData() && |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 353 | a.getNInNacks() == b.getNInNacks() && |
| 354 | a.getNOutInterests() == b.getNOutInterests() && |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 355 | a.getNOutData() == b.getNOutData() && |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 356 | a.getNOutNacks() == b.getNOutNacks(); |
| 357 | } |
| 358 | |
| 359 | std::ostream& |
| 360 | operator<<(std::ostream& os, const ForwarderStatus& status) |
| 361 | { |
| 362 | os << "GeneralStatus(NfdVersion: " << status.getNfdVersion() << ",\n" |
| 363 | << " StartTimestamp: " << status.getStartTimestamp() << ",\n" |
| 364 | << " CurrentTimestamp: " << status.getCurrentTimestamp() << ",\n" |
| 365 | << " Counters: {NameTreeEntries: " << status.getNNameTreeEntries() << ",\n" |
| 366 | << " FibEntries: " << status.getNFibEntries() << ",\n" |
| 367 | << " PitEntries: " << status.getNPitEntries() << ",\n" |
| 368 | << " MeasurementsEntries: " << status.getNMeasurementsEntries() << ",\n" |
| 369 | << " CsEntries: " << status.getNCsEntries() << ",\n" |
| 370 | << " Interests: {in: " << status.getNInInterests() << ", " |
| 371 | << "out: " << status.getNOutInterests() << "},\n" |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame^] | 372 | << " Data: {in: " << status.getNInData() << ", " |
| 373 | << "out: " << status.getNOutData() << "},\n" |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 374 | << " Nacks: {in: " << status.getNInNacks() << ", " |
| 375 | << "out: " << status.getNOutNacks() << "}}\n" |
| 376 | << " )"; |
| 377 | |
| 378 | return os; |
| 379 | } |
| 380 | |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 381 | } // namespace nfd |
| 382 | } // namespace ndn |