diff options
Diffstat (limited to 'src/include/gnunet_gnsrecord_lib.h')
-rw-r--r-- | src/include/gnunet_gnsrecord_lib.h | 168 |
1 files changed, 66 insertions, 102 deletions
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 27228c0bc..8b3a6b720 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -35,9 +35,8 @@ | |||
35 | #define GNUNET_GNSRECORD_LIB_H | 35 | #define GNUNET_GNSRECORD_LIB_H |
36 | 36 | ||
37 | #ifdef __cplusplus | 37 | #ifdef __cplusplus |
38 | extern "C" | 38 | extern "C" { |
39 | { | 39 | #if 0 /* keep Emacsens' auto-indent happy */ |
40 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
41 | } | 40 | } |
42 | #endif | 41 | #endif |
43 | #endif | 42 | #endif |
@@ -125,7 +124,7 @@ extern "C" | |||
125 | /** | 124 | /** |
126 | * Record type for reclaim records | 125 | * Record type for reclaim records |
127 | */ | 126 | */ |
128 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_AUTHZ 65550 | 127 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_ATTR_REF 65550 |
129 | 128 | ||
130 | /** | 129 | /** |
131 | * Record type for RECLAIM master | 130 | * Record type for RECLAIM master |
@@ -145,8 +144,7 @@ extern "C" | |||
145 | /** | 144 | /** |
146 | * Flags that can be set for a record. | 145 | * Flags that can be set for a record. |
147 | */ | 146 | */ |
148 | enum GNUNET_GNSRECORD_Flags | 147 | enum GNUNET_GNSRECORD_Flags { |
149 | { | ||
150 | 148 | ||
151 | /** | 149 | /** |
152 | * No special options. | 150 | * No special options. |
@@ -177,17 +175,17 @@ enum GNUNET_GNSRECORD_Flags | |||
177 | */ | 175 | */ |
178 | GNUNET_GNSRECORD_RF_SHADOW_RECORD = 16 | 176 | GNUNET_GNSRECORD_RF_SHADOW_RECORD = 16 |
179 | 177 | ||
180 | /** | 178 | /** |
181 | * When comparing flags for record equality for removal, | 179 | * When comparing flags for record equality for removal, |
182 | * which flags should must match (in addition to the type, | 180 | * which flags should must match (in addition to the type, |
183 | * name, expiration value and data of the record)? All flags | 181 | * name, expiration value and data of the record)? All flags |
184 | * that are not listed here will be ignored for this purpose. | 182 | * that are not listed here will be ignored for this purpose. |
185 | * (for example, we don't expect that users will remember to | 183 | * (for example, we don't expect that users will remember to |
186 | * pass the '--private' option when removing a record from | 184 | * pass the '--private' option when removing a record from |
187 | * the namestore, hence we don't require this particular option | 185 | * the namestore, hence we don't require this particular option |
188 | * to match upon removal). See also | 186 | * to match upon removal). See also |
189 | * #GNUNET_GNSRECORD_records_cmp. | 187 | * #GNUNET_GNSRECORD_records_cmp. |
190 | */ | 188 | */ |
191 | #define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION) | 189 | #define GNUNET_GNSRECORD_RF_RCMP_FLAGS (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION) |
192 | }; | 190 | }; |
193 | 191 | ||
@@ -195,8 +193,7 @@ enum GNUNET_GNSRECORD_Flags | |||
195 | /** | 193 | /** |
196 | * A GNS record. | 194 | * A GNS record. |
197 | */ | 195 | */ |
198 | struct GNUNET_GNSRECORD_Data | 196 | struct GNUNET_GNSRECORD_Data { |
199 | { | ||
200 | 197 | ||
201 | /** | 198 | /** |
202 | * Binary value stored in the DNS record. Note: "data" must never | 199 | * Binary value stored in the DNS record. Note: "data" must never |
@@ -234,8 +231,7 @@ GNUNET_NETWORK_STRUCT_BEGIN | |||
234 | /** | 231 | /** |
235 | * Data stored in a PLACE record. | 232 | * Data stored in a PLACE record. |
236 | */ | 233 | */ |
237 | struct GNUNET_GNSRECORD_PlaceData | 234 | struct GNUNET_GNSRECORD_PlaceData { |
238 | { | ||
239 | /** | 235 | /** |
240 | * Public key of the place. | 236 | * Public key of the place. |
241 | */ | 237 | */ |
@@ -258,8 +254,7 @@ struct GNUNET_GNSRECORD_PlaceData | |||
258 | /** | 254 | /** |
259 | * Information we have in an encrypted block with record data (i.e. in the DHT). | 255 | * Information we have in an encrypted block with record data (i.e. in the DHT). |
260 | */ | 256 | */ |
261 | struct GNUNET_GNSRECORD_Block | 257 | struct GNUNET_GNSRECORD_Block { |
262 | { | ||
263 | 258 | ||
264 | /** | 259 | /** |
265 | * Signature of the block. | 260 | * Signature of the block. |
@@ -296,8 +291,7 @@ struct GNUNET_GNSRECORD_Block | |||
296 | * records do not require a separate network request, thus making TLSA | 291 | * records do not require a separate network request, thus making TLSA |
297 | * records inseparable from the "main" A/AAAA/VPN/etc. records. | 292 | * records inseparable from the "main" A/AAAA/VPN/etc. records. |
298 | */ | 293 | */ |
299 | struct GNUNET_GNSRECORD_BoxRecord | 294 | struct GNUNET_GNSRECORD_BoxRecord { |
300 | { | ||
301 | 295 | ||
302 | /** | 296 | /** |
303 | * Protocol of the boxed record (6 = TCP, 17 = UDP, etc.). | 297 | * Protocol of the boxed record (6 = TCP, 17 = UDP, etc.). |
@@ -316,7 +310,6 @@ struct GNUNET_GNSRECORD_BoxRecord | |||
316 | uint32_t record_type GNUNET_PACKED; | 310 | uint32_t record_type GNUNET_PACKED; |
317 | 311 | ||
318 | /* followed by the 'original' record */ | 312 | /* followed by the 'original' record */ |
319 | |||
320 | }; | 313 | }; |
321 | 314 | ||
322 | /** | 315 | /** |
@@ -326,8 +319,7 @@ struct GNUNET_GNSRECORD_BoxRecord | |||
326 | * the namespace the record belongs to. | 319 | * the namespace the record belongs to. |
327 | * It is exclusively found under the label ``+''. | 320 | * It is exclusively found under the label ``+''. |
328 | */ | 321 | */ |
329 | struct GNUNET_GNSRECORD_ReverseRecord | 322 | struct GNUNET_GNSRECORD_ReverseRecord { |
330 | { | ||
331 | /** | 323 | /** |
332 | * The public key of the namespace the is delegating to our namespace | 324 | * The public key of the namespace the is delegating to our namespace |
333 | */ | 325 | */ |
@@ -351,11 +343,8 @@ GNUNET_NETWORK_STRUCT_END | |||
351 | * @param rd_count number of entries in @a rd array | 343 | * @param rd_count number of entries in @a rd array |
352 | * @param rd array of records with data to store | 344 | * @param rd array of records with data to store |
353 | */ | 345 | */ |
354 | typedef void | 346 | typedef void (*GNUNET_GNSRECORD_RecordCallback) ( |
355 | (*GNUNET_GNSRECORD_RecordCallback) (void *cls, | 347 | void *cls, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd); |
356 | unsigned int rd_count, | ||
357 | const struct GNUNET_GNSRECORD_Data *rd); | ||
358 | |||
359 | 348 | ||
360 | 349 | ||
361 | /* ***************** API related to GNSRECORD plugins ************** */ | 350 | /* ***************** API related to GNSRECORD plugins ************** */ |
@@ -369,10 +358,8 @@ typedef void | |||
369 | * @param data_size number of bytes in @a data | 358 | * @param data_size number of bytes in @a data |
370 | * @return NULL on error, otherwise human-readable representation of the value | 359 | * @return NULL on error, otherwise human-readable representation of the value |
371 | */ | 360 | */ |
372 | char * | 361 | char *GNUNET_GNSRECORD_value_to_string (uint32_t type, const void *data, |
373 | GNUNET_GNSRECORD_value_to_string (uint32_t type, | 362 | size_t data_size); |
374 | const void *data, | ||
375 | size_t data_size); | ||
376 | 363 | ||
377 | 364 | ||
378 | /** | 365 | /** |
@@ -385,11 +372,8 @@ GNUNET_GNSRECORD_value_to_string (uint32_t type, | |||
385 | * @param data_size set to number of bytes in @a data | 372 | * @param data_size set to number of bytes in @a data |
386 | * @return #GNUNET_OK on success | 373 | * @return #GNUNET_OK on success |
387 | */ | 374 | */ |
388 | int | 375 | int GNUNET_GNSRECORD_string_to_value (uint32_t type, const char *s, void **data, |
389 | GNUNET_GNSRECORD_string_to_value (uint32_t type, | 376 | size_t *data_size); |
390 | const char *s, | ||
391 | void **data, | ||
392 | size_t *data_size); | ||
393 | 377 | ||
394 | 378 | ||
395 | /** | 379 | /** |
@@ -398,8 +382,7 @@ GNUNET_GNSRECORD_string_to_value (uint32_t type, | |||
398 | * @param dns_typename name to convert | 382 | * @param dns_typename name to convert |
399 | * @return corresponding number, UINT32_MAX on error | 383 | * @return corresponding number, UINT32_MAX on error |
400 | */ | 384 | */ |
401 | uint32_t | 385 | uint32_t GNUNET_GNSRECORD_typename_to_number (const char *dns_typename); |
402 | GNUNET_GNSRECORD_typename_to_number (const char *dns_typename); | ||
403 | 386 | ||
404 | 387 | ||
405 | /** | 388 | /** |
@@ -408,8 +391,7 @@ GNUNET_GNSRECORD_typename_to_number (const char *dns_typename); | |||
408 | * @param type number of a type to convert | 391 | * @param type number of a type to convert |
409 | * @return corresponding typestring, NULL on error | 392 | * @return corresponding typestring, NULL on error |
410 | */ | 393 | */ |
411 | const char * | 394 | const char *GNUNET_GNSRECORD_number_to_typename (uint32_t type); |
412 | GNUNET_GNSRECORD_number_to_typename (uint32_t type); | ||
413 | 395 | ||
414 | 396 | ||
415 | /* convenience APIs for serializing / deserializing GNS records */ | 397 | /* convenience APIs for serializing / deserializing GNS records */ |
@@ -424,7 +406,7 @@ GNUNET_GNSRECORD_number_to_typename (uint32_t type); | |||
424 | */ | 406 | */ |
425 | ssize_t | 407 | ssize_t |
426 | GNUNET_GNSRECORD_records_get_size (unsigned int rd_count, | 408 | GNUNET_GNSRECORD_records_get_size (unsigned int rd_count, |
427 | const struct GNUNET_GNSRECORD_Data *rd); | 409 | const struct GNUNET_GNSRECORD_Data *rd); |
428 | 410 | ||
429 | 411 | ||
430 | /** | 412 | /** |
@@ -438,9 +420,8 @@ GNUNET_GNSRECORD_records_get_size (unsigned int rd_count, | |||
438 | */ | 420 | */ |
439 | ssize_t | 421 | ssize_t |
440 | GNUNET_GNSRECORD_records_serialize (unsigned int rd_count, | 422 | GNUNET_GNSRECORD_records_serialize (unsigned int rd_count, |
441 | const struct GNUNET_GNSRECORD_Data *rd, | 423 | const struct GNUNET_GNSRECORD_Data *rd, |
442 | size_t dest_size, | 424 | size_t dest_size, char *dest); |
443 | char *dest); | ||
444 | 425 | ||
445 | 426 | ||
446 | /** | 427 | /** |
@@ -452,17 +433,14 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count, | |||
452 | * @param dest where to put the data | 433 | * @param dest where to put the data |
453 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error | 434 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
454 | */ | 435 | */ |
455 | int | 436 | int GNUNET_GNSRECORD_records_deserialize (size_t len, const char *src, |
456 | GNUNET_GNSRECORD_records_deserialize (size_t len, | 437 | unsigned int rd_count, |
457 | const char *src, | 438 | struct GNUNET_GNSRECORD_Data *dest); |
458 | unsigned int rd_count, | ||
459 | struct GNUNET_GNSRECORD_Data *dest); | ||
460 | 439 | ||
461 | 440 | ||
462 | /* ******* general APIs relating to blocks, records and labels ******** */ | 441 | /* ******* general APIs relating to blocks, records and labels ******** */ |
463 | 442 | ||
464 | 443 | ||
465 | |||
466 | /** | 444 | /** |
467 | * Test if a given record is expired. | 445 | * Test if a given record is expired. |
468 | * | 446 | * |
@@ -470,8 +448,7 @@ GNUNET_GNSRECORD_records_deserialize (size_t len, | |||
470 | * @return #GNUNET_YES if the record is expired, | 448 | * @return #GNUNET_YES if the record is expired, |
471 | * #GNUNET_NO if not | 449 | * #GNUNET_NO if not |
472 | */ | 450 | */ |
473 | int | 451 | int GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd); |
474 | GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd); | ||
475 | 452 | ||
476 | 453 | ||
477 | /** | 454 | /** |
@@ -479,8 +456,7 @@ GNUNET_GNSRECORD_is_expired (const struct GNUNET_GNSRECORD_Data *rd); | |||
479 | * @param src source string | 456 | * @param src source string |
480 | * @return converted result | 457 | * @return converted result |
481 | */ | 458 | */ |
482 | char * | 459 | char *GNUNET_GNSRECORD_string_to_lowercase (const char *src); |
483 | GNUNET_GNSRECORD_string_to_lowercase (const char *src); | ||
484 | 460 | ||
485 | 461 | ||
486 | /** | 462 | /** |
@@ -489,10 +465,10 @@ GNUNET_GNSRECORD_string_to_lowercase (const char *src); | |||
489 | * NOT reentrant! | 465 | * NOT reentrant! |
490 | * | 466 | * |
491 | * @param z public key of a zone | 467 | * @param z public key of a zone |
492 | * @return string form; will be overwritten by next call to #GNUNET_GNSRECORD_z2s. | 468 | * @return string form; will be overwritten by next call to |
469 | * #GNUNET_GNSRECORD_z2s. | ||
493 | */ | 470 | */ |
494 | const char * | 471 | const char *GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z); |
495 | GNUNET_GNSRECORD_z2s (const struct GNUNET_CRYPTO_EcdsaPublicKey *z); | ||
496 | 472 | ||
497 | 473 | ||
498 | /** | 474 | /** |
@@ -518,9 +494,8 @@ GNUNET_GNSRECORD_pkey_to_zkey (const struct GNUNET_CRYPTO_EcdsaPublicKey *pkey); | |||
518 | * @param pkey set to a public key on the eliptic curve | 494 | * @param pkey set to a public key on the eliptic curve |
519 | * @return #GNUNET_SYSERR if @a zkey has the wrong syntax | 495 | * @return #GNUNET_SYSERR if @a zkey has the wrong syntax |
520 | */ | 496 | */ |
521 | int | 497 | int GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, |
522 | GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, | 498 | struct GNUNET_CRYPTO_EcdsaPublicKey *pkey); |
523 | struct GNUNET_CRYPTO_EcdsaPublicKey *pkey); | ||
524 | 499 | ||
525 | 500 | ||
526 | /** | 501 | /** |
@@ -530,10 +505,9 @@ GNUNET_GNSRECORD_zkey_to_pkey (const char *zkey, | |||
530 | * @param label label of the record | 505 | * @param label label of the record |
531 | * @param query hash to use for the query | 506 | * @param query hash to use for the query |
532 | */ | 507 | */ |
533 | void | 508 | void GNUNET_GNSRECORD_query_from_private_key ( |
534 | GNUNET_GNSRECORD_query_from_private_key (const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 509 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, const char *label, |
535 | const char *label, | 510 | struct GNUNET_HashCode *query); |
536 | struct GNUNET_HashCode *query); | ||
537 | 511 | ||
538 | 512 | ||
539 | /** | 513 | /** |
@@ -543,10 +517,9 @@ GNUNET_GNSRECORD_query_from_private_key (const struct GNUNET_CRYPTO_EcdsaPrivate | |||
543 | * @param label label of the record | 517 | * @param label label of the record |
544 | * @param query hash to use for the query | 518 | * @param query hash to use for the query |
545 | */ | 519 | */ |
546 | void | 520 | void GNUNET_GNSRECORD_query_from_public_key ( |
547 | GNUNET_GNSRECORD_query_from_public_key (const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, | 521 | const struct GNUNET_CRYPTO_EcdsaPublicKey *pub, const char *label, |
548 | const char *label, | 522 | struct GNUNET_HashCode *query); |
549 | struct GNUNET_HashCode *query); | ||
550 | 523 | ||
551 | 524 | ||
552 | /** | 525 | /** |
@@ -558,12 +531,10 @@ GNUNET_GNSRECORD_query_from_public_key (const struct GNUNET_CRYPTO_EcdsaPublicKe | |||
558 | * @param rd record data | 531 | * @param rd record data |
559 | * @param rd_count number of records in @a rd | 532 | * @param rd_count number of records in @a rd |
560 | */ | 533 | */ |
561 | struct GNUNET_GNSRECORD_Block * | 534 | struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create ( |
562 | GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 535 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, |
563 | struct GNUNET_TIME_Absolute expire, | 536 | struct GNUNET_TIME_Absolute expire, const char *label, |
564 | const char *label, | 537 | const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count); |
565 | const struct GNUNET_GNSRECORD_Data *rd, | ||
566 | unsigned int rd_count); | ||
567 | 538 | ||
568 | 539 | ||
569 | /** | 540 | /** |
@@ -577,12 +548,10 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
577 | * @param rd record data | 548 | * @param rd record data |
578 | * @param rd_count number of records in @a rd | 549 | * @param rd_count number of records in @a rd |
579 | */ | 550 | */ |
580 | struct GNUNET_GNSRECORD_Block * | 551 | struct GNUNET_GNSRECORD_Block *GNUNET_GNSRECORD_block_create2 ( |
581 | GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 552 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, |
582 | struct GNUNET_TIME_Absolute expire, | 553 | struct GNUNET_TIME_Absolute expire, const char *label, |
583 | const char *label, | 554 | const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count); |
584 | const struct GNUNET_GNSRECORD_Data *rd, | ||
585 | unsigned int rd_count); | ||
586 | 555 | ||
587 | 556 | ||
588 | /** | 557 | /** |
@@ -592,8 +561,7 @@ GNUNET_GNSRECORD_block_create2 (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
592 | * @param block block to verify | 561 | * @param block block to verify |
593 | * @return #GNUNET_OK if the signature is valid | 562 | * @return #GNUNET_OK if the signature is valid |
594 | */ | 563 | */ |
595 | int | 564 | int GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); |
596 | GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); | ||
597 | 565 | ||
598 | 566 | ||
599 | /** | 567 | /** |
@@ -607,12 +575,10 @@ GNUNET_GNSRECORD_block_verify (const struct GNUNET_GNSRECORD_Block *block); | |||
607 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was | 575 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the block was |
608 | * not well-formed | 576 | * not well-formed |
609 | */ | 577 | */ |
610 | int | 578 | int GNUNET_GNSRECORD_block_decrypt ( |
611 | GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, | 579 | const struct GNUNET_GNSRECORD_Block *block, |
612 | const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, | 580 | const struct GNUNET_CRYPTO_EcdsaPublicKey *zone_key, const char *label, |
613 | const char *label, | 581 | GNUNET_GNSRECORD_RecordCallback proc, void *proc_cls); |
614 | GNUNET_GNSRECORD_RecordCallback proc, | ||
615 | void *proc_cls); | ||
616 | 582 | ||
617 | 583 | ||
618 | /** | 584 | /** |
@@ -622,9 +588,8 @@ GNUNET_GNSRECORD_block_decrypt (const struct GNUNET_GNSRECORD_Block *block, | |||
622 | * @param b another record | 588 | * @param b another record |
623 | * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not. | 589 | * @return #GNUNET_YES if the records are equal, or #GNUNET_NO if not. |
624 | */ | 590 | */ |
625 | int | 591 | int GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, |
626 | GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, | 592 | const struct GNUNET_GNSRECORD_Data *b); |
627 | const struct GNUNET_GNSRECORD_Data *b); | ||
628 | 593 | ||
629 | 594 | ||
630 | /** | 595 | /** |
@@ -636,12 +601,11 @@ GNUNET_GNSRECORD_records_cmp (const struct GNUNET_GNSRECORD_Data *a, | |||
636 | * @param rd array of records | 601 | * @param rd array of records |
637 | * @return absolute expiration time | 602 | * @return absolute expiration time |
638 | */ | 603 | */ |
639 | struct GNUNET_TIME_Absolute | 604 | struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time ( |
640 | GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count, | 605 | unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd); |
641 | const struct GNUNET_GNSRECORD_Data *rd); | ||
642 | 606 | ||
643 | 607 | ||
644 | #if 0 /* keep Emacsens' auto-indent happy */ | 608 | #if 0 /* keep Emacsens' auto-indent happy */ |
645 | { | 609 | { |
646 | #endif | 610 | #endif |
647 | #ifdef __cplusplus | 611 | #ifdef __cplusplus |
@@ -650,4 +614,4 @@ GNUNET_GNSRECORD_record_get_expiration_time (unsigned int rd_count, | |||
650 | 614 | ||
651 | #endif | 615 | #endif |
652 | 616 | ||
653 | /** @} */ /* end of group */ | 617 | /** @} */ /* end of group */ |