prefix-ann: provide ==, !=, << operators
Also, ensure toData() adds correct ContentType.
refs #4650
Change-Id: I60956948766190cd713b58c85ba30b3701180b25
diff --git a/src/prefix-announcement.cpp b/src/prefix-announcement.cpp
index 6149526..410d270 100644
--- a/src/prefix-announcement.cpp
+++ b/src/prefix-announcement.cpp
@@ -74,6 +74,7 @@
dataName.appendVersion(version.value_or(time::toUnixTimestamp(time::system_clock::now()).count()));
dataName.appendSegment(0);
m_data.emplace(dataName);
+ m_data->setContentType(tlv::ContentType_PrefixAnn);
Block content(tlv::Content);
content.push_back(makeNonNegativeIntegerBlock(tlv::nfd::ExpirationPeriod,
@@ -116,4 +117,22 @@
return *this;
}
+bool
+operator==(const PrefixAnnouncement& lhs, const PrefixAnnouncement& rhs)
+{
+ return lhs.getAnnouncedName() == rhs.getAnnouncedName() &&
+ lhs.getExpiration() == rhs.getExpiration() &&
+ lhs.getValidityPeriod() == rhs.getValidityPeriod();
+}
+
+std::ostream&
+operator<<(std::ostream& os, const PrefixAnnouncement& pa)
+{
+ os << pa.getAnnouncedName() << " expires=" << pa.getExpiration();
+ if (pa.getValidityPeriod()) {
+ os << " validity=" << *pa.getValidityPeriod();
+ }
+ return os;
+}
+
} // namespace ndn