NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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; -*- */
22 #ifndef NDN_UTIL_DNS_H
23 #define NDN_UTIL_DNS_H
24 
25 #include "../util/time.hpp"
26 #include <boost/asio/ip/address.hpp>
27 #include <boost/asio/io_service.hpp>
28 
29 namespace ndn {
30 namespace dns {
31 
32 typedef function<bool (const boost::asio::ip::address& address)> AddressSelector;
33 
34 struct AnyAddress
35 {
36  bool
37  operator()(const boost::asio::ip::address& address)
38  {
39  return true;
40  }
41 };
42 
43 struct Ipv4Only
44 {
45  bool
46  operator()(const boost::asio::ip::address& address)
47  {
48  return address.is_v4();
49  }
50 };
51 
52 struct Ipv6Only
53 {
54  bool
55  operator()(const boost::asio::ip::address& address)
56  {
57  return address.is_v6();
58  }
59 };
60 
61 struct Error : public std::runtime_error
62 {
63  Error(const std::string& what)
64  : std::runtime_error(what)
65  {
66  }
67 };
68 
69 typedef boost::asio::ip::address IpAddress;
70 
71 typedef function<void (const IpAddress& address)> SuccessCallback;
72 typedef function<void (const std::string& reason)> ErrorCallback;
73 
85 void
86 asyncResolve(const std::string& host,
87  const SuccessCallback& onSuccess,
88  const ErrorCallback& onError,
89  boost::asio::io_service& ioService,
90  const ndn::dns::AddressSelector& addressSelector = ndn::dns::AnyAddress(),
91  const time::nanoseconds& timeout = time::seconds(4));
92 
104 IpAddress
105 syncResolve(const std::string& host,
106  boost::asio::io_service& ioService,
107  const ndn::dns::AddressSelector& addressSelector = ndn::dns::AnyAddress());
108 
109 } // namespace dns
110 } // namespace ndn
111 
112 #endif // NDN_UTIL_DNS_H
Error(const std::string &what)
Definition: dns.hpp:63
Copyright (c) 2011-2015 Regents of the University of California.
void asyncResolve(const std::string &host, const SuccessCallback &onSuccess, const ErrorCallback &onError, boost::asio::io_service &ioService, const ndn::dns::AddressSelector &addressSelector, const time::nanoseconds &timeout)
Asynchronously resolve host.
Definition: dns.cpp:123
function< bool(const boost::asio::ip::address &address)> AddressSelector
Definition: dns.hpp:32
IpAddress syncResolve(const std::string &host, boost::asio::io_service &ioService, const ndn::dns::AddressSelector &addressSelector)
Synchronously resolve host.
Definition: dns.cpp:137
function< void(const IpAddress &address)> SuccessCallback
Definition: dns.hpp:71
bool operator()(const boost::asio::ip::address &address)
Definition: dns.hpp:37
STL namespace.
bool operator()(const boost::asio::ip::address &address)
Definition: dns.hpp:55
function< void(const std::string &reason)> ErrorCallback
Definition: dns.hpp:72
boost::asio::ip::address IpAddress
Definition: dns.hpp:69
bool operator()(const boost::asio::ip::address &address)
Definition: dns.hpp:46