Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2014 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 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. |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #ifndef NDN_MANAGEMENT_NFD_FORWARDER_STATUS_HPP |
| 23 | #define NDN_MANAGEMENT_NFD_FORWARDER_STATUS_HPP |
| 24 | |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 25 | #include "../encoding/block.hpp" |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 26 | #include "../util/time.hpp" |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 27 | |
| 28 | namespace ndn { |
| 29 | namespace nfd { |
| 30 | |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame] | 31 | /** |
| 32 | * \ingroup management |
| 33 | * \brief represents NFD Forwarder Status |
| 34 | * \sa http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 35 | */ |
| 36 | class ForwarderStatus |
| 37 | { |
| 38 | public: |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 39 | class Error : public tlv::Error |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 40 | { |
| 41 | public: |
| 42 | explicit |
| 43 | Error(const std::string& what) |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 44 | : tlv::Error(what) |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 45 | { |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | ForwarderStatus(); |
| 50 | |
| 51 | explicit |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 52 | ForwarderStatus(const Block& payload); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 53 | |
| 54 | /** \brief prepend ForwarderStatus as a Content block to the encoder |
| 55 | * |
| 56 | * The outermost Content element isn't part of ForwardStatus structure. |
| 57 | */ |
| 58 | template<bool T> |
| 59 | size_t |
| 60 | wireEncode(EncodingImpl<T>& encoder) const; |
| 61 | |
| 62 | /** \brief encode ForwarderStatus as a Content block |
| 63 | * |
| 64 | * The outermost Content element isn't part of ForwardStatus structure. |
| 65 | */ |
| 66 | const Block& |
| 67 | wireEncode() const; |
| 68 | |
| 69 | /** \brief decode ForwarderStatus from a Content block |
| 70 | * |
| 71 | * The outermost Content element isn't part of ForwardStatus structure. |
| 72 | */ |
| 73 | void |
| 74 | wireDecode(const Block& wire); |
| 75 | |
| 76 | public: // getters & setters |
| 77 | int |
| 78 | getNfdVersion() const |
| 79 | { |
| 80 | return m_nfdVersion; |
| 81 | } |
| 82 | |
| 83 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 84 | setNfdVersion(int nfdVersion); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 85 | |
| 86 | const time::system_clock::TimePoint& |
| 87 | getStartTimestamp() const |
| 88 | { |
| 89 | return m_startTimestamp; |
| 90 | } |
| 91 | |
| 92 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 93 | setStartTimestamp(const time::system_clock::TimePoint& startTimestamp); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 94 | |
| 95 | const time::system_clock::TimePoint& |
| 96 | getCurrentTimestamp() const |
| 97 | { |
| 98 | return m_currentTimestamp; |
| 99 | } |
| 100 | |
| 101 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 102 | setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 103 | |
| 104 | size_t |
| 105 | getNNameTreeEntries() const |
| 106 | { |
| 107 | return m_nNameTreeEntries; |
| 108 | } |
| 109 | |
| 110 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 111 | setNNameTreeEntries(size_t nNameTreeEntries); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 112 | |
| 113 | size_t |
| 114 | getNFibEntries() const |
| 115 | { |
| 116 | return m_nFibEntries; |
| 117 | } |
| 118 | |
| 119 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 120 | setNFibEntries(size_t nFibEntries); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 121 | |
| 122 | size_t |
| 123 | getNPitEntries() const |
| 124 | { |
| 125 | return m_nPitEntries; |
| 126 | } |
| 127 | |
| 128 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 129 | setNPitEntries(size_t nPitEntries); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 130 | |
| 131 | size_t |
| 132 | getNMeasurementsEntries() const |
| 133 | { |
| 134 | return m_nMeasurementsEntries; |
| 135 | } |
| 136 | |
| 137 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 138 | setNMeasurementsEntries(size_t nMeasurementsEntries); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 139 | |
| 140 | size_t |
| 141 | getNCsEntries() const |
| 142 | { |
| 143 | return m_nCsEntries; |
| 144 | } |
| 145 | |
| 146 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 147 | setNCsEntries(size_t nCsEntries); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 148 | |
| 149 | uint64_t |
| 150 | getNInInterests() const |
| 151 | { |
| 152 | return m_nInInterests; |
| 153 | } |
| 154 | |
| 155 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 156 | setNInInterests(uint64_t nInInterests); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 157 | |
| 158 | uint64_t |
| 159 | getNInDatas() const |
| 160 | { |
| 161 | return m_nInDatas; |
| 162 | } |
| 163 | |
| 164 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 165 | setNInDatas(uint64_t nInDatas); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 166 | |
| 167 | uint64_t |
| 168 | getNOutInterests() const |
| 169 | { |
| 170 | return m_nOutInterests; |
| 171 | } |
| 172 | |
| 173 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 174 | setNOutInterests(uint64_t nOutInterests); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 175 | |
| 176 | uint64_t |
| 177 | getNOutDatas() const |
| 178 | { |
| 179 | return m_nOutDatas; |
| 180 | } |
| 181 | |
| 182 | ForwarderStatus& |
Junxiao Shi | 65f1a71 | 2014-11-20 14:59:36 -0700 | [diff] [blame^] | 183 | setNOutDatas(uint64_t nOutDatas); |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 184 | |
| 185 | private: |
| 186 | int m_nfdVersion; |
| 187 | time::system_clock::TimePoint m_startTimestamp; |
| 188 | time::system_clock::TimePoint m_currentTimestamp; |
| 189 | size_t m_nNameTreeEntries; |
| 190 | size_t m_nFibEntries; |
| 191 | size_t m_nPitEntries; |
| 192 | size_t m_nMeasurementsEntries; |
| 193 | size_t m_nCsEntries; |
| 194 | uint64_t m_nInInterests; |
| 195 | uint64_t m_nInDatas; |
| 196 | uint64_t m_nOutInterests; |
| 197 | uint64_t m_nOutDatas; |
| 198 | |
| 199 | mutable Block m_wire; |
| 200 | }; |
| 201 | |
Junxiao Shi | 5109dee | 2014-03-27 19:40:30 -0700 | [diff] [blame] | 202 | } // namespace nfd |
| 203 | } // namespace ndn |
| 204 | |
| 205 | #endif // NDN_MANAGEMENT_NFD_FORWARDER_STATUS_HPP |