mgmt: add udp listening
refs: #1406
Change-Id: I45bc9fd2fbdbf0a7b3a287d23053f88db97e04ec
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index ea92898..039270f 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -376,7 +376,17 @@
{
shared_ptr<UdpFactory> factory = make_shared<UdpFactory>(boost::cref(port));
- factory->createChannel("::", port, time::seconds(timeout));
+ shared_ptr<UdpChannel> v4Channel =
+ factory->createChannel("0.0.0.0", port, time::seconds(timeout));
+
+ shared_ptr<UdpChannel> v6Channel =
+ factory->createChannel("::", port, time::seconds(timeout));
+
+ v4Channel->listen(bind(&FaceTable::add, &m_faceTable, _1),
+ UdpChannel::ConnectFailedCallback());
+
+ v6Channel->listen(bind(&FaceTable::add, &m_faceTable, _1),
+ UdpChannel::ConnectFailedCallback());
m_factories.insert(std::make_pair("udp", factory));
m_factories.insert(std::make_pair("udp4", factory));
@@ -384,19 +394,6 @@
if (useMcast)
{
- bool useEndpoint = false;
- udp::Endpoint localEndpoint;
-
- try
- {
- localEndpoint.port(boost::lexical_cast<uint16_t>(port));
- useEndpoint = true;
- }
- catch (const boost::bad_lexical_cast& error)
- {
- NFD_LOG_DEBUG("Treating UDP port \"" << port << "\" as a service name");
- }
-
for (std::list<shared_ptr<NetworkInterfaceInfo> >::const_iterator i = nicList.begin();
i != nicList.end();
++i)
@@ -409,35 +406,9 @@
mcastGroup, mcastPort);
addCreatedFaceToForwarder(newFace);
-
- if (useEndpoint)
- {
- for (std::vector<boost::asio::ip::address_v4>::const_iterator j =
- nic->ipv4Addresses.begin();
- j != nic->ipv4Addresses.end();
- ++j)
- {
- localEndpoint.address(*j);
- factory->createChannel(localEndpoint, time::seconds(timeout));
- }
- }
- else
- {
- for (std::vector<boost::asio::ip::address_v4>::const_iterator j =
- nic->ipv4Addresses.begin();
- j != nic->ipv4Addresses.end();
- ++j)
- {
- factory->createChannel(j->to_string(), port, time::seconds(timeout));
- }
- }
}
}
}
- else
- {
- factory->createChannel("0.0.0.0", port, time::seconds(timeout));
- }
}
}