28 #include <ndn-cxx/net/address-converter.hpp>    41   static std::string id(
"tcp");
    63     if (!context.
isDryRun && !m_channels.empty()) {
    64       NFD_LOG_WARN(
"Cannot disable tcp4 and tcp6 channels after initialization");
    69   bool wantListen = 
true;
    74   for (
const auto& pair : *configSection) {
    75     const std::string& key = pair.first;
    77     if (key == 
"listen") {
    80     else if (key == 
"port") {
    81       port = ConfigFile::parseNumber<uint16_t>(pair, 
"face_system.tcp");
    83     else if (key == 
"enable_v4") {
    86     else if (key == 
"enable_v6") {
    90       BOOST_THROW_EXCEPTION(
ConfigFile::Error(
"Unrecognized option face_system.tcp." + key));
    94   if (!enableV4 && !enableV6) {
    96       "IPv4 and IPv6 TCP channels have been disabled. Remove face_system.tcp section to disable "    97       "TCP channels or enable at least one channel type."));
   105       shared_ptr<TcpChannel> v4Channel = this->
createChannel(endpoint);
   106       if (wantListen && !v4Channel->isListening()) {
   107         v4Channel->listen(this->
addFace, 
nullptr);
   112       NFD_LOG_WARN(
"Cannot close tcp4 channel after its creation");
   117       shared_ptr<TcpChannel> v6Channel = this->
createChannel(endpoint);
   118       if (wantListen && !v6Channel->isListening()) {
   119         v6Channel->listen(this->
addFace, 
nullptr);
   124       NFD_LOG_WARN(
"Cannot close tcp6 channel after its creation");
   137     NFD_LOG_TRACE(
"Cannot create unicast TCP face with LocalUri");
   138     onFailure(406, 
"Unicast TCP faces cannot be created with a LocalUri");
   143     NFD_LOG_TRACE(
"createFace does not support FACE_PERSISTENCY_ON_DEMAND");
   144     onFailure(406, 
"Outgoing TCP faces do not support on-demand persistency");
   152   BOOST_ASSERT(!endpoint.address().is_multicast());
   155     NFD_LOG_TRACE(
"createFace cannot create non-local face with local fields enabled");
   156     onFailure(406, 
"Local fields can only be enabled on faces with local scope");
   161   for (
const auto& i : m_channels) {
   162     if ((i.first.address().is_v4() && endpoint.address().is_v4()) ||
   163         (i.first.address().is_v6() && endpoint.address().is_v6())) {
   170   NFD_LOG_TRACE(
"No channels available to connect to " << endpoint);
   171   onFailure(504, 
"No channels available to connect");
   174 shared_ptr<TcpChannel>
   177   auto it = m_channels.find(endpoint);
   178   if (it != m_channels.end())
   181   auto channel = make_shared<TcpChannel>(endpoint);
   182   m_channels[endpoint] = channel;
   186 std::vector<shared_ptr<const Channel>>
 std::set< std::string > providedSchemes
FaceUri schemes provided by this ProtocolFactory. 
 
static bool parseYesNo(const ConfigSection &node, const std::string &key, const std::string §ionName)
parse a config option that can be either "yes" or "no" 
 
ndn::nfd::FacePersistency persistency
 
static const std::string & getId()
 
NFD_REGISTER_PROTOCOL_FACTORY(EthernetFactory)
 
Parameters to ProtocolFactory::createFace. 
 
FaceCreatedCallback addFace
callback when a new face is created 
 
ndn::optional< FaceUri > localUri
 
#define NFD_LOG_TRACE(expression)
 
Provides support for an underlying protocol. 
 
protocol factory for TCP over IPv4 and IPv6 
 
Copyright (c) 2011-2015 Regents of the University of California. 
 
boost::asio::ip::tcp::endpoint Endpoint
 
void createFace(const CreateFaceParams ¶ms, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure) override
Try to create face using the supplied parameters. 
 
boost::optional< const ConfigSection & > OptionalConfigSection
an optional config file section 
 
TcpFactory(const CtorParams ¶ms)
 
Parameters to ProtocolFactory constructor. 
 
context for processing a config section in ProtocolFactory 
 
function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when a face fails to be created. 
 
boost::asio::ip::address addressFromString(const std::string &address, boost::system::error_code &ec)
parse and convert the input string into an IP address 
 
#define NFD_LOG_WARN(expression)
 
bool isCanonical() const 
determine whether this FaceUri is in canonical form 
 
std::vector< shared_ptr< const Channel > > getChannels() const override
 
static std::vector< shared_ptr< const Channel > > getChannelsFromMap(const ChannelMap &channelMap)
 
const std::string & getHost() const 
get host (domain) 
 
const std::string & getPort() const 
get port 
 
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context) override
process face_system.tcp config section 
 
#define NFD_LOG_INIT(name)
 
shared_ptr< TcpChannel > createChannel(const tcp::Endpoint &localEndpoint)
Create TCP-based channel using tcp::Endpoint. 
 
function< void(const shared_ptr< Face > &newFace)> FaceCreatedCallback
Prototype for the callback that is invoked when a face is created (in response to an incoming connect...