30 : m_data(std::move(data))
32 const Name& dataName = m_data->getName();
34 !dataName[-2].isVersion() || !dataName[-1].isSegment()) {
35 NDN_THROW(
Error(
"Data is not a prefix announcement: wrong name structure"));
40 NDN_THROW(
Error(
"Data is not a prefix announcement: ContentType is " +
44 if (m_data->getContent().value_size() == 0) {
48 const Block& payload = m_data->getContent();
55 m_validity.emplace(*validityElement);
68 std::optional<uint64_t> version)
const
71 Name dataName = m_announcedName;
75 m_data.emplace(dataName);
80 m_expiration.count()));
82 content.
push_back(m_validity->wireEncode());
85 m_data->setContent(content);
87 keyChain.
sign(*m_data, si);
96 m_announcedName = std::move(name);
103 if (expiration < 0_ms) {
104 NDN_THROW(std::invalid_argument(
"expiration period is negative"));
107 m_expiration = expiration;
115 m_validity = std::move(validity);
Represents a TLV element of the NDN packet format.
element_const_iterator find(uint32_t type) const
Find the first sub-element of the specified TLV-TYPE.
const element_container & elements() const noexcept
Get container of sub-elements.
element_const_iterator elements_end() const noexcept
Equivalent to elements().end().
void push_back(const Block &element)
Append a sub-element.
void encode()
Encode sub-elements into TLV-VALUE.
void parse() const
Parse TLV-VALUE into sub-elements.
const Block & get(uint32_t type) const
Return the first sub-element of the specified TLV-TYPE.
Represents a Data packet.
Represents an absolute name.
PartialName getPrefix(ssize_t nComponents) const
Returns a prefix of the name.
Name & appendSegment(uint64_t segmentNo)
Append a segment number (sequential) component.
Name & appendVersion(const std::optional< uint64_t > &version=std::nullopt)
Append a version component.
size_t size() const noexcept
Returns the number of components.
Name & append(const Component &component)
Append a name component.
A prefix announcement object that represents an application's intent of registering a prefix toward i...
const Name & getAnnouncedName() const
Return announced name.
std::optional< security::ValidityPeriod > getValidityPeriod() const
Return absolute validity period.
PrefixAnnouncement & setValidityPeriod(std::optional< security::ValidityPeriod > validity)
Set absolute validity period.
time::milliseconds getExpiration() const
Return relative expiration period.
PrefixAnnouncement & setExpiration(time::milliseconds expiration)
Set relative expiration period.
PrefixAnnouncement()
Construct an empty prefix announcement.
PrefixAnnouncement & setAnnouncedName(Name name)
Set announced name.
const Data & toData(KeyChain &keyChain, const ndn::security::SigningInfo &si=security::SigningInfo(), std::optional< uint64_t > version=std::nullopt) const
Create a Data packet representing the prefix announcement, if it does not exist.
static const name::Component & getKeywordComponent()
Returns the well-known keyword name component used for prefix announcements (32=PA)
Represents a name component.
The main interface for signing key management.
void sign(Data &data, const SigningInfo ¶ms=SigningInfo())
Sign a Data packet according to the supplied signing information.
Signing parameters passed to KeyChain.
static time_point now() noexcept
uint64_t readNonNegativeInteger(const Block &block)
Read a non-negative integer from a TLV element.
Block makeNonNegativeIntegerBlock(uint32_t type, uint64_t value)
Create a TLV block containing a non-negative integer.
std::string to_string(const errinfo_stacktrace &x)
constexpr Duration toUnixTimestamp(const system_clock::time_point &tp)
Convert system_clock::time_point to UNIX timestamp.
::boost::chrono::milliseconds milliseconds
constexpr bool isCriticalType(uint32_t type) noexcept
Determine whether a TLV-TYPE is "critical" for evolvability purpose.
@ ContentType_PrefixAnn
prefix announcement
std::ostream & operator<<(std::ostream &os, const Data &data)