28 "PrefixAnnouncement::Error must inherit from tlv::Error");
35 const Name& dataName = m_data->getName();
37 !dataName[-2].isVersion() || !dataName[-1].isSegment()) {
38 NDN_THROW(
Error(
"Data is not a prefix announcement: wrong name structure"));
43 NDN_THROW(
Error(
"Data is not a prefix announcement: ContentType is " +
47 if (m_data->getContent().value_size() == 0) {
51 const Block& payload = m_data->getContent();
58 m_validity.emplace(*validityElement);
71 optional<uint64_t>
version)
const 74 Name dataName = m_announcedName;
78 m_data.emplace(dataName);
83 m_expiration.count()));
85 content.
push_back(m_validity->wireEncode());
88 m_data->setContent(content);
90 keyChain.sign(*m_data, si);
106 if (expiration < 0_ms) {
107 NDN_THROW(std::invalid_argument(
"expiration period is negative"));
110 m_expiration = expiration;
PartialName getPrefix(ssize_t nComponents) const
Returns a prefix of the name.
Copyright (c) 2011-2015 Regents of the University of California.
std::string to_string(const T &val)
constexpr bool isCriticalType(uint32_t type)
Determine whether a TLV-TYPE is "critical" for evolvability purpose.
std::ostream & operator<<(std::ostream &os, const Data &data)
PrefixAnnouncement & setValidityPeriod(optional< security::ValidityPeriod > validity)
Set absolute validity period.
void parse() const
Parse TLV-VALUE into sub-elements.
Represents a TLV element of the NDN packet format.
static time_point now() noexcept
Block makeNonNegativeIntegerBlock(uint32_t type, uint64_t value)
Create a TLV block containing a non-negative integer.
milliseconds toUnixTimestamp(const system_clock::time_point &point)
Convert system_clock::time_point to UNIX timestamp.
Name & append(const Component &component)
Append a component.
const Data & toData(KeyChain &keyChain, const ndn::security::SigningInfo &si=security::SigningInfo(), optional< uint64_t > version=nullopt) const
Create a Data packet representing the prefix announcement, if it does not exist.
Signing parameters passed to KeyChain.
Name & appendVersion(const optional< uint64_t > &version=nullopt)
Append a version component.
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
A prefix announcement object that represents an application's intent of registering a prefix toward i...
const element_container & elements() const
Get container of sub-elements.
element_const_iterator elements_end() const
Equivalent to elements().end()
const Block & get(uint32_t type) const
Return the first sub-element of the specified TLV-TYPE.
element_const_iterator find(uint32_t type) const
Find the first sub-element of the specified TLV-TYPE.
PrefixAnnouncement & setExpiration(time::milliseconds expiration)
Set relative expiration period.
const Name & getAnnouncedName() const
Return announced name.
Represents an absolute name.
void push_back(const Block &element)
Append a sub-element.
PrefixAnnouncement & setAnnouncedName(Name name)
Set announced name.
size_t size() const
Returns the number of components.
optional< security::ValidityPeriod > getValidityPeriod() const
Return absolute validity period.
Represents a name component.
void encode()
Encode sub-elements into TLV-VALUE.
static const name::Component & getKeywordComponent()
Returns the well-known keyword name component used for prefix announcements (32=PA) ...
bool operator==(const Data &lhs, const Data &rhs)
PrefixAnnouncement()
Construct an empty prefix announcement.
time::milliseconds getExpiration() const
Return relative expiration period.
Represents a Data packet.
Name & appendSegment(uint64_t segmentNo)
Append a segment number (sequential) component.
boost::chrono::milliseconds milliseconds