Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [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 | 7357ef2 | 2016-09-07 02:39:37 +0000 | [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 | |
| 22 | #ifndef NDN_MGMT_NFD_FORWARDER_STATUS_HPP |
| 23 | #define NDN_MGMT_NFD_FORWARDER_STATUS_HPP |
| 24 | |
| 25 | #include "../../encoding/block.hpp" |
| 26 | #include "../../util/time.hpp" |
| 27 | |
| 28 | namespace ndn { |
| 29 | namespace nfd { |
| 30 | |
| 31 | /** |
| 32 | * \ingroup management |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 33 | * \brief represents NFD General Status dataset |
| 34 | * \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 35 | */ |
| 36 | class ForwarderStatus |
| 37 | { |
| 38 | public: |
| 39 | class Error : public tlv::Error |
| 40 | { |
| 41 | public: |
Junxiao Shi | 68b5385 | 2018-07-25 13:56:38 -0600 | [diff] [blame] | 42 | using tlv::Error::Error; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | ForwarderStatus(); |
| 46 | |
| 47 | explicit |
| 48 | ForwarderStatus(const Block& payload); |
| 49 | |
| 50 | /** \brief prepend ForwarderStatus as a Content block to the encoder |
| 51 | * |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 52 | * The outermost Content element isn't part of ForwarderStatus structure. |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 53 | */ |
| 54 | template<encoding::Tag TAG> |
| 55 | size_t |
| 56 | wireEncode(EncodingImpl<TAG>& encoder) const; |
| 57 | |
| 58 | /** \brief encode ForwarderStatus as a Content block |
| 59 | * |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 60 | * The outermost Content element isn't part of ForwarderStatus structure. |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 61 | */ |
| 62 | const Block& |
| 63 | wireEncode() const; |
| 64 | |
| 65 | /** \brief decode ForwarderStatus from a Content block |
| 66 | * |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 67 | * The outermost Content element isn't part of ForwarderStatus structure. |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 68 | */ |
| 69 | void |
| 70 | wireDecode(const Block& wire); |
| 71 | |
| 72 | public: // getters & setters |
| 73 | const std::string& |
| 74 | getNfdVersion() const |
| 75 | { |
| 76 | return m_nfdVersion; |
| 77 | } |
| 78 | |
| 79 | ForwarderStatus& |
| 80 | setNfdVersion(const std::string& nfdVersion); |
| 81 | |
| 82 | const time::system_clock::TimePoint& |
| 83 | getStartTimestamp() const |
| 84 | { |
| 85 | return m_startTimestamp; |
| 86 | } |
| 87 | |
| 88 | ForwarderStatus& |
| 89 | setStartTimestamp(const time::system_clock::TimePoint& startTimestamp); |
| 90 | |
| 91 | const time::system_clock::TimePoint& |
| 92 | getCurrentTimestamp() const |
| 93 | { |
| 94 | return m_currentTimestamp; |
| 95 | } |
| 96 | |
| 97 | ForwarderStatus& |
| 98 | setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp); |
| 99 | |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 100 | uint64_t |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 101 | getNNameTreeEntries() const |
| 102 | { |
| 103 | return m_nNameTreeEntries; |
| 104 | } |
| 105 | |
| 106 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 107 | setNNameTreeEntries(uint64_t nNameTreeEntries); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 108 | |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 109 | uint64_t |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 110 | getNFibEntries() const |
| 111 | { |
| 112 | return m_nFibEntries; |
| 113 | } |
| 114 | |
| 115 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 116 | setNFibEntries(uint64_t nFibEntries); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 117 | |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 118 | uint64_t |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 119 | getNPitEntries() const |
| 120 | { |
| 121 | return m_nPitEntries; |
| 122 | } |
| 123 | |
| 124 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 125 | setNPitEntries(uint64_t nPitEntries); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 126 | |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 127 | uint64_t |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 128 | getNMeasurementsEntries() const |
| 129 | { |
| 130 | return m_nMeasurementsEntries; |
| 131 | } |
| 132 | |
| 133 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 134 | setNMeasurementsEntries(uint64_t nMeasurementsEntries); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 135 | |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 136 | uint64_t |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 137 | getNCsEntries() const |
| 138 | { |
| 139 | return m_nCsEntries; |
| 140 | } |
| 141 | |
| 142 | ForwarderStatus& |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 143 | setNCsEntries(uint64_t nCsEntries); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 144 | |
| 145 | uint64_t |
| 146 | getNInInterests() const |
| 147 | { |
| 148 | return m_nInInterests; |
| 149 | } |
| 150 | |
| 151 | ForwarderStatus& |
| 152 | setNInInterests(uint64_t nInInterests); |
| 153 | |
| 154 | uint64_t |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 155 | getNInData() const |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 156 | { |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 157 | return m_nInData; |
| 158 | } |
| 159 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 160 | ForwarderStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 161 | setNInData(uint64_t nInData); |
| 162 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 163 | uint64_t |
| 164 | getNInNacks() const |
| 165 | { |
| 166 | return m_nInNacks; |
| 167 | } |
| 168 | |
| 169 | ForwarderStatus& |
| 170 | setNInNacks(uint64_t nInNacks); |
| 171 | |
| 172 | uint64_t |
| 173 | getNOutInterests() const |
| 174 | { |
| 175 | return m_nOutInterests; |
| 176 | } |
| 177 | |
| 178 | ForwarderStatus& |
| 179 | setNOutInterests(uint64_t nOutInterests); |
| 180 | |
| 181 | uint64_t |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 182 | getNOutData() const |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 183 | { |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 184 | return m_nOutData; |
| 185 | } |
| 186 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 187 | ForwarderStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 188 | setNOutData(uint64_t nOutData); |
| 189 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 190 | uint64_t |
| 191 | getNOutNacks() const |
| 192 | { |
| 193 | return m_nOutNacks; |
| 194 | } |
| 195 | |
| 196 | ForwarderStatus& |
| 197 | setNOutNacks(uint64_t nOutNacks); |
| 198 | |
| 199 | private: |
| 200 | std::string m_nfdVersion; |
| 201 | time::system_clock::TimePoint m_startTimestamp; |
| 202 | time::system_clock::TimePoint m_currentTimestamp; |
Junxiao Shi | 643b7f5 | 2018-07-18 08:05:01 -0600 | [diff] [blame] | 203 | uint64_t m_nNameTreeEntries; |
| 204 | uint64_t m_nFibEntries; |
| 205 | uint64_t m_nPitEntries; |
| 206 | uint64_t m_nMeasurementsEntries; |
| 207 | uint64_t m_nCsEntries; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 208 | uint64_t m_nInInterests; |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 209 | uint64_t m_nInData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 210 | uint64_t m_nInNacks; |
| 211 | uint64_t m_nOutInterests; |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 212 | uint64_t m_nOutData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 213 | uint64_t m_nOutNacks; |
| 214 | |
| 215 | mutable Block m_wire; |
| 216 | }; |
| 217 | |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 218 | NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ForwarderStatus); |
| 219 | |
Davide Pesavento | 25e3d8c | 2017-02-08 22:17:46 -0500 | [diff] [blame] | 220 | bool |
| 221 | operator==(const ForwarderStatus& a, const ForwarderStatus& b); |
| 222 | |
| 223 | inline bool |
| 224 | operator!=(const ForwarderStatus& a, const ForwarderStatus& b) |
| 225 | { |
| 226 | return !(a == b); |
| 227 | } |
| 228 | |
| 229 | std::ostream& |
| 230 | operator<<(std::ostream& os, const ForwarderStatus& status); |
| 231 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 232 | } // namespace nfd |
| 233 | } // namespace ndn |
| 234 | |
| 235 | #endif // NDN_MGMT_NFD_FORWARDER_STATUS_HPP |