25 #include <ndn-cpp/c/data-types.h>
27 #include "publisher-public-key-digest.h"
28 #include "key-locator.h"
40 static __inline
void ndn_Signature_initialize(
struct ndn_Signature *
self,
struct ndn_NameComponent *keyNameComponents,
size_t maxKeyNameComponents) {
41 self->type = (ndn_SignatureType)-1;
42 ndn_Blob_initialize(&self->digestAlgorithm, 0, 0);
43 ndn_Blob_initialize(&self->witness, 0, 0);
44 ndn_Blob_initialize(&self->signature, 0, 0);
45 ndn_PublisherPublicKeyDigest_initialize(&self->publisherPublicKeyDigest);
46 ndn_KeyLocator_initialize(&self->keyLocator, keyNameComponents, maxKeyNameComponents);
54 static __inline
void ndn_Signature_clear(
struct ndn_Signature *
self)
56 ndn_Signature_initialize
57 (
self, self->keyLocator.keyName.components,
58 self->keyLocator.keyName.maxComponents);
68 static __inline ndn_Error
69 ndn_Signature_setFromSignature
76 return NDN_ERROR_success;
79 ndn_Blob_setFromBlob(&self->witness, &other->
witness);
80 ndn_Blob_setFromBlob(&self->signature, &other->signature);
82 if ((error = ndn_KeyLocator_setFromKeyLocator
83 (&self->keyLocator, &other->keyLocator)))
86 return NDN_ERROR_success;
93 static __inline
void ndn_MetaInfo_initialize(
struct ndn_MetaInfo *
self)
95 self->timestampMilliseconds = -1;
96 self->type = ndn_ContentType_BLOB;
97 self->freshnessPeriod = -1;
98 ndn_NameComponent_initialize(&self->finalBlockId, 0, 0);
104 static __inline
int ndn_MetaInfo_getFreshnessSeconds(
const struct ndn_MetaInfo *
self)
106 return self->freshnessPeriod < 0 ? -1 : (int)round(self->freshnessPeriod / 1000.0);
112 static __inline
void ndn_MetaInfo_setFreshnessSeconds(
struct ndn_MetaInfo *
self,
int freshnessSeconds)
114 self->freshnessPeriod = freshnessSeconds < 0 ? -1.0 : (double)freshnessSeconds * 1000.0;
124 static __inline ndn_Error
125 ndn_MetaInfo_setFromMetaInfo
130 return NDN_ERROR_success;
133 self->type = other->
type;
135 ndn_NameComponent_setFromNameComponent(&self->finalBlockId, &other->
finalBlockId);
137 return NDN_ERROR_success;
149 static __inline
void ndn_Data_initialize
153 ndn_Signature_initialize(&self->signature, keyNameComponents, maxKeyNameComponents);
154 ndn_Name_initialize(&self->name, nameComponents, maxNameComponents);
155 ndn_MetaInfo_initialize(&self->metaInfo);
156 ndn_Blob_initialize(&self->content, 0, 0);
166 static __inline ndn_Error
173 return NDN_ERROR_success;
175 if ((error = ndn_Signature_setFromSignature
176 (&self->signature, &other->signature)))
178 if ((error = ndn_Name_setFromName(&self->name, &other->name)))
180 if ((error = ndn_MetaInfo_setFromMetaInfo
181 (&self->metaInfo, &other->metaInfo)))
183 ndn_Blob_setFromBlob(&self->content, &other->
content);
185 return NDN_ERROR_success;
struct ndn_PublisherPublicKeyDigest publisherPublicKeyDigest
Definition: data-types.h:72
Definition: data-types.h:86
struct ndn_Blob content
A Blob with a pointer to the content.
Definition: data-types.h:90
struct ndn_Blob witness
A Blob whose value is a pointer to pre-allocated buffer.
Definition: data-types.h:68
Copyright (C) 2015 Regents of the University of California.
Definition: name-types.h:33
An ndn_Signature struct holds the signature bits and other info representing the signature in a data ...
Definition: data-types.h:64
struct ndn_Blob digestAlgorithm
A Blob whose value is a pointer to a pre-allocated buffer.
Definition: data-types.h:66