32 const Name Entry::LOCALHOST_NAME(
"ndn:/localhost");
33 const Name Entry::LOCALHOP_NAME(
"ndn:/localhop");
36 : m_interest(interest.shared_from_this())
43 return m_interest->getName();
49 return std::any_of(m_inRecords.begin(), m_inRecords.end(),
50 [] (
const InRecord& inRecord) {
return inRecord.getFace()->isLocal(); });
56 time::steady_clock::TimePoint now = time::steady_clock::now();
58 bool hasUnexpiredOutRecord = std::any_of(m_outRecords.begin(), m_outRecords.end(),
59 [&face, &now] (
const OutRecord& outRecord) {
60 return outRecord.getFace().get() == &face && outRecord.getExpiry() >= now;
62 if (hasUnexpiredOutRecord) {
66 bool hasUnexpiredOtherInRecord = std::any_of(m_inRecords.begin(), m_inRecords.end(),
67 [&face, &now] (
const InRecord& inRecord) {
68 return inRecord.getFace().get() != &face && inRecord.getExpiry() >= now;
70 if (!hasUnexpiredOtherInRecord) {
81 bool isViolatingLocalhost = !face.
isLocal() &&
82 LOCALHOST_NAME.isPrefixOf(this->
getName());
83 if (isViolatingLocalhost) {
88 bool isViolatingLocalhop = !face.
isLocal() &&
89 LOCALHOP_NAME.isPrefixOf(this->
getName()) &&
91 if (isViolatingLocalhop) {
105 for (
const InRecord& inRecord : m_inRecords) {
106 if (inRecord.getLastNonce() == nonce) {
107 if (inRecord.getFace().get() == &face) {
116 for (
const OutRecord& outRecord : m_outRecords) {
117 if (outRecord.getLastNonce() == nonce) {
118 if (outRecord.getFace().get() == &face) {
130 InRecordCollection::iterator
133 auto it = std::find_if(m_inRecords.begin(), m_inRecords.end(),
134 [&face] (
const InRecord& inRecord) {
return inRecord.getFace() == face; });
135 if (it == m_inRecords.end()) {
136 m_inRecords.emplace_front(face);
137 it = m_inRecords.begin();
140 it->update(interest);
144 InRecordCollection::const_iterator
147 return std::find_if(m_inRecords.begin(), m_inRecords.end(),
148 [&face] (
const InRecord& inRecord) {
return inRecord.getFace().get() == &face; });
157 OutRecordCollection::iterator
160 auto it = std::find_if(m_outRecords.begin(), m_outRecords.end(),
161 [&face] (
const OutRecord& outRecord) {
return outRecord.getFace() == face; });
162 if (it == m_outRecords.end()) {
163 m_outRecords.emplace_front(face);
164 it = m_outRecords.begin();
167 it->update(interest);
171 OutRecordCollection::const_iterator
174 return std::find_if(m_outRecords.begin(), m_outRecords.end(),
175 [&face] (
const OutRecord& outRecord) {
return outRecord.getFace().get() == &face; });
181 auto it = std::find_if(m_outRecords.begin(), m_outRecords.end(),
182 [&face] (
const OutRecord& outRecord) {
return outRecord.getFace().get() == &face; });
183 if (it != m_outRecords.end()) {
184 m_outRecords.erase(it);
191 time::steady_clock::TimePoint now = time::steady_clock::now();
193 return std::any_of(m_outRecords.begin(), m_outRecords.end(),
194 [&now] (
const OutRecord& outRecord) {
return outRecord.getExpiry() >= now; });
InRecordCollection::const_iterator getInRecord(const Face &face) const
get the InRecord for face
OutRecordCollection::const_iterator getOutRecord(const Face &face) const
get the OutRecord for face
contains information about an Interest from an incoming face
bool canForwardTo(const Face &face) const
decides whether Interest can be forwarded to face
int findNonce(uint32_t nonce, const Face &face) const
finds where a duplicate Nonce appears
InRecordCollection::iterator insertOrUpdateInRecord(shared_ptr< Face > face, const Interest &interest)
inserts a InRecord for face, and updates it with interest
bool hasLocalInRecord() const
determines whether any InRecord is a local Face
bool violatesScope(const Face &face) const
decides whether forwarding Interest to face would violate scope
const Name & getName() const
void deleteOutRecord(const Face &face)
deletes one OutRecord for face if exists
Entry(const Interest &interest)
void deleteInRecords()
deletes all InRecords
contains information about an Interest toward an outgoing face
OutRecordCollection::iterator insertOrUpdateOutRecord(shared_ptr< Face > face, const Interest &interest)
inserts a OutRecord for face, and updates it with interest
bool hasUnexpiredOutRecords() const
bool isLocal() const
Get whether face is connected to a local app.