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