face-status.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2023 Regents of the University of California.
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_CXX_MGMT_NFD_FACE_STATUS_HPP
23 #define NDN_CXX_MGMT_NFD_FACE_STATUS_HPP
24 
26 #include "ndn-cxx/util/time.hpp"
27 
28 #include <optional>
29 
30 namespace ndn::nfd {
31 
37 class FaceStatus : public FaceTraits<FaceStatus>
38 {
39 public:
41 
42  explicit
43  FaceStatus(const Block& block);
44 
47  template<encoding::Tag TAG>
48  size_t
49  wireEncode(EncodingImpl<TAG>& encoder) const;
50 
53  const Block&
54  wireEncode() const;
55 
58  void
59  wireDecode(const Block& wire);
60 
61 public: // getters & setters
62  bool
64  {
65  return !!m_expirationPeriod;
66  }
67 
70  {
71  BOOST_ASSERT(hasExpirationPeriod());
72  return *m_expirationPeriod;
73  }
74 
75  FaceStatus&
76  setExpirationPeriod(time::milliseconds expirationPeriod);
77 
78  FaceStatus&
80 
81  bool
83  {
84  return !!m_baseCongestionMarkingInterval;
85  }
86 
89  {
90  BOOST_ASSERT(hasBaseCongestionMarkingInterval());
91  return *m_baseCongestionMarkingInterval;
92  }
93 
94  FaceStatus&
96 
97  FaceStatus&
99 
100  bool
102  {
103  return !!m_defaultCongestionThreshold;
104  }
105 
108  uint64_t
110  {
111  BOOST_ASSERT(hasDefaultCongestionThreshold());
112  return *m_defaultCongestionThreshold;
113  }
114 
117  FaceStatus&
118  setDefaultCongestionThreshold(uint64_t threshold);
119 
120  FaceStatus&
122 
123  bool
124  hasMtu() const
125  {
126  return !!m_mtu;
127  }
128 
133  uint64_t
134  getMtu() const
135  {
136  BOOST_ASSERT(hasMtu());
137  return *m_mtu;
138  }
139 
144  FaceStatus&
145  setMtu(uint64_t mtu);
146 
147  FaceStatus&
148  unsetMtu();
149 
150  uint64_t
152  {
153  return m_nInInterests;
154  }
155 
156  FaceStatus&
157  setNInInterests(uint64_t nInInterests);
158 
159  uint64_t
160  getNInData() const
161  {
162  return m_nInData;
163  }
164 
165  FaceStatus&
166  setNInData(uint64_t nInData);
167 
168  uint64_t
169  getNInNacks() const
170  {
171  return m_nInNacks;
172  }
173 
174  FaceStatus&
175  setNInNacks(uint64_t nInNacks);
176 
177  uint64_t
179  {
180  return m_nOutInterests;
181  }
182 
183  FaceStatus&
184  setNOutInterests(uint64_t nOutInterests);
185 
186  uint64_t
187  getNOutData() const
188  {
189  return m_nOutData;
190  }
191 
192  FaceStatus&
193  setNOutData(uint64_t nOutData);
194 
195  uint64_t
196  getNOutNacks() const
197  {
198  return m_nOutNacks;
199  }
200 
201  FaceStatus&
202  setNOutNacks(uint64_t nOutNacks);
203 
204  uint64_t
205  getNInBytes() const
206  {
207  return m_nInBytes;
208  }
209 
210  FaceStatus&
211  setNInBytes(uint64_t nInBytes);
212 
213  uint64_t
214  getNOutBytes() const
215  {
216  return m_nOutBytes;
217  }
218 
219  FaceStatus&
220  setNOutBytes(uint64_t nOutBytes);
221 
222 private:
223  std::optional<time::milliseconds> m_expirationPeriod;
224  std::optional<time::nanoseconds> m_baseCongestionMarkingInterval;
225  std::optional<uint64_t> m_defaultCongestionThreshold;
226  std::optional<uint64_t> m_mtu;
227  uint64_t m_nInInterests = 0;
228  uint64_t m_nInData = 0;
229  uint64_t m_nInNacks = 0;
230  uint64_t m_nOutInterests = 0;
231  uint64_t m_nOutData = 0;
232  uint64_t m_nOutNacks = 0;
233  uint64_t m_nInBytes = 0;
234  uint64_t m_nOutBytes = 0;
235 };
236 
238 
239 bool
240 operator==(const FaceStatus& a, const FaceStatus& b);
241 
242 inline bool
243 operator!=(const FaceStatus& a, const FaceStatus& b)
244 {
245  return !(a == b);
246 }
247 
248 std::ostream&
249 operator<<(std::ostream& os, const FaceStatus& status);
250 
251 } // namespace ndn::nfd
252 
253 #endif // NDN_CXX_MGMT_NFD_FACE_STATUS_HPP
Represents a TLV element of the NDN packet format.
Definition: block.hpp:45
Represents an item in NFD Face dataset.
Definition: face-status.hpp:38
FaceStatus & setNOutInterests(uint64_t nOutInterests)
const Block & wireEncode() const
Encode FaceStatus.
Definition: face-status.cpp:82
FaceStatus & unsetExpirationPeriod()
FaceStatus & setNOutData(uint64_t nOutData)
FaceStatus & unsetDefaultCongestionThreshold()
FaceStatus & setNOutBytes(uint64_t nOutBytes)
uint64_t getNOutInterests() const
FaceStatus & setNInInterests(uint64_t nInInterests)
FaceStatus & setNOutNacks(uint64_t nOutNacks)
uint64_t getNInData() const
uint64_t getNInBytes() const
void wireDecode(const Block &wire)
Decode FaceStatus.
Definition: face-status.cpp:98
uint64_t getNOutData() const
FaceStatus & setNInData(uint64_t nInData)
FaceStatus & setExpirationPeriod(time::milliseconds expirationPeriod)
FaceStatus & unsetMtu()
uint64_t getDefaultCongestionThreshold() const
Get default congestion threshold (measured in bytes).
bool hasBaseCongestionMarkingInterval() const
Definition: face-status.hpp:82
time::nanoseconds getBaseCongestionMarkingInterval() const
Definition: face-status.hpp:88
uint64_t getNInInterests() const
uint64_t getNInNacks() const
FaceStatus & setNInNacks(uint64_t nInNacks)
FaceStatus & setNInBytes(uint64_t nInBytes)
FaceStatus & setMtu(uint64_t mtu)
Set MTU (measured in bytes).
bool hasExpirationPeriod() const
Definition: face-status.hpp:63
uint64_t getMtu() const
Get MTU (measured in bytes).
FaceStatus & setDefaultCongestionThreshold(uint64_t threshold)
Set default congestion threshold (measured in bytes).
bool hasDefaultCongestionThreshold() const
FaceStatus & setBaseCongestionMarkingInterval(time::nanoseconds interval)
uint64_t getNOutBytes() const
FaceStatus & unsetBaseCongestionMarkingInterval()
time::milliseconds getExpirationPeriod() const
Definition: face-status.hpp:69
uint64_t getNOutNacks() const
Provides getters and setters for face information fields.
Definition: face-traits.hpp:37
#define NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ClassName)
Contains classes and functions related to the NFD Management protocol.
bool operator!=(const ChannelStatus &a, const ChannelStatus &b)
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
bool operator==(const ChannelStatus &a, const ChannelStatus &b)
::boost::chrono::milliseconds milliseconds
Definition: time.hpp:52
::boost::chrono::nanoseconds nanoseconds
Definition: time.hpp:54