NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
face-uri.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2019 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 ndn-cxx library (NDN C++ library with eXperimental eXtensions).
12  *
13  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
14  * terms of the GNU Lesser General Public License as published by the Free Software
15  * Foundation, either version 3 of the License, or (at your option) any later version.
16  *
17  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
18  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
20  *
21  * You should have received copies of the GNU General Public License and GNU Lesser
22  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
23  * <http://www.gnu.org/licenses/>.
24  *
25  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
26  */
27 
28 #include "ndn-cxx/net/face-uri.hpp"
29 // #include "ndn-cxx/net/dns.hpp"
31 
32 #include <boost/algorithm/string.hpp>
33 #include <boost/lexical_cast.hpp>
34 #include <boost/mpl/vector.hpp>
35 #include <boost/mpl/for_each.hpp>
36 
37 #include <regex>
38 #include <set>
39 #include <sstream>
40 
41 namespace ndn {
42 
43 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<FaceUri>));
44 
46  : m_isV6(false)
47 {
48 }
49 
50 FaceUri::FaceUri(const std::string& uri)
51 {
52  if (!parse(uri)) {
53  NDN_THROW(Error("Malformed URI: " + uri));
54  }
55 }
56 
57 FaceUri::FaceUri(const char* uri)
58  : FaceUri(std::string(uri))
59 {
60 }
61 
62 bool
63 FaceUri::parse(const std::string& uri)
64 {
65  m_scheme.clear();
66  m_host.clear();
67  m_port.clear();
68  m_path.clear();
69  m_isV6 = false;
70 
71  static const std::regex protocolExp("(\\w+\\d?(\\+\\w+)?)://([^/]*)(\\/[^?]*)?");
72  std::smatch protocolMatch;
73  if (!std::regex_match(uri, protocolMatch, protocolExp)) {
74  return false;
75  }
76  m_scheme = protocolMatch[1];
77  std::string authority = protocolMatch[3];
78  m_path = protocolMatch[4];
79 
80  // pattern for IPv6 link local address enclosed in [ ], with optional port number
81  static const std::regex v6LinkLocalExp("^\\[([a-fA-F0-9:]+)%([^\\s/:]+)\\](?:\\:(\\d+))?$");
82  // pattern for IPv6 address enclosed in [ ], with optional port number
83  static const std::regex v6Exp("^\\[([a-fA-F0-9:]+)\\](?:\\:(\\d+))?$");
84  // pattern for Ethernet address in standard hex-digits-and-colons notation
85  static const std::regex etherExp("^\\[((?:[a-fA-F0-9]{1,2}\\:){5}(?:[a-fA-F0-9]{1,2}))\\]$");
86  // pattern for IPv4-mapped IPv6 address, with optional port number
87  static const std::regex v4MappedV6Exp("^\\[::ffff:(\\d+(?:\\.\\d+){3})\\](?:\\:(\\d+))?$");
88  // pattern for IPv4/hostname/fd/ifname, with optional port number
89  static const std::regex v4HostExp("^([^:]+)(?:\\:(\\d+))?$");
90 
91  if (authority.empty()) {
92  // UNIX, internal
93  }
94  else {
95  std::smatch match;
96  if (std::regex_match(authority, match, v6LinkLocalExp)) {
97  m_isV6 = true;
98  m_host = match[1].str() + "%" + match[2].str();
99  m_port = match[3];
100  return true;
101  }
102 
103  m_isV6 = std::regex_match(authority, match, v6Exp);
104  if (m_isV6 ||
105  std::regex_match(authority, match, etherExp) ||
106  std::regex_match(authority, match, v4MappedV6Exp) ||
107  std::regex_match(authority, match, v4HostExp)) {
108  m_host = match[1];
109  m_port = match[2];
110  }
111  else {
112  return false;
113  }
114  }
115 
116  return true;
117 }
118 
119 FaceUri::FaceUri(const boost::asio::ip::udp::endpoint& endpoint)
120 {
121  m_isV6 = endpoint.address().is_v6();
122  m_scheme = m_isV6 ? "udp6" : "udp4";
123  m_host = endpoint.address().to_string();
124  m_port = to_string(endpoint.port());
125 }
126 
127 FaceUri::FaceUri(const boost::asio::ip::tcp::endpoint& endpoint)
128 {
129  m_isV6 = endpoint.address().is_v6();
130  m_scheme = m_isV6 ? "tcp6" : "tcp4";
131  m_host = endpoint.address().to_string();
132  m_port = to_string(endpoint.port());
133 }
134 
135 FaceUri::FaceUri(const boost::asio::ip::tcp::endpoint& endpoint, const std::string& scheme)
136 {
137  m_isV6 = endpoint.address().is_v6();
138  m_scheme = scheme;
139  m_host = endpoint.address().to_string();
140  m_port = to_string(endpoint.port());
141 }
142 
143 #ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS
144 FaceUri::FaceUri(const boost::asio::local::stream_protocol::endpoint& endpoint)
145  : m_scheme("unix")
146  , m_path(endpoint.path())
147  , m_isV6(false)
148 {
149 }
150 #endif // BOOST_ASIO_HAS_LOCAL_SOCKETS
151 
152 FaceUri
154 {
155  FaceUri uri;
156  uri.m_scheme = "fd";
157  uri.m_host = to_string(fd);
158  return uri;
159 }
160 
162  : m_scheme("ether")
163  , m_host(address.toString())
164  , m_isV6(true)
165 {
166 }
167 
168 FaceUri
169 FaceUri::fromDev(const std::string& ifname)
170 {
171  FaceUri uri;
172  uri.m_scheme = "dev";
173  uri.m_host = ifname;
174  return uri;
175 }
176 
177 FaceUri
178 FaceUri::fromUdpDev(const boost::asio::ip::udp::endpoint& endpoint, const std::string& ifname)
179 {
180  FaceUri uri;
181  uri.m_scheme = endpoint.address().is_v6() ? "udp6+dev" : "udp4+dev";
182  uri.m_host = ifname;
183  uri.m_port = to_string(endpoint.port());
184  return uri;
185 }
186 
187 std::string
189 {
190  std::ostringstream os;
191  os << *this;
192  return os.str();
193 }
194 
195 std::ostream&
196 operator<<(std::ostream& os, const FaceUri& uri)
197 {
198  os << uri.m_scheme << "://";
199  if (uri.m_isV6) {
200  os << "[" << uri.m_host << "]";
201  }
202  else {
203  os << uri.m_host;
204  }
205  if (!uri.m_port.empty()) {
206  os << ":" << uri.m_port;
207  }
208  os << uri.m_path;
209  return os;
210 }
211 
212 
215 class CanonizeProvider : noncopyable
216 {
217 public:
218  virtual
219  ~CanonizeProvider() = default;
220 
221  virtual std::set<std::string>
222  getSchemes() const = 0;
223 
224  virtual bool
225  isCanonical(const FaceUri& faceUri) const = 0;
226 
227  virtual void
228  canonize(const FaceUri& faceUri,
229  const FaceUri::CanonizeSuccessCallback& onSuccess,
230  const FaceUri::CanonizeFailureCallback& onFailure,
231  time::nanoseconds timeout) const = 0;
232 };
233 
234 template<typename Protocol>
236 {
237 public:
238  std::set<std::string>
239  getSchemes() const override
240  {
241  return {m_baseScheme, m_v4Scheme, m_v6Scheme};
242  }
243 
244  bool
245  isCanonical(const FaceUri& faceUri) const override
246  {
247  BOOST_THROW_EXCEPTION(std::runtime_error("IP host canonization not supported"));
248  // if (faceUri.getPort().empty()) {
249  // return false;
250  // }
251  // if (!faceUri.getPath().empty()) {
252  // return false;
253  // }
254 
255  // boost::system::error_code ec;
256  // auto addr = ip::addressFromString(unescapeHost(faceUri.getHost()), ec);
257  // if (ec) {
258  // return false;
259  // }
260 
261  // bool hasCorrectScheme = (faceUri.getScheme() == m_v4Scheme && addr.is_v4()) ||
262  // (faceUri.getScheme() == m_v6Scheme && addr.is_v6());
263  // if (!hasCorrectScheme) {
264  // return false;
265  // }
266 
267  // auto checkAddressWithUri = [] (const boost::asio::ip::address& addr,
268  // const FaceUri& faceUri) -> bool {
269  // if (addr.is_v4() || !addr.to_v6().is_link_local()) {
270  // return addr.to_string() == faceUri.getHost();
271  // }
272 
273  // std::vector<std::string> addrFields, faceUriFields;
274  // std::string addrString = addr.to_string();
275  // std::string faceUriString = faceUri.getHost();
276 
277  // boost::algorithm::split(addrFields, addrString, boost::is_any_of("%"));
278  // boost::algorithm::split(faceUriFields, faceUriString, boost::is_any_of("%"));
279  // if (addrFields.size() != 2 || faceUriFields.size() != 2) {
280  // return false;
281  // }
282 
283  // if (faceUriFields[1].size() > 2 && faceUriFields[1].compare(0, 2, "25") == 0) {
284  // // %25... is accepted, but not a canonical form
285  // return false;
286  // }
287 
288  // return addrFields[0] == faceUriFields[0] &&
289  // addrFields[1] == faceUriFields[1];
290  // };
291 
292  // return checkAddressWithUri(addr, faceUri) && checkAddress(addr).first;
293  }
294 
295  void
296  canonize(const FaceUri& faceUri,
297  const FaceUri::CanonizeSuccessCallback& onSuccess,
298  const FaceUri::CanonizeFailureCallback& onFailure,
299  time::nanoseconds timeout) const override
300  {
301  BOOST_THROW_EXCEPTION(std::runtime_error("IP host canonization not supported"));
302  // if (this->isCanonical(faceUri)) {
303  // onSuccess(faceUri);
304  // return;
305  // }
306 
307  // // make a copy because caller may modify faceUri
308  // auto uri = make_shared<FaceUri>(faceUri);
309  // boost::system::error_code ec;
310  // auto ipAddress = ip::addressFromString(unescapeHost(faceUri.getHost()), ec);
311  // if (!ec) {
312  // // No need to resolve IP address if host is already an IP
313  // if ((faceUri.getScheme() == m_v4Scheme && !ipAddress.is_v4()) ||
314  // (faceUri.getScheme() == m_v6Scheme && !ipAddress.is_v6())) {
315  // return onFailure("IPv4/v6 mismatch");
316  // }
317 
318  // onDnsSuccess(uri, onSuccess, onFailure, ipAddress);
319  // }
320  // else {
321  // dns::AddressSelector addressSelector;
322  // if (faceUri.getScheme() == m_v4Scheme) {
323  // addressSelector = dns::Ipv4Only();
324  // }
325  // else if (faceUri.getScheme() == m_v6Scheme) {
326  // addressSelector = dns::Ipv6Only();
327  // }
328  // else {
329  // BOOST_ASSERT(faceUri.getScheme() == m_baseScheme);
330  // addressSelector = dns::AnyAddress();
331  // }
332 
333  // dns::asyncResolve(unescapeHost(faceUri.getHost()),
334  // bind(&IpHostCanonizeProvider<Protocol>::onDnsSuccess, this, uri, onSuccess, onFailure, _1),
335  // bind(&IpHostCanonizeProvider<Protocol>::onDnsFailure, this, uri, onFailure, _1),
336  // io, addressSelector, timeout);
337  // }
338  }
339 
340 protected:
341  explicit
342  IpHostCanonizeProvider(const std::string& baseScheme,
343  uint16_t defaultUnicastPort = 6363,
344  uint16_t defaultMulticastPort = 56363)
345  : m_baseScheme(baseScheme)
346  , m_v4Scheme(baseScheme + '4')
347  , m_v6Scheme(baseScheme + '6')
348  , m_defaultUnicastPort(defaultUnicastPort)
349  , m_defaultMulticastPort(defaultMulticastPort)
350  {
351  }
352 
353 private:
354  // void
355  // onDnsSuccess(const shared_ptr<FaceUri>& faceUri,
356  // const FaceUri::CanonizeSuccessCallback& onSuccess,
357  // const FaceUri::CanonizeFailureCallback& onFailure,
358  // const dns::IpAddress& ipAddress) const
359  // {
360  // bool isOk = false;
361  // std::string reason;
362  // std::tie(isOk, reason) = this->checkAddress(ipAddress);
363  // if (!isOk) {
364  // return onFailure(reason);
365  // }
366 
367  // uint16_t port = 0;
368  // if (faceUri->getPort().empty()) {
369  // port = ipAddress.is_multicast() ? m_defaultMulticastPort : m_defaultUnicastPort;
370  // }
371  // else {
372  // try {
373  // port = boost::lexical_cast<uint16_t>(faceUri->getPort());
374  // }
375  // catch (const boost::bad_lexical_cast&) {
376  // return onFailure("invalid port number '" + faceUri->getPort() + "'");
377  // }
378  // }
379 
380  // FaceUri canonicalUri(typename Protocol::endpoint(ipAddress, port));
381  // BOOST_ASSERT(canonicalUri.isCanonical());
382  // onSuccess(canonicalUri);
383  // }
384 
385  // void
386  // onDnsFailure(const shared_ptr<FaceUri>& faceUri,
387  // const FaceUri::CanonizeFailureCallback& onFailure,
388  // const std::string& reason) const
389  // {
390  // onFailure(reason);
391  // }
392 
397  // virtual std::pair<bool, std::string>
398  // checkAddress(const dns::IpAddress& ipAddress) const
399  // {
400  // return {true, ""};
401  // }
402 
403  static std::string
404  unescapeHost(std::string host)
405  {
406  auto escapePos = host.find("%25");
407  if (escapePos != std::string::npos && escapePos < host.size() - 3) {
408  host = unescape(host);
409  }
410  return host;
411  }
412 
413 private:
414  std::string m_baseScheme;
415  std::string m_v4Scheme;
416  std::string m_v6Scheme;
417  uint16_t m_defaultUnicastPort;
418  uint16_t m_defaultMulticastPort;
419 };
420 
421 class UdpCanonizeProvider : public IpHostCanonizeProvider<boost::asio::ip::udp>
422 {
423 public:
425  : IpHostCanonizeProvider("udp")
426  {
427  }
428 };
429 
430 class TcpCanonizeProvider : public IpHostCanonizeProvider<boost::asio::ip::tcp>
431 {
432 public:
434  : IpHostCanonizeProvider("tcp")
435  {
436  }
437 
438 protected:
439  // std::pair<bool, std::string>
440  // checkAddress(const dns::IpAddress& ipAddress) const override
441  // {
442  // if (ipAddress.is_multicast()) {
443  // return {false, "cannot use multicast address"};
444  // }
445  // return {true, ""};
446  // }
447 };
448 
450 {
451 public:
452  std::set<std::string>
453  getSchemes() const override
454  {
455  return {"ether"};
456  }
457 
458  bool
459  isCanonical(const FaceUri& faceUri) const override
460  {
461  if (!faceUri.getPort().empty()) {
462  return false;
463  }
464  if (!faceUri.getPath().empty()) {
465  return false;
466  }
467 
468  auto addr = ethernet::Address::fromString(faceUri.getHost());
469  return addr.toString() == faceUri.getHost();
470  }
471 
472  void
473  canonize(const FaceUri& faceUri,
474  const FaceUri::CanonizeSuccessCallback& onSuccess,
475  const FaceUri::CanonizeFailureCallback& onFailure,
476  time::nanoseconds timeout) const override
477  {
478  auto addr = ethernet::Address::fromString(faceUri.getHost());
479  if (addr.isNull()) {
480  return onFailure("invalid ethernet address '" + faceUri.getHost() + "'");
481  }
482 
483  FaceUri canonicalUri(addr);
484  BOOST_ASSERT(canonicalUri.isCanonical());
485  onSuccess(canonicalUri);
486  }
487 };
488 
490 {
491 public:
492  std::set<std::string>
493  getSchemes() const override
494  {
495  return {"dev"};
496  }
497 
498  bool
499  isCanonical(const FaceUri& faceUri) const override
500  {
501  return !faceUri.getHost().empty() && faceUri.getPort().empty() && faceUri.getPath().empty();
502  }
503 
504  void
505  canonize(const FaceUri& faceUri,
506  const FaceUri::CanonizeSuccessCallback& onSuccess,
507  const FaceUri::CanonizeFailureCallback& onFailure,
508  time::nanoseconds timeout) const override
509  {
510  if (faceUri.getHost().empty()) {
511  onFailure("network interface name is missing");
512  return;
513  }
514  if (!faceUri.getPort().empty()) {
515  onFailure("port number is not allowed");
516  return;
517  }
518  if (!faceUri.getPath().empty() && faceUri.getPath() != "/") { // permit trailing slash only
519  onFailure("path is not allowed");
520  return;
521  }
522 
523  FaceUri canonicalUri = FaceUri::fromDev(faceUri.getHost());
524  BOOST_ASSERT(canonicalUri.isCanonical());
525  onSuccess(canonicalUri);
526  }
527 };
528 
530 {
531 public:
532  std::set<std::string>
533  getSchemes() const override
534  {
535  return {"udp4+dev", "udp6+dev"};
536  }
537 
538  bool
539  isCanonical(const FaceUri& faceUri) const override
540  {
541  if (faceUri.getPort().empty()) {
542  return false;
543  }
544  if (!faceUri.getPath().empty()) {
545  return false;
546  }
547  return true;
548  }
549 
550  void
551  canonize(const FaceUri& faceUri,
552  const FaceUri::CanonizeSuccessCallback& onSuccess,
553  const FaceUri::CanonizeFailureCallback& onFailure,
554  time::nanoseconds timeout) const override
555  {
556  if (this->isCanonical(faceUri)) {
557  onSuccess(faceUri);
558  }
559  else {
560  onFailure("cannot canonize " + faceUri.toString());
561  }
562  }
563 };
564 
565 using CanonizeProviders = boost::mpl::vector<UdpCanonizeProvider*,
570 using CanonizeProviderTable = std::map<std::string, shared_ptr<CanonizeProvider>>;
571 
573 {
574 public:
575  explicit
577  : m_providerTable(providerTable)
578  {
579  }
580 
581  template<typename CP>
582  void
584  {
585  shared_ptr<CanonizeProvider> cp = make_shared<CP>();
586  auto schemes = cp->getSchemes();
587  BOOST_ASSERT(!schemes.empty());
588 
589  for (const auto& scheme : schemes) {
590  BOOST_ASSERT(m_providerTable.count(scheme) == 0);
591  m_providerTable[scheme] = cp;
592  }
593  }
594 
595 private:
596  CanonizeProviderTable& m_providerTable;
597 };
598 
599 static const CanonizeProvider*
600 getCanonizeProvider(const std::string& scheme)
601 {
602  static CanonizeProviderTable providerTable;
603  if (providerTable.empty()) {
604  boost::mpl::for_each<CanonizeProviders>(CanonizeProviderTableInitializer(providerTable));
605  BOOST_ASSERT(!providerTable.empty());
606  }
607 
608  auto it = providerTable.find(scheme);
609  return it == providerTable.end() ? nullptr : it->second.get();
610 }
611 
612 
613 bool
614 FaceUri::canCanonize(const std::string& scheme)
615 {
616  return getCanonizeProvider(scheme) != nullptr;
617 }
618 
619 bool
621 {
622  const CanonizeProvider* cp = getCanonizeProvider(this->getScheme());
623  if (cp == nullptr) {
624  return false;
625  }
626 
627  return cp->isCanonical(*this);
628 }
629 
630 void
632  const CanonizeFailureCallback& onFailure,
633  time::nanoseconds timeout) const
634 {
635  const CanonizeProvider* cp = getCanonizeProvider(this->getScheme());
636  if (cp == nullptr) {
637  if (onFailure) {
638  onFailure("scheme not supported");
639  }
640  return;
641  }
642 
643  cp->canonize(*this,
644  onSuccess ? onSuccess : [] (auto&&) {},
645  onFailure ? onFailure : [] (auto&&) {},
646  timeout);
647 }
648 
649 } // namespace ndn
ndn::getCanonizeProvider
static const CanonizeProvider * getCanonizeProvider(const std::string &scheme)
Definition: face-uri.cpp:600
ndn::FaceUri::getPath
const std::string & getPath() const
get path
Definition: face-uri.hpp:130
ndn::DevCanonizeProvider::isCanonical
bool isCanonical(const FaceUri &faceUri) const override
Definition: face-uri.cpp:499
string-helper.hpp
ndn::UdpDevCanonizeProvider::getSchemes
std::set< std::string > getSchemes() const override
Definition: face-uri.cpp:533
ndn::UdpCanonizeProvider::UdpCanonizeProvider
UdpCanonizeProvider()
Definition: face-uri.cpp:424
ndn::IpHostCanonizeProvider::canonize
void canonize(const FaceUri &faceUri, const FaceUri::CanonizeSuccessCallback &onSuccess, const FaceUri::CanonizeFailureCallback &onFailure, time::nanoseconds timeout) const override
Definition: face-uri.cpp:296
ndn::IpHostCanonizeProvider::isCanonical
bool isCanonical(const FaceUri &faceUri) const override
Definition: face-uri.cpp:245
ndn::FaceUri
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:45
ndn::FaceUri::CanonizeSuccessCallback
function< void(const FaceUri &)> CanonizeSuccessCallback
Definition: face-uri.hpp:153
ndn::ethernet::Address
represents an Ethernet hardware address
Definition: ethernet.hpp:53
ndn::TcpCanonizeProvider
Definition: face-uri.cpp:431
ndn::FaceUri::CanonizeFailureCallback
function< void(const std::string &reason)> CanonizeFailureCallback
Definition: face-uri.hpp:154
ndn::CanonizeProvider::isCanonical
virtual bool isCanonical(const FaceUri &faceUri) const =0
ndn::DevCanonizeProvider::getSchemes
std::set< std::string > getSchemes() const override
Definition: face-uri.cpp:493
ndn::CanonizeProvider::~CanonizeProvider
virtual ~CanonizeProvider()=default
ndn::DevCanonizeProvider
Definition: face-uri.cpp:490
ndn::IpHostCanonizeProvider::getSchemes
std::set< std::string > getSchemes() const override
Definition: face-uri.cpp:239
ndn::CanonizeProviderTableInitializer::CanonizeProviderTableInitializer
CanonizeProviderTableInitializer(CanonizeProviderTable &providerTable)
Definition: face-uri.cpp:576
ndn::ethernet::Address::fromString
static Address fromString(const std::string &str)
Creates an Address from a string containing an Ethernet address in hexadecimal notation,...
Definition: ethernet.cpp:92
ndn::FaceUri::canonize
void canonize(const CanonizeSuccessCallback &onSuccess, const CanonizeFailureCallback &onFailure, time::nanoseconds timeout) const
asynchronously convert this FaceUri to canonical form
Definition: face-uri.cpp:631
ndn::CanonizeProviderTableInitializer::operator()
void operator()(CP *)
Definition: face-uri.cpp:583
ndn::CanonizeProviderTable
std::map< std::string, shared_ptr< CanonizeProvider > > CanonizeProviderTable
Definition: face-uri.cpp:570
ndn::UdpCanonizeProvider
Definition: face-uri.cpp:422
ndn::FaceUri::toString
std::string toString() const
write as a string
Definition: face-uri.cpp:188
ndn::FaceUri::fromUdpDev
static FaceUri fromUdpDev(const boost::asio::ip::udp::endpoint &endpoint, const std::string &ifname)
create udp4 or udp6 NIC-associated FaceUri from endpoint and network device name
Definition: face-uri.cpp:178
ndn::EtherCanonizeProvider::getSchemes
std::set< std::string > getSchemes() const override
Definition: face-uri.cpp:453
face-uri.hpp
ndn::UdpDevCanonizeProvider::isCanonical
bool isCanonical(const FaceUri &faceUri) const override
Definition: face-uri.cpp:539
ndn::EtherCanonizeProvider
Definition: face-uri.cpp:450
ndn::IpHostCanonizeProvider
Definition: face-uri.cpp:236
NDN_THROW
#define NDN_THROW(e)
Definition: exception.hpp:61
ndn::FaceUri::fromDev
static FaceUri fromDev(const std::string &ifname)
create dev FaceUri from network device name
Definition: face-uri.cpp:169
ndn::UdpDevCanonizeProvider::canonize
void canonize(const FaceUri &faceUri, const FaceUri::CanonizeSuccessCallback &onSuccess, const FaceUri::CanonizeFailureCallback &onFailure, time::nanoseconds timeout) const override
Definition: face-uri.cpp:551
ndn::unescape
std::string unescape(const std::string &str)
Decode a percent-encoded string.
Definition: string-helper.cpp:126
ndn::IpHostCanonizeProvider::IpHostCanonizeProvider
IpHostCanonizeProvider(const std::string &baseScheme, uint16_t defaultUnicastPort=6363, uint16_t defaultMulticastPort=56363)
Definition: face-uri.cpp:342
ndn::FaceUri::getHost
const std::string & getHost() const
get host (domain)
Definition: face-uri.hpp:116
ndn::FaceUri::Error
Definition: face-uri.hpp:48
ndn::CanonizeProviders
boost::mpl::vector< UdpCanonizeProvider *, TcpCanonizeProvider *, EtherCanonizeProvider *, DevCanonizeProvider *, UdpDevCanonizeProvider * > CanonizeProviders
Definition: face-uri.cpp:569
ndn::DevCanonizeProvider::canonize
void canonize(const FaceUri &faceUri, const FaceUri::CanonizeSuccessCallback &onSuccess, const FaceUri::CanonizeFailureCallback &onFailure, time::nanoseconds timeout) const override
Definition: face-uri.cpp:505
ndn::FaceUri::canCanonize
static bool canCanonize(const std::string &scheme)
Definition: face-uri.cpp:614
ndn::CanonizeProvider
a CanonizeProvider provides FaceUri canonization functionality for a group of schemes
Definition: face-uri.cpp:216
ndn::FaceUri::fromFd
static FaceUri fromFd(int fd)
create fd FaceUri from file descriptor
Definition: face-uri.cpp:153
ndn::to_string
std::string to_string(const T &val)
Definition: backports.hpp:102
ndn::TcpCanonizeProvider::TcpCanonizeProvider
TcpCanonizeProvider()
Definition: face-uri.cpp:433
ndn::FaceUri::isCanonical
bool isCanonical() const
determine whether this FaceUri is in canonical form
Definition: face-uri.cpp:620
ndn::operator<<
std::ostream & operator<<(std::ostream &os, const Data &data)
Definition: data.cpp:322
ndn::EtherCanonizeProvider::isCanonical
bool isCanonical(const FaceUri &faceUri) const override
Definition: face-uri.cpp:459
ndn::FaceUri::getPort
const std::string & getPort() const
get port
Definition: face-uri.hpp:123
ndn::UdpDevCanonizeProvider
Definition: face-uri.cpp:530
ndn::EtherCanonizeProvider::canonize
void canonize(const FaceUri &faceUri, const FaceUri::CanonizeSuccessCallback &onSuccess, const FaceUri::CanonizeFailureCallback &onFailure, time::nanoseconds timeout) const override
Definition: face-uri.cpp:473
ndn::time::toString
std::string toString(const system_clock::TimePoint &timePoint, const std::string &format, const std::locale &locale)
Convert time point to string with specified format.
Definition: time.cpp:170
ndn::CanonizeProvider::canonize
virtual void canonize(const FaceUri &faceUri, const FaceUri::CanonizeSuccessCallback &onSuccess, const FaceUri::CanonizeFailureCallback &onFailure, time::nanoseconds timeout) const =0
ndn::CanonizeProviderTableInitializer
Definition: face-uri.cpp:573
ndn::FaceUri::FaceUri
FaceUri()
Definition: face-uri.cpp:45
ndn::FaceUri::parse
NDN_CXX_NODISCARD bool parse(const std::string &uri)
exception-safe parsing
Definition: face-uri.cpp:63
ndn::FaceUri::getScheme
const std::string & getScheme() const
get scheme (protocol)
Definition: face-uri.hpp:109
ndn::CanonizeProvider::getSchemes
virtual std::set< std::string > getSchemes() const =0
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34