Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_FW_FORWARDER_HPP |
| 8 | #define NFD_FW_FORWARDER_HPP |
| 9 | |
| 10 | #include "common.hpp" |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 11 | #include "core/scheduler.hpp" |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 12 | #include "face/face.hpp" |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 13 | #include "table/fib.hpp" |
| 14 | #include "table/pit.hpp" |
| 15 | #include "table/cs.hpp" |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 16 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 17 | namespace nfd { |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Forwarder is the main class of NFD. |
| 21 | * |
| 22 | * It creates and owns a set of Face listeners |
| 23 | */ |
| 24 | class Forwarder |
| 25 | { |
| 26 | public: |
| 27 | Forwarder(boost::asio::io_service& ioService); |
| 28 | |
| 29 | uint64_t |
| 30 | addFace(const shared_ptr<Face>& face); |
| 31 | |
| 32 | void |
| 33 | removeFace(const shared_ptr<Face>& face); |
| 34 | |
| 35 | void |
| 36 | onInterest(const Face& face, const Interest& interest); |
| 37 | |
| 38 | void |
| 39 | onData(const Face& face, const Data& data); |
| 40 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 41 | private: // pipelines |
| 42 | /** \brief incoming Interest pipeline |
| 43 | */ |
| 44 | void |
| 45 | onIncomingInterest(Face& inFace, const Interest& interest); |
| 46 | |
| 47 | /** \brief Interest loop pipeline |
| 48 | */ |
| 49 | void |
| 50 | onInterestLoop(Face& inFace, const Interest& interest, |
| 51 | shared_ptr<pit::Entry> pitEntry); |
| 52 | |
| 53 | /** \brief outgoing Interest pipeline |
| 54 | */ |
| 55 | void |
| 56 | onOutgoingInterest(shared_ptr<pit::Entry> pitEntry, Face& outFace); |
| 57 | |
| 58 | /** \brief Interest rebuff pipeline |
| 59 | */ |
| 60 | void |
| 61 | onInterestRebuff(shared_ptr<pit::Entry> pitEntry); |
| 62 | |
| 63 | /** \brief Interest unsatisfied pipeline |
| 64 | */ |
| 65 | void |
| 66 | onInterestUnsatisfied(shared_ptr<pit::Entry> pitEntry); |
| 67 | |
| 68 | /** \brief incoming Data pipeline |
| 69 | */ |
| 70 | void |
| 71 | onIncomingData(Face& inFace, const Data& data); |
| 72 | |
| 73 | /** \brief Data unsolicited pipeline |
| 74 | */ |
| 75 | void |
| 76 | onDataUnsolicited(Face& inFace, const Data& data); |
| 77 | |
| 78 | /** \brief outgoing Data pipeline |
| 79 | */ |
| 80 | void |
| 81 | onOutgoingData(const Data& data, Face& outFace); |
| 82 | |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 83 | private: |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 84 | void |
| 85 | setUnsatisfyTimer(shared_ptr<pit::Entry> pitEntry); |
| 86 | |
| 87 | void |
| 88 | setStragglerTimer(shared_ptr<pit::Entry> pitEntry); |
| 89 | |
| 90 | void |
| 91 | cancelUnsatisfyAndStragglerTimer(shared_ptr<pit::Entry> pitEntry); |
| 92 | |
| 93 | private: |
| 94 | Scheduler m_scheduler; |
| 95 | Fib m_fib; |
| 96 | Pit m_pit; |
| 97 | Cs m_cs; |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 98 | // container< shared_ptr<Face> > m_faces; |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 99 | |
| 100 | // allow Strategy (base class) to enter pipelines |
| 101 | friend class Strategy; |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 102 | }; |
| 103 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame^] | 104 | } // namespace nfd |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 105 | |
| 106 | #endif // NFD_FW_FORWARDER_HPP |