diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-15 10:25:25 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-15 10:25:25 +0000 |
commit | 8b99bff307642ab05bea6601bae3d11a9cd457a0 (patch) | |
tree | 475868b34046ba9491811cb3a7167afb4f363968 | |
parent | 3c8feec5381491be406c1032fb72464b0f177a1d (diff) | |
download | gnunet-8b99bff307642ab05bea6601bae3d11a9cd457a0.tar.gz gnunet-8b99bff307642ab05bea6601bae3d11a9cd457a0.zip |
-fixing #2993
-rw-r--r-- | src/include/gnunet_namestore_plugin.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_namestore_service.h | 50 | ||||
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 62 |
3 files changed, 60 insertions, 54 deletions
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h index 9a6a00462..5ab374ed0 100644 --- a/src/include/gnunet_namestore_plugin.h +++ b/src/include/gnunet_namestore_plugin.h | |||
@@ -77,7 +77,7 @@ struct GNUNET_NAMESTORE_PluginFunctions | |||
77 | void *cls; | 77 | void *cls; |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Cache a block in the datastore. Overwrites (older) existing blocks | 80 | * Cache a block in the datastore. Overwrites existing blocks |
81 | * for the same zone and label. | 81 | * for the same zone and label. |
82 | * | 82 | * |
83 | * @param cls closure (internal context for the plugin) | 83 | * @param cls closure (internal context for the plugin) |
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index 5b622e6f2..853352109 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h | |||
@@ -272,7 +272,7 @@ GNUNET_NETWORK_STRUCT_END | |||
272 | * @param h handle to the namestore | 272 | * @param h handle to the namestore |
273 | * @param block block to store | 273 | * @param block block to store |
274 | * @param cont continuation to call when done | 274 | * @param cont continuation to call when done |
275 | * @param cont_cls closure for cont | 275 | * @param cont_cls closure for @a cont |
276 | * @return handle to abort the request | 276 | * @return handle to abort the request |
277 | */ | 277 | */ |
278 | struct GNUNET_NAMESTORE_QueueEntry * | 278 | struct GNUNET_NAMESTORE_QueueEntry * |
@@ -293,7 +293,7 @@ GNUNET_NAMESTORE_block_cache (struct GNUNET_NAMESTORE_Handle *h, | |||
293 | * @param rd_count number of records in the 'rd' array | 293 | * @param rd_count number of records in the 'rd' array |
294 | * @param rd array of records with data to store | 294 | * @param rd array of records with data to store |
295 | * @param cont continuation to call when done | 295 | * @param cont continuation to call when done |
296 | * @param cont_cls closure for 'cont' | 296 | * @param cont_cls closure for @a cont |
297 | * @return handle to abort the request | 297 | * @return handle to abort the request |
298 | */ | 298 | */ |
299 | struct GNUNET_NAMESTORE_QueueEntry * | 299 | struct GNUNET_NAMESTORE_QueueEntry * |
@@ -339,7 +339,7 @@ GNUNET_NAMESTORE_lookup_block (struct GNUNET_NAMESTORE_Handle *h, | |||
339 | * @param cls closure | 339 | * @param cls closure |
340 | * @param zone private key of the zone | 340 | * @param zone private key of the zone |
341 | * @param label label of the records | 341 | * @param label label of the records |
342 | * @param rd_count number of entries in 'rd' array | 342 | * @param rd_count number of entries in @a rd array |
343 | * @param rd array of records with data to store | 343 | * @param rd array of records with data to store |
344 | */ | 344 | */ |
345 | typedef void (*GNUNET_NAMESTORE_RecordMonitor) (void *cls, | 345 | typedef void (*GNUNET_NAMESTORE_RecordMonitor) (void *cls, |
@@ -414,7 +414,7 @@ GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, | |||
414 | 414 | ||
415 | 415 | ||
416 | /** | 416 | /** |
417 | * Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start | 417 | * Calls the record processor specified in #GNUNET_NAMESTORE_zone_iteration_start |
418 | * for the next record. | 418 | * for the next record. |
419 | * | 419 | * |
420 | * @param it the iterator | 420 | * @param it the iterator |
@@ -452,10 +452,10 @@ typedef void (*GNUNET_NAMESTORE_RecordsSynchronizedCallback)(void *cls); | |||
452 | 452 | ||
453 | 453 | ||
454 | /** | 454 | /** |
455 | * Begin monitoring a zone for changes. Will first call the 'monitor' function | 455 | * Begin monitoring a zone for changes. Will first call the @a monitor function |
456 | * on all existing records in the selected zone(s), then calls 'sync_cb', | 456 | * on all existing records in the selected zone(s), then calls @a sync_cb, |
457 | * and then calls the 'monitor' whenever a record changes. If the namestore | 457 | * and then calls the @a monitor whenever a record changes. If the namestore |
458 | * disconnects, the 'monitor' function is called with a disconnect event; if | 458 | * disconnects, the @a monitor function is called with a disconnect event; if |
459 | * the connection is re-established, the process begins from the start (all | 459 | * the connection is re-established, the process begins from the start (all |
460 | * existing records, sync, then updates). | 460 | * existing records, sync, then updates). |
461 | * | 461 | * |
@@ -463,7 +463,7 @@ typedef void (*GNUNET_NAMESTORE_RecordsSynchronizedCallback)(void *cls); | |||
463 | * @param zone zone to monitor | 463 | * @param zone zone to monitor |
464 | * @param monitor function to call on zone changes | 464 | * @param monitor function to call on zone changes |
465 | * @param sync_cb function called when we're in sync with the namestore | 465 | * @param sync_cb function called when we're in sync with the namestore |
466 | * @param cls closure for 'monitor' and 'sync_cb' | 466 | * @param cls closure for @a monitor' and @a sync_cb |
467 | * @return handle to stop monitoring | 467 | * @return handle to stop monitoring |
468 | */ | 468 | */ |
469 | struct GNUNET_NAMESTORE_ZoneMonitor * | 469 | struct GNUNET_NAMESTORE_ZoneMonitor * |
@@ -489,11 +489,9 @@ GNUNET_NAMESTORE_zone_monitor_stop (struct GNUNET_NAMESTORE_ZoneMonitor *zm); | |||
489 | * Calculate how many bytes we will need to serialize the given | 489 | * Calculate how many bytes we will need to serialize the given |
490 | * records. | 490 | * records. |
491 | * | 491 | * |
492 | * @param rd_count number of records in the rd array | 492 | * @param rd_count number of records in the @a rd array |
493 | * @param rd array of #GNUNET_NAMESTORE_RecordData with @a rd_count elements | 493 | * @param rd array of #GNUNET_NAMESTORE_RecordData with @a rd_count elements |
494 | * | ||
495 | * @return the required size to serialize | 494 | * @return the required size to serialize |
496 | * | ||
497 | */ | 495 | */ |
498 | size_t | 496 | size_t |
499 | GNUNET_NAMESTORE_records_get_size (unsigned int rd_count, | 497 | GNUNET_NAMESTORE_records_get_size (unsigned int rd_count, |
@@ -503,9 +501,9 @@ GNUNET_NAMESTORE_records_get_size (unsigned int rd_count, | |||
503 | /** | 501 | /** |
504 | * Serialize the given records to the given destination buffer. | 502 | * Serialize the given records to the given destination buffer. |
505 | * | 503 | * |
506 | * @param rd_count number of records in the rd array | 504 | * @param rd_count number of records in the @a rd array |
507 | * @param rd array of #GNUNET_NAMESTORE_RecordData with @a rd_count elements | 505 | * @param rd array of #GNUNET_NAMESTORE_RecordData with @a rd_count elements |
508 | * @param dest_size size of the destination array | 506 | * @param dest_size size of the destination array @a dst |
509 | * @param dest where to write the result | 507 | * @param dest where to write the result |
510 | * @return the size of serialized records, -1 if records do not fit | 508 | * @return the size of serialized records, -1 if records do not fit |
511 | */ | 509 | */ |
@@ -521,10 +519,9 @@ GNUNET_NAMESTORE_records_serialize (unsigned int rd_count, | |||
521 | * | 519 | * |
522 | * @param len size of the serialized record data | 520 | * @param len size of the serialized record data |
523 | * @param src the serialized record data | 521 | * @param src the serialized record data |
524 | * @param rd_count number of records in the rd array | 522 | * @param rd_count number of records in the @a dest array |
525 | * @param dest where to put the data | 523 | * @param dest where to put the data |
526 | * | 524 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error |
527 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
528 | */ | 525 | */ |
529 | int | 526 | int |
530 | GNUNET_NAMESTORE_records_deserialize (size_t len, | 527 | GNUNET_NAMESTORE_records_deserialize (size_t len, |
@@ -534,11 +531,12 @@ GNUNET_NAMESTORE_records_deserialize (size_t len, | |||
534 | 531 | ||
535 | 532 | ||
536 | /** | 533 | /** |
537 | * Convert the 'value' of a record to a string. | 534 | * Convert the binary value @a data of a record of |
535 | * type @a type to a human-readable string. | ||
538 | * | 536 | * |
539 | * @param type type of the record | 537 | * @param type type of the record |
540 | * @param data value in binary encoding | 538 | * @param data value in binary encoding |
541 | * @param data_size number of bytes in data | 539 | * @param data_size number of bytes in @a data |
542 | * @return NULL on error, otherwise human-readable representation of the value | 540 | * @return NULL on error, otherwise human-readable representation of the value |
543 | */ | 541 | */ |
544 | char * | 542 | char * |
@@ -548,14 +546,14 @@ GNUNET_NAMESTORE_value_to_string (uint32_t type, | |||
548 | 546 | ||
549 | 547 | ||
550 | /** | 548 | /** |
551 | * Convert human-readable version of a 'value' of a record to the binary | 549 | * Convert human-readable version of the value @a s of a record |
552 | * representation. | 550 | * of type @a type to the respective binary representation. |
553 | * | 551 | * |
554 | * @param type type of the record | 552 | * @param type type of the record |
555 | * @param s human-readable string | 553 | * @param s human-readable string |
556 | * @param data set to value in binary encoding (will be allocated) | 554 | * @param data set to value in binary encoding (will be allocated) |
557 | * @param data_size set to number of bytes in data | 555 | * @param data_size set to number of bytes in @a data |
558 | * @return GNUNET_OK on success | 556 | * @return #GNUNET_OK on success |
559 | */ | 557 | */ |
560 | int | 558 | int |
561 | GNUNET_NAMESTORE_string_to_value (uint32_t type, | 559 | GNUNET_NAMESTORE_string_to_value (uint32_t type, |
@@ -649,7 +647,7 @@ GNUNET_NAMESTORE_query_from_public_key (const struct GNUNET_CRYPTO_EccPublicKey | |||
649 | * @param expire block expiration | 647 | * @param expire block expiration |
650 | * @param label the name for the records | 648 | * @param label the name for the records |
651 | * @param rd record data | 649 | * @param rd record data |
652 | * @param rd_count number of records | 650 | * @param rd_count number of records in @a rd |
653 | */ | 651 | */ |
654 | struct GNUNET_NAMESTORE_Block * | 652 | struct GNUNET_NAMESTORE_Block * |
655 | GNUNET_NAMESTORE_block_create (const struct GNUNET_CRYPTO_EccPrivateKey *key, | 653 | GNUNET_NAMESTORE_block_create (const struct GNUNET_CRYPTO_EccPrivateKey *key, |
@@ -706,8 +704,8 @@ GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a, | |||
706 | * expiration time is the expiration time of the block with smallest | 704 | * expiration time is the expiration time of the block with smallest |
707 | * expiration time. | 705 | * expiration time. |
708 | * | 706 | * |
709 | * @param rd_count number of records given in 'rd' | 707 | * @param rd_count number of records given in @a rd |
710 | * @param rd array of records | 708 | * @param rd array of records |
711 | * @return absolute expiration time | 709 | * @return absolute expiration time |
712 | */ | 710 | */ |
713 | struct GNUNET_TIME_Absolute | 711 | struct GNUNET_TIME_Absolute |
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 200b167de..af231ae5b 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -23,13 +23,6 @@ | |||
23 | * @brief namestore for the GNUnet naming system | 23 | * @brief namestore for the GNUnet naming system |
24 | * @author Matthias Wachs | 24 | * @author Matthias Wachs |
25 | * @author Christian Grothoff | 25 | * @author Christian Grothoff |
26 | * | ||
27 | * TODO: | ||
28 | * - private records can currently not be used for resolving | ||
29 | * our own queries as our lookup only goes for the encrypted | ||
30 | * records; we need a way to ensure that the records available | ||
31 | * in our own zone can actually always be used for our own | ||
32 | * resolutions! (#2993) | ||
33 | */ | 26 | */ |
34 | #include "platform.h" | 27 | #include "platform.h" |
35 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
@@ -163,8 +156,8 @@ struct ZoneMonitor | |||
163 | * Offset of the zone iteration used to address next result of the zone | 156 | * Offset of the zone iteration used to address next result of the zone |
164 | * iteration in the store | 157 | * iteration in the store |
165 | * | 158 | * |
166 | * Initialy set to 0 in handle_iteration_start | 159 | * Initialy set to 0. |
167 | * Incremented with by every call to handle_iteration_next | 160 | * Incremented with by every call to #handle_iteration_next |
168 | */ | 161 | */ |
169 | uint32_t offset; | 162 | uint32_t offset; |
170 | 163 | ||
@@ -443,7 +436,7 @@ handle_lookup_block (void *cls, | |||
443 | 436 | ||
444 | 437 | ||
445 | /** | 438 | /** |
446 | * Handles a 'GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE' message | 439 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_BLOCK_CACHE message |
447 | * | 440 | * |
448 | * @param cls unused | 441 | * @param cls unused |
449 | * @param client GNUNET_SERVER_Client sending the message | 442 | * @param client GNUNET_SERVER_Client sending the message |
@@ -507,7 +500,7 @@ handle_block_cache (void *cls, | |||
507 | * @param request_id request ID to use | 500 | * @param request_id request ID to use |
508 | * @param zone_key zone key of the zone | 501 | * @param zone_key zone key of the zone |
509 | * @param name name | 502 | * @param name name |
510 | * @param rd_count number of records | 503 | * @param rd_count number of records in @a rd |
511 | * @param rd array of records | 504 | * @param rd array of records |
512 | */ | 505 | */ |
513 | static void | 506 | static void |
@@ -555,7 +548,7 @@ send_lookup_response (struct GNUNET_SERVER_NotificationContext *nc, | |||
555 | 548 | ||
556 | 549 | ||
557 | /** | 550 | /** |
558 | * Handles a 'GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE' message | 551 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message |
559 | * | 552 | * |
560 | * @param cls unused | 553 | * @param cls unused |
561 | * @param client client sending the message | 554 | * @param client client sending the message |
@@ -649,10 +642,25 @@ handle_record_store (void *cls, | |||
649 | res = GSN_database->store_records (GSN_database->cls, | 642 | res = GSN_database->store_records (GSN_database->cls, |
650 | &rp_msg->private_key, | 643 | &rp_msg->private_key, |
651 | conv_name, | 644 | conv_name, |
652 | rd_count, rd); | 645 | rd_count, rd); |
653 | if (GNUNET_OK == res) | 646 | if (GNUNET_OK == res) |
654 | { | 647 | { |
655 | struct ZoneMonitor *zm; | 648 | struct ZoneMonitor *zm; |
649 | struct GNUNET_NAMESTORE_Block *block; | ||
650 | |||
651 | block = GNUNET_NAMESTORE_block_create (&rp_msg->private_key, | ||
652 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
653 | conv_name, | ||
654 | rd, rd_count); | ||
655 | if (GNUNET_OK != | ||
656 | GSN_database->cache_block (GSN_database->cls, | ||
657 | block)) | ||
658 | { | ||
659 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
660 | _("Failed to cache encrypted block of my own zone!\n")); | ||
661 | res = GNUNET_SYSERR; | ||
662 | } | ||
663 | GNUNET_free (block); | ||
656 | 664 | ||
657 | for (zm = monitor_head; NULL != zm; zm = zm->next) | 665 | for (zm = monitor_head; NULL != zm; zm = zm->next) |
658 | if (0 == memcmp (&rp_msg->private_key, | 666 | if (0 == memcmp (&rp_msg->private_key, |
@@ -684,8 +692,8 @@ handle_record_store (void *cls, | |||
684 | 692 | ||
685 | 693 | ||
686 | /** | 694 | /** |
687 | * Context for record remove operations passed from 'handle_zone_to_name' to | 695 | * Context for record remove operations passed from #handle_zone_to_name to |
688 | * 'handle_zone_to_name_it' as closure | 696 | * #handle_zone_to_name_it as closure |
689 | */ | 697 | */ |
690 | struct ZoneToNameCtx | 698 | struct ZoneToNameCtx |
691 | { | 699 | { |
@@ -700,7 +708,7 @@ struct ZoneToNameCtx | |||
700 | uint32_t rid; | 708 | uint32_t rid; |
701 | 709 | ||
702 | /** | 710 | /** |
703 | * Set to GNUNET_OK on success, GNUNET_SYSERR on error. Note that | 711 | * Set to #GNUNET_OK on success, #GNUNET_SYSERR on error. Note that |
704 | * not finding a name for the zone still counts as a 'success' here, | 712 | * not finding a name for the zone still counts as a 'success' here, |
705 | * as this field is about the success of executing the IPC protocol. | 713 | * as this field is about the success of executing the IPC protocol. |
706 | */ | 714 | */ |
@@ -714,7 +722,7 @@ struct ZoneToNameCtx | |||
714 | * @param cls struct ZoneToNameCtx * | 722 | * @param cls struct ZoneToNameCtx * |
715 | * @param zone_key the zone key | 723 | * @param zone_key the zone key |
716 | * @param name name | 724 | * @param name name |
717 | * @param rd_count number of records | 725 | * @param rd_count number of records in @a rd |
718 | * @param rd record data | 726 | * @param rd record data |
719 | */ | 727 | */ |
720 | static void | 728 | static void |
@@ -769,10 +777,10 @@ handle_zone_to_name_it (void *cls, | |||
769 | 777 | ||
770 | 778 | ||
771 | /** | 779 | /** |
772 | * Handles a 'GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME' message | 780 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME message |
773 | * | 781 | * |
774 | * @param cls unused | 782 | * @param cls unused |
775 | * @param client GNUNET_SERVER_Client sending the message | 783 | * @param client client sending the message |
776 | * @param message message of type 'struct ZoneToNameMessage' | 784 | * @param message message of type 'struct ZoneToNameMessage' |
777 | */ | 785 | */ |
778 | static void | 786 | static void |
@@ -858,10 +866,10 @@ struct ZoneIterationProcResult | |||
858 | 866 | ||
859 | /** | 867 | /** |
860 | * Iteration result: iteration done? | 868 | * Iteration result: iteration done? |
861 | * IT_SUCCESS_MORE_AVAILABLE: if there may be more results overall but | 869 | * #IT_SUCCESS_MORE_AVAILABLE: if there may be more results overall but |
862 | * we got one for now and have sent it to the client | 870 | * we got one for now and have sent it to the client |
863 | * IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE: if there are no further results, | 871 | * #IT_SUCCESS_NOT_MORE_RESULTS_AVAILABLE: if there are no further results, |
864 | * IT_ALL_RECORDS_FILTERED: if all results were filtered so far. | 872 | * #IT_START: if we are still trying to find a result. |
865 | */ | 873 | */ |
866 | int res_iteration_finished; | 874 | int res_iteration_finished; |
867 | 875 | ||
@@ -964,7 +972,7 @@ run_zone_iteration_round (struct ZoneIteration *zi) | |||
964 | 972 | ||
965 | 973 | ||
966 | /** | 974 | /** |
967 | * Handles a 'GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START' message | 975 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START message |
968 | * | 976 | * |
969 | * @param cls unused | 977 | * @param cls unused |
970 | * @param client GNUNET_SERVER_Client sending the message | 978 | * @param client GNUNET_SERVER_Client sending the message |
@@ -999,7 +1007,7 @@ handle_iteration_start (void *cls, | |||
999 | 1007 | ||
1000 | 1008 | ||
1001 | /** | 1009 | /** |
1002 | * Handles a 'GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP' message | 1010 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP message |
1003 | * | 1011 | * |
1004 | * @param cls unused | 1012 | * @param cls unused |
1005 | * @param client GNUNET_SERVER_Client sending the message | 1013 | * @param client GNUNET_SERVER_Client sending the message |
@@ -1042,7 +1050,7 @@ handle_iteration_stop (void *cls, | |||
1042 | 1050 | ||
1043 | 1051 | ||
1044 | /** | 1052 | /** |
1045 | * Handles a 'GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT' message | 1053 | * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT message |
1046 | * | 1054 | * |
1047 | * @param cls unused | 1055 | * @param cls unused |
1048 | * @param client GNUNET_SERVER_Client sending the message | 1056 | * @param client GNUNET_SERVER_Client sending the message |
@@ -1112,12 +1120,12 @@ monitor_next (void *cls, | |||
1112 | 1120 | ||
1113 | 1121 | ||
1114 | /** | 1122 | /** |
1115 | * A 'GNUNET_NAMESTORE_RecordIterator' for monitors. | 1123 | * A #GNUNET_NAMESTORE_RecordIterator for monitors. |
1116 | * | 1124 | * |
1117 | * @param cls a 'struct ZoneMonitor *' with information about the monitor | 1125 | * @param cls a 'struct ZoneMonitor *' with information about the monitor |
1118 | * @param zone_key zone key of the zone | 1126 | * @param zone_key zone key of the zone |
1119 | * @param name name | 1127 | * @param name name |
1120 | * @param rd_count number of records | 1128 | * @param rd_count number of records in @a rd |
1121 | * @param rd array of records | 1129 | * @param rd array of records |
1122 | */ | 1130 | */ |
1123 | static void | 1131 | static void |