28 #include <boost/filesystem.hpp> 39 static std::string id(
"unix");
60 if (!context.
isDryRun && !m_channels.empty()) {
61 NFD_LOG_WARN(
"Cannot disable unix channel after initialization");
66 std::string path =
"/var/run/nfd.sock";
68 for (
const auto& pair : *configSection) {
69 const std::string& key = pair.first;
73 path = value.get_value<std::string>();
76 BOOST_THROW_EXCEPTION(
ConfigFile::Error(
"Unrecognized option face_system.unix." + key));
82 if (!channel->isListening()) {
83 channel->listen(this->
addFace,
nullptr);
93 onFailure(406,
"Unsupported protocol");
96 shared_ptr<UnixStreamChannel>
99 boost::filesystem::path p(unixSocketPath);
100 p = boost::filesystem::canonical(p.parent_path()) / p.filename();
103 auto channel = findChannel(endpoint);
107 channel = make_shared<UnixStreamChannel>(endpoint, m_wantCongestionMarking);
108 m_channels[endpoint] = channel;
112 std::vector<shared_ptr<const Channel>>
118 shared_ptr<UnixStreamChannel>
121 auto i = m_channels.find(endpoint);
122 if (i != m_channels.end())
bool wantCongestionMarking
void processConfig(OptionalConfigSection configSection, FaceSystem::ConfigContext &context) override
process face_system.unix config section
function< void(const shared_ptr< Face > &face)> FaceCreatedCallback
Prototype for the callback that is invoked when a face is created (in response to an incoming connect...
GeneralConfig generalConfig
UnixStreamFactory(const CtorParams ¶ms)
void createFace(const CreateFaceRequest &req, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure) override
Try to create a unicast face using the supplied parameters.
NFD_REGISTER_PROTOCOL_FACTORY(EthernetFactory)
function< void(uint32_t status, const std::string &reason)> FaceCreationFailedCallback
Prototype for the callback that is invoked when a face fails to be created.
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
#define NFD_LOG_WARN(expression)
std::vector< shared_ptr< const Channel > > getChannels() const override
Encapsulates a face creation request and all its parameters.
boost::asio::local::stream_protocol::endpoint Endpoint
static std::vector< shared_ptr< const Channel > > getChannelsFromMap(const ChannelMap &channelMap)
#define NFD_LOG_INIT(name)