blob: 591254e029b73e5b3c1831c93eb318aa88c62f40 [file] [log] [blame]
Alexander Afanasyev33b72772014-01-26 23:22:58 -08001/* -*- 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 Shid3c792f2014-01-30 00:46:13 -070011#include "core/scheduler.hpp"
Alexander Afanasyev33b72772014-01-26 23:22:58 -080012#include "face/face.hpp"
Junxiao Shid3c792f2014-01-30 00:46:13 -070013#include "table/fib.hpp"
14#include "table/pit.hpp"
15#include "table/cs.hpp"
Alexander Afanasyev33b72772014-01-26 23:22:58 -080016
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080017namespace nfd {
Alexander Afanasyev33b72772014-01-26 23:22:58 -080018
19/**
20 * Forwarder is the main class of NFD.
21 *
22 * It creates and owns a set of Face listeners
23 */
24class Forwarder
25{
26public:
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 Shid3c792f2014-01-30 00:46:13 -070041private: // 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 Afanasyev33b72772014-01-26 23:22:58 -080083private:
Junxiao Shid3c792f2014-01-30 00:46:13 -070084 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
93private:
94 Scheduler m_scheduler;
95 Fib m_fib;
96 Pit m_pit;
97 Cs m_cs;
Alexander Afanasyev33b72772014-01-26 23:22:58 -080098 // container< shared_ptr<Face> > m_faces;
Junxiao Shid3c792f2014-01-30 00:46:13 -070099
100 // allow Strategy (base class) to enter pipelines
101 friend class Strategy;
Alexander Afanasyev33b72772014-01-26 23:22:58 -0800102};
103
Junxiao Shid3c792f2014-01-30 00:46:13 -0700104} // namespace nfd
Alexander Afanasyev33b72772014-01-26 23:22:58 -0800105
106#endif // NFD_FW_FORWARDER_HPP