28 #ifndef NDN_CXX_NET_FACE_URI_HPP
29 #define NDN_CXX_NET_FACE_URI_HPP
35 #include <boost/asio/ip/tcp.hpp>
36 #include <boost/asio/ip/udp.hpp>
37 #include <boost/asio/local/stream_protocol.hpp>
38 #include <boost/operators.hpp>
46 class FaceUri :
private boost::totally_ordered<FaceUri>
49 class Error :
public std::invalid_argument
52 using std::invalid_argument::invalid_argument;
64 FaceUri(
const std::string& uri);
78 parse(std::string_view uri);
83 FaceUri(
const boost::asio::ip::udp::endpoint& endpoint);
87 FaceUri(
const boost::asio::ip::tcp::endpoint& endpoint);
90 FaceUri(
const boost::asio::ip::tcp::endpoint& endpoint, std::string_view scheme);
92 #ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS
95 FaceUri(
const boost::asio::local::stream_protocol::endpoint& endpoint);
108 fromDev(std::string_view ifname);
112 fromUdpDev(
const boost::asio::ip::udp::endpoint& endpoint, std::string_view ifname);
178 boost::asio::io_context& io,
183 print(std::ostream& os)
const;
193 return lhs.m_isV6 == rhs.m_isV6 &&
194 lhs.m_scheme == rhs.m_scheme &&
195 lhs.m_host == rhs.m_host &&
196 lhs.m_port == rhs.m_port &&
197 lhs.m_path == rhs.m_path;
203 return std::tie(lhs.m_scheme, lhs.m_isV6, lhs.m_host, lhs.m_port, lhs.m_path) <
204 std::tie(rhs.m_scheme, rhs.m_isV6, rhs.m_host, rhs.m_port, rhs.m_path);
215 std::string m_scheme;
The underlying protocol and address used by a Face.
std::string toString() const
Return string representation.
void canonize(const CanonizeSuccessCallback &onSuccess, const CanonizeFailureCallback &onFailure, boost::asio::io_context &io, time::nanoseconds timeout) const
Asynchronously convert this FaceUri to canonical form.
std::function< void(const std::string &reason)> CanonizeFailureCallback
friend bool operator==(const FaceUri &lhs, const FaceUri &rhs) noexcept
static FaceUri fromDev(std::string_view ifname)
Construct a dev FaceUri from a network device name.
FaceUri()
Construct an empty FaceUri.
friend std::ostream & operator<<(std::ostream &os, const FaceUri &uri)
const std::string & getScheme() const
Get scheme (protocol)
static bool canCanonize(const std::string &scheme)
Return whether a FaceUri of the specified scheme can be canonized.
bool isCanonical() const
Determine whether this FaceUri is in canonical form.
const std::string & getHost() const
Get host (domain or address)
const std::string & getPath() const
Get path.
bool parse(std::string_view uri)
Exception-safe parsing.
const std::string & getPort() const
Get port.
friend bool operator<(const FaceUri &lhs, const FaceUri &rhs) noexcept
std::function< void(const FaceUri &)> CanonizeSuccessCallback
static FaceUri fromUdpDev(const boost::asio::ip::udp::endpoint &endpoint, std::string_view ifname)
Construct a udp4 or udp6 NIC-associated FaceUri from endpoint and network device name.
static FaceUri fromFd(int fd)
Construct an fd FaceUri from a file descriptor.
Represents an Ethernet hardware address.
::boost::chrono::nanoseconds nanoseconds