NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
unsolicited-data-policy.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#include "
unsolicited-data-policy.hpp
"
27
#include <boost/range/adaptor/map.hpp>
28
#include <boost/range/algorithm/copy.hpp>
29
30
namespace
nfd
{
31
namespace
fw {
32
33
std::ostream&
34
operator<<
(std::ostream& os,
UnsolicitedDataDecision
d)
35
{
36
switch
(d) {
37
case
UnsolicitedDataDecision::DROP
:
38
return
os <<
"drop"
;
39
case
UnsolicitedDataDecision::CACHE
:
40
return
os <<
"cache"
;
41
}
42
return
os << static_cast<int>(d);
43
}
44
45
UnsolicitedDataPolicy::Registry&
46
UnsolicitedDataPolicy::getRegistry()
47
{
48
static
Registry registry;
49
return
registry;
50
}
51
52
unique_ptr<UnsolicitedDataPolicy>
53
UnsolicitedDataPolicy::create
(
const
std::string& policyName)
54
{
55
Registry& registry = getRegistry();
56
auto
i = registry.find(policyName);
57
return
i == registry.end() ? nullptr : i->second();
58
}
59
60
std::set<std::string>
61
UnsolicitedDataPolicy::getPolicyNames
()
62
{
63
std::set<std::string> policyNames;
64
boost::copy(getRegistry() | boost::adaptors::map_keys,
65
std::inserter(policyNames, policyNames.end()));
66
return
policyNames;
67
}
68
69
const
std::string
DropAllUnsolicitedDataPolicy::POLICY_NAME
(
"drop-all"
);
70
NFD_REGISTER_UNSOLICITED_DATA_POLICY
(
DropAllUnsolicitedDataPolicy
);
71
72
UnsolicitedDataDecision
73
DropAllUnsolicitedDataPolicy::decide
(
const
Face
& inFace,
const
Data
& data)
const
74
{
75
return
UnsolicitedDataDecision::DROP
;
76
}
77
78
const
std::string
AdmitLocalUnsolicitedDataPolicy::POLICY_NAME
(
"admit-local"
);
79
NFD_REGISTER_UNSOLICITED_DATA_POLICY
(
AdmitLocalUnsolicitedDataPolicy
);
80
81
UnsolicitedDataDecision
82
AdmitLocalUnsolicitedDataPolicy::decide
(
const
Face
& inFace,
const
Data
& data)
const
83
{
84
if
(inFace.
getScope
() ==
ndn::nfd::FACE_SCOPE_LOCAL
) {
85
return
UnsolicitedDataDecision::CACHE
;
86
}
87
return
UnsolicitedDataDecision::DROP
;
88
}
89
90
const
std::string
AdmitNetworkUnsolicitedDataPolicy::POLICY_NAME
(
"admit-network"
);
91
NFD_REGISTER_UNSOLICITED_DATA_POLICY
(
AdmitNetworkUnsolicitedDataPolicy
);
92
93
UnsolicitedDataDecision
94
AdmitNetworkUnsolicitedDataPolicy::decide
(
const
Face
& inFace,
const
Data
& data)
const
95
{
96
if
(inFace.
getScope
() ==
ndn::nfd::FACE_SCOPE_NON_LOCAL
) {
97
return
UnsolicitedDataDecision::CACHE
;
98
}
99
return
UnsolicitedDataDecision::DROP
;
100
}
101
102
const
std::string
AdmitAllUnsolicitedDataPolicy::POLICY_NAME
(
"admit-all"
);
103
NFD_REGISTER_UNSOLICITED_DATA_POLICY
(
AdmitAllUnsolicitedDataPolicy
);
104
105
UnsolicitedDataDecision
106
AdmitAllUnsolicitedDataPolicy::decide
(
const
Face
& inFace,
const
Data
& data)
const
107
{
108
return
UnsolicitedDataDecision::CACHE
;
109
}
110
111
}
// namespace fw
112
}
// namespace nfd
nfd::fw::AdmitAllUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition:
unsolicited-data-policy.cpp:106
nfd::fw::AdmitAllUnsolicitedDataPolicy
admits all unsolicited Data
Definition:
unsolicited-data-policy.hpp:126
ndn::nfd::FACE_SCOPE_NON_LOCAL
face is non-local
Definition:
nfd-constants.hpp:36
nfd::fw::AdmitNetworkUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition:
unsolicited-data-policy.hpp:121
nfd::face::Face
generalization of a network interface
Definition:
face.hpp:67
nfd::fw::AdmitNetworkUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition:
unsolicited-data-policy.cpp:94
NFD_REGISTER_UNSOLICITED_DATA_POLICY
#define NFD_REGISTER_UNSOLICITED_DATA_POLICY(P)
registers an unsolicited data policy
Definition:
unsolicited-data-policy.hpp:147
nfd::fw::DropAllUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition:
unsolicited-data-policy.cpp:73
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
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
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
nfd::fw::UnsolicitedDataPolicy::create
static unique_ptr< UnsolicitedDataPolicy > create(const std::string &policyName)
Definition:
unsolicited-data-policy.cpp:53
nfd::face::Face::getScope
ndn::nfd::FaceScope getScope() const
Definition:
face.hpp:269
unsolicited-data-policy.hpp
ndn::nfd::FACE_SCOPE_LOCAL
face is local
Definition:
nfd-constants.hpp:37
nfd::fw::UnsolicitedDataDecision
UnsolicitedDataDecision
a decision made by UnsolicitedDataPolicy
Definition:
unsolicited-data-policy.hpp:36
nfd::fw::UnsolicitedDataPolicy::getPolicyNames
static std::set< std::string > getPolicyNames()
Definition:
unsolicited-data-policy.cpp:61
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:35
nfd::fw::AdmitLocalUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition:
unsolicited-data-policy.cpp:82
ndnSIM
NFD
daemon
fw
unsolicited-data-policy.cpp
Generated on Tue Aug 7 2018 16:19:18 for ndnSIM by
1.8.14