29 #include <boost/filesystem.hpp>
40 static std::string id(
"unix");
55 if (!context.
isDryRun && !m_channels.empty()) {
56 NFD_LOG_WARN(
"Cannot disable unix channel after initialization");
61 std::string path =
"/var/run/nfd.sock";
63 for (
const auto& pair : *configSection) {
64 const std::string& key = pair.first;
68 path = value.get_value<std::string>();
71 BOOST_THROW_EXCEPTION(
ConfigFile::Error(
"Unrecognized option face_system.unix." + key));
77 if (!channel->isListening()) {
78 channel->listen(context.
addFace,
nullptr);
85 ndn::nfd::FacePersistency persistency,
86 bool wantLocalFieldsEnabled,
90 onFailure(406,
"Unsupported protocol");
93 shared_ptr<UnixStreamChannel>
96 boost::filesystem::path p(unixSocketPath);
97 p = boost::filesystem::canonical(p.parent_path()) / p.filename();
100 auto channel = findChannel(endpoint);
104 channel = make_shared<UnixStreamChannel>(endpoint);
105 m_channels[endpoint] = channel;
109 std::vector<shared_ptr<const Channel>>
115 shared_ptr<UnixStreamChannel>
118 auto i = m_channels.find(endpoint);
119 if (i != m_channels.end())
void createFace(const FaceUri &uri, ndn::nfd::FacePersistency persistency, bool wantLocalFieldsEnabled, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure) override
Try to create Face using the supplied FaceUri.
FaceCreatedCallback addFace
#define NFD_REGISTER_PROTOCOL_FACTORY(PF)
registers a protocol factory
#define NFD_LOG_WARN(expression)
context for processing a config section in ProtocolFactory
static std::vector< shared_ptr< const Channel > > getChannelsFromMap(const ChannelMap &channelMap)
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
boost::optional< const ConfigSection & > OptionalConfigSection
an optional config file section
boost::property_tree::ptree ConfigSection
a config file section
function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when the face fails to be created.
#define NFD_LOG_INIT(name)
shared_ptr< UnixStreamChannel > createChannel(const std::string &unixSocketPath)
Create stream-oriented Unix channel using specified socket path.
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...
boost::asio::local::stream_protocol::endpoint Endpoint
std::vector< shared_ptr< const Channel > > getChannels() const override
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context) override
process face_system.unix config section
static const std::string & getId()