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 | /* |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 3 | * Copyright (c) 2013-2018 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) |
Ju Pan | dca56ea | 2018-10-24 06:20:44 +0000 | [diff] [blame^] | 45 | , m_nSatisfiedInterests(0) |
| 46 | , m_nUnsatisfiedInterests(0) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 47 | { |
| 48 | } |
| 49 | |
| 50 | ForwarderStatus::ForwarderStatus(const Block& payload) |
| 51 | { |
| 52 | this->wireDecode(payload); |
| 53 | } |
| 54 | |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 55 | template<encoding::Tag TAG> |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 56 | size_t |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 57 | ForwarderStatus::wireEncode(EncodingImpl<TAG>& encoder) const |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 58 | { |
| 59 | size_t totalLength = 0; |
| 60 | |
Ju Pan | dca56ea | 2018-10-24 06:20:44 +0000 | [diff] [blame^] | 61 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NUnsatisfiedInterests, m_nUnsatisfiedInterests); |
| 62 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NSatisfiedInterests, m_nSatisfiedInterests); |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 63 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutNacks, m_nOutNacks); |
| 64 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutData, m_nOutData); |
| 65 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NOutInterests, m_nOutInterests); |
| 66 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInNacks, m_nInNacks); |
| 67 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInData, m_nInData); |
| 68 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NInInterests, m_nInInterests); |
| 69 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NCsEntries, m_nCsEntries); |
| 70 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NMeasurementsEntries, m_nMeasurementsEntries); |
| 71 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NPitEntries, m_nPitEntries); |
| 72 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NFibEntries, m_nFibEntries); |
| 73 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::NNameTreeEntries, m_nNameTreeEntries); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 74 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::CurrentTimestamp, |
| 75 | time::toUnixTimestamp(m_currentTimestamp).count()); |
| 76 | totalLength += prependNonNegativeIntegerBlock(encoder, tlv::nfd::StartTimestamp, |
| 77 | time::toUnixTimestamp(m_startTimestamp).count()); |
Junxiao Shi | 5d75fd9 | 2017-08-08 18:09:20 +0000 | [diff] [blame] | 78 | totalLength += prependStringBlock(encoder, tlv::nfd::NfdVersion, m_nfdVersion); |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 79 | |
| 80 | totalLength += encoder.prependVarNumber(totalLength); |
| 81 | totalLength += encoder.prependVarNumber(tlv::Content); |
| 82 | return totalLength; |
| 83 | } |
| 84 | |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 85 | NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(ForwarderStatus); |
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 | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 138 | m_nNameTreeEntries = readNonNegativeInteger(*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 | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 146 | m_nFibEntries = readNonNegativeInteger(*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 | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 154 | m_nPitEntries = readNonNegativeInteger(*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 | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 162 | m_nMeasurementsEntries = readNonNegativeInteger(*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 | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 170 | m_nCsEntries = readNonNegativeInteger(*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 | } |
Ju Pan | dca56ea | 2018-10-24 06:20:44 +0000 | [diff] [blame^] | 224 | |
| 225 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NSatisfiedInterests) { |
| 226 | m_nSatisfiedInterests = readNonNegativeInteger(*val); |
| 227 | ++val; |
| 228 | } |
| 229 | else { |
| 230 | BOOST_THROW_EXCEPTION(Error("missing required NSatisfiedInterests field")); |
| 231 | } |
| 232 | |
| 233 | if (val != m_wire.elements_end() && val->type() == tlv::nfd::NUnsatisfiedInterests) { |
| 234 | m_nUnsatisfiedInterests = readNonNegativeInteger(*val); |
| 235 | ++val; |
| 236 | } |
| 237 | else { |
| 238 | BOOST_THROW_EXCEPTION(Error("missing required NUnsatisfiedInterests field")); |
| 239 | } |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | ForwarderStatus& |
Hila Ben Abraham | 23f9e78 | 2014-12-02 02:21:34 -0600 | [diff] [blame] | 243 | ForwarderStatus::setNfdVersion(const std::string& nfdVersion) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 244 | { |
| 245 | m_wire.reset(); |
| 246 | m_nfdVersion = nfdVersion; |
| 247 | return *this; |
| 248 | } |
| 249 | |
| 250 | ForwarderStatus& |
| 251 | ForwarderStatus::setStartTimestamp(const time::system_clock::TimePoint& startTimestamp) |
| 252 | { |
| 253 | m_wire.reset(); |
| 254 | m_startTimestamp = startTimestamp; |
| 255 | return *this; |
| 256 | } |
| 257 | |
| 258 | ForwarderStatus& |
| 259 | ForwarderStatus::setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp) |
| 260 | { |
| 261 | m_wire.reset(); |
| 262 | m_currentTimestamp = currentTimestamp; |
| 263 | return *this; |
| 264 | } |
| 265 | |
| 266 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 267 | ForwarderStatus::setNNameTreeEntries(uint64_t nNameTreeEntries) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 268 | { |
| 269 | m_wire.reset(); |
| 270 | m_nNameTreeEntries = nNameTreeEntries; |
| 271 | return *this; |
| 272 | } |
| 273 | |
| 274 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 275 | ForwarderStatus::setNFibEntries(uint64_t nFibEntries) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 276 | { |
| 277 | m_wire.reset(); |
| 278 | m_nFibEntries = nFibEntries; |
| 279 | return *this; |
| 280 | } |
| 281 | |
| 282 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 283 | ForwarderStatus::setNPitEntries(uint64_t nPitEntries) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 284 | { |
| 285 | m_wire.reset(); |
| 286 | m_nPitEntries = nPitEntries; |
| 287 | return *this; |
| 288 | } |
| 289 | |
| 290 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 291 | ForwarderStatus::setNMeasurementsEntries(uint64_t nMeasurementsEntries) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 292 | { |
| 293 | m_wire.reset(); |
| 294 | m_nMeasurementsEntries = nMeasurementsEntries; |
| 295 | return *this; |
| 296 | } |
| 297 | |
| 298 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 299 | ForwarderStatus::setNCsEntries(uint64_t nCsEntries) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 300 | { |
| 301 | m_wire.reset(); |
| 302 | m_nCsEntries = nCsEntries; |
| 303 | return *this; |
| 304 | } |
| 305 | |
| 306 | ForwarderStatus& |
| 307 | ForwarderStatus::setNInInterests(uint64_t nInInterests) |
| 308 | { |
| 309 | m_wire.reset(); |
| 310 | m_nInInterests = nInInterests; |
| 311 | return *this; |
| 312 | } |
| 313 | |
| 314 | ForwarderStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 315 | ForwarderStatus::setNInData(uint64_t nInData) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 316 | { |
| 317 | m_wire.reset(); |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 318 | m_nInData = nInData; |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 319 | return *this; |
| 320 | } |
| 321 | |
| 322 | ForwarderStatus& |
Eric Newberry | 95bd96a | 2015-09-04 23:34:22 -0700 | [diff] [blame] | 323 | ForwarderStatus::setNInNacks(uint64_t nInNacks) |
| 324 | { |
| 325 | m_wire.reset(); |
| 326 | m_nInNacks = nInNacks; |
| 327 | return *this; |
| 328 | } |
| 329 | |
| 330 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 331 | ForwarderStatus::setNOutInterests(uint64_t nOutInterests) |
| 332 | { |
| 333 | m_wire.reset(); |
| 334 | m_nOutInterests = nOutInterests; |
| 335 | return *this; |
| 336 | } |
| 337 | |
| 338 | ForwarderStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 339 | ForwarderStatus::setNOutData(uint64_t nOutData) |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 340 | { |
| 341 | m_wire.reset(); |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 342 | m_nOutData = nOutData; |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 343 | return *this; |
| 344 | } |
| 345 | |
Eric Newberry | 95bd96a | 2015-09-04 23:34:22 -0700 | [diff] [blame] | 346 | ForwarderStatus& |
| 347 | ForwarderStatus::setNOutNacks(uint64_t nOutNacks) |
| 348 | { |
| 349 | m_wire.reset(); |
| 350 | m_nOutNacks = nOutNacks; |
| 351 | return *this; |
| 352 | } |
| 353 | |
Ju Pan | dca56ea | 2018-10-24 06:20:44 +0000 | [diff] [blame^] | 354 | ForwarderStatus& |
| 355 | ForwarderStatus::setNSatisfiedInterests(uint64_t nSatisfiedInterests) |
| 356 | { |
| 357 | m_wire.reset(); |
| 358 | m_nSatisfiedInterests = nSatisfiedInterests; |
| 359 | return *this; |
| 360 | } |
| 361 | |
| 362 | ForwarderStatus& |
| 363 | ForwarderStatus::setNUnsatisfiedInterests(uint64_t nUnsatisfiedInterests) |
| 364 | { |
| 365 | m_wire.reset(); |
| 366 | m_nUnsatisfiedInterests = nUnsatisfiedInterests; |
| 367 | return *this; |
| 368 | } |
| 369 | |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 370 | bool |
| 371 | operator==(const ForwarderStatus& a, const ForwarderStatus& b) |
| 372 | { |
| 373 | return a.getNfdVersion() == b.getNfdVersion() && |
| 374 | a.getStartTimestamp() == b.getStartTimestamp() && |
| 375 | a.getCurrentTimestamp() == b.getCurrentTimestamp() && |
| 376 | a.getNNameTreeEntries() == b.getNNameTreeEntries() && |
| 377 | a.getNFibEntries() == b.getNFibEntries() && |
| 378 | a.getNPitEntries() == b.getNPitEntries() && |
| 379 | a.getNMeasurementsEntries() == b.getNMeasurementsEntries() && |
| 380 | a.getNCsEntries() == b.getNCsEntries() && |
| 381 | a.getNInInterests() == b.getNInInterests() && |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 382 | a.getNInData() == b.getNInData() && |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 383 | a.getNInNacks() == b.getNInNacks() && |
| 384 | a.getNOutInterests() == b.getNOutInterests() && |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 385 | a.getNOutData() == b.getNOutData() && |
Ju Pan | dca56ea | 2018-10-24 06:20:44 +0000 | [diff] [blame^] | 386 | a.getNOutNacks() == b.getNOutNacks() && |
| 387 | a.getNSatisfiedInterests() == b.getNSatisfiedInterests() && |
| 388 | a.getNUnsatisfiedInterests() == b.getNUnsatisfiedInterests(); |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | std::ostream& |
| 392 | operator<<(std::ostream& os, const ForwarderStatus& status) |
| 393 | { |
| 394 | os << "GeneralStatus(NfdVersion: " << status.getNfdVersion() << ",\n" |
| 395 | << " StartTimestamp: " << status.getStartTimestamp() << ",\n" |
| 396 | << " CurrentTimestamp: " << status.getCurrentTimestamp() << ",\n" |
| 397 | << " Counters: {NameTreeEntries: " << status.getNNameTreeEntries() << ",\n" |
| 398 | << " FibEntries: " << status.getNFibEntries() << ",\n" |
| 399 | << " PitEntries: " << status.getNPitEntries() << ",\n" |
| 400 | << " MeasurementsEntries: " << status.getNMeasurementsEntries() << ",\n" |
| 401 | << " CsEntries: " << status.getNCsEntries() << ",\n" |
| 402 | << " Interests: {in: " << status.getNInInterests() << ", " |
| 403 | << "out: " << status.getNOutInterests() << "},\n" |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 404 | << " Data: {in: " << status.getNInData() << ", " |
| 405 | << "out: " << status.getNOutData() << "},\n" |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 406 | << " Nacks: {in: " << status.getNInNacks() << ", " |
Ju Pan | dca56ea | 2018-10-24 06:20:44 +0000 | [diff] [blame^] | 407 | << "out: " << status.getNOutNacks() << "},\n" |
| 408 | << " SatisfiedInterests: " << status.getNSatisfiedInterests() << ",\n" |
| 409 | << " UnsatisfiedInterests: " << status.getNUnsatisfiedInterests() << "}\n" |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 410 | << " )"; |
| 411 | |
| 412 | return os; |
| 413 | } |
| 414 | |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame] | 415 | } // namespace nfd |
| 416 | } // namespace ndn |