Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | 330136a | 2016-03-10 04:53:08 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, 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. |
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 | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 24 | */ |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 25 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 26 | #ifndef NFD_DAEMON_FW_FORWARDER_HPP |
| 27 | #define NFD_DAEMON_FW_FORWARDER_HPP |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 28 | |
| 29 | #include "common.hpp" |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 30 | #include "core/scheduler.hpp" |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 31 | #include "forwarder-counters.hpp" |
Junxiao Shi | a4f2be8 | 2014-03-02 22:56:41 -0700 | [diff] [blame] | 32 | #include "face-table.hpp" |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 33 | #include "table/fib.hpp" |
| 34 | #include "table/pit.hpp" |
| 35 | #include "table/cs.hpp" |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 36 | #include "table/measurements.hpp" |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 37 | #include "table/strategy-choice.hpp" |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 38 | #include "table/dead-nonce-list.hpp" |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 39 | #include "table/network-region-table.hpp" |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 40 | |
Spyridon Mastorakis | 31d4a08 | 2014-12-05 22:43:34 -0800 | [diff] [blame] | 41 | #include "ns3/ndnSIM/model/cs/ndn-content-store.hpp" |
| 42 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 43 | namespace nfd { |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 44 | |
Junxiao Shi | 2d9bdc8 | 2014-03-02 20:55:42 -0700 | [diff] [blame] | 45 | namespace fw { |
| 46 | class Strategy; |
| 47 | } // namespace fw |
| 48 | |
Alexander Afanasyev | d980dcd | 2015-01-08 21:41:48 -0800 | [diff] [blame] | 49 | class NullFace; |
| 50 | |
Junxiao Shi | 2d9bdc8 | 2014-03-02 20:55:42 -0700 | [diff] [blame] | 51 | /** \brief main class of NFD |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 52 | * |
Junxiao Shi | 2d9bdc8 | 2014-03-02 20:55:42 -0700 | [diff] [blame] | 53 | * Forwarder owns all faces and tables, and implements forwarding pipelines. |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 54 | */ |
| 55 | class Forwarder |
| 56 | { |
| 57 | public: |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 58 | Forwarder(); |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 59 | |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 60 | VIRTUAL_WITH_TESTS |
| 61 | ~Forwarder(); |
| 62 | |
Junxiao Shi | b289cc1 | 2014-03-15 12:19:05 -0700 | [diff] [blame] | 63 | const ForwarderCounters& |
| 64 | getCounters() const; |
| 65 | |
Junxiao Shi | a4f2be8 | 2014-03-02 22:56:41 -0700 | [diff] [blame] | 66 | public: // faces |
| 67 | FaceTable& |
| 68 | getFaceTable(); |
| 69 | |
| 70 | /** \brief get existing Face |
| 71 | * |
| 72 | * shortcut to .getFaceTable().get(face) |
| 73 | */ |
| 74 | shared_ptr<Face> |
| 75 | getFace(FaceId id) const; |
| 76 | |
| 77 | /** \brief add new Face |
| 78 | * |
| 79 | * shortcut to .getFaceTable().add(face) |
| 80 | */ |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 81 | void |
| 82 | addFace(shared_ptr<Face> face); |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 83 | |
Junxiao Shi | a4f2be8 | 2014-03-02 22:56:41 -0700 | [diff] [blame] | 84 | public: // forwarding entrypoints and tables |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 85 | /** \brief start incoming Interest processing |
Alexander Afanasyev | b755e9d | 2015-10-20 17:35:51 -0500 | [diff] [blame] | 86 | * \param face face on which Interest is received |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 87 | * \param interest the incoming Interest, must be created with make_shared |
| 88 | */ |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 89 | void |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 90 | startProcessInterest(Face& face, const Interest& interest); |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 91 | |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 92 | /** \brief start incoming Data processing |
Alexander Afanasyev | b755e9d | 2015-10-20 17:35:51 -0500 | [diff] [blame] | 93 | * \param face face on which Data is received |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 94 | * \param data the incoming Data, must be created with make_shared |
| 95 | */ |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 96 | void |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 97 | startProcessData(Face& face, const Data& data); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 98 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 99 | /** \brief start incoming Nack processing |
Alexander Afanasyev | b755e9d | 2015-10-20 17:35:51 -0500 | [diff] [blame] | 100 | * \param face face on which Nack is received |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 101 | * \param nack the incoming Nack, must be created with make_shared |
| 102 | */ |
| 103 | void |
| 104 | startProcessNack(Face& face, const lp::Nack& nack); |
| 105 | |
Junxiao Shi | ea48d8b | 2014-03-16 13:53:47 -0700 | [diff] [blame] | 106 | NameTree& |
| 107 | getNameTree(); |
| 108 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 109 | Fib& |
| 110 | getFib(); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 111 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 112 | Pit& |
| 113 | getPit(); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 114 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 115 | Cs& |
| 116 | getCs(); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 117 | |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 118 | Measurements& |
| 119 | getMeasurements(); |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 120 | |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 121 | StrategyChoice& |
| 122 | getStrategyChoice(); |
| 123 | |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 124 | DeadNonceList& |
| 125 | getDeadNonceList(); |
| 126 | |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 127 | NetworkRegionTable& |
| 128 | getNetworkRegionTable(); |
| 129 | |
Spyridon Mastorakis | 31d4a08 | 2014-12-05 22:43:34 -0800 | [diff] [blame] | 130 | public: // allow enabling ndnSIM content store (will be removed in the future) |
| 131 | void |
| 132 | setCsFromNdnSim(ns3::Ptr<ns3::ndn::ContentStore> cs); |
| 133 | |
Alexander Afanasyev | d980dcd | 2015-01-08 21:41:48 -0800 | [diff] [blame] | 134 | public: |
| 135 | /** \brief trigger before PIT entry is satisfied |
| 136 | * \sa Strategy::beforeSatisfyInterest |
| 137 | */ |
| 138 | signal::Signal<Forwarder, pit::Entry, Face, Data> beforeSatisfyInterest; |
| 139 | |
| 140 | /** \brief trigger before PIT entry expires |
| 141 | * \sa Strategy::beforeExpirePendingInterest |
| 142 | */ |
| 143 | signal::Signal<Forwarder, pit::Entry> beforeExpirePendingInterest; |
| 144 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 145 | PUBLIC_WITH_TESTS_ELSE_PRIVATE: // pipelines |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 146 | /** \brief incoming Interest pipeline |
| 147 | */ |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 148 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 149 | onIncomingInterest(Face& inFace, const Interest& interest); |
| 150 | |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 151 | /** \brief Interest loop pipeline |
| 152 | */ |
| 153 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | 330136a | 2016-03-10 04:53:08 -0700 | [diff] [blame] | 154 | onInterestLoop(Face& inFace, const Interest& interest); |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 155 | |
mzhang4 | eab7249 | 2015-02-25 11:16:09 -0600 | [diff] [blame] | 156 | /** \brief Content Store miss pipeline |
| 157 | */ |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 158 | VIRTUAL_WITH_TESTS void |
mzhang4 | eab7249 | 2015-02-25 11:16:09 -0600 | [diff] [blame] | 159 | onContentStoreMiss(const Face& inFace, shared_ptr<pit::Entry> pitEntry, const Interest& interest); |
| 160 | |
| 161 | /** \brief Content Store hit pipeline |
| 162 | */ |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 163 | VIRTUAL_WITH_TESTS void |
mzhang4 | eab7249 | 2015-02-25 11:16:09 -0600 | [diff] [blame] | 164 | onContentStoreHit(const Face& inFace, shared_ptr<pit::Entry> pitEntry, |
| 165 | const Interest& interest, const Data& data); |
| 166 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 167 | /** \brief outgoing Interest pipeline |
| 168 | */ |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 169 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | d938a6b | 2014-05-11 23:40:29 -0700 | [diff] [blame] | 170 | onOutgoingInterest(shared_ptr<pit::Entry> pitEntry, Face& outFace, |
| 171 | bool wantNewNonce = false); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 172 | |
Junxiao Shi | 09498f0 | 2014-02-26 19:41:08 -0700 | [diff] [blame] | 173 | /** \brief Interest reject pipeline |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 174 | */ |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 175 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | 09498f0 | 2014-02-26 19:41:08 -0700 | [diff] [blame] | 176 | onInterestReject(shared_ptr<pit::Entry> pitEntry); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 177 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 178 | /** \brief Interest unsatisfied pipeline |
| 179 | */ |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 180 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 181 | onInterestUnsatisfied(shared_ptr<pit::Entry> pitEntry); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 182 | |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 183 | /** \brief Interest finalize pipeline |
| 184 | * \param isSatisfied whether the Interest has been satisfied |
| 185 | * \param dataFreshnessPeriod FreshnessPeriod of satisfying Data |
| 186 | */ |
| 187 | VIRTUAL_WITH_TESTS void |
| 188 | onInterestFinalize(shared_ptr<pit::Entry> pitEntry, bool isSatisfied, |
| 189 | const time::milliseconds& dataFreshnessPeriod = time::milliseconds(-1)); |
| 190 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 191 | /** \brief incoming Data pipeline |
| 192 | */ |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 193 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 194 | onIncomingData(Face& inFace, const Data& data); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 195 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 196 | /** \brief Data unsolicited pipeline |
| 197 | */ |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 198 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 199 | onDataUnsolicited(Face& inFace, const Data& data); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 200 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 201 | /** \brief outgoing Data pipeline |
| 202 | */ |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 203 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 204 | onOutgoingData(const Data& data, Face& outFace); |
| 205 | |
Junxiao Shi | 5e5e445 | 2015-09-24 16:56:52 -0700 | [diff] [blame] | 206 | /** \brief incoming Nack pipeline |
| 207 | */ |
| 208 | VIRTUAL_WITH_TESTS void |
| 209 | onIncomingNack(Face& inFace, const lp::Nack& nack); |
| 210 | |
| 211 | /** \brief outgoing Nack pipeline |
| 212 | */ |
| 213 | VIRTUAL_WITH_TESTS void |
| 214 | onOutgoingNack(shared_ptr<pit::Entry> pitEntry, const Face& outFace, const lp::NackHeader& nack); |
| 215 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 216 | PROTECTED_WITH_TESTS_ELSE_PRIVATE: |
| 217 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 218 | setUnsatisfyTimer(shared_ptr<pit::Entry> pitEntry); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 219 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 220 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 221 | setStragglerTimer(shared_ptr<pit::Entry> pitEntry, bool isSatisfied, |
| 222 | const time::milliseconds& dataFreshnessPeriod = time::milliseconds(-1)); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 223 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 224 | VIRTUAL_WITH_TESTS void |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 225 | cancelUnsatisfyAndStragglerTimer(shared_ptr<pit::Entry> pitEntry); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 226 | |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 227 | /** \brief insert Nonce to Dead Nonce List if necessary |
| 228 | * \param upstream if null, insert Nonces from all OutRecords; |
| 229 | * if not null, insert Nonce only on the OutRecord of this face |
| 230 | */ |
| 231 | VIRTUAL_WITH_TESTS void |
| 232 | insertDeadNonceList(pit::Entry& pitEntry, bool isSatisfied, |
| 233 | const time::milliseconds& dataFreshnessPeriod, |
| 234 | Face* upstream); |
| 235 | |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 236 | /// call trigger (method) on the effective strategy of pitEntry |
| 237 | #ifdef WITH_TESTS |
| 238 | virtual void |
| 239 | dispatchToStrategy(shared_ptr<pit::Entry> pitEntry, function<void(fw::Strategy*)> trigger); |
| 240 | #else |
| 241 | template<class Function> |
| 242 | void |
| 243 | dispatchToStrategy(shared_ptr<pit::Entry> pitEntry, Function trigger); |
| 244 | #endif |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 245 | |
| 246 | private: |
Junxiao Shi | b289cc1 | 2014-03-15 12:19:05 -0700 | [diff] [blame] | 247 | ForwarderCounters m_counters; |
| 248 | |
Junxiao Shi | a4f2be8 | 2014-03-02 22:56:41 -0700 | [diff] [blame] | 249 | FaceTable m_faceTable; |
HangZhang | ad4afd1 | 2014-03-01 11:03:08 +0800 | [diff] [blame] | 250 | |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 251 | // tables |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 252 | NameTree m_nameTree; |
| 253 | Fib m_fib; |
| 254 | Pit m_pit; |
| 255 | Cs m_cs; |
| 256 | Measurements m_measurements; |
| 257 | StrategyChoice m_strategyChoice; |
| 258 | DeadNonceList m_deadNonceList; |
| 259 | NetworkRegionTable m_networkRegionTable; |
Alexander Afanasyev | d980dcd | 2015-01-08 21:41:48 -0800 | [diff] [blame] | 260 | shared_ptr<Face> m_csFace; |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 261 | |
Spyridon Mastorakis | 31d4a08 | 2014-12-05 22:43:34 -0800 | [diff] [blame] | 262 | ns3::Ptr<ns3::ndn::ContentStore> m_csFromNdnSim; |
| 263 | |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 264 | static const Name LOCALHOST_NAME; |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 265 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 266 | // allow Strategy (base class) to enter pipelines |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 267 | friend class fw::Strategy; |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 268 | }; |
| 269 | |
Junxiao Shi | b289cc1 | 2014-03-15 12:19:05 -0700 | [diff] [blame] | 270 | inline const ForwarderCounters& |
| 271 | Forwarder::getCounters() const |
| 272 | { |
| 273 | return m_counters; |
| 274 | } |
| 275 | |
Junxiao Shi | a4f2be8 | 2014-03-02 22:56:41 -0700 | [diff] [blame] | 276 | inline FaceTable& |
| 277 | Forwarder::getFaceTable() |
| 278 | { |
| 279 | return m_faceTable; |
| 280 | } |
| 281 | |
| 282 | inline shared_ptr<Face> |
| 283 | Forwarder::getFace(FaceId id) const |
| 284 | { |
| 285 | return m_faceTable.get(id); |
| 286 | } |
| 287 | |
| 288 | inline void |
| 289 | Forwarder::addFace(shared_ptr<Face> face) |
| 290 | { |
| 291 | m_faceTable.add(face); |
| 292 | } |
| 293 | |
Junxiao Shi | ea48d8b | 2014-03-16 13:53:47 -0700 | [diff] [blame] | 294 | inline NameTree& |
| 295 | Forwarder::getNameTree() |
| 296 | { |
| 297 | return m_nameTree; |
| 298 | } |
| 299 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 300 | inline Fib& |
| 301 | Forwarder::getFib() |
| 302 | { |
| 303 | return m_fib; |
| 304 | } |
| 305 | |
| 306 | inline Pit& |
| 307 | Forwarder::getPit() |
| 308 | { |
| 309 | return m_pit; |
| 310 | } |
| 311 | |
| 312 | inline Cs& |
| 313 | Forwarder::getCs() |
| 314 | { |
| 315 | return m_cs; |
| 316 | } |
| 317 | |
Junxiao Shi | dbe7173 | 2014-02-21 22:23:28 -0700 | [diff] [blame] | 318 | inline Measurements& |
| 319 | Forwarder::getMeasurements() |
| 320 | { |
| 321 | return m_measurements; |
| 322 | } |
| 323 | |
Junxiao Shi | bb5105f | 2014-03-03 12:06:45 -0700 | [diff] [blame] | 324 | inline StrategyChoice& |
| 325 | Forwarder::getStrategyChoice() |
| 326 | { |
| 327 | return m_strategyChoice; |
| 328 | } |
Junxiao Shi | a4f2be8 | 2014-03-02 22:56:41 -0700 | [diff] [blame] | 329 | |
Junxiao Shi | a110f26 | 2014-10-12 12:35:20 -0700 | [diff] [blame] | 330 | inline DeadNonceList& |
| 331 | Forwarder::getDeadNonceList() |
| 332 | { |
| 333 | return m_deadNonceList; |
| 334 | } |
| 335 | |
Junxiao Shi | 0355e9f | 2015-09-02 07:24:53 -0700 | [diff] [blame] | 336 | inline NetworkRegionTable& |
| 337 | Forwarder::getNetworkRegionTable() |
| 338 | { |
| 339 | return m_networkRegionTable; |
| 340 | } |
| 341 | |
Spyridon Mastorakis | 31d4a08 | 2014-12-05 22:43:34 -0800 | [diff] [blame] | 342 | inline void |
| 343 | Forwarder::setCsFromNdnSim(ns3::Ptr<ns3::ndn::ContentStore> cs) |
| 344 | { |
| 345 | m_csFromNdnSim = cs; |
| 346 | } |
| 347 | |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 348 | #ifdef WITH_TESTS |
| 349 | inline void |
| 350 | Forwarder::dispatchToStrategy(shared_ptr<pit::Entry> pitEntry, function<void(fw::Strategy*)> trigger) |
| 351 | #else |
| 352 | template<class Function> |
| 353 | inline void |
| 354 | Forwarder::dispatchToStrategy(shared_ptr<pit::Entry> pitEntry, Function trigger) |
| 355 | #endif |
| 356 | { |
| 357 | fw::Strategy& strategy = m_strategyChoice.findEffectiveStrategy(*pitEntry); |
| 358 | trigger(&strategy); |
| 359 | } |
| 360 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 361 | } // namespace nfd |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 362 | |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 363 | #endif // NFD_DAEMON_FW_FORWARDER_HPP |