Various fixes for NFD/ndn-cxx 0.7.0
Change-Id: I68e5d4d57d81c3f2e46fc59680cd416b06c8190c
diff --git a/model/ndn-app-link-service.cpp b/model/ndn-app-link-service.cpp
index 2dbce52..e5b1ee7 100644
--- a/model/ndn-app-link-service.cpp
+++ b/model/ndn-app-link-service.cpp
@@ -47,7 +47,7 @@
}
void
-AppLinkService::doSendInterest(const Interest& interest)
+AppLinkService::doSendInterest(const Interest& interest, const nfd::EndpointId& endpoint)
{
NS_LOG_FUNCTION(this << &interest);
@@ -56,7 +56,7 @@
}
void
-AppLinkService::doSendData(const Data& data)
+AppLinkService::doSendData(const Data& data, const nfd::EndpointId& endpoint)
{
NS_LOG_FUNCTION(this << &data);
@@ -65,7 +65,7 @@
}
void
-AppLinkService::doSendNack(const lp::Nack& nack)
+AppLinkService::doSendNack(const lp::Nack& nack, const nfd::EndpointId& endpoint)
{
NS_LOG_FUNCTION(this << &nack);
@@ -78,19 +78,19 @@
void
AppLinkService::onReceiveInterest(const Interest& interest)
{
- this->receiveInterest(interest);
+ this->receiveInterest(interest, 0);
}
void
AppLinkService::onReceiveData(const Data& data)
{
- this->receiveData(data);
+ this->receiveData(data, 0);
}
void
AppLinkService::onReceiveNack(const lp::Nack& nack)
{
- this->receiveNack(nack);
+ this->receiveNack(nack, 0);
}
} // namespace ndn
diff --git a/model/ndn-app-link-service.hpp b/model/ndn-app-link-service.hpp
index 798ac1a..21c50d1 100644
--- a/model/ndn-app-link-service.hpp
+++ b/model/ndn-app-link-service.hpp
@@ -60,16 +60,16 @@
private:
virtual void
- doSendInterest(const Interest& interest) override;
+ doSendInterest(const Interest& interest, const nfd::EndpointId& endpoint) override;
virtual void
- doSendData(const Data& data) override;
+ doSendData(const Data& data, const nfd::EndpointId& endpoint) override;
virtual void
- doSendNack(const lp::Nack& nack) override;
+ doSendNack(const lp::Nack& nack, const nfd::EndpointId& endpoint) override;
virtual void
- doReceivePacket(nfd::face::Transport::Packet&& packet) override
+ doReceivePacket(const Block& packet, const nfd::EndpointId& endpoint) override
{
// does nothing (all operations for now handled by LinkService)
BOOST_ASSERT(false);
diff --git a/model/ndn-block-header.cpp b/model/ndn-block-header.cpp
index fbab70f..6665fa4 100644
--- a/model/ndn-block-header.cpp
+++ b/model/ndn-block-header.cpp
@@ -56,8 +56,8 @@
{
}
-BlockHeader::BlockHeader(const nfdFace::Transport::Packet& packet)
- : m_block(packet.packet)
+BlockHeader::BlockHeader(const Block& packet)
+ : m_block(packet)
{
}
diff --git a/model/ndn-block-header.hpp b/model/ndn-block-header.hpp
index f2c73ab..4c9f491 100644
--- a/model/ndn-block-header.hpp
+++ b/model/ndn-block-header.hpp
@@ -39,7 +39,7 @@
BlockHeader();
- BlockHeader(const nfdFace::Transport::Packet& packet);
+ BlockHeader(const Block& packet);
virtual uint32_t
GetSerializedSize(void) const;
diff --git a/model/ndn-common.hpp b/model/ndn-common.hpp
index a678f5d..b0cfe7a 100644
--- a/model/ndn-common.hpp
+++ b/model/ndn-common.hpp
@@ -56,8 +56,6 @@
using namespace ::ndn::lp;
}
-using ::ndn::Exclude;
-
using std::shared_ptr;
using std::make_shared;
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index f7ad619..8271587 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -171,6 +171,7 @@
// note that shared_ptr needed for Python bindings
std::shared_ptr<::nfd::Forwarder> m_forwarder;
+ std::unique_ptr<::nfd::FaceTable> m_faceTable;
std::unique_ptr<::nfd::face::FaceSystem> m_faceSystem;
std::shared_ptr<::nfd::face::Face> m_internalFace;
@@ -209,12 +210,9 @@
void
L3Protocol::initialize()
{
- m_impl->m_forwarder = make_shared<::nfd::Forwarder>();
-
- ::nfd::FaceTable& faceTable = m_impl->m_forwarder->getFaceTable();
- faceTable.addReserved(::nfd::face::makeNullFace(), ::nfd::face::FACEID_NULL);
- // faceTable.addReserved(face::makeNullFace(FaceUri("contentstore://")), face::FACEID_CONTENT_STORE);
- m_impl->m_faceSystem = make_unique<::nfd::face::FaceSystem>(faceTable, nullptr);
+ m_impl->m_faceTable = make_unique<::nfd::FaceTable>();
+ m_impl->m_forwarder = make_shared<::nfd::Forwarder>(*m_impl->m_faceTable);
+ m_impl->m_faceSystem = make_unique<::nfd::face::FaceSystem>(*m_impl->m_faceTable, nullptr);
initializeManagement();
initializeRibManager();
@@ -263,10 +261,10 @@
using namespace nfd;
std::tie(m_impl->m_internalFace, m_impl->m_internalClientFace) = face::makeInternalFace(StackHelper::getKeyChain());
- forwarder->getFaceTable().addReserved(m_impl->m_internalFace, face::FACEID_INTERNAL_FACE);
+ m_impl->m_faceTable->addReserved(m_impl->m_internalFace, face::FACEID_INTERNAL_FACE);
std::tie(m_impl->m_internalFaceForInjects, m_impl->m_internalClientFaceForInjects) = face::makeInternalFace(StackHelper::getKeyChain());
- forwarder->getFaceTable().addReserved(m_impl->m_internalFaceForInjects, face::FACEID_INTERNAL_FACE + 1);
+ m_impl->m_faceTable->addReserved(m_impl->m_internalFaceForInjects, face::FACEID_INTERNAL_FACE + 1);
m_impl->m_dispatcher = make_unique<::ndn::mgmt::Dispatcher>(*m_impl->m_internalClientFace, StackHelper::getKeyChain());
m_impl->m_authenticator = ::nfd::CommandAuthenticator::create();
@@ -275,7 +273,7 @@
m_impl->m_forwarderStatusManager = make_unique<::nfd::ForwarderStatusManager>(*m_impl->m_forwarder, *m_impl->m_dispatcher);
}
m_impl->m_faceManager = make_unique<::nfd::FaceManager>(*m_impl->m_faceSystem, *m_impl->m_dispatcher, *m_impl->m_authenticator);
- m_impl->m_fibManager = make_shared<::nfd::FibManager>(m_impl->m_forwarder->getFib(), m_impl->m_forwarder->getFaceTable(),
+ m_impl->m_fibManager = make_shared<::nfd::FibManager>(m_impl->m_forwarder->getFib(), *m_impl->m_faceTable,
*m_impl->m_dispatcher, *m_impl->m_authenticator);
m_impl->m_csManager = make_unique<::nfd::CsManager>(m_impl->m_forwarder->getCs(), m_impl->m_forwarder->getCounters(),
*m_impl->m_dispatcher, *m_impl->m_authenticator);
@@ -308,7 +306,8 @@
// add FIB entry for NFD Management Protocol
Name topPrefix("/localhost/nfd");
- m_impl->m_forwarder->getFib().insert(topPrefix).first->addOrUpdateNextHop(*m_impl->m_internalFace, 0, 0);
+ auto entry = m_impl->m_forwarder->getFib().insert(topPrefix).first;
+ m_impl->m_forwarder->getFib().addOrUpdateNextHop(*entry, *m_impl->m_internalFace, 0);
m_impl->m_dispatcher->addTopPrefix(topPrefix, false);
}
@@ -318,7 +317,7 @@
using namespace nfd;
std::tie(m_impl->m_internalRibFace, m_impl->m_internalRibClientFace) = face::makeInternalFace(StackHelper::getKeyChain());
- m_impl->m_forwarder->getFaceTable().add(m_impl->m_internalRibFace);
+ m_impl->m_faceTable->add(m_impl->m_internalRibFace);
m_impl->m_ribService = make_unique<rib::Service>(m_impl->m_config,
std::ref(*m_impl->m_internalRibClientFace),
@@ -331,6 +330,12 @@
return m_impl->m_forwarder;
}
+nfd::FaceTable&
+L3Protocol::getFaceTable()
+{
+ return *m_impl->m_faceTable;
+}
+
shared_ptr<nfd::FibManager>
L3Protocol::getFibManager()
{
@@ -392,26 +397,26 @@
{
NS_LOG_FUNCTION(this << face.get());
- m_impl->m_forwarder->addFace(face);
+ m_impl->m_faceTable->add(face);
std::weak_ptr<Face> weakFace = face;
// // Connect Signals to TraceSource
- face->afterReceiveInterest.connect([this, weakFace](const Interest& interest) {
+ face->afterReceiveInterest.connect([this, weakFace](const Interest& interest, const nfd::EndpointId&) {
shared_ptr<Face> face = weakFace.lock();
if (face != nullptr) {
this->m_inInterests(interest, *face);
}
});
- face->afterReceiveData.connect([this, weakFace](const Data& data) {
+ face->afterReceiveData.connect([this, weakFace](const Data& data, const nfd::EndpointId&) {
shared_ptr<Face> face = weakFace.lock();
if (face != nullptr) {
this->m_inData(data, *face);
}
});
- face->afterReceiveNack.connect([this, weakFace](const lp::Nack& nack) {
+ face->afterReceiveNack.connect([this, weakFace](const lp::Nack& nack, const nfd::EndpointId&) {
shared_ptr<Face> face = weakFace.lock();
if (face != nullptr) {
this->m_inNack(nack, *face);
@@ -447,13 +452,13 @@
shared_ptr<Face>
L3Protocol::getFaceById(nfd::FaceId id) const
{
- return m_impl->m_forwarder->getFaceTable().get(id)->shared_from_this();
+ return m_impl->m_faceTable->get(id)->shared_from_this();
}
shared_ptr<Face>
L3Protocol::getFaceByNetDevice(Ptr<NetDevice> netDevice) const
{
- for (auto& i : m_impl->m_forwarder->getFaceTable()) {
+ for (auto& i : *m_impl->m_faceTable) {
auto transport = dynamic_cast<NetDeviceTransport*>(i.getTransport());
if (transport == nullptr)
continue;
diff --git a/model/ndn-l3-protocol.hpp b/model/ndn-l3-protocol.hpp
index e5169af..3b8c775 100644
--- a/model/ndn-l3-protocol.hpp
+++ b/model/ndn-l3-protocol.hpp
@@ -35,6 +35,7 @@
namespace nfd {
class Forwarder;
class FibManager;
+class FaceTable;
class StrategyChoiceManager;
typedef boost::property_tree::ptree ConfigSection;
namespace pit {
@@ -104,6 +105,9 @@
shared_ptr<nfd::Forwarder>
getForwarder();
+ nfd::FaceTable&
+ getFaceTable();
+
/**
* \brief Get smart pointer to nfd::FibManager, used by node's NFD
*/
diff --git a/model/ndn-net-device-transport.cpp b/model/ndn-net-device-transport.cpp
index a8565fb..e0439f0 100644
--- a/model/ndn-net-device-transport.cpp
+++ b/model/ndn-net-device-transport.cpp
@@ -106,7 +106,7 @@
}
void
-NetDeviceTransport::doSend(Packet&& packet)
+NetDeviceTransport::doSend(const Block& packet, const nfd::EndpointId& endpoint)
{
NS_LOG_FUNCTION(this << "Sending packet from netDevice with URI"
<< this->getLocalUri());
@@ -125,10 +125,10 @@
// callback
void
NetDeviceTransport::receiveFromNetDevice(Ptr<NetDevice> device,
- Ptr<const ns3::Packet> p,
- uint16_t protocol,
- const Address& from, const Address& to,
- NetDevice::PacketType packetType)
+ Ptr<const ns3::Packet> p,
+ uint16_t protocol,
+ const Address& from, const Address& to,
+ NetDevice::PacketType packetType)
{
NS_LOG_FUNCTION(device << p << protocol << from << to << packetType);
@@ -138,9 +138,7 @@
BlockHeader header;
packet->RemoveHeader(header);
- auto nfdPacket = Packet(std::move(header.getBlock()));
-
- this->receive(std::move(nfdPacket));
+ this->receive(std::move(header.getBlock()));
}
Ptr<NetDevice>
diff --git a/model/ndn-net-device-transport.hpp b/model/ndn-net-device-transport.hpp
index e68382d..22b07de 100644
--- a/model/ndn-net-device-transport.hpp
+++ b/model/ndn-net-device-transport.hpp
@@ -62,7 +62,7 @@
doClose() override;
virtual void
- doSend(Packet&& packet) override;
+ doSend(const Block& packet, const nfd::EndpointId& endpoint) override;
void
receiveFromNetDevice(Ptr<NetDevice> device,
diff --git a/model/null-transport.hpp b/model/null-transport.hpp
index 42ef9c6..3c27e1f 100644
--- a/model/null-transport.hpp
+++ b/model/null-transport.hpp
@@ -47,19 +47,14 @@
}
private:
- virtual void
- beforeChangePersistency(::ndn::nfd::FacePersistency newPersistency)
- {
- }
-
- virtual void
- doClose()
+ void
+ doClose() final
{
this->setState(nfd::face::TransportState::CLOSED);
}
- virtual void
- doSend(Packet&& packet)
+ void
+ doSend(const Block& packet, const nfd::EndpointId& endpoint) final
{
}
};