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 | /* |
Eric Newberry | 07d05c9 | 2018-01-22 16:08:01 -0700 | [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_FACE_STATUS_HPP |
| 23 | #define NDN_MGMT_NFD_FACE_STATUS_HPP |
| 24 | |
Davide Pesavento | 7f20d6e | 2017-01-16 14:43:58 -0500 | [diff] [blame] | 25 | #include "face-traits.hpp" |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 26 | #include "../../util/time.hpp" |
| 27 | |
| 28 | namespace ndn { |
| 29 | namespace nfd { |
| 30 | |
| 31 | /** |
| 32 | * \ingroup management |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 33 | * \brief represents an item in NFD Face dataset |
| 34 | * \sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Face-Dataset |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 35 | */ |
| 36 | class FaceStatus : public FaceTraits<FaceStatus> |
| 37 | { |
| 38 | public: |
| 39 | FaceStatus(); |
| 40 | |
| 41 | explicit |
| 42 | FaceStatus(const Block& block); |
| 43 | |
| 44 | /** \brief prepend FaceStatus to the encoder |
| 45 | */ |
| 46 | template<encoding::Tag TAG> |
| 47 | size_t |
| 48 | wireEncode(EncodingImpl<TAG>& encoder) const; |
| 49 | |
| 50 | /** \brief encode FaceStatus |
| 51 | */ |
| 52 | const Block& |
| 53 | wireEncode() const; |
| 54 | |
| 55 | /** \brief decode FaceStatus |
| 56 | */ |
| 57 | void |
| 58 | wireDecode(const Block& wire); |
| 59 | |
| 60 | public: // getters & setters |
| 61 | bool |
| 62 | hasExpirationPeriod() const |
| 63 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 64 | return !!m_expirationPeriod; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 67 | time::milliseconds |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 68 | getExpirationPeriod() const |
| 69 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 70 | BOOST_ASSERT(hasExpirationPeriod()); |
| 71 | return *m_expirationPeriod; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | FaceStatus& |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 75 | setExpirationPeriod(time::milliseconds expirationPeriod); |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 76 | |
Davide Pesavento | 156c1ea | 2017-03-19 16:09:33 -0400 | [diff] [blame] | 77 | FaceStatus& |
| 78 | unsetExpirationPeriod(); |
| 79 | |
Eric Newberry | d567aab | 2018-01-27 16:38:24 -0700 | [diff] [blame] | 80 | bool |
| 81 | hasBaseCongestionMarkingInterval() const |
| 82 | { |
| 83 | return !!m_baseCongestionMarkingInterval; |
| 84 | } |
| 85 | |
Eric Newberry | 07d05c9 | 2018-01-22 16:08:01 -0700 | [diff] [blame] | 86 | time::nanoseconds |
| 87 | getBaseCongestionMarkingInterval() const |
| 88 | { |
Eric Newberry | d567aab | 2018-01-27 16:38:24 -0700 | [diff] [blame] | 89 | BOOST_ASSERT(hasBaseCongestionMarkingInterval()); |
| 90 | return *m_baseCongestionMarkingInterval; |
Eric Newberry | 07d05c9 | 2018-01-22 16:08:01 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | FaceStatus& |
| 94 | setBaseCongestionMarkingInterval(time::nanoseconds interval); |
| 95 | |
Eric Newberry | d567aab | 2018-01-27 16:38:24 -0700 | [diff] [blame] | 96 | FaceStatus& |
| 97 | unsetBaseCongestionMarkingInterval(); |
| 98 | |
| 99 | bool |
| 100 | hasDefaultCongestionThreshold() const |
| 101 | { |
| 102 | return !!m_defaultCongestionThreshold; |
| 103 | } |
| 104 | |
Eric Newberry | 07d05c9 | 2018-01-22 16:08:01 -0700 | [diff] [blame] | 105 | /** \brief get default congestion threshold (measured in bytes) |
| 106 | */ |
| 107 | uint64_t |
| 108 | getDefaultCongestionThreshold() const |
| 109 | { |
Eric Newberry | d567aab | 2018-01-27 16:38:24 -0700 | [diff] [blame] | 110 | BOOST_ASSERT(hasDefaultCongestionThreshold()); |
| 111 | return *m_defaultCongestionThreshold; |
Eric Newberry | 07d05c9 | 2018-01-22 16:08:01 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | /** \brief set default congestion threshold (measured in bytes) |
| 115 | */ |
| 116 | FaceStatus& |
| 117 | setDefaultCongestionThreshold(uint64_t threshold); |
| 118 | |
Eric Newberry | d567aab | 2018-01-27 16:38:24 -0700 | [diff] [blame] | 119 | FaceStatus& |
| 120 | unsetDefaultCongestionThreshold(); |
| 121 | |
Eric Newberry | 3c9bc04 | 2018-06-02 17:58:10 -0700 | [diff] [blame^] | 122 | bool |
| 123 | hasMtu() const |
| 124 | { |
| 125 | return !!m_mtu; |
| 126 | } |
| 127 | |
| 128 | /** \brief get MTU (measured in bytes) |
| 129 | * |
| 130 | * This value is capped at MAX_NDN_PACKET_SIZE, even if the MTU of the face is unlimited. |
| 131 | */ |
| 132 | uint64_t |
| 133 | getMtu() const |
| 134 | { |
| 135 | BOOST_ASSERT(hasMtu()); |
| 136 | return *m_mtu; |
| 137 | } |
| 138 | |
| 139 | /** \brief set MTU (measured in bytes) |
| 140 | * |
| 141 | * This value is capped at MAX_NDN_PACKET_SIZE, even if the MTU of the face is unlimited. |
| 142 | */ |
| 143 | FaceStatus& |
| 144 | setMtu(uint64_t mtu); |
| 145 | |
| 146 | FaceStatus& |
| 147 | unsetMtu(); |
| 148 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 149 | uint64_t |
| 150 | getNInInterests() const |
| 151 | { |
| 152 | return m_nInInterests; |
| 153 | } |
| 154 | |
| 155 | FaceStatus& |
| 156 | setNInInterests(uint64_t nInInterests); |
| 157 | |
| 158 | uint64_t |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 159 | getNInData() const |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 160 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 161 | return m_nInData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | FaceStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 165 | setNInData(uint64_t nInData); |
| 166 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 167 | uint64_t |
| 168 | getNInNacks() const |
| 169 | { |
| 170 | return m_nInNacks; |
| 171 | } |
| 172 | |
| 173 | FaceStatus& |
| 174 | setNInNacks(uint64_t nInNacks); |
| 175 | |
| 176 | uint64_t |
| 177 | getNOutInterests() const |
| 178 | { |
| 179 | return m_nOutInterests; |
| 180 | } |
| 181 | |
| 182 | FaceStatus& |
| 183 | setNOutInterests(uint64_t nOutInterests); |
| 184 | |
| 185 | uint64_t |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 186 | getNOutData() const |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 187 | { |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 188 | return m_nOutData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | FaceStatus& |
Junxiao Shi | 9a53d78 | 2017-04-04 20:09:57 +0000 | [diff] [blame] | 192 | setNOutData(uint64_t nOutData); |
| 193 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 194 | uint64_t |
| 195 | getNOutNacks() const |
| 196 | { |
| 197 | return m_nOutNacks; |
| 198 | } |
| 199 | |
| 200 | FaceStatus& |
| 201 | setNOutNacks(uint64_t nOutNacks); |
| 202 | |
| 203 | uint64_t |
| 204 | getNInBytes() const |
| 205 | { |
| 206 | return m_nInBytes; |
| 207 | } |
| 208 | |
| 209 | FaceStatus& |
| 210 | setNInBytes(uint64_t nInBytes); |
| 211 | |
| 212 | uint64_t |
| 213 | getNOutBytes() const |
| 214 | { |
| 215 | return m_nOutBytes; |
| 216 | } |
| 217 | |
| 218 | FaceStatus& |
| 219 | setNOutBytes(uint64_t nOutBytes); |
| 220 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 221 | private: |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 222 | optional<time::milliseconds> m_expirationPeriod; |
Eric Newberry | d567aab | 2018-01-27 16:38:24 -0700 | [diff] [blame] | 223 | optional<time::nanoseconds> m_baseCongestionMarkingInterval; |
| 224 | optional<uint64_t> m_defaultCongestionThreshold; |
Eric Newberry | 3c9bc04 | 2018-06-02 17:58:10 -0700 | [diff] [blame^] | 225 | optional<uint64_t> m_mtu; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 226 | uint64_t m_nInInterests; |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 227 | uint64_t m_nInData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 228 | uint64_t m_nInNacks; |
| 229 | uint64_t m_nOutInterests; |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 230 | uint64_t m_nOutData; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 231 | uint64_t m_nOutNacks; |
| 232 | uint64_t m_nInBytes; |
| 233 | uint64_t m_nOutBytes; |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 234 | }; |
| 235 | |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 236 | NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(FaceStatus); |
| 237 | |
Davide Pesavento | 4ec7a5a | 2017-02-07 23:13:39 -0500 | [diff] [blame] | 238 | bool |
| 239 | operator==(const FaceStatus& a, const FaceStatus& b); |
| 240 | |
| 241 | inline bool |
| 242 | operator!=(const FaceStatus& a, const FaceStatus& b) |
| 243 | { |
| 244 | return !(a == b); |
| 245 | } |
| 246 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 247 | std::ostream& |
| 248 | operator<<(std::ostream& os, const FaceStatus& status); |
| 249 | |
| 250 | } // namespace nfd |
| 251 | } // namespace ndn |
| 252 | |
| 253 | #endif // NDN_MGMT_NFD_FACE_STATUS_HPP |