NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
rule.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25
#ifndef NDN_SECURITY_CONF_RULE_HPP
26
#define NDN_SECURITY_CONF_RULE_HPP
27
28
#include "
filter.hpp
"
29
#include "
checker.hpp
"
30
31
32
namespace
ndn
{
33
namespace
security
{
34
namespace
conf {
35
36
template
<
class
Packet>
37
class
Rule
38
{
39
public
:
40
explicit
41
Rule
(
const
std::string&
id
)
42
:
m_id
(id)
43
{
44
}
45
46
virtual
47
~Rule
()
48
{
49
}
50
51
const
std::string&
52
getId
()
53
{
54
return
m_id
;
55
}
56
57
void
58
addFilter
(
const
shared_ptr<Filter>& filter)
59
{
60
m_filters
.push_back(filter);
61
}
62
63
void
64
addChecker
(
const
shared_ptr<Checker>& checker)
65
{
66
m_checkers
.push_back(checker);
67
}
68
69
bool
70
match
(
const
Packet& packet)
71
{
72
if
(
m_filters
.empty())
73
return
true
;
74
75
for
(
FilterList::iterator
it =
m_filters
.begin();
76
it !=
m_filters
.end(); it++)
77
{
78
if
(!(*it)->match(packet))
79
return
false
;
80
}
81
82
return
true
;
83
}
84
95
template
<
class
Val
id
atedCallback,
class
Val
id
ationFailureCallback>
96
int8_t
97
check
(
const
Packet& packet,
98
const
ValidatedCallback& onValidated,
99
const
ValidationFailureCallback& onValidationFailed)
100
{
101
bool
hasPendingResult =
false
;
102
for
(
CheckerList::iterator
it =
m_checkers
.begin(); it !=
m_checkers
.end(); it++) {
103
int8_t result = (*it)->check(packet);
104
if
(result > 0) {
105
onValidated(packet.shared_from_this());
106
return
result;
107
}
108
else
if
(result == 0)
109
hasPendingResult =
true
;
110
}
111
if
(hasPendingResult) {
112
return
0;
113
}
114
else
{
115
onValidationFailed(packet.shared_from_this(),
"Packet cannot pass any checkers."
);
116
return
-1;
117
}
118
}
119
120
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
:
121
typedef
std::vector<shared_ptr<Filter>> FilterList;
122
typedef
std::vector<shared_ptr<Checker>>
CheckerList
;
123
124
std::string
m_id
;
125
FilterList
m_filters
;
126
CheckerList
m_checkers
;
127
};
128
129
}
// namespace conf
130
}
// namespace security
131
}
// namespace ndn
132
133
#endif // NDN_SECURITY_CONF_RULE_HPP
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::security::conf::Rule::m_filters
FilterList m_filters
Definition:
rule.hpp:125
ndn::security::conf::Rule::getId
const std::string & getId()
Definition:
rule.hpp:52
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition:
common.hpp:43
ndn::security::conf::Rule::CheckerList
std::vector< shared_ptr< Checker > > CheckerList
Definition:
rule.hpp:122
ndn::security::conf::Rule::m_id
std::string m_id
Definition:
rule.hpp:124
nfd::cs::iterator
Table::const_iterator iterator
Definition:
cs-internal.hpp:41
ndn::security::conf::Rule
Definition:
rule.hpp:37
ndn::security::conf::Rule::~Rule
virtual ~Rule()
Definition:
rule.hpp:47
ndn::security::conf::Rule::match
bool match(const Packet &packet)
Definition:
rule.hpp:70
ndn::security::conf::Rule::addFilter
void addFilter(const shared_ptr< Filter > &filter)
Definition:
rule.hpp:58
ndn::security::conf::Rule::Rule
Rule(const std::string &id)
Definition:
rule.hpp:41
ndn::security::conf::Rule::addChecker
void addChecker(const shared_ptr< Checker > &checker)
Definition:
rule.hpp:64
ndn::security::conf::Rule::check
int8_t check(const Packet &packet, const ValidatedCallback &onValidated, const ValidationFailureCallback &onValidationFailed)
check if packet satisfies certain condition
Definition:
rule.hpp:97
ndn::security::conf::Rule::m_checkers
CheckerList m_checkers
Definition:
rule.hpp:126
security
filter.hpp
checker.hpp
ndnSIM
ndn-cxx
src
security
conf
rule.hpp
Generated on Wed Jan 11 2017 18:17:14 for ndnSIM by
1.8.13