NFD: Named Data Networking Forwarding Daemon 24.07-28-gdcc0e6e0
Loading...
Searching...
No Matches
pit-entry.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2024, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#ifndef NFD_DAEMON_TABLE_PIT_ENTRY_HPP
27#define NFD_DAEMON_TABLE_PIT_ENTRY_HPP
28
30
31#include <ndn-cxx/util/scheduler.hpp>
32
33#include <list>
34
35namespace nfd {
36
37namespace face {
38class Face;
39} // namespace face
40using face::Face;
41
42namespace name_tree {
43class Entry;
44} // namespace name_tree
45
46namespace pit {
47
54{
55public:
56 explicit
58 : m_face(face)
59 {
60 }
61
62 Face&
63 getFace() const noexcept
64 {
65 return m_face;
66 }
67
68 Interest::Nonce
69 getLastNonce() const noexcept
70 {
71 return m_lastNonce;
72 }
73
74 time::steady_clock::time_point
75 getLastRenewed() const noexcept
76 {
77 return m_lastRenewed;
78 }
79
84 time::steady_clock::time_point
85 getExpiry() const noexcept
86 {
87 return m_expiry;
88 }
89
93 void
94 update(const Interest& interest);
95
96private:
97 Face& m_face;
98 Interest::Nonce m_lastNonce{0, 0, 0, 0};
99 time::steady_clock::time_point m_lastRenewed = time::steady_clock::time_point::min();
100 time::steady_clock::time_point m_expiry = time::steady_clock::time_point::min();
101};
102
106class InRecord : public FaceRecord
107{
108public:
110
111 const Interest&
112 getInterest() const noexcept
113 {
114 BOOST_ASSERT(m_interest != nullptr);
115 return *m_interest;
116 }
117
118 void
119 update(const Interest& interest);
120
121private:
122 shared_ptr<const Interest> m_interest;
123};
124
128class OutRecord : public FaceRecord
129{
130public:
132
139 const lp::NackHeader*
140 getIncomingNack() const noexcept
141 {
142 return m_incomingNack.get();
143 }
144
155 bool
156 setIncomingNack(const lp::Nack& nack);
157
165 void
167 {
168 m_incomingNack.reset();
169 }
170
171private:
172 unique_ptr<lp::NackHeader> m_incomingNack;
173};
174
178using InRecordCollection = std::list<InRecord>;
179
183using OutRecordCollection = std::list<OutRecord>;
184
196class Entry : public StrategyInfoHost, noncopyable
197{
198public:
199 explicit
200 Entry(const Interest& interest);
201
207 const Interest&
209 {
210 return *m_interest;
211 }
212
215 const Name&
216 getName() const
217 {
218 return m_interest->getName();
219 }
220
225 bool
226 canMatch(const Interest& interest, size_t nEqualNameComps = 0) const;
227
228public: // in-record
232 const InRecordCollection&
233 getInRecords() const noexcept
234 {
235 return m_inRecords;
236 }
237
243 bool
244 hasInRecords() const noexcept
245 {
246 return !m_inRecords.empty();
247 }
248
249 InRecordCollection::iterator
250 in_begin() noexcept
251 {
252 return m_inRecords.begin();
253 }
254
255 InRecordCollection::const_iterator
256 in_begin() const noexcept
257 {
258 return m_inRecords.begin();
259 }
260
261 InRecordCollection::iterator
262 in_end() noexcept
263 {
264 return m_inRecords.end();
265 }
266
267 InRecordCollection::const_iterator
268 in_end() const noexcept
269 {
270 return m_inRecords.end();
271 }
272
277 InRecordCollection::iterator
278 findInRecord(const Face& face) noexcept;
279
284 InRecordCollection::iterator
285 insertOrUpdateInRecord(Face& face, const Interest& interest);
286
291 void
292 deleteInRecord(InRecordCollection::const_iterator pos)
293 {
294 m_inRecords.erase(pos);
295 }
296
300 void
301 clearInRecords() noexcept
302 {
303 m_inRecords.clear();
304 }
305
306public: // out-record
311 getOutRecords() const noexcept
312 {
313 return m_outRecords;
314 }
315
322 bool
323 hasOutRecords() const noexcept
324 {
325 return !m_outRecords.empty();
326 }
327
328 OutRecordCollection::iterator
329 out_begin() noexcept
330 {
331 return m_outRecords.begin();
332 }
333
334 OutRecordCollection::const_iterator
335 out_begin() const noexcept
336 {
337 return m_outRecords.begin();
338 }
339
340 OutRecordCollection::iterator
341 out_end() noexcept
342 {
343 return m_outRecords.end();
344 }
345
346 OutRecordCollection::const_iterator
347 out_end() const noexcept
348 {
349 return m_outRecords.end();
350 }
351
356 OutRecordCollection::iterator
357 findOutRecord(const Face& face) noexcept;
358
363 OutRecordCollection::iterator
364 insertOrUpdateOutRecord(Face& face, const Interest& interest);
365
369 void
370 deleteOutRecord(const Face& face);
371
372public:
377 ndn::scheduler::EventId expiryTimer;
378
381 bool isSatisfied = false;
382
386 time::milliseconds dataFreshnessPeriod = 0_ms;
387
388private:
389 shared_ptr<const Interest> m_interest;
390 InRecordCollection m_inRecords;
391 OutRecordCollection m_outRecords;
392
393 name_tree::Entry* m_nameTreeEntry = nullptr;
394
395 friend ::nfd::name_tree::Entry;
396};
397
398} // namespace pit
399} // namespace nfd
400
401#endif // NFD_DAEMON_TABLE_PIT_ENTRY_HPP
Base class for an entity onto which StrategyInfo items may be placed.
Generalization of a network interface.
Definition face.hpp:118
An entry in the name tree.
Represents an entry in the Interest table (PIT).
time::milliseconds dataFreshnessPeriod
Data freshness period.
bool canMatch(const Interest &interest, size_t nEqualNameComps=0) const
Definition pit-entry.cpp:68
InRecordCollection::const_iterator in_end() const noexcept
InRecordCollection::iterator in_begin() noexcept
const Name & getName() const
OutRecordCollection::const_iterator out_end() const noexcept
OutRecordCollection::iterator out_begin() noexcept
void deleteInRecord(InRecordCollection::const_iterator pos)
Removes the in-record at position pos.
const Interest & getInterest() const
void clearInRecords() noexcept
Removes all in-records.
bool isSatisfied
Indicates whether this PIT entry is satisfied.
OutRecordCollection::iterator findOutRecord(const Face &face) noexcept
Get the out-record for face.
OutRecordCollection::iterator out_end() noexcept
const InRecordCollection & getInRecords() const noexcept
Returns the collection of in-records.
OutRecordCollection::iterator insertOrUpdateOutRecord(Face &face, const Interest &interest)
Insert or update an out-record.
InRecordCollection::iterator in_end() noexcept
InRecordCollection::iterator findInRecord(const Face &face) noexcept
Get the in-record for face.
Definition pit-entry.cpp:81
OutRecordCollection::const_iterator out_begin() const noexcept
ndn::scheduler::EventId expiryTimer
Expiry timer.
bool hasOutRecords() const noexcept
InRecordCollection::iterator insertOrUpdateInRecord(Face &face, const Interest &interest)
Insert or update an in-record.
Definition pit-entry.cpp:88
InRecordCollection::const_iterator in_begin() const noexcept
bool hasInRecords() const noexcept
const OutRecordCollection & getOutRecords() const noexcept
Returns the collection of out-records.
void deleteOutRecord(const Face &face)
Delete the out-record for face if it exists.
Contains information about an Interest on an incoming or outgoing face.
Definition pit-entry.hpp:54
Face & getFace() const noexcept
Definition pit-entry.hpp:63
time::steady_clock::time_point getExpiry() const noexcept
Returns the time point at which this record expires.
Definition pit-entry.hpp:85
void update(const Interest &interest)
Updates lastNonce, lastRenewed, expiry fields.
Definition pit-entry.cpp:33
time::steady_clock::time_point getLastRenewed() const noexcept
Definition pit-entry.hpp:75
FaceRecord(Face &face)
Definition pit-entry.hpp:57
Interest::Nonce getLastNonce() const noexcept
Definition pit-entry.hpp:69
Contains information about an Interest from an incoming face.
void update(const Interest &interest)
Definition pit-entry.cpp:45
const Interest & getInterest() const noexcept
Contains information about an Interest toward an outgoing face.
void clearIncomingNack() noexcept
Clears last Nack.
bool setIncomingNack(const lp::Nack &nack)
Sets a Nack received from getFace().
Definition pit-entry.cpp:52
const lp::NackHeader * getIncomingNack() const noexcept
Returns the last Nack returned by getFace().
std::list< OutRecord > OutRecordCollection
An unordered collection of out-records.
std::list< InRecord > InRecordCollection
An unordered collection of in-records.
Definition common.hpp:71