blob: 06354d07539104cf110a65b99262325cdcfe046f [file] [log] [blame]
Junxiao Shifbe8efe2016-08-22 16:02:30 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
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.
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_FW_UNSOLICITED_DATA_POLICY_HPP
27#define NFD_DAEMON_FW_UNSOLICITED_DATA_POLICY_HPP
28
29#include "face/face.hpp"
30
31namespace nfd {
32namespace fw {
33
34/** \brief a decision made by UnsolicitedDataPolicy
35 */
36enum class UnsolicitedDataDecision {
37 DROP, ///< the Data should be dropped
38 CACHE ///< the Data should be cached in the ContentStore
39};
40
41std::ostream&
42operator<<(std::ostream& os, UnsolicitedDataDecision d);
43
44/** \brief determines how to process an unsolicited Data
45 *
46 * An incoming Data is unsolicited if it does not match any PIT entry.
47 * This class assists forwarding pipelines to decide whether to drop an unsolicited Data
48 * or admit it into the ContentStore.
49 */
50class UnsolicitedDataPolicy : noncopyable
51{
52public:
53 virtual ~UnsolicitedDataPolicy() = default;
54
55 virtual UnsolicitedDataDecision
56 decide(const Face& inFace, const Data& data) const = 0;
57};
58
Junxiao Shi36b22252016-08-25 13:22:21 +000059/** \brief drops all unsolicited Data
60 */
61class DropAllUnsolicitedDataPolicy : public UnsolicitedDataPolicy
62{
63public:
64 virtual UnsolicitedDataDecision
65 decide(const Face& inFace, const Data& data) const final;
66};
67
Junxiao Shifbe8efe2016-08-22 16:02:30 +000068/** \brief admits unsolicited Data from local faces
69 */
70class AdmitLocalUnsolicitedDataPolicy : public UnsolicitedDataPolicy
71{
72public:
73 virtual UnsolicitedDataDecision
74 decide(const Face& inFace, const Data& data) const final;
75};
76
Junxiao Shi36b22252016-08-25 13:22:21 +000077/** \brief admits unsolicited Data from non-local faces
78 */
79class AdmitNetworkUnsolicitedDataPolicy : public UnsolicitedDataPolicy
80{
81public:
82 virtual UnsolicitedDataDecision
83 decide(const Face& inFace, const Data& data) const final;
84};
85
86/** \brief admits all unsolicited Data
87 */
88class AdmitAllUnsolicitedDataPolicy : public UnsolicitedDataPolicy
89{
90public:
91 virtual UnsolicitedDataDecision
92 decide(const Face& inFace, const Data& data) const final;
93};
94
Junxiao Shi9685cc52016-08-29 12:47:05 +000095/** \return an UnsolicitedDataPolicy identified by \p key, or nullptr if \p key is unknown
96 */
97unique_ptr<UnsolicitedDataPolicy>
98makeUnsolicitedDataPolicy(const std::string& key);
99
100/** \brief the default UnsolicitedDataPolicy
101 */
102typedef AdmitLocalUnsolicitedDataPolicy DefaultUnsolicitedDataPolicy;
103
Junxiao Shifbe8efe2016-08-22 16:02:30 +0000104} // namespace fw
105} // namespace nfd
106
107#endif // NFD_DAEMON_FW_UNSOLICITED_DATA_POLICY_HPP