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())
void createFace(const CreateFaceParams ¶ms, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure) override
Try to create face using the supplied parameters.
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context) override
process face_system.unix config section
UnixStreamFactory(const CtorParams ¶ms)
NFD_REGISTER_PROTOCOL_FACTORY(EthernetFactory)
Parameters to ProtocolFactory::createFace.
protocol factory for stream-oriented Unix sockets
FaceCreatedCallback addFace
callback when a new face is created
Provides support for an underlying protocol.
Copyright (c) 2011-2015 Regents of the University of California.
boost::optional< const ConfigSection & > OptionalConfigSection
an optional config file section
shared_ptr< UnixStreamChannel > createChannel(const std::string &unixSocketPath)
Create stream-oriented Unix channel using specified socket path.
Parameters to ProtocolFactory constructor.
boost::property_tree::ptree ConfigSection
a config file section
static const std::string & getId()
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.
#define NFD_LOG_WARN(expression)
std::vector< shared_ptr< const Channel > > getChannels() const override
boost::asio::local::stream_protocol::endpoint Endpoint
static std::vector< shared_ptr< const Channel > > getChannelsFromMap(const ChannelMap &channelMap)
#define NFD_LOG_INIT(name)
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...