NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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
28
namespace
nfd
{
29
namespace
fw {
30
31
std::ostream&
32
operator<<
(std::ostream& os,
UnsolicitedDataDecision
d)
33
{
34
switch
(d) {
35
case
UnsolicitedDataDecision::DROP
:
36
return
os <<
"drop"
;
37
case
UnsolicitedDataDecision::CACHE
:
38
return
os <<
"cache"
;
39
}
40
return
os << static_cast<int>(d);
41
}
42
43
UnsolicitedDataPolicy::Registry&
44
UnsolicitedDataPolicy::getRegistry()
45
{
46
static
Registry registry;
47
return
registry;
48
}
49
50
unique_ptr<UnsolicitedDataPolicy>
51
UnsolicitedDataPolicy::create
(
const
std::string& key)
52
{
53
Registry& registry = getRegistry();
54
auto
i = registry.find(key);
55
return
i == registry.end() ? nullptr : i->second();
56
}
57
58
NFD_REGISTER_UNSOLICITED_DATA_POLICY
(
DropAllUnsolicitedDataPolicy
,
"drop-all"
);
59
60
UnsolicitedDataDecision
61
DropAllUnsolicitedDataPolicy::decide
(
const
Face
& inFace,
const
Data
& data)
const
62
{
63
return
UnsolicitedDataDecision::DROP
;
64
}
65
66
NFD_REGISTER_UNSOLICITED_DATA_POLICY
(
AdmitLocalUnsolicitedDataPolicy
,
"admit-local"
);
67
68
UnsolicitedDataDecision
69
AdmitLocalUnsolicitedDataPolicy::decide
(
const
Face
& inFace,
const
Data
& data)
const
70
{
71
if
(inFace.
getScope
() ==
ndn::nfd::FACE_SCOPE_LOCAL
) {
72
return
UnsolicitedDataDecision::CACHE
;
73
}
74
return
UnsolicitedDataDecision::DROP
;
75
}
76
77
NFD_REGISTER_UNSOLICITED_DATA_POLICY
(
AdmitNetworkUnsolicitedDataPolicy
,
"admit-network"
);
78
79
UnsolicitedDataDecision
80
AdmitNetworkUnsolicitedDataPolicy::decide
(
const
Face
& inFace,
const
Data
& data)
const
81
{
82
if
(inFace.
getScope
() ==
ndn::nfd::FACE_SCOPE_NON_LOCAL
) {
83
return
UnsolicitedDataDecision::CACHE
;
84
}
85
return
UnsolicitedDataDecision::DROP
;
86
}
87
88
NFD_REGISTER_UNSOLICITED_DATA_POLICY
(
AdmitAllUnsolicitedDataPolicy
,
"admit-all"
);
89
90
UnsolicitedDataDecision
91
AdmitAllUnsolicitedDataPolicy::decide
(
const
Face
& inFace,
const
Data
& data)
const
92
{
93
return
UnsolicitedDataDecision::CACHE
;
94
}
95
96
}
// namespace fw
97
}
// namespace nfd
nfd::fw::AdmitAllUnsolicitedDataPolicy::decide
virtual UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition:
unsolicited-data-policy.cpp:91
nfd::fw::AdmitAllUnsolicitedDataPolicy
admits all unsolicited Data
Definition:
unsolicited-data-policy.hpp:110
NFD_REGISTER_UNSOLICITED_DATA_POLICY
#define NFD_REGISTER_UNSOLICITED_DATA_POLICY(P, key)
registers an unsolicited data policy
Definition:
unsolicited-data-policy.hpp:128
ndn::nfd::FACE_SCOPE_NON_LOCAL
face is non-local
Definition:
nfd-constants.hpp:38
nfd::face::Face
generalization of a network interface
Definition:
face.hpp:67
nfd::fw::AdmitNetworkUnsolicitedDataPolicy::decide
virtual UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition:
unsolicited-data-policy.cpp:80
nfd::fw::DropAllUnsolicitedDataPolicy::decide
virtual UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition:
unsolicited-data-policy.cpp:61
nfd::fw::AdmitLocalUnsolicitedDataPolicy
admits unsolicited Data from local faces
Definition:
unsolicited-data-policy.hpp:92
nfd::fw::AdmitNetworkUnsolicitedDataPolicy
admits unsolicited Data from non-local faces
Definition:
unsolicited-data-policy.hpp:101
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::face::Face::getScope
ndn::nfd::FaceScope getScope() const
Definition:
face.hpp:265
unsolicited-data-policy.hpp
ndn::nfd::FACE_SCOPE_LOCAL
face is local
Definition:
nfd-constants.hpp:41
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:83
nfd::fw::operator<<
std::ostream & operator<<(std::ostream &os, UnsolicitedDataDecision d)
Definition:
unsolicited-data-policy.cpp:32
ndn::Data
represents a Data packet
Definition:
data.hpp:37
nfd::fw::UnsolicitedDataPolicy::create
static unique_ptr< UnsolicitedDataPolicy > create(const std::string &key)
Definition:
unsolicited-data-policy.cpp:51
nfd::fw::AdmitLocalUnsolicitedDataPolicy::decide
virtual UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition:
unsolicited-data-policy.cpp:69
ndnSIM
NFD
daemon
fw
unsolicited-data-policy.cpp
Generated on Wed Jan 11 2017 18:17:15 for ndnSIM by
1.8.13