ndn::FaceUri Class Reference

The underlying protocol and address used by a Face. More...

#include <ndn-cxx/net/face-uri.hpp>

+ Inheritance diagram for ndn::FaceUri:
+ Collaboration diagram for ndn::FaceUri:

Classes

class  Error
 

Public Types

using CanonizeFailureCallback = std::function< void(const std::string &reason)>
 
using CanonizeSuccessCallback = std::function< void(const FaceUri &)>
 

Public Member Functions

 FaceUri ()
 Construct an empty FaceUri. More...
 
 FaceUri (const boost::asio::ip::tcp::endpoint &endpoint)
 Construct a tcp4 or tcp6 canonical FaceUri. More...
 
 FaceUri (const boost::asio::ip::tcp::endpoint &endpoint, std::string_view scheme)
 Construct a tcp canonical FaceUri with custom scheme. More...
 
 FaceUri (const boost::asio::ip::udp::endpoint &endpoint)
 Construct a udp4 or udp6 canonical FaceUri. More...
 
 FaceUri (const char *uri)
 Construct by parsing from a null-terminated string. More...
 
 FaceUri (const ethernet::Address &address)
 Construct an ether canonical FaceUri. More...
 
 FaceUri (const std::string &uri)
 Construct by parsing from a string. More...
 
void canonize (const CanonizeSuccessCallback &onSuccess, const CanonizeFailureCallback &onFailure, boost::asio::io_context &io, time::nanoseconds timeout) const
 Asynchronously convert this FaceUri to canonical form. More...
 
const std::string & getHost () const
 Get host (domain or address) More...
 
const std::string & getPath () const
 Get path. More...
 
const std::string & getPort () const
 Get port. More...
 
const std::string & getScheme () const
 Get scheme (protocol) More...
 
bool isCanonical () const
 Determine whether this FaceUri is in canonical form. More...
 
bool parse (std::string_view uri)
 Exception-safe parsing. More...
 
std::string toString () const
 Return string representation. More...
 

Static Public Member Functions

static bool canCanonize (const std::string &scheme)
 Return whether a FaceUri of the specified scheme can be canonized. More...
 
static FaceUri fromDev (std::string_view ifname)
 Construct a dev FaceUri from a network device name. More...
 
static FaceUri fromFd (int fd)
 Construct an fd FaceUri from a file descriptor. More...
 
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. More...
 

Friends

bool operator< (const FaceUri &lhs, const FaceUri &rhs) noexcept
 
std::ostream & operator<< (std::ostream &os, const FaceUri &uri)
 
bool operator== (const FaceUri &lhs, const FaceUri &rhs) noexcept
 

Detailed Description

The underlying protocol and address used by a Face.

See also
https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#FaceUri

Definition at line 46 of file face-uri.hpp.

Member Typedef Documentation

◆ CanonizeFailureCallback

using ndn::FaceUri::CanonizeFailureCallback = std::function<void(const std::string& reason)>

Definition at line 163 of file face-uri.hpp.

◆ CanonizeSuccessCallback

using ndn::FaceUri::CanonizeSuccessCallback = std::function<void(const FaceUri&)>

Definition at line 162 of file face-uri.hpp.

Constructor & Destructor Documentation

◆ FaceUri() [1/7]

ndn::FaceUri::FaceUri ( )
default

Construct an empty FaceUri.

◆ FaceUri() [2/7]

ndn::FaceUri::FaceUri ( const std::string &  uri)
explicit

Construct by parsing from a string.

Parameters
urischeme://host[:port]/path
Exceptions
ErrorURI cannot be parsed

Definition at line 49 of file face-uri.cpp.

◆ FaceUri() [3/7]

ndn::FaceUri::FaceUri ( const char *  uri)
explicit

Construct by parsing from a null-terminated string.

Parameters
urischeme://host[:port]/path
Exceptions
ErrorURI cannot be parsed
Note
This overload is needed so that calls with a string literal won't be resolved to the boost::asio::local::stream_protocol::endpoint overload.

Definition at line 56 of file face-uri.cpp.

◆ FaceUri() [4/7]

ndn::FaceUri::FaceUri ( const boost::asio::ip::udp::endpoint &  endpoint)
explicit

Construct a udp4 or udp6 canonical FaceUri.

