summaryrefslogtreecommitdiff
path: root/src/namestore/gnunet-service-namestore.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-15 10:25:25 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-15 10:25:25 +0000
commit8b99bff307642ab05bea6601bae3d11a9cd457a0 (patch)
tree475868b34046ba9491811cb3a7167afb4f363968 /src/namestore/gnunet-service-namestore.c
parent3c8feec5381491be406c1032fb72464b0f177a1d (diff)
downloadgnunet-8b99bff307642ab05bea6601bae3d11a9cd457a0.tar.gz
gnunet-8b99bff307642ab05bea6601bae3d11a9cd457a0.zip
-fixing #2993
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r--src/namestore/gnunet-service-namestore.c62
1 files changed, 35 insertions, 27 deletions
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 */
513static void 506static 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 */
690struct ZoneToNameCtx 698struct 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 */
720static void 728static 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 */
778static void 786static 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 */
1123static void 1131static void