Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Teng Liang | 6f09ab6 | 2018-03-01 20:04:08 -0700 | [diff] [blame] | 2 | /* |
Davide Pesavento | 2c9d2ca | 2024-01-27 16:36:51 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2024, Regents of the University of California, |
Junxiao Shi | 1e46be3 | 2015-01-08 20:18:05 -0700 | [diff] [blame] | 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. |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 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/>. |
Alexander Afanasyev | 28d586a | 2014-07-10 20:10:54 -0700 | [diff] [blame] | 24 | */ |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 25 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 26 | #ifndef NFD_DAEMON_TABLE_PIT_ENTRY_HPP |
| 27 | #define NFD_DAEMON_TABLE_PIT_ENTRY_HPP |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 28 | |
Davide Pesavento | b124b8e | 2024-02-16 16:54:26 -0500 | [diff] [blame] | 29 | #include "strategy-info-host.hpp" |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 30 | |
Davide Pesavento | 2c9d2ca | 2024-01-27 16:36:51 -0500 | [diff] [blame] | 31 | #include <ndn-cxx/util/scheduler.hpp> |
| 32 | |
Davide Pesavento | c0822fa | 2018-05-10 21:54:10 -0400 | [diff] [blame] | 33 | #include <list> |
| 34 | |
Davide Pesavento | b124b8e | 2024-02-16 16:54:26 -0500 | [diff] [blame] | 35 | namespace nfd { |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 36 | |
Davide Pesavento | b124b8e | 2024-02-16 16:54:26 -0500 | [diff] [blame] | 37 | namespace face { |
| 38 | class Face; |
| 39 | } // namespace face |
| 40 | using face::Face; |
| 41 | |
| 42 | namespace name_tree { |
| 43 | class Entry; |
| 44 | } // namespace name_tree |
| 45 | |
| 46 | namespace pit { |
| 47 | |
| 48 | /** |
| 49 | * \brief Contains information about an Interest on an incoming or outgoing face. |
| 50 | * \note This class is an implementation detail to extract common functionality |
| 51 | * of InRecord and OutRecord. |
| 52 | */ |
| 53 | class FaceRecord : public StrategyInfoHost |
| 54 | { |
| 55 | public: |
| 56 | explicit |
| 57 | FaceRecord(Face& face) |
| 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 | |
| 80 | /** |
| 81 | * \brief Returns the time point at which this record expires. |
| 82 | * \return getLastRenewed() + InterestLifetime |
| 83 | */ |
| 84 | time::steady_clock::time_point |
| 85 | getExpiry() const noexcept |
| 86 | { |
| 87 | return m_expiry; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * \brief Updates lastNonce, lastRenewed, expiry fields. |
| 92 | */ |
| 93 | void |
| 94 | update(const Interest& interest); |
| 95 | |
| 96 | private: |
| 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 | |
| 103 | /** |
| 104 | * \brief Contains information about an Interest from an incoming face. |
| 105 | */ |
| 106 | class InRecord : public FaceRecord |
| 107 | { |
| 108 | public: |
| 109 | using FaceRecord::FaceRecord; |
| 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 | |
| 121 | private: |
| 122 | shared_ptr<const Interest> m_interest; |
| 123 | }; |
| 124 | |
| 125 | /** |
| 126 | * \brief Contains information about an Interest toward an outgoing face. |
| 127 | */ |
| 128 | class OutRecord : public FaceRecord |
| 129 | { |
| 130 | public: |
| 131 | using FaceRecord::FaceRecord; |
| 132 | |
| 133 | /** |
| 134 | * \brief Returns the last Nack returned by getFace(). |
| 135 | * |
| 136 | * A nullptr return value means the Interest is still pending or has timed out. |
| 137 | * A non-null return value means the last outgoing Interest has been Nacked. |
| 138 | */ |
| 139 | const lp::NackHeader* |
| 140 | getIncomingNack() const noexcept |
| 141 | { |
| 142 | return m_incomingNack.get(); |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * \brief Sets a Nack received from getFace(). |
| 147 | * \return whether incoming Nack is accepted |
| 148 | * |
| 149 | * This is invoked in incoming Nack pipeline. |
| 150 | * |
| 151 | * An incoming Nack is accepted if its Nonce matches getLastNonce(). |
| 152 | * If accepted, `nack.getHeader()` will be copied, and any pointers |
| 153 | * previously returned by getIncomingNack() are invalidated. |
| 154 | */ |
| 155 | bool |
| 156 | setIncomingNack(const lp::Nack& nack); |
| 157 | |
| 158 | /** |
| 159 | * \brief Clears last Nack. |
| 160 | * |
| 161 | * This is invoked in outgoing Interest pipeline. |
| 162 | * |
| 163 | * Any pointers previously returned by getIncomingNack() are invalidated. |
| 164 | */ |
| 165 | void |
| 166 | clearIncomingNack() noexcept |
| 167 | { |
| 168 | m_incomingNack.reset(); |
| 169 | } |
| 170 | |
| 171 | private: |
| 172 | unique_ptr<lp::NackHeader> m_incomingNack; |
| 173 | }; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 174 | |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 175 | /** |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 176 | * \brief An unordered collection of in-records. |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 177 | */ |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 178 | using InRecordCollection = std::list<InRecord>; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 179 | |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 180 | /** |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 181 | * \brief An unordered collection of out-records. |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 182 | */ |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 183 | using OutRecordCollection = std::list<OutRecord>; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 184 | |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 185 | /** |
| 186 | * \brief Represents an entry in the %Interest table (PIT). |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 187 | * |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 188 | * An Interest table entry represents either a pending Interest or a recently satisfied Interest. |
| 189 | * Each entry contains a collection of in-records, a collection of out-records, |
| 190 | * and two timers used in forwarding pipelines. |
| 191 | * In addition, the entry, in-records, and out-records are subclasses of StrategyInfoHost, |
| 192 | * which allows forwarding strategy to store arbitrary information on them. |
| 193 | * |
| 194 | * \sa Pit |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 195 | */ |
Junxiao Shi | 408a700 | 2014-02-12 17:53:47 -0700 | [diff] [blame] | 196 | class Entry : public StrategyInfoHost, noncopyable |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 197 | { |
| 198 | public: |
| 199 | explicit |
| 200 | Entry(const Interest& interest); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 201 | |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 202 | /** \return the representative Interest of the PIT entry |
| 203 | * \note Every Interest in in-records and out-records should have same Name and Selectors |
| 204 | * as the representative Interest. |
| 205 | * \todo #3162 require Link field to match the representative Interest |
| 206 | */ |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 207 | const Interest& |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 208 | getInterest() const |
| 209 | { |
| 210 | return *m_interest; |
| 211 | } |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 212 | |
| 213 | /** \return Interest Name |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 214 | */ |
| 215 | const Name& |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 216 | getName() const |
| 217 | { |
| 218 | return m_interest->getName(); |
| 219 | } |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 220 | |
Junxiao Shi | a274292 | 2016-11-17 22:53:23 +0000 | [diff] [blame] | 221 | /** \return whether interest matches this entry |
| 222 | * \param interest the Interest |
| 223 | * \param nEqualNameComps number of initial name components guaranteed to be equal |
| 224 | */ |
| 225 | bool |
| 226 | canMatch(const Interest& interest, size_t nEqualNameComps = 0) const; |
| 227 | |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 228 | public: // in-record |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 229 | /** |
| 230 | * \brief Returns the collection of in-records. |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 231 | */ |
Junxiao Shi | 66f91f8 | 2014-05-10 17:28:58 -0700 | [diff] [blame] | 232 | const InRecordCollection& |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 233 | getInRecords() const noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 234 | { |
| 235 | return m_inRecords; |
| 236 | } |
Junxiao Shi | 66f91f8 | 2014-05-10 17:28:58 -0700 | [diff] [blame] | 237 | |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 238 | /** \retval true There is at least one in-record. |
| 239 | * This implies some downstream is waiting for Data or Nack. |
| 240 | * \retval false There is no in-record. |
| 241 | * This implies the entry is new or has been satisfied or Nacked. |
| 242 | */ |
| 243 | bool |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 244 | hasInRecords() const noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 245 | { |
| 246 | return !m_inRecords.empty(); |
| 247 | } |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 248 | |
| 249 | InRecordCollection::iterator |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 250 | in_begin() noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 251 | { |
| 252 | return m_inRecords.begin(); |
| 253 | } |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 254 | |
| 255 | InRecordCollection::const_iterator |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 256 | in_begin() const noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 257 | { |
| 258 | return m_inRecords.begin(); |
| 259 | } |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 260 | |
| 261 | InRecordCollection::iterator |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 262 | in_end() noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 263 | { |
| 264 | return m_inRecords.end(); |
| 265 | } |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 266 | |
| 267 | InRecordCollection::const_iterator |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 268 | in_end() const noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 269 | { |
| 270 | return m_inRecords.end(); |
| 271 | } |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 272 | |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 273 | /** |
| 274 | * \brief Get the in-record for \p face. |
| 275 | * \return an iterator to the in-record, or in_end() if it does not exist |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 276 | */ |
| 277 | InRecordCollection::iterator |
Davide Pesavento | 972de80 | 2024-02-16 18:42:55 -0500 | [diff] [blame] | 278 | findInRecord(const Face& face) noexcept; |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 279 | |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 280 | /** |
| 281 | * \brief Insert or update an in-record. |
| 282 | * \return an iterator to the new or updated in-record |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 283 | */ |
| 284 | InRecordCollection::iterator |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 285 | insertOrUpdateInRecord(Face& face, const Interest& interest); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 286 | |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 287 | /** |
| 288 | * \brief Removes the in-record at position \p pos. |
| 289 | * \param pos iterator to the in-record to remove; must be valid and dereferenceable. |
Junxiao Shi | 66f91f8 | 2014-05-10 17:28:58 -0700 | [diff] [blame] | 290 | */ |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 291 | void |
Davide Pesavento | b124b8e | 2024-02-16 16:54:26 -0500 | [diff] [blame] | 292 | deleteInRecord(InRecordCollection::const_iterator pos) |
| 293 | { |
| 294 | m_inRecords.erase(pos); |
| 295 | } |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 296 | |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 297 | /** |
| 298 | * \brief Removes all in-records. |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 299 | */ |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 300 | void |
Davide Pesavento | b124b8e | 2024-02-16 16:54:26 -0500 | [diff] [blame] | 301 | clearInRecords() noexcept |
| 302 | { |
| 303 | m_inRecords.clear(); |
| 304 | } |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 305 | |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 306 | public: // out-record |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 307 | /** |
| 308 | * \brief Returns the collection of out-records. |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 309 | */ |
Junxiao Shi | 66f91f8 | 2014-05-10 17:28:58 -0700 | [diff] [blame] | 310 | const OutRecordCollection& |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 311 | getOutRecords() const noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 312 | { |
| 313 | return m_outRecords; |
| 314 | } |
Junxiao Shi | 66f91f8 | 2014-05-10 17:28:58 -0700 | [diff] [blame] | 315 | |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 316 | /** \retval true There is at least one out-record. |
| 317 | * This implies the Interest has been forwarded to some upstream, |
| 318 | * and they haven't returned Data, but may have returned Nacks. |
| 319 | * \retval false There is no out-record. |
| 320 | * This implies the Interest has not been forwarded. |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 321 | */ |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 322 | bool |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 323 | hasOutRecords() const noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 324 | { |
| 325 | return !m_outRecords.empty(); |
| 326 | } |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 327 | |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 328 | OutRecordCollection::iterator |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 329 | out_begin() noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 330 | { |
| 331 | return m_outRecords.begin(); |
| 332 | } |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 333 | |
| 334 | OutRecordCollection::const_iterator |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 335 | out_begin() const noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 336 | { |
| 337 | return m_outRecords.begin(); |
| 338 | } |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 339 | |
| 340 | OutRecordCollection::iterator |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 341 | out_end() noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 342 | { |
| 343 | return m_outRecords.end(); |
| 344 | } |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 345 | |
| 346 | OutRecordCollection::const_iterator |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 347 | out_end() const noexcept |
Junxiao Shi | 340d553 | 2016-08-13 04:00:35 +0000 | [diff] [blame] | 348 | { |
| 349 | return m_outRecords.end(); |
| 350 | } |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 351 | |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 352 | /** |
| 353 | * \brief Get the out-record for \p face. |
| 354 | * \return an iterator to the out-record, or out_end() if it does not exist |
Junxiao Shi | 66f91f8 | 2014-05-10 17:28:58 -0700 | [diff] [blame] | 355 | */ |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 356 | OutRecordCollection::iterator |
Davide Pesavento | 972de80 | 2024-02-16 18:42:55 -0500 | [diff] [blame] | 357 | findOutRecord(const Face& face) noexcept; |
Junxiao Shi | 66f91f8 | 2014-05-10 17:28:58 -0700 | [diff] [blame] | 358 | |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 359 | /** |
| 360 | * \brief Insert or update an out-record. |
| 361 | * \return an iterator to the new or updated out-record |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 362 | */ |
| 363 | OutRecordCollection::iterator |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 364 | insertOrUpdateOutRecord(Face& face, const Interest& interest); |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 365 | |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 366 | /** |
| 367 | * \brief Delete the out-record for \p face if it exists. |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 368 | */ |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 369 | void |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 370 | deleteOutRecord(const Face& face); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 371 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 372 | public: |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 373 | /** \brief Expiry timer. |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 374 | * |
| 375 | * This timer is used in forwarding pipelines to delete the entry |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 376 | */ |
Davide Pesavento | 2c9d2ca | 2024-01-27 16:36:51 -0500 | [diff] [blame] | 377 | ndn::scheduler::EventId expiryTimer; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 378 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 379 | /** \brief Indicates whether this PIT entry is satisfied. |
Teng Liang | 6f09ab6 | 2018-03-01 20:04:08 -0700 | [diff] [blame] | 380 | */ |
Davide Pesavento | 50a6af3 | 2019-02-21 00:04:40 -0500 | [diff] [blame] | 381 | bool isSatisfied = false; |
Teng Liang | 6f09ab6 | 2018-03-01 20:04:08 -0700 | [diff] [blame] | 382 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 383 | /** \brief Data freshness period. |
Davide Pesavento | 4d2e788 | 2024-02-15 23:00:21 -0500 | [diff] [blame] | 384 | * \note This field is meaningful only if #isSatisfied is true |
Teng Liang | 6f09ab6 | 2018-03-01 20:04:08 -0700 | [diff] [blame] | 385 | */ |
Davide Pesavento | 50a6af3 | 2019-02-21 00:04:40 -0500 | [diff] [blame] | 386 | time::milliseconds dataFreshnessPeriod = 0_ms; |
Teng Liang | 6f09ab6 | 2018-03-01 20:04:08 -0700 | [diff] [blame] | 387 | |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 388 | private: |
Alexander Afanasyev | 28d586a | 2014-07-10 20:10:54 -0700 | [diff] [blame] | 389 | shared_ptr<const Interest> m_interest; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 390 | InRecordCollection m_inRecords; |
| 391 | OutRecordCollection m_outRecords; |
Junxiao Shi | 57f0f31 | 2014-03-16 11:52:20 -0700 | [diff] [blame] | 392 | |
Davide Pesavento | 50a6af3 | 2019-02-21 00:04:40 -0500 | [diff] [blame] | 393 | name_tree::Entry* m_nameTreeEntry = nullptr; |
HangZhang | cb4fc83 | 2014-03-11 16:57:11 +0800 | [diff] [blame] | 394 | |
Davide Pesavento | 9a28c3f | 2022-06-11 21:50:01 -0400 | [diff] [blame] | 395 | friend ::nfd::name_tree::Entry; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 396 | }; |
| 397 | |
Davide Pesavento | b124b8e | 2024-02-16 16:54:26 -0500 | [diff] [blame] | 398 | } // namespace pit |
| 399 | } // namespace nfd |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 400 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 401 | #endif // NFD_DAEMON_TABLE_PIT_ENTRY_HPP |