28 #include <boost/filesystem.hpp> 39 static std::string id(
"unix");
58 if (!context.
isDryRun && !m_channels.empty()) {
59 NFD_LOG_WARN(
"Cannot disable unix channel after initialization");
64 std::string path =
"/var/run/nfd.sock";
66 for (
const auto& pair : *configSection) {
67 const std::string& key = pair.first;
71 path = value.get_value<std::string>();
74 BOOST_THROW_EXCEPTION(
ConfigFile::Error(
"Unrecognized option face_system.unix." + key));
80 if (!channel->isListening()) {
81 channel->listen(this->
addFace,
nullptr);
91 onFailure(406,
"Unsupported protocol");
94 shared_ptr<UnixStreamChannel>
97 boost::filesystem::path p(unixSocketPath);
98 p = boost::filesystem::canonical(p.parent_path()) / p.filename();
101 auto channel = findChannel(endpoint);
105 channel = make_shared<UnixStreamChannel>(endpoint);
106 m_channels[endpoint] = channel;
110 std::vector<shared_ptr<const Channel>>
116 shared_ptr<UnixStreamChannel>
119 auto i = m_channels.find(endpoint);
120 if (i != m_channels.end())
FaceCreatedCallback addFace
callback when a new face is created
#define NFD_REGISTER_PROTOCOL_FACTORY(PF)
registers a protocol factory
void createFace(const CreateFaceParams ¶ms, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure) override
Try to create face using the supplied parameters.
#define NFD_LOG_WARN(expression)
std::vector< shared_ptr< const Channel > > getChannels() const override
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
UnixStreamFactory(const CtorParams ¶ms)
function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when a face fails to be created.
Provides support for an underlying protocol.
Parameters to ProtocolFactory constructor.
#define NFD_LOG_INIT(name)
shared_ptr< UnixStreamChannel > createChannel(const std::string &unixSocketPath)
Create stream-oriented Unix channel using specified socket path.
boost::asio::local::stream_protocol::endpoint Endpoint
Parameters to ProtocolFactory::createFace.
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context) override
process face_system.unix config section
static const std::string & getId()
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...