pit: add EndpointId field in in-record and out-record
refs: #4842
Change-Id: Id4bca4ad9c2d7c8a2fd975c0b052fb9271b6e47d
diff --git a/daemon/table/pit-entry.cpp b/daemon/table/pit-entry.cpp
index ee4b726..2edbc9f 100644
--- a/daemon/table/pit-entry.cpp
+++ b/daemon/table/pit-entry.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -50,21 +50,25 @@
}
InRecordCollection::iterator
-Entry::getInRecord(const Face& face)
+Entry::getInRecord(const Face& face, uint64_t endpointId)
{
return std::find_if(m_inRecords.begin(), m_inRecords.end(),
- [&face] (const InRecord& inRecord) { return &inRecord.getFace() == &face; });
+ [&face, endpointId] (const InRecord& inRecord) {
+ return &inRecord.getFace() == &face && inRecord.getEndpointId() == endpointId;
+ });
}
InRecordCollection::iterator
-Entry::insertOrUpdateInRecord(Face& face, const Interest& interest)
+Entry::insertOrUpdateInRecord(Face& face, uint64_t endpointId, const Interest& interest)
{
BOOST_ASSERT(this->canMatch(interest));
auto it = std::find_if(m_inRecords.begin(), m_inRecords.end(),
- [&face] (const InRecord& inRecord) { return &inRecord.getFace() == &face; });
+ [&face, endpointId] (const InRecord& inRecord) {
+ return &inRecord.getFace() == &face && inRecord.getEndpointId() == endpointId;
+ });
if (it == m_inRecords.end()) {
- m_inRecords.emplace_front(face);
+ m_inRecords.emplace_front(face, endpointId);
it = m_inRecords.begin();
}
@@ -73,10 +77,12 @@
}
void
-Entry::deleteInRecord(const Face& face)
+Entry::deleteInRecord(const Face& face, uint64_t endpointId)
{
auto it = std::find_if(m_inRecords.begin(), m_inRecords.end(),
- [&face] (const InRecord& inRecord) { return &inRecord.getFace() == &face; });
+ [&face, endpointId] (const InRecord& inRecord) {
+ return &inRecord.getFace() == &face && inRecord.getEndpointId() == endpointId;
+ });
if (it != m_inRecords.end()) {
m_inRecords.erase(it);
}
@@ -89,21 +95,25 @@
}
OutRecordCollection::iterator
-Entry::getOutRecord(const Face& face)
+Entry::getOutRecord(const Face& face, uint64_t endpointId)
{
return std::find_if(m_outRecords.begin(), m_outRecords.end(),
- [&face] (const OutRecord& outRecord) { return &outRecord.getFace() == &face; });
+ [&face, endpointId] (const OutRecord& outRecord) {
+ return &outRecord.getFace() == &face && outRecord.getEndpointId() == endpointId;
+ });
}
OutRecordCollection::iterator
-Entry::insertOrUpdateOutRecord(Face& face, const Interest& interest)
+Entry::insertOrUpdateOutRecord(Face& face, uint64_t endpointId, const Interest& interest)
{
BOOST_ASSERT(this->canMatch(interest));
auto it = std::find_if(m_outRecords.begin(), m_outRecords.end(),
- [&face] (const OutRecord& outRecord) { return &outRecord.getFace() == &face; });
+ [&face, endpointId] (const OutRecord& outRecord) {
+ return &outRecord.getFace() == &face && outRecord.getEndpointId() == endpointId;
+ });
if (it == m_outRecords.end()) {
- m_outRecords.emplace_front(face);
+ m_outRecords.emplace_front(face, endpointId);
it = m_outRecords.begin();
}
@@ -112,14 +122,27 @@
}
void
-Entry::deleteOutRecord(const Face& face)
+Entry::deleteOutRecord(const Face& face, uint64_t endpointId)
{
auto it = std::find_if(m_outRecords.begin(), m_outRecords.end(),
- [&face] (const OutRecord& outRecord) { return &outRecord.getFace() == &face; });
+ [&face, endpointId] (const OutRecord& outRecord) {
+ return &outRecord.getFace() == &face && outRecord.getEndpointId() == endpointId;
+ });
if (it != m_outRecords.end()) {
m_outRecords.erase(it);
}
}
+void
+Entry::deleteInOutRecordsByFace(const Face& face)
+{
+ m_inRecords.remove_if([&face] (const InRecord& inRecord) {
+ return &inRecord.getFace() == &face;
+ });
+ m_outRecords.remove_if([&face] (const OutRecord& outRecord) {
+ return &outRecord.getFace() == &face;
+ });
+}
+
} // namespace pit
} // namespace nfd