blob: 1014fcac65b50fe686421682a7d78fdaa1833153 [file] [log] [blame]
Yanbiao Li4ee73d42015-08-19 16:30:16 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2015, 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.
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/>.
24 */
25
26#ifndef NFD_DAEMON_FACE_INTERNAL_FACE_HPP
27#define NFD_DAEMON_FACE_INTERNAL_FACE_HPP
28
29#include "face.hpp"
30
31namespace nfd {
32
33/**
34 * @brief represents a face for internal use in NFD.
35 */
36class InternalFace : public Face
37{
38public:
39
40 InternalFace();
41
42 virtual void
43 sendInterest(const Interest& interest) DECL_OVERRIDE;
44
45 virtual void
46 sendData(const Data& data) DECL_OVERRIDE;
47
48 virtual void
49 close() DECL_OVERRIDE;
50
51 /**
52 * @brief receive a block from a client face
53 *
54 * step1. extracte the packet payload from the received block.
55 * step2. check the type (either Interest or Data) through the payload.
56 * step3. call receiveInterest / receiveData respectively according to the type.
57 *
58 * @param blockFromClient the block from a client face
59 */
60 void
61 receive(const Block& blockFromClient);
62
63 /**
64 * @brief receive an Interest from a client face
65 *
66 * emit the onReceiveInterest signal.
67 *
68 * @param interest the received Interest packet
69 */
70 void
71 receiveInterest(const Interest& interest);
72
73 /**
74 * @brief receive a Data from a client face
75 *
76 * emit the onReceiveData signal.
77 *
78 * @param data the received Data packet
79 */
80 void
81 receiveData(const Data& data);
82
83 /**
84 * @brief compose the whole packet from the received block after payload is extracted
85 *
86 * construct a packet from the extracted payload, and then decode the localControlHeader if the
87 * received block holds more information than the payload.
88 *
89 * @tparam Packet the type of packet, Interest or Data
90 * @param blockFromClient the received block
91 * @param payLoad the extracted payload
92 *
93 * @return a complete packet
94 */
95 template<typename Packet>
96 static shared_ptr<Packet>
97 extractPacketFromBlock(const Block& blockFromClient, const Block& payLoad);
98};
99
100} // namespace nfd
101
102#endif // NFD_DAEMON_FACE_INTERNAL_FACE_HPP