39 if (endpoint.address().is_v4() &&
40 endpoint.address() == ip::address_v4::any()) {
41 prohibitAllIpv4Endpoints(endpoint.port());
43 else if (endpoint.address().is_v6() &&
44 endpoint.address() == ip::address_v6::any()) {
45 prohibitAllIpv6Endpoints(endpoint.port());
49 m_prohibitedEndpoints.insert(endpoint);
53 TcpFactory::prohibitAllIpv4Endpoints(uint16_t port)
56 for (
const auto& addr : nic.ipv4Addresses) {
57 if (addr != ip::address_v4::any()) {
65 TcpFactory::prohibitAllIpv6Endpoints(uint16_t port)
68 for (
const auto& addr : nic.ipv6Addresses) {
69 if (addr != ip::address_v6::any()) {
76 shared_ptr<TcpChannel>
79 auto channel = findChannel(endpoint);
83 channel = make_shared<TcpChannel>(endpoint);
84 m_channels[endpoint] = channel;
85 prohibitEndpoint(endpoint);
91 shared_ptr<TcpChannel>
95 boost::lexical_cast<uint16_t>(localPort));
108 BOOST_THROW_EXCEPTION(
Error(
"TcpFactory::createFace supports only FACE_PERSISTENCY_PERSISTENT"));
112 boost::lexical_cast<uint16_t>(uri.
getPort()));
114 if (m_prohibitedEndpoints.find(endpoint) != m_prohibitedEndpoints.end()) {
115 onConnectFailed(
"Requested endpoint is prohibited " 116 "(reserved by this NFD or disallowed by face management protocol)");
121 for (
const auto& i : m_channels) {
122 if ((i.first.address().is_v4() && endpoint.address().is_v4()) ||
123 (i.first.address().is_v6() && endpoint.address().is_v6())) {
124 i.second->connect(endpoint, onCreated, onConnectFailed);
129 onConnectFailed(
"No channels available to connect to " + boost::lexical_cast<std::string>(endpoint));
132 std::vector<shared_ptr<const Channel>>
135 std::vector<shared_ptr<const Channel>> channels;
136 channels.reserve(m_channels.size());
138 for (
const auto& i : m_channels)
139 channels.push_back(i.second);
144 shared_ptr<TcpChannel>
145 TcpFactory::findChannel(
const tcp::Endpoint& localEndpoint)
const 147 auto i = m_channels.find(localEndpoint);
148 if (i != m_channels.end())
#define NFD_LOG_DEBUG(expression)
function< void(const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when the face fails to be created.
represents the underlying protocol and address used by a Face
bool isCanonical() const
determine whether this FaceUri is in canonical form
contains information about a network interface
virtual void createFace(const FaceUri &uri, ndn::nfd::FacePersistency persistency, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onConnectFailed) 1
Try to create Face using the supplied FaceUri.
std::vector< NetworkInterfaceInfo > listNetworkInterfaces()
List configured network interfaces on the system and their info.
virtual std::vector< shared_ptr< const Channel > > getChannels() const 1
Copyright (c) 2011-2015 Regents of the University of California.
const std::string & getPort() const
get port
boost::asio::ip::tcp::endpoint Endpoint
#define NFD_LOG_INIT(name)
#define NFD_LOG_TRACE(expression)
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback that is invoked when the face is created (as a response to incoming connec...
shared_ptr< TcpChannel > createChannel(const tcp::Endpoint &localEndpoint)
Create TCP-based channel using tcp::Endpoint.
const std::string & getHost() const
get host (domain)