Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -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 | faf3eb0 | 2015-02-16 10:50:36 -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/>. |
Junxiao Shi | 82e7f58 | 2014-09-07 15:15:40 -0700 | [diff] [blame] | 24 | */ |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 25 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 26 | #ifndef NFD_DAEMON_FW_STRATEGY_HPP |
| 27 | #define NFD_DAEMON_FW_STRATEGY_HPP |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 28 | |
Junxiao Shi | 2d9bdc8 | 2014-03-02 20:55:42 -0700 | [diff] [blame] | 29 | #include "forwarder.hpp" |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 30 | #include "table/measurements-accessor.hpp" |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 31 | |
Davide Pesavento | a9b09b6 | 2022-06-04 14:07:25 -0400 | [diff] [blame] | 32 | #include <boost/lexical_cast/try_lexical_convert.hpp> |
| 33 | |
Davide Pesavento | 2c9d2ca | 2024-01-27 16:36:51 -0500 | [diff] [blame] | 34 | #include <functional> |
| 35 | #include <map> |
| 36 | #include <set> |
| 37 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 38 | namespace nfd::fw { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 39 | |
Ashlesh Gawande | 1ef93d0 | 2022-04-08 00:25:06 -0400 | [diff] [blame] | 40 | class StrategyParameters; |
| 41 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 42 | /** |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 43 | * \brief Base class of all forwarding strategies. |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 44 | */ |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 45 | class Strategy : noncopyable |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 46 | { |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 47 | public: // registry |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 48 | /** |
| 49 | * \brief Register a strategy type. |
| 50 | * \tparam S subclass of Strategy |
| 51 | * \param strategyName strategy program name, must contain version |
| 52 | * \note It is permitted to register the same strategy type under multiple names, |
| 53 | * which is useful in tests and for creating aliases. |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 54 | */ |
| 55 | template<typename S> |
| 56 | static void |
Junxiao Shi | 037f4ab | 2016-12-13 04:27:06 +0000 | [diff] [blame] | 57 | registerType(const Name& strategyName = S::getStrategyName()) |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 58 | { |
Junxiao Shi | 91f6ee0 | 2016-12-29 21:44:44 +0000 | [diff] [blame] | 59 | BOOST_ASSERT(strategyName.size() > 1); |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 60 | BOOST_ASSERT(strategyName.at(-1).isVersion()); |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 61 | auto r = getRegistry().insert_or_assign(strategyName, [] (auto&&... args) { |
Davide Pesavento | 3dade00 | 2019-03-19 11:29:56 -0600 | [diff] [blame] | 62 | return make_unique<S>(std::forward<decltype(args)>(args)...); |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 63 | }); |
| 64 | BOOST_VERIFY(r.second); |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 65 | } |
| 66 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 67 | /** |
| 68 | * \brief Returns whether a strategy instance can be created from \p instanceName. |
| 69 | * \param instanceName strategy instance name, may contain version and parameters |
| 70 | * \note This function finds a strategy type using the same rules as create(), |
| 71 | * but does not attempt to construct an instance. |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 72 | */ |
| 73 | static bool |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 74 | canCreate(const Name& instanceName); |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 75 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 76 | /** |
| 77 | * \brief Returns a strategy instance created from \p instanceName. |
| 78 | * \retval nullptr if `canCreate(instanceName) == false` |
| 79 | * \throw std::invalid_argument strategy type constructor does not accept the |
| 80 | * specified version or parameters |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 81 | */ |
| 82 | static unique_ptr<Strategy> |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 83 | create(const Name& instanceName, Forwarder& forwarder); |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 84 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 85 | /** |
| 86 | * \brief Returns whether two names will instantiate the same strategy type. |
Junxiao Shi | 55e21b9 | 2017-01-23 03:27:47 +0000 | [diff] [blame] | 87 | */ |
| 88 | static bool |
| 89 | areSameType(const Name& instanceNameA, const Name& instanceNameB); |
| 90 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 91 | /** |
| 92 | * \brief Returns all registered versioned strategy names. |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 93 | */ |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 94 | [[nodiscard]] static std::set<Name> |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 95 | listRegistered(); |
| 96 | |
Ju Pan | 2feb459 | 2019-09-16 20:56:38 +0000 | [diff] [blame] | 97 | public: // constructor, destructor, strategy info |
Davide Pesavento | 3dade00 | 2019-03-19 11:29:56 -0600 | [diff] [blame] | 98 | /** \brief Construct a strategy instance. |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 99 | * \param forwarder a reference to the forwarder, used to enable actions and accessors. |
Davide Pesavento | 3dade00 | 2019-03-19 11:29:56 -0600 | [diff] [blame] | 100 | * \note Strategy subclass constructor must not retain a reference to \p forwarder. |
Junxiao Shi | e93d6a3 | 2014-09-07 16:13:22 -0700 | [diff] [blame] | 101 | */ |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 102 | explicit |
| 103 | Strategy(Forwarder& forwarder); |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 104 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 105 | virtual |
| 106 | ~Strategy(); |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 107 | |
Junxiao Shi | 037f4ab | 2016-12-13 04:27:06 +0000 | [diff] [blame] | 108 | #ifdef DOXYGEN |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 109 | /** |
| 110 | * \brief Returns the strategy's program name. |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 111 | * |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 112 | * The strategy name is defined by the strategy program. |
| 113 | * It must end with a version component. |
Junxiao Shi | 037f4ab | 2016-12-13 04:27:06 +0000 | [diff] [blame] | 114 | */ |
| 115 | static const Name& |
| 116 | getStrategyName(); |
| 117 | #endif |
| 118 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 119 | /** |
| 120 | * \brief Returns the strategy's instance name. |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 121 | * |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 122 | * The instance name is assigned during instantiation. |
| 123 | * It contains a version component and may have extra parameter components. |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 124 | */ |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 125 | const Name& |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 126 | getInstanceName() const noexcept |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 127 | { |
| 128 | return m_name; |
| 129 | } |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 130 | |
Junxiao Shi | 679e927 | 2014-02-15 20:10:21 -0700 | [diff] [blame] | 131 | public: // triggers |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 132 | /** |
| 133 | * \brief Trigger after an Interest is received. |
Junxiao Shi | 679e927 | 2014-02-15 20:10:21 -0700 | [diff] [blame] | 134 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 135 | * The Interest: |
Eric Newberry | c68b2e8 | 2020-04-16 12:40:30 -0700 | [diff] [blame] | 136 | * - has not exceeded HopLimit |
Junxiao Shi | 679e927 | 2014-02-15 20:10:21 -0700 | [diff] [blame] | 137 | * - does not violate Scope |
| 138 | * - is not looped |
| 139 | * - cannot be satisfied by ContentStore |
| 140 | * - is under a namespace managed by this strategy |
| 141 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 142 | * The PIT entry is set to expire after InterestLifetime has elapsed at each downstream. |
Teng Liang | 7003e0b | 2018-03-03 16:03:30 -0700 | [diff] [blame] | 143 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 144 | * The strategy should decide whether and where to forward this Interest. |
Junxiao Shi | 679e927 | 2014-02-15 20:10:21 -0700 | [diff] [blame] | 145 | * - If the strategy decides to forward this Interest, |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 146 | * invoke sendInterest() for each upstream, either now or shortly after via a scheduler event, |
| 147 | * but before the PIT entry expires. |
| 148 | * Optionally, the strategy can invoke setExpiryTimer() to adjust how long it would wait for a response. |
| 149 | * - If the strategy has already forwarded this Interest previously and decides to continue |
| 150 | * waiting, do nothing. |
| 151 | * Optionally, the strategy can invoke setExpiryTimer() to adjust how long it would wait for a response. |
Teng Liang | 7003e0b | 2018-03-03 16:03:30 -0700 | [diff] [blame] | 152 | * - If the strategy concludes that this Interest cannot be satisfied, |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 153 | * invoke rejectPendingInterest() to erase the PIT entry. |
Junxiao Shi | 82e7f58 | 2014-09-07 15:15:40 -0700 | [diff] [blame] | 154 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 155 | * \warning The strategy must not retain a copy of the \p pitEntry shared_ptr after this function |
| 156 | * returns, otherwise undefined behavior may occur. However, the strategy is allowed to |
| 157 | * construct and keep a weak_ptr to \p pitEntry. |
Junxiao Shi | 679e927 | 2014-02-15 20:10:21 -0700 | [diff] [blame] | 158 | */ |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 159 | virtual void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 160 | afterReceiveInterest(const Interest& interest, const FaceEndpoint& ingress, |
Junxiao Shi | 15e98b0 | 2016-08-12 11:21:44 +0000 | [diff] [blame] | 161 | const shared_ptr<pit::Entry>& pitEntry) = 0; |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 162 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 163 | /** |
| 164 | * \brief Trigger after a matching Data is found in the Content Store. |
Junxiao Shi | 22be22c | 2014-02-16 22:53:48 -0700 | [diff] [blame] | 165 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 166 | * In the base class, this method sends \p data to \p ingress. |
Teng Liang | 7003e0b | 2018-03-03 16:03:30 -0700 | [diff] [blame] | 167 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 168 | * \warning The strategy must not retain a copy of the \p pitEntry shared_ptr after this function |
| 169 | * returns, otherwise undefined behavior may occur. However, the strategy is allowed to |
| 170 | * construct and keep a weak_ptr to \p pitEntry. |
Junxiao Shi | 22be22c | 2014-02-16 22:53:48 -0700 | [diff] [blame] | 171 | */ |
| 172 | virtual void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 173 | afterContentStoreHit(const Data& data, const FaceEndpoint& ingress, |
| 174 | const shared_ptr<pit::Entry>& pitEntry); |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 175 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 176 | /** |
| 177 | * \brief Trigger before a PIT entry is satisfied. |
Teng Liang | 85a3663 | 2018-03-21 05:59:34 -0700 | [diff] [blame] | 178 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 179 | * This trigger is invoked when an incoming Data satisfies more than one PIT entry. |
| 180 | * The strategy can collect measurements information, but cannot manipulate Data forwarding. |
| 181 | * When an incoming Data satisfies only one PIT entry, afterReceiveData() is invoked instead |
| 182 | * and given full control over Data forwarding. If a strategy does not override afterReceiveData(), |
| 183 | * the default implementation invokes beforeSatisfyInterest(). |
| 184 | * |
| 185 | * Normally, PIT entries are erased after receiving the first matching Data. |
| 186 | * If the strategy wishes to collect responses from additional upstream nodes, |
| 187 | * it should invoke setExpiryTimer() within this function to prolong the PIT entry lifetime. |
| 188 | * If a Data arrives from another upstream during the extended PIT entry lifetime, this trigger |
| 189 | * will be invoked again. At that time, the strategy must invoke setExpiryTimer() again to |
| 190 | * continue collecting more responses. |
| 191 | * |
| 192 | * In the base class, this method does nothing. |
| 193 | * |
| 194 | * \warning The strategy must not retain a copy of the \p pitEntry shared_ptr after this function |
| 195 | * returns, otherwise undefined behavior may occur. However, the strategy is allowed to |
| 196 | * construct and keep a weak_ptr to \p pitEntry. |
Teng Liang | 85a3663 | 2018-03-21 05:59:34 -0700 | [diff] [blame] | 197 | */ |
| 198 | virtual void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 199 | beforeSatisfyInterest(const Data& data, const FaceEndpoint& ingress, |
| 200 | const shared_ptr<pit::Entry>& pitEntry); |
Teng Liang | 85a3663 | 2018-03-21 05:59:34 -0700 | [diff] [blame] | 201 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 202 | /** |
| 203 | * \brief Trigger after Data is received. |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 204 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 205 | * This trigger is invoked when an incoming Data satisfies exactly one PIT entry, |
| 206 | * and gives the strategy full control over Data forwarding. |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 207 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 208 | * When this trigger is invoked: |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 209 | * - The Data has been verified to satisfy the PIT entry. |
| 210 | * - The PIT entry expiry timer is set to now |
| 211 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 212 | * Inside this function: |
| 213 | * - A strategy should return Data to downstream nodes via sendData() or sendDataToAll(). |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 214 | * - A strategy can modify the Data as long as it still satisfies the PIT entry, such as |
| 215 | * adding or removing congestion marks. |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 216 | * - A strategy can delay Data forwarding by prolonging the PIT entry lifetime via setExpiryTimer(), |
| 217 | * and later forward the Data before the PIT entry is erased. |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 218 | * - A strategy can collect measurements about the upstream. |
| 219 | * - A strategy can collect responses from additional upstream nodes by prolonging the PIT entry |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 220 | * lifetime via setExpiryTimer() every time a Data is received. Note that only one Data should |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 221 | * be returned to each downstream node. |
| 222 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 223 | * In the base class, this method invokes beforeSatisfyInterest() and then returns the Data |
| 224 | * to all downstream faces via sendDataToAll(). |
| 225 | * |
| 226 | * \warning The strategy must not retain a copy of the \p pitEntry shared_ptr after this function |
| 227 | * returns, otherwise undefined behavior may occur. However, the strategy is allowed to |
| 228 | * construct and keep a weak_ptr to \p pitEntry. |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 229 | */ |
| 230 | virtual void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 231 | afterReceiveData(const Data& data, const FaceEndpoint& ingress, |
Junxiao Shi | 15e98b0 | 2016-08-12 11:21:44 +0000 | [diff] [blame] | 232 | const shared_ptr<pit::Entry>& pitEntry); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 233 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 234 | /** |
| 235 | * \brief Trigger after a Nack is received. |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 236 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 237 | * This trigger is invoked when an incoming Nack is received in response to |
| 238 | * an forwarded Interest. |
| 239 | * The Nack has been confirmed to be a response to the last Interest forwarded |
| 240 | * to that upstream, i.e. the PIT out-record exists and has a matching Nonce. |
| 241 | * The NackHeader has been recorded in the PIT out-record. |
| 242 | * |
| 243 | * If the PIT entry is not yet satisfied, its expiry timer remains unchanged. |
| 244 | * Otherwise, the PIT entry will normally expire immediately after this function returns. |
| 245 | * |
| 246 | * If the strategy wishes to collect responses from additional upstream nodes, |
| 247 | * it should invoke setExpiryTimer() within this function to prolong the PIT entry lifetime. |
| 248 | * If a Nack arrives from another upstream during the extended PIT entry lifetime, this trigger |
| 249 | * will be invoked again. At that time, the strategy must invoke setExpiryTimer() again to |
| 250 | * continue collecting more responses. |
| 251 | * |
| 252 | * In the base class, this method does nothing. |
| 253 | * |
| 254 | * \warning The strategy must not retain a copy of the \p pitEntry shared_ptr after this function |
| 255 | * returns, otherwise undefined behavior may occur. However, the strategy is allowed to |
| 256 | * construct and keep a weak_ptr to \p pitEntry. |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 257 | */ |
| 258 | virtual void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 259 | afterReceiveNack(const lp::Nack& nack, const FaceEndpoint& ingress, |
| 260 | const shared_ptr<pit::Entry>& pitEntry); |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 261 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 262 | /** |
| 263 | * \brief Trigger after an Interest is dropped (e.g., for exceeding allowed retransmissions). |
Ju Pan | 2feb459 | 2019-09-16 20:56:38 +0000 | [diff] [blame] | 264 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 265 | * In the base class, this method does nothing. |
| 266 | */ |
| 267 | virtual void |
| 268 | onDroppedInterest(const Interest& interest, Face& egress); |
| 269 | |
| 270 | /** |
| 271 | * \brief Trigger after a new nexthop is added. |
| 272 | * |
| 273 | * The strategy should decide whether to send the buffered Interests to the new nexthop. |
| 274 | * |
| 275 | * In the base class, this method does nothing. |
Ju Pan | 2feb459 | 2019-09-16 20:56:38 +0000 | [diff] [blame] | 276 | */ |
| 277 | virtual void |
| 278 | afterNewNextHop(const fib::NextHop& nextHop, const shared_ptr<pit::Entry>& pitEntry); |
| 279 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 280 | protected: // actions |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 281 | /** |
| 282 | * \brief Send an Interest packet. |
| 283 | * \param interest the Interest packet |
| 284 | * \param egress face through which to send out the Interest |
| 285 | * \param pitEntry the PIT entry |
| 286 | * \return A pointer to the out-record created or nullptr if the Interest was dropped |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 287 | */ |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 288 | NFD_VIRTUAL_WITH_TESTS pit::OutRecord* |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 289 | sendInterest(const Interest& interest, Face& egress, const shared_ptr<pit::Entry>& pitEntry); |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 290 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 291 | /** |
| 292 | * \brief Send a Data packet. |
| 293 | * \param data the Data packet |
| 294 | * \param egress face through which to send out the Data |
| 295 | * \param pitEntry the PIT entry |
| 296 | * \return Whether the Data was sent (true) or dropped (false) |
Teng Liang | 85a3663 | 2018-03-21 05:59:34 -0700 | [diff] [blame] | 297 | */ |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 298 | NFD_VIRTUAL_WITH_TESTS bool |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 299 | sendData(const Data& data, Face& egress, const shared_ptr<pit::Entry>& pitEntry); |
Teng Liang | 85a3663 | 2018-03-21 05:59:34 -0700 | [diff] [blame] | 300 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 301 | /** |
| 302 | * \brief Send a Data packet to all matched and qualified faces. |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 303 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 304 | * A matched face qualifies if it is ad-hoc OR it is NOT \p inFace. |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 305 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 306 | * \param data the Data packet |
| 307 | * \param pitEntry the PIT entry |
| 308 | * \param inFace face on which the Data arrived |
Teng Liang | 43bb231 | 2018-03-26 04:16:42 -0700 | [diff] [blame] | 309 | */ |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 310 | NFD_VIRTUAL_WITH_TESTS void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 311 | sendDataToAll(const Data& data, const shared_ptr<pit::Entry>& pitEntry, const Face& inFace); |
Teng Liang | 85a3663 | 2018-03-21 05:59:34 -0700 | [diff] [blame] | 312 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 313 | /** |
| 314 | * \brief Schedule the PIT entry for immediate deletion. |
Junxiao Shi | 679e927 | 2014-02-15 20:10:21 -0700 | [diff] [blame] | 315 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 316 | * This helper function sets the PIT entry expiry time to zero. |
| 317 | * The strategy should invoke this function when it concludes that the Interest cannot |
| 318 | * be forwarded and it does not want to wait for responses from existing upstream nodes. |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 319 | */ |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 320 | NFD_VIRTUAL_WITH_TESTS void |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 321 | rejectPendingInterest(const shared_ptr<pit::Entry>& pitEntry) |
| 322 | { |
Teng Liang | 7003e0b | 2018-03-03 16:03:30 -0700 | [diff] [blame] | 323 | this->setExpiryTimer(pitEntry, 0_ms); |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 324 | } |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 325 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 326 | /** |
| 327 | * \brief Send a Nack packet. |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 328 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 329 | * The egress face must have a PIT in-record, otherwise this method has no effect. |
Teng Liang | ebc20f6 | 2020-06-23 16:55:20 -0700 | [diff] [blame] | 330 | * |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 331 | * \param header the Nack header |
| 332 | * \param egress face through which to send out the Nack |
| 333 | * \param pitEntry the PIT entry |
| 334 | * \return Whether the Nack was sent (true) or dropped (false) |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 335 | */ |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 336 | NFD_VIRTUAL_WITH_TESTS bool |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 337 | sendNack(const lp::NackHeader& header, Face& egress, const shared_ptr<pit::Entry>& pitEntry) |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 338 | { |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 339 | return m_forwarder.onOutgoingNack(header, egress, pitEntry); |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 340 | } |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 341 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 342 | /** |
| 343 | * \brief Send Nack to every face that has an in-record, except those in \p exceptFaces |
| 344 | * \param header the Nack header |
| 345 | * \param pitEntry the PIT entry |
| 346 | * \param exceptFaces list of faces that should be excluded from sending Nacks |
| 347 | * \note This is not an action, but a helper that invokes the sendNack() action. |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 348 | */ |
| 349 | void |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 350 | sendNacks(const lp::NackHeader& header, const shared_ptr<pit::Entry>& pitEntry, |
Teng Liang | ebc20f6 | 2020-06-23 16:55:20 -0700 | [diff] [blame] | 351 | std::initializer_list<const Face*> exceptFaces = {}); |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 352 | |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 353 | /** |
| 354 | * \brief Schedule the PIT entry to be erased after \p duration. |
Teng Liang | 7003e0b | 2018-03-03 16:03:30 -0700 | [diff] [blame] | 355 | */ |
| 356 | void |
| 357 | setExpiryTimer(const shared_ptr<pit::Entry>& pitEntry, time::milliseconds duration) |
| 358 | { |
| 359 | m_forwarder.setExpiryTimer(pitEntry, duration); |
| 360 | } |
| 361 | |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 362 | protected: // accessors |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 363 | /** |
| 364 | * \brief Performs a FIB lookup, considering Link object if present. |
Junxiao Shi | cf0f3ce | 2016-09-02 13:01:59 +0000 | [diff] [blame] | 365 | */ |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame] | 366 | const fib::Entry& |
Junxiao Shi | cf0f3ce | 2016-09-02 13:01:59 +0000 | [diff] [blame] | 367 | lookupFib(const pit::Entry& pitEntry) const; |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame] | 368 | |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 369 | MeasurementsAccessor& |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 370 | getMeasurements() noexcept |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 371 | { |
| 372 | return m_measurements; |
| 373 | } |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 374 | |
Junxiao Shi | 5b43f9a | 2016-07-19 13:15:56 +0000 | [diff] [blame] | 375 | Face* |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 376 | getFace(FaceId id) const noexcept |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 377 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 378 | return getFaceTable().get(id); |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 379 | } |
Junxiao Shi | 2d9bdc8 | 2014-03-02 20:55:42 -0700 | [diff] [blame] | 380 | |
Junxiao Shi | 49e11e7 | 2014-12-14 19:46:05 -0700 | [diff] [blame] | 381 | const FaceTable& |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 382 | getFaceTable() const noexcept |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 383 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 384 | return m_forwarder.m_faceTable; |
Junxiao Shi | b9420cf | 2016-08-13 04:38:52 +0000 | [diff] [blame] | 385 | } |
Junxiao Shi | 49e11e7 | 2014-12-14 19:46:05 -0700 | [diff] [blame] | 386 | |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 387 | protected: // instance name |
| 388 | struct ParsedInstanceName |
| 389 | { |
Ashlesh Gawande | 1ef93d0 | 2022-04-08 00:25:06 -0400 | [diff] [blame] | 390 | Name strategyName; ///< Strategy name without parameters |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 391 | std::optional<uint64_t> version; ///< The strategy version number, if present |
Ashlesh Gawande | 1ef93d0 | 2022-04-08 00:25:06 -0400 | [diff] [blame] | 392 | PartialName parameters; ///< Parameter components, may be empty |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 393 | }; |
| 394 | |
Eric Newberry | c68b2e8 | 2020-04-16 12:40:30 -0700 | [diff] [blame] | 395 | /** \brief Parse a strategy instance name |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 396 | * \param input strategy instance name, may contain version and parameters |
| 397 | * \throw std::invalid_argument input format is unacceptable |
| 398 | */ |
| 399 | static ParsedInstanceName |
| 400 | parseInstanceName(const Name& input); |
| 401 | |
Eric Newberry | c68b2e8 | 2020-04-16 12:40:30 -0700 | [diff] [blame] | 402 | /** \brief Construct a strategy instance name |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 403 | * \param input strategy instance name, may contain version and parameters |
| 404 | * \param strategyName strategy name with version but without parameters; |
| 405 | * typically this should be \p getStrategyName() |
| 406 | * |
| 407 | * If \p input contains a version component, return \p input unchanged. |
| 408 | * Otherwise, return \p input plus the version component taken from \p strategyName. |
| 409 | * This allows a strategy instance to be constructed with an unversioned name, |
| 410 | * but its final instance name should contain the version. |
| 411 | */ |
| 412 | static Name |
| 413 | makeInstanceName(const Name& input, const Name& strategyName); |
| 414 | |
Eric Newberry | c68b2e8 | 2020-04-16 12:40:30 -0700 | [diff] [blame] | 415 | /** \brief Set strategy instance name |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 416 | * \note This must be called by strategy subclass constructor. |
| 417 | */ |
| 418 | void |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 419 | setInstanceName(const Name& name) noexcept |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 420 | { |
| 421 | m_name = name; |
| 422 | } |
Junxiao Shi | 49e11e7 | 2014-12-14 19:46:05 -0700 | [diff] [blame] | 423 | |
Ashlesh Gawande | 1ef93d0 | 2022-04-08 00:25:06 -0400 | [diff] [blame] | 424 | NFD_PUBLIC_WITH_TESTS_ELSE_PROTECTED: |
| 425 | /** |
| 426 | * \brief Parse strategy parameters encoded in a strategy instance name |
| 427 | * \param params encoded parameters, typically obtained from a call to parseInstanceName() |
| 428 | * \throw std::invalid_argument the encoding format is invalid or unsupported by this implementation |
| 429 | */ |
| 430 | static StrategyParameters |
| 431 | parseParameters(const PartialName& params); |
| 432 | |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 433 | private: // registry |
Davide Pesavento | 0498ce8 | 2021-06-14 02:02:21 -0400 | [diff] [blame] | 434 | using CreateFunc = std::function<unique_ptr<Strategy>(Forwarder&, const Name& /*strategyName*/)>; |
| 435 | using Registry = std::map<Name, CreateFunc>; // indexed by strategy name |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 436 | |
| 437 | static Registry& |
| 438 | getRegistry(); |
| 439 | |
| 440 | static Registry::const_iterator |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame] | 441 | find(const Name& instanceName); |
| 442 | |
| 443 | protected: // accessors |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 444 | signal::Signal<FaceTable, Face>& afterAddFace; |
| 445 | signal::Signal<FaceTable, Face>& beforeRemoveFace; |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 446 | |
| 447 | private: // instance fields |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 448 | Name m_name; |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 449 | Forwarder& m_forwarder; |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 450 | MeasurementsAccessor m_measurements; |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 451 | }; |
| 452 | |
Ashlesh Gawande | 1ef93d0 | 2022-04-08 00:25:06 -0400 | [diff] [blame] | 453 | class StrategyParameters : public std::map<std::string, std::string> |
| 454 | { |
| 455 | public: |
| 456 | // Note: only arithmetic types are supported by getOrDefault() for now |
| 457 | |
| 458 | template<typename T> |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 459 | std::enable_if_t<std::is_signed_v<T>, T> |
Ashlesh Gawande | 1ef93d0 | 2022-04-08 00:25:06 -0400 | [diff] [blame] | 460 | getOrDefault(const key_type& key, const T& defaultVal) const |
| 461 | { |
| 462 | auto it = find(key); |
| 463 | if (it == end()) { |
| 464 | return defaultVal; |
| 465 | } |
| 466 | |
| 467 | T val{}; |
| 468 | if (!boost::conversion::try_lexical_convert(it->second, val)) { |
| 469 | NDN_THROW(std::invalid_argument(key + " value is malformed")); |
| 470 | } |
| 471 | return val; |
| 472 | } |
| 473 | |
| 474 | template<typename T> |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 475 | std::enable_if_t<std::is_unsigned_v<T>, T> |
Ashlesh Gawande | 1ef93d0 | 2022-04-08 00:25:06 -0400 | [diff] [blame] | 476 | getOrDefault(const key_type& key, const T& defaultVal) const |
| 477 | { |
| 478 | auto it = find(key); |
| 479 | if (it == end()) { |
| 480 | return defaultVal; |
| 481 | } |
| 482 | |
| 483 | if (it->second.find('-') != std::string::npos) { |
| 484 | NDN_THROW(std::invalid_argument(key + " cannot be negative")); |
| 485 | } |
| 486 | |
| 487 | T val{}; |
| 488 | if (!boost::conversion::try_lexical_convert(it->second, val)) { |
| 489 | NDN_THROW(std::invalid_argument(key + " value is malformed")); |
| 490 | } |
| 491 | return val; |
| 492 | } |
| 493 | }; |
| 494 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 495 | } // namespace nfd::fw |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 496 | |
Alex Lane | 653eb07 | 2023-07-27 22:11:46 -0400 | [diff] [blame] | 497 | /** |
| 498 | * \brief Registers a forwarding strategy. |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 499 | * |
Alex Lane | 653eb07 | 2023-07-27 22:11:46 -0400 | [diff] [blame] | 500 | * This macro should appear once in the `.cpp` of each strategy. |
Junxiao Shi | c34d167 | 2016-12-09 15:57:59 +0000 | [diff] [blame] | 501 | */ |
| 502 | #define NFD_REGISTER_STRATEGY(S) \ |
| 503 | static class NfdAuto ## S ## StrategyRegistrationClass \ |
| 504 | { \ |
| 505 | public: \ |
| 506 | NfdAuto ## S ## StrategyRegistrationClass() \ |
| 507 | { \ |
| 508 | ::nfd::fw::Strategy::registerType<S>(); \ |
| 509 | } \ |
| 510 | } g_nfdAuto ## S ## StrategyRegistrationVariable |
| 511 | |
Alex Lane | 653eb07 | 2023-07-27 22:11:46 -0400 | [diff] [blame] | 512 | /// Logs the reception of \p interest on \p ingress, followed by \p msg, at DEBUG level. |
| 513 | #define NFD_LOG_INTEREST_FROM(interest, ingress, msg) \ |
| 514 | NFD_LOG_DEBUG("interest=" << (interest).getName() << \ |
| 515 | " nonce=" << (interest).getNonce() << \ |
| 516 | " from=" << (ingress) << \ |
| 517 | ' ' << msg) |
| 518 | |
| 519 | /// Logs the reception of \p data on \p ingress, followed by \p msg, at DEBUG level. |
| 520 | #define NFD_LOG_DATA_FROM(data, ingress, msg) \ |
| 521 | NFD_LOG_DEBUG("data=" << (data).getName() << \ |
| 522 | " from=" << (ingress) << \ |
| 523 | ' ' << msg) |
| 524 | |
| 525 | /// Logs the reception of \p nack on \p ingress, followed by \p msg, at DEBUG level. |
| 526 | #define NFD_LOG_NACK_FROM(nack, ingress, msg) \ |
| 527 | NFD_LOG_DEBUG("nack=" << (nack).getInterest().getName() << \ |
| 528 | " nonce=" << (nack).getInterest().getNonce() << \ |
| 529 | " reason=" << (nack).getReason() << \ |
| 530 | " from=" << (ingress) << \ |
| 531 | ' ' << msg) |
| 532 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 533 | #endif // NFD_DAEMON_FW_STRATEGY_HPP |