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
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
#define NFD_REGISTER_UNSOLICITED_DATA_POLICY(P)
registers an unsolicited data policy
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final
admits unsolicited Data from local faces
ndn Face
Definition: face-impl.hpp:42
admits unsolicited Data from non-local faces
the Data should be dropped
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:39
static unique_ptr< UnsolicitedDataPolicy > create(const std::string &policyName)
UnsolicitedDataDecision
a decision made by UnsolicitedDataPolicy
static std::set< std::string > getPolicyNames()
the Data should be cached in the ContentStore
std::ostream & operator<<(std::ostream &os, UnsolicitedDataDecision d)
Represents a Data packet.
Definition: data.hpp:37
UnsolicitedDataDecision decide(const Face &inFace, const Data &data) const final