aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_gnsrecord_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_gnsrecord_lib.h')
-rw-r--r--src/include/gnunet_gnsrecord_lib.h76
1 files changed, 53 insertions, 23 deletions
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h
index 94e20323d..fdbac3cf5 100644
--- a/src/include/gnunet_gnsrecord_lib.h
+++ b/src/include/gnunet_gnsrecord_lib.h
@@ -61,6 +61,7 @@ extern "C" {
61 61
62/** 62/**
63 * Flags that can be set for a record. 63 * Flags that can be set for a record.
64 * MUST fit into 16 bit.
64 */ 65 */
65enum GNUNET_GNSRECORD_Flags 66enum GNUNET_GNSRECORD_Flags
66{ 67{
@@ -70,10 +71,17 @@ enum GNUNET_GNSRECORD_Flags
70 GNUNET_GNSRECORD_RF_NONE = 0, 71 GNUNET_GNSRECORD_RF_NONE = 0,
71 72
72 /** 73 /**
73 * This is a private record of this peer and it should 74 * This record is critical. If it cannot be processed
74 * thus not be handed out to other peers. 75 * (for example beacuse the record type is unknown)
76 * resolution MUST fail
75 */ 77 */
76 GNUNET_GNSRECORD_RF_PRIVATE = 2, 78 GNUNET_GNSRECORD_RF_CRITICAL = 1,
79
80 /**
81 * This record should not be used unless all (other) records with an absolute
82 * expiration time have expired.
83 */
84 GNUNET_GNSRECORD_RF_SHADOW_RECORD = 2,
77 85
78 /** 86 /**
79 * This is a supplemental record. 87 * This is a supplemental record.
@@ -84,13 +92,14 @@ enum GNUNET_GNSRECORD_Flags
84 * This expiration time of the record is a relative 92 * This expiration time of the record is a relative
85 * time (not an absolute time). 93 * time (not an absolute time).
86 */ 94 */
87 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION = 8, 95 GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION = 16384, /* 2^14 */
88 96
89 /** 97 /**
90 * This record should not be used unless all (other) records with an absolute 98 * This is a private record of this peer and it should
91 * expiration time have expired. 99 * thus not be handed out to other peers.
92 */ 100 */
93 GNUNET_GNSRECORD_RF_SHADOW_RECORD = 16 101 GNUNET_GNSRECORD_RF_PRIVATE = 32768, /* 2^15 */
102
94 103
95/** 104/**
96 * When comparing flags for record equality for removal, 105 * When comparing flags for record equality for removal,
@@ -184,12 +193,6 @@ struct GNUNET_GNSRECORD_EcdsaBlock
184 struct GNUNET_CRYPTO_EcdsaSignature signature; 193 struct GNUNET_CRYPTO_EcdsaSignature signature;
185 194
186 /** 195 /**
187 * Number of bytes signed; also specifies the number of bytes
188 * of encrypted data that follow.
189 */
190 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
191
192 /**
193 * Expiration time of the block. 196 * Expiration time of the block.
194 */ 197 */
195 struct GNUNET_TIME_AbsoluteNBO expiration_time; 198 struct GNUNET_TIME_AbsoluteNBO expiration_time;
@@ -214,22 +217,25 @@ struct GNUNET_GNSRECORD_EddsaBlock
214 struct GNUNET_CRYPTO_EddsaSignature signature; 217 struct GNUNET_CRYPTO_EddsaSignature signature;
215 218
216 /** 219 /**
217 * Number of bytes signed; also specifies the number of bytes
218 * of encrypted data that follow.
219 */
220 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
221
222 /**
223 * Expiration time of the block. 220 * Expiration time of the block.
224 */ 221 */
225 struct GNUNET_TIME_AbsoluteNBO expiration_time; 222 struct GNUNET_TIME_AbsoluteNBO expiration_time;
226 223
224
227 /* followed by encrypted data */ 225 /* followed by encrypted data */
228}; 226};
229 227
230 228
231struct GNUNET_GNSRECORD_Block 229struct GNUNET_GNSRECORD_Block
232{ 230{
231 /**
232 * Size of the block.
233 */
234 uint32_t size;
235
236 /**
237 * The zone type (GNUNET_GNSRECORD_TYPE_PKEY)
238 */
233 uint32_t type; 239 uint32_t type;
234 240
235 union 241 union
@@ -387,6 +393,9 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count,
387 const struct GNUNET_GNSRECORD_Data *rd, 393 const struct GNUNET_GNSRECORD_Data *rd,
388 size_t dest_size, char *dest); 394 size_t dest_size, char *dest);
389 395
396unsigned int
397GNUNET_GNSRECORD_records_deserialize_get_size (size_t len,
398 const char *src);
390 399
391/** 400/**
392 * Deserialize the given records to the given destination. 401 * Deserialize the given records to the given destination.
@@ -503,6 +512,21 @@ GNUNET_GNSRECORD_query_from_public_key (
503 512
504 513
505/** 514/**
515 * Get size of buffer for block creation.
516 *
517 * @param key the zone key
518 * @param rd record data
519 * @param rd_count number of records
520 * @return -1 on error (otherwise the length of the block)
521 */
522ssize_t
523GNUNET_GNSRECORD_block_calculate_size (const struct
524 GNUNET_IDENTITY_PrivateKey *key,
525 const struct GNUNET_GNSRECORD_Data *rd,
526 unsigned int rd_count);
527
528
529/**
506 * Sign name and records 530 * Sign name and records
507 * 531 *
508 * @param key the private key 532 * @param key the private key
@@ -510,13 +534,16 @@ GNUNET_GNSRECORD_query_from_public_key (
510 * @param label the name for the records 534 * @param label the name for the records
511 * @param rd record data 535 * @param rd record data
512 * @param rd_count number of records in @a rd 536 * @param rd_count number of records in @a rd
537 * @param result the block buffer. Will be allocated.
538 * @return GNUNET_OK on success
513 */ 539 */
514struct GNUNET_GNSRECORD_Block * 540enum GNUNET_GenericReturnValue
515GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key, 541GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key,
516 struct GNUNET_TIME_Absolute expire, 542 struct GNUNET_TIME_Absolute expire,
517 const char *label, 543 const char *label,
518 const struct GNUNET_GNSRECORD_Data *rd, 544 const struct GNUNET_GNSRECORD_Data *rd,
519 unsigned int rd_count); 545 unsigned int rd_count,
546 struct GNUNET_GNSRECORD_Block **block);
520 547
521 548
522/** 549/**
@@ -529,13 +556,16 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_IDENTITY_PrivateKey *key,
529 * @param label the name for the records 556 * @param label the name for the records
530 * @param rd record data 557 * @param rd record data
531 * @param rd_count number of records in @a rd 558 * @param rd_count number of records in @a rd
559 * @param result the block buffer. Will be allocated.
560 * @return GNUNET_OK on success.
532 */ 561 */
533struct GNUNET_GNSRECORD_Block * 562enum GNUNET_GenericReturnValue
534GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *key, 563GNUNET_GNSRECORD_block_create2 (const struct GNUNET_IDENTITY_PrivateKey *key,
535 struct GNUNET_TIME_Absolute expire, 564 struct GNUNET_TIME_Absolute expire,
536 const char *label, 565 const char *label,
537 const struct GNUNET_GNSRECORD_Data *rd, 566 const struct GNUNET_GNSRECORD_Data *rd,
538 unsigned int rd_count); 567 unsigned int rd_count,
568 struct GNUNET_GNSRECORD_Block **result);
539 569
540 570
541/** 571/**