NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
network-predicate.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2014-2018, Regents of the University of California,
4
* Arizona Board of Regents,
5
* Colorado State University,
6
* University Pierre & Marie Curie, Sorbonne University,
7
* Washington University in St. Louis,
8
* Beijing Institute of Technology,
9
* The University of Memphis.
10
*
11
* This file is part of NFD (Named Data Networking Forwarding Daemon).
12
* See AUTHORS.md for complete list of NFD authors and contributors.
13
*
14
* NFD is free software: you can redistribute it and/or modify it under the terms
15
* of the GNU General Public License as published by the Free Software Foundation,
16
* either version 3 of the License, or (at your option) any later version.
17
*
18
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20
* PURPOSE. See the GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License along with
23
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24
*/
25
26
#ifndef NFD_CORE_NETWORK_PREDICATE_HPP
27
#define NFD_CORE_NETWORK_PREDICATE_HPP
28
29
#include "
common.hpp
"
30
#include <
ndn-cxx/net/network-interface.hpp
>
31
32
namespace
nfd
{
33
34
class
NetworkPredicateBase
35
{
36
public
:
37
NetworkPredicateBase
();
38
39
virtual
40
~NetworkPredicateBase
();
41
45
void
46
clear
();
47
48
void
49
parseWhitelist
(
const
boost::property_tree::ptree& list);
50
51
void
52
parseBlacklist
(
const
boost::property_tree::ptree& list);
53
54
void
55
assign
(std::initializer_list<std::pair<std::string, std::string>> whitelist,
56
std::initializer_list<std::pair<std::string, std::string>> blacklist);
57
58
bool
59
operator==
(
const
NetworkPredicateBase
& other)
const
;
60
61
bool
62
operator!=
(
const
NetworkPredicateBase
& other)
const
63
{
64
return
!this->
operator==
(other);
65
}
66
67
private
:
68
virtual
bool
69
isRuleSupported(
const
std::string& key) = 0;
70
71
virtual
bool
72
isRuleValid(
const
std::string& key,
const
std::string& value) = 0;
73
74
void
75
parseList(std::set<std::string>& set,
const
boost::property_tree::ptree& list,
const
std::string& section);
76
77
void
78
parseList(std::set<std::string>& set, std::initializer_list<std::pair<std::string, std::string>> list);
79
80
PUBLIC_WITH_TESTS_ELSE_PROTECTED
:
81
std::set<std::string>
m_whitelist
;
82
std::set<std::string>
m_blacklist
;
83
};
84
95
class
NetworkInterfacePredicate
:
public
NetworkPredicateBase
96
{
97
public
:
98
bool
99
operator()
(
const
ndn::net::NetworkInterface
& netif)
const
;
100
101
private
:
102
bool
103
isRuleSupported(
const
std::string& key)
final
;
104
105
bool
106
isRuleValid(
const
std::string& key,
const
std::string& value)
final
;
107
};
108
117
class
IpAddressPredicate
:
public
NetworkPredicateBase
118
{
119
public
:
120
bool
121
operator()
(
const
boost::asio::ip::address& address)
const
;
122
123
private
:
124
bool
125
isRuleSupported(
const
std::string& key)
final
;
126
127
bool
128
isRuleValid(
const
std::string& key,
const
std::string& value)
final
;
129
};
130
131
}
// namespace nfd
132
133
#endif // NFD_CORE_NETWORK_PREDICATE_HPP
network-interface.hpp
nfd::NetworkPredicateBase::assign
void assign(std::initializer_list< std::pair< std::string, std::string >> whitelist, std::initializer_list< std::pair< std::string, std::string >> blacklist)
Definition:
network-predicate.cpp:109
nfd::NetworkPredicateBase::~NetworkPredicateBase
virtual ~NetworkPredicateBase()
nfd::IpAddressPredicate::operator()
bool operator()(const boost::asio::ip::address &address) const
Definition:
network-predicate.cpp:215
nfd::NetworkPredicateBase::parseWhitelist
void parseWhitelist(const boost::property_tree::ptree &list)
Definition:
network-predicate.cpp:97
nfd::NetworkPredicateBase
Definition:
network-predicate.hpp:34
nfd::NetworkPredicateBase::NetworkPredicateBase
NetworkPredicateBase()
Definition:
network-predicate.cpp:35
common.hpp
nfd::NetworkPredicateBase::m_whitelist
std::set< std::string > m_whitelist
Definition:
network-predicate.hpp:81
ndn::net::NetworkInterface
Represents one network interface attached to the host.
Definition:
network-interface.hpp:69
nfd::NetworkInterfacePredicate
Represents a predicate to accept or reject a ndn::net::NetworkInterface.
Definition:
network-predicate.hpp:95
nfd::NetworkPredicateBase::parseBlacklist
void parseBlacklist(const boost::property_tree::ptree &list)
Definition:
network-predicate.cpp:103
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
nfd::NetworkPredicateBase::operator==
bool operator==(const NetworkPredicateBase &other) const
Definition:
network-predicate.cpp:161
nfd::NetworkInterfacePredicate::operator()
bool operator()(const ndn::net::NetworkInterface &netif) const
Definition:
network-predicate.cpp:194
nfd::NetworkPredicateBase::clear
void clear()
Set the whitelist to "*" and clear the blacklist.
Definition:
network-predicate.cpp:43
nfd::NetworkPredicateBase::m_blacklist
std::set< std::string > m_blacklist
Definition:
network-predicate.hpp:82
nfd::NetworkPredicateBase::operator!=
bool operator!=(const NetworkPredicateBase &other) const
Definition:
network-predicate.hpp:62
nfd::IpAddressPredicate
Represents a predicate to accept or reject an IP address.
Definition:
network-predicate.hpp:117
PUBLIC_WITH_TESTS_ELSE_PROTECTED
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED
Definition:
common.hpp:39
ndnSIM
NFD
core
network-predicate.hpp
Generated on Sun Feb 24 2019 22:16:07 for ndnSIM by
1.8.15