ndn::FaceUri Class Reference

represents the underlying protocol and address used by a Face More...

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

Classes

class  Error
 

Public Types

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

Public Member Functions

 FaceUri ()
 
 FaceUri (const std::string &uri)
 construct by parsing More...
 
 FaceUri (const char *uri)
 
 FaceUri (const boost::asio::ip::udp::endpoint &endpoint)
 construct udp4 or udp6 canonical FaceUri More...
 
 FaceUri (const boost::asio::ip::tcp::endpoint &endpoint)
 construct tcp4 or tcp6 canonical FaceUri More...
 
 FaceUri (const boost::asio::ip::tcp::endpoint &endpoint, const std::string &scheme)
 construct tcp canonical FaceUri with custom scheme More...
 
 FaceUri (const ethernet::Address &address)
 construct ether canonical FaceUri More...
 
void canonize (const CanonizeSuccessCallback &onSuccess, const CanonizeFailureCallback &onFailure, boost::asio::io_service &io, time::nanoseconds timeout) const
 asynchronously convert this FaceUri to canonical form More...
 
const std::string & getHost () const
 get host (domain) 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 (const std::string &uri)
 exception-safe parsing More...
 
std::string toString () const
 write as a string More...
 

Static Public Member Functions

static bool canCanonize (const std::string &scheme)
 
static FaceUri fromDev (const std::string &ifname)
 create dev FaceUri from network device name More...
 
static FaceUri fromFd (int fd)
 create fd FaceUri from file descriptor More...
 
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 More...
 

Friends

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

Detailed Description

represents the underlying protocol and address used by a Face

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

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

Member Typedef Documentation

◆ CanonizeFailureCallback

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

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

◆ CanonizeSuccessCallback

typedef function<void(const FaceUri&)> ndn::FaceUri::CanonizeSuccessCallback

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

Constructor & Destructor Documentation

◆ FaceUri() [1/7]

ndn::FaceUri::FaceUri ( )

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

◆ FaceUri() [2/7]

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

construct by parsing

Parameters
urischeme://host[:port]/path
Exceptions
FaceUri::Errorif URI cannot be parsed

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

◆ FaceUri() [3/7]

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

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

◆ FaceUri() [4/7]

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

construct udp4 or udp6 canonical FaceUri

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

◆ FaceUri() [5/7]

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

construct tcp4 or tcp6 canonical FaceUri

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

◆ FaceUri() [6/7]

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

construct tcp canonical FaceUri with custom scheme

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

◆ FaceUri() [7/7]

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

construct ether canonical FaceUri

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

Member Function Documentation

◆ canCanonize()

bool ndn::FaceUri::canCanonize ( const std::string &  scheme)
static
Returns
whether a FaceUri of the scheme can be canonized

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

◆ canonize()

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

asynchronously convert this FaceUri to canonical form

Parameters
onSuccessfunction to call after this FaceUri is converted to canonical form
Note
A new FaceUri in canonical form will be created; this FaceUri is unchanged.
Parameters
onFailurefunction to call if this FaceUri cannot be converted to canonical form
ioreference to boost::asio::io_service 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 630 of file face-uri.cpp.

◆ fromDev()

FaceUri ndn::FaceUri::fromDev ( const std::string &  ifname)
static

create dev FaceUri from network device name

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

◆ fromFd()

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

create fd FaceUri from file descriptor

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

◆ fromUdpDev()

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

create udp4 or udp6 NIC-associated FaceUri from endpoint and network device name

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

◆ getHost()

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

get host (domain)

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

◆ getPath()

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

get path

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

◆ getPort()

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

get port

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

◆ getScheme()

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

get scheme (protocol)

Definition at line 109 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 619 of file face-uri.cpp.

◆ parse()

bool ndn::FaceUri::parse ( const std::string &  uri)

exception-safe parsing

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

◆ toString()

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

write as a string

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

Friends And Related Function Documentation

◆ operator!=

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

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

◆ operator<<

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

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

◆ operator==

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

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