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