25 #include <ndn-cpp/c/data-types.h>
27 #include "key-locator.h"
39 static __inline
void ndn_Signature_initialize(
struct ndn_Signature *
self,
struct ndn_NameComponent *keyNameComponents,
size_t maxKeyNameComponents) {
40 self->type = (ndn_SignatureType)-1;
41 ndn_Blob_initialize(&self->signature, 0, 0);
42 ndn_Blob_initialize(&self->signatureInfoEncoding, 0, 0);
43 self->genericTypeCode = -1;
44 ndn_KeyLocator_initialize(&self->keyLocator, keyNameComponents, maxKeyNameComponents);
52 static __inline
void ndn_Signature_clear(
struct ndn_Signature *
self)
54 ndn_Signature_initialize
55 (
self, self->keyLocator.keyName.components,
56 self->keyLocator.keyName.maxComponents);
66 static __inline ndn_Error
67 ndn_Signature_setFromSignature
74 return NDN_ERROR_success;
76 self->type = other->
type;
77 ndn_Blob_setFromBlob(&self->signature, &other->signature);
80 if ((error = ndn_KeyLocator_setFromKeyLocator
84 return NDN_ERROR_success;
91 static __inline
void ndn_MetaInfo_initialize(
struct ndn_MetaInfo *
self)
93 self->timestampMilliseconds = -1;
94 self->type = ndn_ContentType_BLOB;
95 self->freshnessPeriod = -1;
96 ndn_NameComponent_initialize(&self->finalBlockId, 0, 0);
102 static __inline
int ndn_MetaInfo_getFreshnessSeconds(
const struct ndn_MetaInfo *
self)
104 return self->freshnessPeriod < 0 ? -1 : (int)round(self->freshnessPeriod / 1000.0);
110 static __inline
void ndn_MetaInfo_setFreshnessSeconds(
struct ndn_MetaInfo *
self,
int freshnessSeconds)
112 self->freshnessPeriod = freshnessSeconds < 0 ? -1.0 : (double)freshnessSeconds * 1000.0;
122 static __inline ndn_Error
123 ndn_MetaInfo_setFromMetaInfo
128 return NDN_ERROR_success;
131 self->type = other->
type;
133 ndn_NameComponent_setFromNameComponent(&self->finalBlockId, &other->
finalBlockId);
135 return NDN_ERROR_success;
147 static __inline
void ndn_Data_initialize
151 ndn_Signature_initialize(&self->signature, keyNameComponents, maxKeyNameComponents);
152 ndn_Name_initialize(&self->name, nameComponents, maxNameComponents);
153 ndn_MetaInfo_initialize(&self->metaInfo);
154 ndn_Blob_initialize(&self->content, 0, 0);
164 static __inline ndn_Error
171 return NDN_ERROR_success;
173 if ((error = ndn_Signature_setFromSignature
174 (&self->signature, &other->signature)))
176 if ((error = ndn_Name_setFromName(&self->name, &other->name)))
178 if ((error = ndn_MetaInfo_setFromMetaInfo
179 (&self->metaInfo, &other->metaInfo)))
181 ndn_Blob_setFromBlob(&self->content, &other->
content);
183 return NDN_ERROR_success;
int genericTypeCode
used with Generic.
Definition: data-types.h:63
Definition: data-types.h:78
struct ndn_Blob content
A Blob with a pointer to the content.
Definition: data-types.h:82
ndn_SignatureType type
-1 for unspecified
Definition: data-types.h:60
struct ndn_KeyLocator keyLocator
used with Sha256WithRsaSignature, Sha256WithEcdsaSignature, HmacWithSha256Signature ...
Definition: data-types.h:64
Copyright (C) 2015-2016 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:59
struct ndn_Blob signatureInfoEncoding
used with Generic
Definition: data-types.h:62