NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
dns.hpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013-2018 Regents of the University of California.
4
*
5
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6
*
7
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
8
* terms of the GNU Lesser General Public License as published by the Free Software
9
* Foundation, either version 3 of the License, or (at your option) any later version.
10
*
11
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14
*
15
* You should have received copies of the GNU General Public License and GNU Lesser
16
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17
* <http://www.gnu.org/licenses/>.
18
*
19
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20
*/
21
22
#ifndef NDN_NET_DNS_HPP
23
#define NDN_NET_DNS_HPP
24
25
#include "
asio-fwd.hpp
"
26
#include "../util/time.hpp"
27
28
#include <boost/asio/ip/address.hpp>
29
30
namespace
ndn
{
31
namespace
dns {
32
33
typedef
boost::asio::ip::address
IpAddress
;
34
typedef
function<bool (const IpAddress& address)>
AddressSelector
;
35
36
struct
AnyAddress
37
{
38
bool
39
operator()
(
const
IpAddress
& address)
const
40
{
41
return
true
;
42
}
43
};
44
45
struct
Ipv4Only
46
{
47
bool
48
operator()
(
const
IpAddress
& address)
const
49
{
50
return
address.is_v4();
51
}
52
};
53
54
struct
Ipv6Only
55
{
56
bool
57
operator()
(
const
IpAddress
& address)
const
58
{
59
return
address.is_v6();
60
}
61
};
62
63
struct
Error
:
public
std::runtime_error
64
{
65
explicit
66
Error
(
const
std::string& what)
67
:
std
::runtime_error(what)
68
{
69
}
70
};
71
72
typedef
function<void (const IpAddress& address)>
SuccessCallback
;
73
typedef
function<void (const std::string& reason)>
ErrorCallback
;
74
91
void
92
asyncResolve
(
const
std::string& host,
93
const
SuccessCallback
& onSuccess,
94
const
ErrorCallback
& onError,
95
boost::asio::io_service& ioService,
96
const
AddressSelector
& addressSelector =
AnyAddress
(),
97
time::nanoseconds timeout = 4_s);
98
110
IpAddress
111
syncResolve
(
const
std::string& host,
112
boost::asio::io_service& ioService,
113
const
AddressSelector
& addressSelector =
AnyAddress
());
114
115
}
// namespace dns
116
}
// namespace ndn
117
118
#endif // NDN_NET_DNS_HPP
ndn::dns::AnyAddress
Definition:
dns.hpp:36
ndn::dns::Error::Error
Error(const std::string &what)
Definition:
dns.hpp:66
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::dns::SuccessCallback
function< void(const IpAddress &address)> SuccessCallback
Definition:
dns.hpp:72
std
STL namespace.
ndn::dns::syncResolve
IpAddress syncResolve(const std::string &host, boost::asio::io_service &ioService, const AddressSelector &addressSelector)
Synchronously resolve host.
Definition:
dns.cpp:145
ndn::dns::AddressSelector
function< bool(const IpAddress &address)> AddressSelector
Definition:
dns.hpp:34
ndn::dns::ErrorCallback
function< void(const std::string &reason)> ErrorCallback
Definition:
dns.hpp:73
asio-fwd.hpp
ndn::dns::Ipv6Only::operator()
bool operator()(const IpAddress &address) const
Definition:
dns.hpp:57
ndn::dns::Error
Definition:
dns.hpp:63
ndn::dns::Ipv6Only
Definition:
dns.hpp:54
ndn::dns::IpAddress
boost::asio::ip::address IpAddress
Definition:
dns.hpp:33
ndn::dns::Ipv4Only
Definition:
dns.hpp:45
ndn::dns::AnyAddress::operator()
bool operator()(const IpAddress &address) const
Definition:
dns.hpp:39
ndn::dns::Ipv4Only::operator()
bool operator()(const IpAddress &address) const
Definition:
dns.hpp:48
ndn::dns::asyncResolve
void asyncResolve(const std::string &host, const SuccessCallback &onSuccess, const ErrorCallback &onError, boost::asio::io_service &ioService, const AddressSelector &addressSelector, time::nanoseconds timeout)
Asynchronously resolve host.
Definition:
dns.cpp:132
ndnSIM
ndn-cxx
src
net
dns.hpp
Generated on Sun Feb 25 2018 13:27:05 for ndnSIM by
1.8.14