NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
face-uri.hpp
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
#ifndef NDN_NET_FACE_URI_HPP
29
#define NDN_NET_FACE_URI_HPP
30
31
#include "
ndn-cxx/detail/asio-fwd.hpp
"
32
#include "
ndn-cxx/net/ethernet.hpp
"
33
#include "
ndn-cxx/util/time.hpp
"
34
35
#include <boost/asio/ip/tcp.hpp>
36
#include <boost/asio/ip/udp.hpp>
37
#include <boost/asio/local/stream_protocol.hpp>
38
39
namespace
ndn
{
40
44
class
FaceUri
45
{
46
public
:
47
class
Error
:
public
std::invalid_argument
48
{
49
public
:
50
using
std::invalid_argument::invalid_argument;
51
};
52
53
FaceUri
();
54
60
explicit
61
FaceUri
(
const
std::string& uri);
62
63
// This overload is needed so that calls with string literal won't be
64
// resolved to boost::asio::local::stream_protocol::endpoint overload.
65
explicit
66
FaceUri
(
const
char
* uri);
67
69
NDN_CXX_NODISCARD
bool
70
parse
(
const
std::string& uri);
71
72
public
:
// scheme-specific construction
74
explicit
75
FaceUri
(
const
boost::asio::ip::udp::endpoint& endpoint);
76
78
explicit
79
FaceUri
(
const
boost::asio::ip::tcp::endpoint& endpoint);
80
82
FaceUri
(
const
boost::asio::ip::tcp::endpoint& endpoint,
const
std::string& scheme);
83
84
#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS
85
explicit
87
FaceUri
(
const
boost::asio::local::stream_protocol::endpoint& endpoint);
88
#endif // BOOST_ASIO_HAS_LOCAL_SOCKETS
89
91
static
FaceUri
92
fromFd
(
int
fd);
93
95
explicit
96
FaceUri
(
const
ethernet::Address
& address);
97
99
static
FaceUri
100
fromDev
(
const
std::string& ifname);
101
103
static
FaceUri
104
fromUdpDev
(
const
boost::asio::ip::udp::endpoint& endpoint,
const
std::string& ifname);
105
106
public
:
// getters
108
const
std::string&
109
getScheme
()
const
110
{
111
return
m_scheme;
112
}
113
115
const
std::string&
116
getHost
()
const
117
{
118
return
m_host;
119
}
120
122
const
std::string&
123
getPort
()
const
124
{
125
return
m_port;
126
}
127
129
const
std::string&
130
getPath
()
const
131
{
132
return
m_path;
133
}
134
136
std::string
137
toString
()
const
;
138
139
public
:
// canonical FaceUri
142
static
bool
143
canCanonize
(
const
std::string& scheme);
144
150
bool
151
isCanonical
()
const
;
152
153
typedef
function
<void(
const
FaceUri
&)>
CanonizeSuccessCallback
;
154
typedef
function
<void(
const
std::string& reason)>
CanonizeFailureCallback
;
155
164
void
165
canonize
(
const
CanonizeSuccessCallback
& onSuccess,
166
const
CanonizeFailureCallback
& onFailure,
167
time::nanoseconds timeout)
const
;
168
169
private
:
// non-member operators
170
// NOTE: the following "hidden friend" operators are available via
171
// argument-dependent lookup only and must be defined inline.
172
173
friend
bool
174
operator==
(
const
FaceUri
& lhs,
const
FaceUri
& rhs)
175
{
176
return
!(lhs != rhs);
177
}
178
179
friend
bool
180
operator!=
(
const
FaceUri
& lhs,
const
FaceUri
& rhs)
181
{
182
return
lhs.m_isV6 != rhs.m_isV6 ||
183
lhs.m_scheme != rhs.m_scheme ||
184
lhs.m_host != rhs.m_host ||
185
lhs.m_port != rhs.m_port ||
186
lhs.m_path != rhs.m_path;
187
}
188
189
private
:
190
std::string m_scheme;
191
std::string m_host;
192
std::string m_port;
193
std::string m_path;
195
bool
m_isV6;
196
197
friend
std::ostream&
operator<<
(std::ostream& os,
const
FaceUri
& uri);
198
};
199
200
std::ostream&
201
operator<<
(std::ostream& os,
const
FaceUri& uri);
202
203
}
// namespace ndn
204
205
#endif // NDN_NET_FACE_URI_HPP
ndn::FaceUri::getPath
const std::string & getPath() const
get path
Definition:
face-uri.hpp:130
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::FaceUri::CanonizeFailureCallback
function< void(const std::string &reason)> CanonizeFailureCallback
Definition:
face-uri.hpp:154
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::FaceUri::operator!=
friend bool operator!=(const FaceUri &lhs, const FaceUri &rhs)
Definition:
face-uri.hpp:180
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::FaceUri::operator==
friend bool operator==(const FaceUri &lhs, const FaceUri &rhs)
Definition:
face-uri.hpp:174
NDN_CXX_NODISCARD
#define NDN_CXX_NODISCARD
Definition:
backports.hpp:68
ndn::FaceUri::fromDev
static FaceUri fromDev(const std::string &ifname)
create dev FaceUri from network device name
Definition:
face-uri.cpp:169
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::FaceUri::canCanonize
static bool canCanonize(const std::string &scheme)
Definition:
face-uri.cpp:614
ndn::FaceUri::fromFd
static FaceUri fromFd(int fd)
create fd FaceUri from file descriptor
Definition:
face-uri.cpp:153
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::FaceUri::getPort
const std::string & getPort() const
get port
Definition:
face-uri.hpp:123
time.hpp
ethernet.hpp
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
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
asio-fwd.hpp
ndn::FaceUri::operator<<
friend std::ostream & operator<<(std::ostream &os, const FaceUri &uri)
Definition:
face-uri.cpp:196
ndnSIM
ndn-cxx
ndn-cxx
net
face-uri.hpp
Generated on Mon Jun 1 2020 22:32:14 for ndnSIM by
1.8.18