NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
unsolicited-data-policy.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2014-2021, 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
31
namespace
nfd
{
32
namespace
fw {
33
36
enum class
UnsolicitedDataDecision
{
37
DROP
,
38
CACHE
39
};
40
41
std::ostream&
42
operator<<
(std::ostream& os,
UnsolicitedDataDecision
d);
43
50
class
UnsolicitedDataPolicy
: noncopyable
51
{
52
public
:
53
virtual
54
~
UnsolicitedDataPolicy
() =
default
;
55
56
virtual
UnsolicitedDataDecision
57
decide(
const
Face
& inFace,
const
Data
& data)
const
= 0;
58
59
public
:
// registry
60
template
<
typename
P>
61
static
void
62
registerPolicy
(
const
std::string& policyName = P::POLICY_NAME)
63
{
64
Registry& registry = getRegistry();
65
BOOST_ASSERT(registry.count(policyName) == 0);
66
registry[policyName] = [] {
return
make_unique<P>(); };
67
}
68
72
static
unique_ptr<UnsolicitedDataPolicy>
73
create(
const
std::string& policyName);
74
77
static
std::set<std::string>
78
getPolicyNames();
79
80
private
:
81
typedef
std::function<unique_ptr<UnsolicitedDataPolicy>()> CreateFunc;
82
typedef
std::map<std::string, CreateFunc> Registry;
// indexed by policy name
83
84
static
Registry&
85
getRegistry();
86
};
87
90
class
DropAllUnsolicitedDataPolicy
final :
public
UnsolicitedDataPolicy
91
{
92
public
:
93
UnsolicitedDataDecision
94
decide(
const
Face
& inFace,
const
Data
& data)
const
final
;
95
96
public
:
97
static
const
std::string
POLICY_NAME
;
98
};
99
102
class
AdmitLocalUnsolicitedDataPolicy
final :
public
UnsolicitedDataPolicy
103
{
104
public
:
105
UnsolicitedDataDecision
106
decide(
const
Face
& inFace,
const
Data
& data)
const
final
;
107
108
public
:
109
static
const
std::string
POLICY_NAME
;
110
};
111
114
class
AdmitNetworkUnsolicitedDataPolicy
final :
public
UnsolicitedDataPolicy
115
{
116
public
:
117
UnsolicitedDataDecision
118
decide(
const
Face
& inFace,
const
Data
& data)
const
final
;
119
120
public
:
121
static
const
std::string
POLICY_NAME
;
122
};
123
126
class
AdmitAllUnsolicitedDataPolicy
final :
public
UnsolicitedDataPolicy
127
{
128
public
:
129
UnsolicitedDataDecision
130
decide(
const
Face
& inFace,
const
Data
& data)
const
final
;
131
132
public
:
133
static
const
std::string
POLICY_NAME
;
134
};
135
138
using
DefaultUnsolicitedDataPolicy
=
DropAllUnsolicitedDataPolicy
;
139
140
}
// namespace fw
141
}
// namespace nfd
142
147
#define NFD_REGISTER_UNSOLICITED_DATA_POLICY(P) \
148
static class NfdAuto ## P ## UnsolicitedDataPolicyRegistrationClass \
149
{ \
150
public: \
151
NfdAuto ## P ## UnsolicitedDataPolicyRegistrationClass() \
152
{ \
153
::nfd::fw::UnsolicitedDataPolicy::registerPolicy<P>(); \
154
} \
155
} g_nfdAuto ## P ## UnsolicitedDataPolicyRegistrationVariable
156
157
#endif // NFD_DAEMON_FW_UNSOLICITED_DATA_POLICY_HPP
nfd::fw::AdmitAllUnsolicitedDataPolicy
admits all unsolicited Data
Definition:
unsolicited-data-policy.hpp:126
face.hpp
nfd::fw::DropAllUnsolicitedDataPolicy
DropAllUnsolicitedDataPolicy
Definition:
unsolicited-data-policy.cpp:70
nfd::fw::AdmitNetworkUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition:
unsolicited-data-policy.hpp:121
nfd::fw::UnsolicitedDataPolicy
determines how to process an unsolicited Data
Definition:
unsolicited-data-policy.hpp:50
nfd::fw::AdmitLocalUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition:
unsolicited-data-policy.hpp:109
nfd::fw::AdmitLocalUnsolicitedDataPolicy
admits unsolicited Data from local faces
Definition:
unsolicited-data-policy.hpp:102
nfd::fw::DropAllUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition:
unsolicited-data-policy.hpp:97
nfd::fw::AdmitAllUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition:
unsolicited-data-policy.hpp:133
Face
ndn Face
Definition:
face-impl.hpp:42
nfd::fw::AdmitNetworkUnsolicitedDataPolicy
admits unsolicited Data from non-local faces
Definition:
unsolicited-data-policy.hpp:114
nfd::fw::UnsolicitedDataDecision::DROP
the Data should be dropped
nfd::fw::UnsolicitedDataPolicy::registerPolicy
static void registerPolicy(const std::string &policyName=P::POLICY_NAME)
Definition:
unsolicited-data-policy.hpp:62
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:39
nfd::fw::UnsolicitedDataDecision
UnsolicitedDataDecision
a decision made by UnsolicitedDataPolicy
Definition:
unsolicited-data-policy.hpp:36
nfd::fw::UnsolicitedDataDecision::CACHE
the Data should be cached in the ContentStore
nfd::fw::DropAllUnsolicitedDataPolicy
drops all unsolicited Data
Definition:
unsolicited-data-policy.hpp:90
nfd::fw::operator<<
std::ostream & operator<<(std::ostream &os, UnsolicitedDataDecision d)
Definition:
unsolicited-data-policy.cpp:34
ndn::Data
Represents a Data packet.
Definition:
data.hpp:37
ndnSIM
NFD
daemon
fw
unsolicited-data-policy.hpp
Generated on Fri May 6 2022 12:34:13 for ndnSIM by
1.8.13