Definition at line 116 of file face-uri.cpp.

◆ FaceUri() [5/7]

ndn::FaceUri::FaceUri ( const boost::asio::ip::tcp::endpoint &  endpoint)
explicit

Construct a tcp4 or tcp6 canonical FaceUri.

Definition at line 124 of file face-uri.cpp.

◆ FaceUri() [6/7]

ndn::FaceUri::FaceUri ( const boost::asio::ip::tcp::endpoint &  endpoint,
std::string_view  scheme 
)

Construct a tcp canonical FaceUri with custom scheme.

Definition at line 132 of file face-uri.cpp.

◆ FaceUri() [7/7]

ndn::FaceUri::FaceUri ( const ethernet::Address address)
explicit

Construct an ether canonical FaceUri.

Definition at line 148 of file face-uri.cpp.

Member Function Documentation

◆ canCanonize()

bool ndn::FaceUri::canCanonize ( const std::string &  scheme)
static

Return whether a FaceUri of the specified scheme can be canonized.

Definition at line 600 of file face-uri.cpp.

◆ canonize()

void ndn::FaceUri::canonize ( const CanonizeSuccessCallback onSuccess,
const CanonizeFailureCallback onFailure,
boost::asio::io_context &  io,
time::nanoseconds  timeout 
) const

Asynchronously convert this FaceUri to canonical form.

Note
A new FaceUri in canonical form will be created; this FaceUri is unchanged.
Parameters
onSuccessfunction to call after this FaceUri is converted to canonical form
onFailurefunction to call if this FaceUri cannot be converted to canonical form
ioreference to boost::asio::io_context instance
timeoutmaximum allowable duration of the operations. It's intentional not to provide a default value: the caller should set a reasonable value in balance between network delay and user experience.

Definition at line 617 of file face-uri.cpp.

◆ fromDev()

FaceUri ndn::FaceUri::fromDev ( std::string_view  ifname)
static

Construct a dev FaceUri from a network device name.

Definition at line 165 of file face-uri.cpp.

◆ fromFd()

FaceUri ndn::FaceUri::fromFd ( int  fd)
static

Construct an fd FaceUri from a file descriptor.

Definition at line 156 of file face-uri.cpp.

◆ fromUdpDev()

FaceUri ndn::FaceUri::fromUdpDev ( const boost::asio::ip::udp::endpoint &  endpoint,
std::string_view  ifname 
)
static

Construct a udp4 or udp6 NIC-associated FaceUri from endpoint and network device name.

Definition at line 174 of file face-uri.cpp.

◆ getHost()

const std::string& ndn::FaceUri::getHost ( ) const
inline

Get host (domain or address)

Definition at line 124 of file face-uri.hpp.

◆ getPath()

const std::string& ndn::FaceUri::getPath ( ) const
inline

Get path.

Definition at line 138 of file face-uri.hpp.

◆ getPort()

const std::string& ndn::FaceUri::getPort ( ) const
inline

Get port.

Definition at line 131 of file face-uri.hpp.

◆ getScheme()

const std::string& ndn::FaceUri::getScheme ( ) const
inline

Get scheme (protocol)

Definition at line 117 of file face-uri.hpp.

◆ isCanonical()

bool ndn::FaceUri::isCanonical ( ) const

Determine whether this FaceUri is in canonical form.

Returns
true if this FaceUri is in canonical form, false if this FaceUri is not in canonical form or or it's undetermined whether this FaceUri is in canonical form

Definition at line 606 of file face-uri.cpp.

◆ parse()

bool ndn::FaceUri::parse ( std::string_view  uri)

Exception-safe parsing.

Definition at line 64 of file face-uri.cpp.

◆ toString()

std::string ndn::FaceUri::toString ( ) const

Return string representation.

Definition at line 184 of file face-uri.cpp.

Friends And Related Function Documentation

◆ operator<

bool operator< ( const FaceUri lhs,
const FaceUri rhs 
)
friend

Definition at line 200 of file face-uri.hpp.

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const FaceUri uri 
)
friend

Definition at line 207 of file face-uri.hpp.

◆ operator==

bool operator== ( const FaceUri lhs,
const FaceUri rhs 
)
friend

Definition at line 191 of file face-uri.hpp.