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; -*- */
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) {
38  return os << "drop";
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>
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");
71 
73 DropAllUnsolicitedDataPolicy::decide(const Face& inFace, const Data& data) const
74 {
76 }
77 
78 const std::string AdmitLocalUnsolicitedDataPolicy::POLICY_NAME("admit-local");
80 
82 AdmitLocalUnsolicitedDataPolicy::decide(const Face& inFace, const Data& data) const
83 {
84  if (inFace.getScope() == ndn::nfd::FACE_SCOPE_LOCAL) {
86  }
88 }
89 
90 const std::string AdmitNetworkUnsolicitedDataPolicy::POLICY_NAME("admit-network");
92 
94 AdmitNetworkUnsolicitedDataPolicy::decide(const Face& inFace, const Data& data) const
95 {
96  if (inFace.getScope() == ndn::nfd::FACE_SCOPE_NON_LOCAL) {
98  }
100 }
101 
102 const std::string AdmitAllUnsolicitedDataPolicy::POLICY_NAME("admit-all");
104 
106 AdmitAllUnsolicitedDataPolicy::decide(const Face& inFace, const Data& data) const
107 {
109 }
110 
111 } // namespace fw
112 } // namespace nfd
ndn::nfd::FACE_SCOPE_NON_LOCAL
@ FACE_SCOPE_NON_LOCAL
face is non-local
Definition: nfd-constants.hpp:36
nfd::fw::UnsolicitedDataDecision
UnsolicitedDataDecision
a decision made by UnsolicitedDataPolicy
Definition: unsolicited-data-policy.hpp:36
nfd::fw::AdmitLocalUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition: unsolicited-data-policy.hpp:109
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::UnsolicitedDataPolicy::getPolicyNames
static std::set< std::string > getPolicyNames()
Definition: unsolicited-data-policy.cpp:61
nfd::fw::AdmitNetworkUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition: unsolicited-data-policy.hpp:121
unsolicited-data-policy.hpp
nfd::fw::DropAllUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition: unsolicited-data-policy.hpp:97
nfd::fw::UnsolicitedDataDecision::CACHE
@ CACHE
the Data should be cached in the ContentStore
nfd::fw::AdmitAllUnsolicitedDataPolicy::POLICY_NAME
static const std::string POLICY_NAME
Definition: unsolicited-data-policy.hpp:133
nfd::fw::UnsolicitedDataPolicy::create
static unique_ptr< UnsolicitedDataPolicy > create(const std::string &policyName)
Definition: unsolicited-data-policy.cpp:53
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::fw::DropAllUnsolicitedDataPolicy
drops all unsolicited Data
Definition: unsolicited-data-policy.hpp:91
nfd::face::Face
generalization of a network interface
Definition: face.hpp:53
nfd::fw::DropAllUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition: unsolicited-data-policy.cpp:73
nfd::fw::AdmitNetworkUnsolicitedDataPolicy
admits unsolicited Data from non-local faces
Definition: unsolicited-data-policy.hpp:115
nfd::fw::AdmitAllUnsolicitedDataPolicy
admits all unsolicited Data
Definition: unsolicited-data-policy.hpp:127
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
nfd::fw::AdmitLocalUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition: unsolicited-data-policy.cpp:82
nfd::fw::operator<<
std::ostream & operator<<(std::ostream &os, UnsolicitedDataDecision d)
Definition: unsolicited-data-policy.cpp:34
nfd::face::Face::getScope
ndn::nfd::FaceScope getScope() const
Definition: face.hpp:250
ndn::nfd::FACE_SCOPE_LOCAL
@ FACE_SCOPE_LOCAL
face is local
Definition: nfd-constants.hpp:37
nfd::fw::AdmitLocalUnsolicitedDataPolicy
admits unsolicited Data from local faces
Definition: unsolicited-data-policy.hpp:103
nfd::fw::AdmitAllUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition: unsolicited-data-policy.cpp:106
nfd::fw::UnsolicitedDataDecision::DROP
@ DROP
the Data should be dropped
nfd::fw::AdmitNetworkUnsolicitedDataPolicy::decide
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
Definition: unsolicited-data-policy.cpp:94