GNUnet 0.28.0-dev.1-1-gd5f66caac
 
Loading...
Searching...
No Matches
gnunet-service-namestore.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2012, 2013, 2014, 2018 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
27#include "platform.h"
28#include "gnunet_error_codes.h"
30#include "gnunet_protocols.h"
31#include "gnunet_util_lib.h"
34#include "namestore.h"
35
36#define LOG_STRERROR_FILE(kind, syscall, filename) \
37 GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
38
42#define MONITOR_STALL_WARN_DELAY GNUNET_TIME_UNIT_MINUTES
43
47#define NC_SIZE 16
48
52struct NamestoreClient;
53
54
59{
64
69
74
79
84
89
97 uint64_t seq;
98
102 uint32_t request_id;
103
111 uint32_t offset;
112
119};
120
158
159
246
247
253{
258
263
268
272 uint32_t rid;
273
277 uint16_t rd_set_pos;
278
282 uint16_t rd_set_count;
283
288
293 const struct RecordSet *rs;
294
299
300};
301
302
323
328
333
338
343
347static char *db_lib_name;
348
353
354
359
364
368static struct StoreActivity *sa_head;
369
373static struct StoreActivity *sa_tail;
374
379
384
390static void
391cleanup_task (void *cls)
392{
393 (void) cls;
394 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n");
395 if (NULL != monitor_nc)
396 {
398 monitor_nc = NULL;
399 }
400 if (NULL != statistics)
401 {
403 statistics = NULL;
404 }
407 db_lib_name = NULL;
408}
409
410
416static void
422
423
436static void
437lookup_nick_it (void *cls,
438 uint64_t seq,
439 const char *editor_hint,
440 const struct GNUNET_CRYPTO_BlindablePrivateKey *private_key,
441 const char *label,
442 unsigned int rd_count,
443 const struct GNUNET_GNSRECORD_Data *rd)
444{
445 struct GNUNET_GNSRECORD_Data **res = cls;
446
447 (void) private_key;
448 GNUNET_assert (0 != seq);
449 if (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT))
450 {
451 GNUNET_break (0);
452 return;
453 }
454 for (unsigned int c = 0; c < rd_count; c++)
455 {
457 {
458 (*res) =
459 GNUNET_malloc (rd[c].data_size + sizeof(struct GNUNET_GNSRECORD_Data));
460 (*res)->data = &(*res)[1];
461 GNUNET_memcpy ((void *) (*res)->data, rd[c].data, rd[c].data_size);
462 (*res)->data_size = rd[c].data_size;
463 (*res)->expiration_time = rd[c].expiration_time;
464 (*res)->flags = rd[c].flags;
465 (*res)->record_type = GNUNET_GNSRECORD_TYPE_NICK;
466 return;
467 }
468 }
469 (*res) = NULL;
470}
471
472
479static void
481 const struct GNUNET_GNSRECORD_Data *nick)
482{
483 struct NickCache *oldest;
484
485 oldest = NULL;
486 for (unsigned int i = 0; i < NC_SIZE; i++)
487 {
488 struct NickCache *pos = &nick_cache[i];
489
490 if ((NULL == oldest) ||
492 oldest = pos;
493 if (0 == GNUNET_memcmp (zone, &pos->zone))
494 {
495 oldest = pos;
496 break;
497 }
498 }
499 GNUNET_free (oldest->rd);
500 oldest->zone = *zone;
501 if (NULL != nick)
502 {
503 oldest->rd = GNUNET_malloc (sizeof(*nick) + nick->data_size);
504 *oldest->rd = *nick;
505 oldest->rd->data = &oldest->rd[1];
506 memcpy (&oldest->rd[1], nick->data, nick->data_size);
507 }
508 else
509 {
510 oldest->rd = NULL;
511 }
513}
514
515
523static struct GNUNET_GNSRECORD_Data *
525{
527 struct GNUNET_GNSRECORD_Data *nick;
528 int res;
529
530 /* check cache first */
531 for (unsigned int i = 0; i < NC_SIZE; i++)
532 {
533 struct NickCache *pos = &nick_cache[i];
534 if ((NULL != pos->rd) && (0 == GNUNET_memcmp (zone, &pos->zone)))
535 {
536 if (NULL == pos->rd)
537 return NULL;
538 nick = GNUNET_malloc (sizeof(*nick) + pos->rd->data_size);
539 *nick = *pos->rd;
540 nick->data = &nick[1];
541 memcpy (&nick[1], pos->rd->data, pos->rd->data_size);
543 return nick;
544 }
545 }
546
547 nick = NULL;
549 zone,
552 &nick);
553 if ((GNUNET_OK != res) || (NULL == nick))
554 {
555#if ! defined(GNUNET_CULL_LOGGING)
556 static int do_log = GNUNET_LOG_CALL_STATUS;
557
558 if (0 == do_log)
560 "namestore",
561 __FILE__,
562 __FUNCTION__,
563 __LINE__);
564 if (1 == do_log)
565 {
568 "No nick name set for zone `%s'\n",
570 }
571#endif
572 /* update cache */
573 cache_nick (zone, NULL);
574 return NULL;
575 }
576
577 /* update cache */
578 cache_nick (zone, nick);
579 return nick;
580}
581
582
598static void
600 unsigned int rd2_length,
601 const struct GNUNET_GNSRECORD_Data *rd2,
602 unsigned int *rdc_res,
603 struct GNUNET_GNSRECORD_Data **rd_res)
604{
605 uint64_t latest_expiration;
606 size_t req;
607 char *data;
608 size_t data_offset;
609 struct GNUNET_GNSRECORD_Data *target;
610
611 (*rdc_res) = 1 + rd2_length;
612 if (0 == 1 + rd2_length)
613 {
614 GNUNET_break (0);
615 (*rd_res) = NULL;
616 return;
617 }
618 req = sizeof(struct GNUNET_GNSRECORD_Data) + nick_rd->data_size;
619 for (unsigned int i = 0; i < rd2_length; i++)
620 {
621 const struct GNUNET_GNSRECORD_Data *orig = &rd2[i];
622
623 if (req + sizeof(struct GNUNET_GNSRECORD_Data) + orig->data_size < req)
624 {
625 GNUNET_break (0);
626 (*rd_res) = NULL;
627 return;
628 }
629 req += sizeof(struct GNUNET_GNSRECORD_Data) + orig->data_size;
630 }
631 target = GNUNET_malloc (req);
632 (*rd_res) = target;
633 data = (char *) &target[1 + rd2_length];
634 data_offset = 0;
635 latest_expiration = 0;
636 for (unsigned int i = 0; i < rd2_length; i++)
637 {
638 const struct GNUNET_GNSRECORD_Data *orig = &rd2[i];
639
641 {
642 if ((GNUNET_TIME_absolute_get ().abs_value_us + orig->expiration_time) >
643 latest_expiration)
644 latest_expiration = orig->expiration_time;
645 }
646 else if (orig->expiration_time > latest_expiration)
647 latest_expiration = orig->expiration_time;
648 target[i] = *orig;
649 target[i].data = (void *) &data[data_offset];
650 GNUNET_memcpy (&data[data_offset], orig->data, orig->data_size);
651 data_offset += orig->data_size;
652 }
653 /* append nick */
654 target[rd2_length] = *nick_rd;
655 /* Mark as supplemental */
656 target[rd2_length].flags = nick_rd->flags | GNUNET_GNSRECORD_RF_SUPPLEMENTAL;
657 target[rd2_length].expiration_time = latest_expiration;
658 target[rd2_length].data = (void *) &data[data_offset];
659 GNUNET_memcpy (&data[data_offset], nick_rd->data, nick_rd->data_size);
660 data_offset += nick_rd->data_size;
661 GNUNET_assert (req == (sizeof(struct GNUNET_GNSRECORD_Data)) * (*rdc_res)
662 + data_offset);
663}
664
665
678static int
680 uint32_t request_id,
681 const struct
683 const char *name,
684 unsigned int rd_count,
685 const struct GNUNET_GNSRECORD_Data *rd,
687{
688 struct GNUNET_MQ_Envelope *env;
689 struct RecordResultMessage *zir_msg;
690 struct GNUNET_GNSRECORD_Data *nick;
692 struct GNUNET_GNSRECORD_Data rd_nf[rd_count];
693 struct GNUNET_TIME_Absolute block_exp;
694 unsigned int res_count;
695 unsigned int rd_nf_count;
696 size_t name_len;
697 size_t key_len;
698 ssize_t rd_ser_len;
699 char *name_tmp;
700 char *rd_ser;
701 char *emsg;
702
703 block_exp = GNUNET_TIME_UNIT_ZERO_ABS;
704 nick = get_nick_record (zone_key);
706
708 rd,
709 rd_count,
710 rd_nf,
711 &rd_nf_count,
712 &block_exp,
713 filter,
714 &emsg))
715 {
716 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
717 GNUNET_free (emsg);
718 GNUNET_assert (0);
719 }
720
725 if ((NULL != nick) && (0 != strcmp (name, GNUNET_GNS_EMPTY_LABEL_AT)))
726 {
727 nick->flags =
729 merge_with_nick_records (nick, rd_nf_count, rd_nf, &res_count, &res);
730 }
731 else
732 {
733 res_count = rd_nf_count;
734 res = (struct GNUNET_GNSRECORD_Data *) rd_nf;
735 }
736 if (NULL != nick)
737 GNUNET_free (nick);
738
739 if (0 == res_count)
740 {
741 if (rd_nf != res)
743 return 0;
744 }
746
747
748 name_len = strlen (name) + 1;
749 rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res);
750 if (rd_ser_len < 0)
751 {
752 if (rd_nf != res)
754 GNUNET_break (0);
756 return 0;
757 }
758 if (((size_t) rd_ser_len) >= UINT16_MAX - name_len - sizeof(*zir_msg))
759 {
760 if (rd_nf != res)
762 GNUNET_break (0);
764 return 0;
765 }
766 key_len = GNUNET_CRYPTO_blindable_sk_get_length (zone_key);
767 env = GNUNET_MQ_msg_extra (zir_msg,
768 name_len + rd_ser_len + key_len,
770 zir_msg->gns_header.r_id = htonl (request_id);
771 zir_msg->name_len = htons (name_len);
772 zir_msg->rd_count = htons (res_count);
773 zir_msg->rd_len = htons ((uint16_t) rd_ser_len);
774 zir_msg->key_len = htons (key_len);
776 &zir_msg[1],
777 key_len);
778 zir_msg->expire = GNUNET_TIME_absolute_hton (block_exp);
779 name_tmp = (char *) &zir_msg[1] + key_len;
780 GNUNET_memcpy (name_tmp, name, name_len);
781 rd_ser = &name_tmp[name_len];
783 rd_ser_len ==
784 GNUNET_GNSRECORD_records_serialize (res_count, res, rd_ser_len, rd_ser));
786 "Sending RECORD_RESULT message with %u records\n",
787 res_count);
789 "Record sets sent to clients",
790 1,
791 GNUNET_NO);
792 GNUNET_MQ_send (nc->mq, env);
793 if (rd_nf != res)
795 return res_count;
796}
797
798
806static void
808 enum GNUNET_ErrorCode ec,
809 uint32_t rid)
810{
811 struct GNUNET_MQ_Envelope *env;
812 struct NamestoreResponseMessage *rcr_msg;
813
814 GNUNET_assert (NULL != nc);
816 "Sending GENERIC_RESPONSE message\n");
818 "Store requests completed",
819 1,
820 GNUNET_NO);
821 env = GNUNET_MQ_msg (rcr_msg,
823 rcr_msg->gns_header.r_id = htonl (rid);
824 rcr_msg->ec = htonl (ec);
825 GNUNET_MQ_send (nc->mq, env);
826}
827
828
835static void
837{
838 struct GNUNET_MQ_Envelope *env;
839 struct GNUNET_NAMESTORE_Header *em;
840
842 if (! zi->send_end)
843 return;
844 /* send empty response to indicate end of list */
846 em->r_id = htonl (zi->request_id);
847 GNUNET_MQ_send (zi->nc->mq, env);
848
850 GNUNET_free (zi);
851}
852
853
859static void
861{
862 struct ZoneMonitor *zm = cls;
863
865 "No response from monitor since %s\n",
866 GNUNET_STRINGS_absolute_time_to_string (zm->sa_waiting_start));
869 zm);
870}
871
872
878static int
880 int call_continue)
881{
882 const struct RecordSet *rd_set = sa->rs;
883 unsigned int rd_count;
884 size_t name_len;
885 size_t rd_ser_len;
886 const char *name;
887 const char *rd_ser;
888 const char *buf;
889
890 buf = (const char *) &sa[1];
891 for (int i = sa->rd_set_pos; i < sa->rd_set_count; i++)
892 {
893 rd_set = (struct RecordSet *) buf;
894 name_len = ntohs (rd_set->name_len);
895 rd_count = ntohs (rd_set->rd_count);
896 rd_ser_len = ntohs (rd_set->rd_len);
897 name = (const char *) &rd_set[1];
898 buf += sizeof (struct RecordSet) + name_len + rd_ser_len;
899 rd_ser = &name[name_len];
900 {
902
903 /* We did this before, must succeed again */
905 GNUNET_OK ==
907 rd));
908
910 "Checking monitors watching for `%s'\n",
911 name);
912 for (struct ZoneMonitor *zm = sa->zm_pos; NULL != zm; zm = sa->zm_pos)
913 {
914 if ((0 != GNUNET_memcmp (&sa->private_key, &zm->zone)) &&
915 (0 != GNUNET_memcmp (&zm->zone, &zero)))
916 {
917 sa->zm_pos = zm->next; /* not interesting to this monitor */
918 continue;
919 }
920 if (zm->limit == zm->iteration_cnt)
921 {
922 zm->sa_waiting = GNUNET_YES;
923 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
924 if (NULL != zm->sa_wait_warning)
925 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
926 zm->sa_wait_warning =
929 zm);
931 "Monitor is blocking client for `%s'\n",
932 name);
933 return GNUNET_NO; /* blocked on zone monitor */
934 }
936 "Notifying monitor about changes under label `%s'\n",
937 name);
939 0,
940 &sa->private_key,
941 name,
942 rd_count,
943 rd,
944 zm->filter))
945 zm->limit--;
946 sa->zm_pos = zm->next;
947 }
948 sa->rd_set_pos++;
949 }
950 }
951 if (GNUNET_YES == call_continue)
955 return GNUNET_OK;
956}
957
958
967static void
969 struct GNUNET_SERVICE_Client *client,
970 void *app_ctx)
971{
972 struct NamestoreClient *nc = app_ctx;
973 struct ZoneIteration *no;
974 struct StoreActivity *sa = sa_head;
975 struct StoreActivity *sn;
976
977 (void) cls;
978 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
979 for (struct ZoneMonitor *zm = monitor_head; NULL != zm; zm = zm->next)
980 {
981 if (nc != zm->nc)
982 continue;
984 if (NULL != zm->task)
985 {
987 zm->task = NULL;
988 }
989 if (NULL != zm->sa_wait_warning)
990 {
991 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
992 zm->sa_wait_warning = NULL;
993 }
994 for (sa = sa_head; NULL != sa; sa = sn)
995 {
996 sn = sa->next;
997 if (zm == sa->zm_pos)
998 {
999 sa->zm_pos = zm->next;
1000 /* this may free sa */
1002 }
1003 }
1004 GNUNET_free (zm);
1005 break;
1006 }
1007 sa = sa_head;
1008 while (NULL != sa)
1009 {
1010 if (nc != sa->nc)
1011 {
1012 sa = sa->next;
1013 continue;
1014 }
1015 sn = sa->next;
1017 sa = sn;
1018 }
1019 while (NULL != (no = nc->op_head))
1020 {
1021 GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no);
1022 GNUNET_free (no);
1023 }
1024 GNUNET_break (NULL == GNUNET_PLUGIN_unload (nc->db_lib_name,
1025 nc->GSN_database));
1026 GNUNET_free (nc->db_lib_name);
1027 GNUNET_free (nc);
1028}
1029
1030
1039static void *
1041 struct GNUNET_SERVICE_Client *client,
1042 struct GNUNET_MQ_Handle *mq)
1043{
1044 struct NamestoreClient *nc;
1045 char *database;
1046
1047 (void) cls;
1048 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1049 nc = GNUNET_new (struct NamestoreClient);
1050 nc->client = client;
1051 nc->mq = mq;
1052 /* Loading database plugin */
1054 "namestore",
1055 "database",
1056 &database))
1057 {
1058 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
1059 GNUNET_free (nc);
1060 return NULL;
1061 }
1063 "Loading %s\n",
1064 db_lib_name);
1067 (void *) GSN_cfg);
1068 GNUNET_free (database);
1069 if (NULL == nc->GSN_database)
1070 {
1072 "Could not load database backend `%s'\n",
1073 db_lib_name);
1074 GNUNET_free (nc);
1075 return NULL;
1076 }
1077 nc->db_lib_name = GNUNET_strdup (db_lib_name);
1079 "Loaded %s\n",
1080 db_lib_name);
1081 return nc;
1082}
1083
1084
1089{
1093 const char *label;
1094
1099
1103 char *res_rd;
1104
1109
1114
1119
1123 unsigned int res_rd_count;
1124
1128 ssize_t rd_ser_len;
1129};
1130
1131
1144static void
1145lookup_it (void *cls,
1146 uint64_t seq,
1147 const char *editor_hint,
1148 const struct GNUNET_CRYPTO_BlindablePrivateKey *private_key,
1149 const char *label,
1150 unsigned int rd_count_nf,
1151 const struct GNUNET_GNSRECORD_Data *rd_nf)
1152{
1153 struct RecordLookupContext *rlc = cls;
1154 struct GNUNET_GNSRECORD_Data rd[rd_count_nf];
1155 struct GNUNET_TIME_Absolute block_exp;
1156 unsigned int rd_count = 0;
1157 char *emsg;
1158
1159 (void) private_key;
1160 GNUNET_assert (0 != seq);
1161 if (0 != strcmp (label, rlc->label))
1162 return;
1163 rlc->found = GNUNET_YES;
1164 if (NULL == rlc->editor_hint)
1165 rlc->editor_hint = GNUNET_strdup (editor_hint);
1167 rd_nf,
1168 rd_count_nf,
1169 rd,
1170 &rd_count,
1171 &block_exp,
1172 rlc->filter,
1173 &emsg))
1174 {
1175 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
1176 GNUNET_free (emsg);
1177 GNUNET_assert (0);
1178 }
1179
1180 if (0 == rd_count)
1181 {
1182 rlc->rd_ser_len = 0;
1183 rlc->res_rd_count = 0;
1184 rlc->res_rd = NULL;
1185 return;
1186 }
1187 if ((NULL != rlc->nick) && (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT)))
1188 {
1189 /* Merge */
1190 struct GNUNET_GNSRECORD_Data *rd_res;
1191 unsigned int rdc_res;
1192
1193 rd_res = NULL;
1194 rdc_res = 0;
1197 merge_with_nick_records (rlc->nick, rd_count, rd, &rdc_res, &rd_res);
1198 rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rdc_res, rd_res);
1199 if (rlc->rd_ser_len < 0)
1200 {
1201 GNUNET_break (0);
1202 GNUNET_free (rd_res);
1203 rlc->found = GNUNET_NO;
1204 rlc->rd_ser_len = 0;
1205 return;
1206 }
1207 rlc->res_rd_count = rdc_res;
1208 rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len);
1210 rd_res,
1211 rlc->rd_ser_len,
1212 rlc->res_rd))
1213 {
1214 GNUNET_break (0);
1215 GNUNET_free (rlc->res_rd);
1216 rlc->res_rd = NULL;
1217 rlc->res_rd_count = 0;
1218 rlc->rd_ser_len = 0;
1219 GNUNET_free (rd_res);
1220 rlc->found = GNUNET_NO;
1221 return;
1222 }
1223 GNUNET_free (rd_res);
1224 GNUNET_free (rlc->nick);
1225 rlc->nick = NULL;
1226 }
1227 else
1228 {
1230 if (rlc->rd_ser_len < 0)
1231 {
1232 GNUNET_break (0);
1233 rlc->found = GNUNET_NO;
1234 rlc->rd_ser_len = 0;
1235 return;
1236 }
1237 rlc->res_rd_count = rd_count;
1238 rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len);
1240 rd,
1241 rlc->rd_ser_len,
1242 rlc->res_rd))
1243 {
1244 GNUNET_break (0);
1245 GNUNET_free (rlc->res_rd);
1246 rlc->res_rd = NULL;
1247 rlc->res_rd_count = 0;
1248 rlc->rd_ser_len = 0;
1249 rlc->found = GNUNET_NO;
1250 return;
1251 }
1252 }
1253}
1254
1255
1263static int
1264check_edit_record_set (void *cls, const struct EditRecordSetMessage *er_msg)
1265{
1266 uint16_t name_len;
1267 uint16_t editor_hint_len;
1268 size_t src_size;
1269 size_t key_len;
1270
1271 (void) cls;
1272 name_len = ntohs (er_msg->label_len);
1273 editor_hint_len = ntohs (er_msg->editor_hint_len);
1274 key_len = ntohs (er_msg->key_len);
1275 src_size = ntohs (er_msg->gns_header.header.size);
1276 if (name_len + editor_hint_len + key_len != src_size - sizeof(struct
1278 {
1279 GNUNET_break (0);
1280 return GNUNET_SYSERR;
1281 }
1282 return GNUNET_OK;
1283}
1284
1285
1292static void
1293handle_edit_record_set (void *cls, const struct EditRecordSetMessage *er_msg)
1294{
1296 struct NamestoreClient *nc = cls;
1297 struct GNUNET_MQ_Envelope *env;
1298 struct EditRecordSetResponseMessage *rer_msg;
1299 struct RecordLookupContext rlc;
1300 const char *name_tmp;
1301 const char *editor_hint;
1302 char *conv_name;
1303 uint16_t name_len;
1304 uint16_t old_editor_hint_len;
1305 int res;
1306 size_t key_len;
1307 size_t kb_read;
1308
1309 key_len = ntohs (er_msg->key_len);
1310 name_len = ntohs (er_msg->label_len);
1311 if ((GNUNET_SYSERR ==
1313 key_len,
1314 &zone,
1315 &kb_read)) ||
1316 (kb_read != key_len))
1317 {
1319 "Error reading private key\n");
1321 return;
1322 }
1323 name_tmp = (const char *) &er_msg[1] + key_len;
1324 editor_hint = (const char *) name_tmp + name_len;
1327 "Received NAMESTORE_RECORD_SET_EDIT message for name `%s'\n",
1328 name_tmp);
1329
1330 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1331 if (NULL == conv_name)
1332 {
1334 "Error converting name `%s'\n",
1335 name_tmp);
1337 return;
1338 }
1339 name_len = strlen (conv_name) + 1;
1340 rlc.editor_hint = NULL;
1341 rlc.label = conv_name;
1343 "Looking up without filter\n");
1345 rlc.found = GNUNET_NO;
1346 rlc.res_rd_count = 0;
1347 rlc.res_rd = NULL;
1348 rlc.rd_ser_len = 0;
1349 rlc.nick = get_nick_record (&zone);
1350 res = nc->GSN_database->edit_records (nc->GSN_database->cls,
1352 &zone,
1353 conv_name,
1354 &lookup_it,
1355 &rlc);
1356
1357 old_editor_hint_len = 0;
1358 if (NULL != rlc.editor_hint)
1359 old_editor_hint_len = strlen (rlc.editor_hint) + 1;
1360 env =
1361 GNUNET_MQ_msg_extra (rer_msg,
1362 rlc.rd_ser_len + old_editor_hint_len,
1364 ;
1365 rer_msg->editor_hint_len = htons (old_editor_hint_len);
1366 rer_msg->gns_header.r_id = er_msg->gns_header.r_id;
1367 rer_msg->rd_count = htons (rlc.res_rd_count);
1368 rer_msg->rd_len = htons (rlc.rd_ser_len);
1369 if (GNUNET_YES == rlc.found)
1370 rer_msg->ec = htons (GNUNET_EC_NONE);
1371 else if (GNUNET_SYSERR == res)
1372 rer_msg->ec = htons (GNUNET_EC_NAMESTORE_UNKNOWN);
1373 else
1374 rer_msg->ec = htons (GNUNET_EC_NAMESTORE_NO_RESULTS);
1375 GNUNET_memcpy (&rer_msg[1], rlc.editor_hint, old_editor_hint_len);
1376 GNUNET_memcpy ((char*) &rer_msg[1] + old_editor_hint_len, rlc.res_rd,
1377 rlc.rd_ser_len);
1378 GNUNET_MQ_send (nc->mq, env);
1380 GNUNET_free (rlc.res_rd);
1381 GNUNET_free (conv_name);
1382}
1383
1384
1392static int
1393check_edit_record_set_cancel (void *cls, const struct
1395{
1396 uint16_t name_len;
1397 uint16_t editor_hint_len;
1398 uint16_t editor_hint_repl_len;
1399 size_t src_size;
1400 size_t key_len;
1401
1402 (void) cls;
1403 name_len = ntohs (er_msg->label_len);
1404 editor_hint_len = ntohs (er_msg->editor_hint_len);
1405 editor_hint_repl_len = ntohs (er_msg->editor_hint_len);
1406 key_len = ntohs (er_msg->key_len);
1407 src_size = ntohs (er_msg->gns_header.header.size);
1408 if (name_len + editor_hint_len + editor_hint_repl_len + key_len != src_size
1409 - sizeof(struct
1411 {
1412 GNUNET_break (0);
1413 return GNUNET_SYSERR;
1414 }
1415 return GNUNET_OK;
1416}
1417
1418
1425static void
1426handle_edit_record_set_cancel (void *cls, const struct
1428{
1430 struct NamestoreClient *nc = cls;
1431 struct GNUNET_MQ_Envelope *env;
1432 struct NamestoreResponseMessage *rer_msg;
1433 const char *name_tmp;
1434 const char *editor_hint;
1435 const char *editor_hint_repl;
1436 char *conv_name;
1437 uint16_t name_len;
1438 uint16_t editor_hint_len;
1439 int res;
1440 size_t key_len;
1441 size_t kb_read;
1442
1443 key_len = ntohs (er_msg->key_len);
1444 name_len = ntohs (er_msg->label_len);
1445 editor_hint_len = ntohs (er_msg->editor_hint_len);
1446 if ((GNUNET_SYSERR ==
1448 key_len,
1449 &zone,
1450 &kb_read)) ||
1451 (kb_read != key_len))
1452 {
1454 "Error reading private key\n");
1456 return;
1457 }
1458 name_tmp = (const char *) &er_msg[1] + key_len;
1459 editor_hint = (const char *) name_tmp + name_len;
1460 editor_hint_repl = (const char *) name_tmp + name_len + editor_hint_len;
1463 "Received NAMESTORE_RECORD_SET_EDIT message for name `%s'\n",
1464 name_tmp);
1465
1466 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1467 if (NULL == conv_name)
1468 {
1470 "Error converting name `%s'\n",
1471 name_tmp);
1473 return;
1474 }
1475 name_len = strlen (conv_name) + 1;
1477 "Clearing editor hint\n");
1478 res = nc->GSN_database->clear_editor_hint (nc->GSN_database->cls,
1479 editor_hint,
1480 editor_hint_repl,
1481 &zone,
1482 conv_name);
1484 "Clearing editor hint %s\n", (GNUNET_SYSERR == res) ? "failed." :
1485 "successful.");
1486
1487 env =
1488 GNUNET_MQ_msg (rer_msg,
1490 rer_msg->gns_header.r_id = er_msg->gns_header.r_id;
1491 rer_msg->ec = htons ((GNUNET_OK == res) ? GNUNET_EC_NONE :
1493 GNUNET_MQ_send (nc->mq, env);
1494 GNUNET_free (conv_name);
1495}
1496
1497
1505static int
1506check_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
1507{
1508 uint32_t name_len;
1509 size_t src_size;
1510 size_t key_len;
1511
1512 (void) cls;
1513 name_len = ntohs (ll_msg->label_len);
1514 key_len = ntohs (ll_msg->key_len);
1515 src_size = ntohs (ll_msg->gns_header.header.size);
1516 if (name_len + key_len != src_size - sizeof(struct LabelLookupMessage))
1517 {
1518 GNUNET_break (0);
1519 return GNUNET_SYSERR;
1520 }
1521 return GNUNET_OK;
1522}
1523
1524
1531static void
1532handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
1533{
1535 struct NamestoreClient *nc = cls;
1536 struct GNUNET_MQ_Envelope *env;
1537 struct LabelLookupResponseMessage *llr_msg;
1538 struct RecordLookupContext rlc;
1539 const char *name_tmp;
1540 char *res_name;
1541 char *conv_name;
1542 uint32_t name_len;
1543 int res;
1544 size_t key_len;
1545 size_t kb_read;
1546
1547 key_len = ntohs (ll_msg->key_len);
1548 if ((GNUNET_SYSERR ==
1550 key_len,
1551 &zone,
1552 &kb_read)) ||
1553 (kb_read != key_len))
1554 {
1556 "Error reading private key\n");
1558 return;
1559 }
1560 name_tmp = (const char *) &ll_msg[1] + key_len;
1563 "Received NAMESTORE_RECORD_LOOKUP message for name `%s'\n",
1564 name_tmp);
1565
1566 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1567 if (NULL == conv_name)
1568 {
1570 "Error converting name `%s'\n",
1571 name_tmp);
1573 return;
1574 }
1575 name_len = strlen (conv_name) + 1;
1576 rlc.editor_hint = NULL;
1577 rlc.label = conv_name;
1579 "Looking up with filter %u\n", ntohs (ll_msg->filter));
1580 rlc.filter = ntohs (ll_msg->filter);
1581 rlc.found = GNUNET_NO;
1582 rlc.res_rd_count = 0;
1583 rlc.res_rd = NULL;
1584 rlc.rd_ser_len = 0;
1585 rlc.nick = get_nick_record (&zone);
1586 res = nc->GSN_database->lookup_records (nc->GSN_database->cls,
1587 &zone,
1588 conv_name,
1589 &lookup_it,
1590 &rlc);
1591 env =
1592 GNUNET_MQ_msg_extra (llr_msg,
1593 key_len + name_len + rlc.rd_ser_len,
1595 llr_msg->gns_header.r_id = ll_msg->gns_header.r_id;
1596 GNUNET_memcpy (&llr_msg[1], &ll_msg[1], key_len);
1597 llr_msg->key_len = ll_msg->key_len;
1598 llr_msg->name_len = htons (name_len);
1599 llr_msg->rd_count = htons (rlc.res_rd_count);
1600 llr_msg->rd_len = htons (rlc.rd_ser_len);
1601 llr_msg->reserved = htons (0);
1602 res_name = ((char *) &llr_msg[1]) + key_len;
1603 if (GNUNET_YES == rlc.found)
1604 llr_msg->found = htons (GNUNET_YES);
1605 else if (GNUNET_SYSERR == res)
1606 llr_msg->found = htons (GNUNET_SYSERR);
1607 else
1608 llr_msg->found = htons (GNUNET_NO);
1609 GNUNET_memcpy (res_name, conv_name, name_len);
1610 GNUNET_memcpy (&res_name[name_len], rlc.res_rd, rlc.rd_ser_len);
1611 GNUNET_MQ_send (nc->mq, env);
1613 GNUNET_free (rlc.res_rd);
1614 GNUNET_free (conv_name);
1615}
1616
1617
1625static int
1626check_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1627{
1628 size_t msg_size;
1629 size_t min_size_exp;
1630 size_t rd_set_count;
1631 size_t key_len;
1632
1633 (void) cls;
1634 msg_size = ntohs (rp_msg->gns_header.header.size);
1635 rd_set_count = ntohs (rp_msg->rd_set_count);
1636 key_len = ntohs (rp_msg->key_len);
1637
1638 min_size_exp = sizeof(*rp_msg) + key_len + sizeof (struct RecordSet)
1639 * rd_set_count;
1640 if (msg_size < min_size_exp)
1641 {
1642 GNUNET_break (0);
1643 return GNUNET_SYSERR;
1644 }
1645 return GNUNET_OK;
1646}
1647
1648
1664
1665
1676static void
1678 uint64_t seq,
1679 const char *editor_hint,
1680 const struct
1682 const char *label,
1683 unsigned int rd_count,
1684 const struct GNUNET_GNSRECORD_Data *rd)
1685{
1686 struct LookupExistingRecordsContext *lctx = cls;
1687 struct GNUNET_GNSRECORD_Data rd_pub[rd_count];
1688 unsigned int rd_pub_count;
1689 char *emsg;
1690
1691 if ((1 == rd_count) &&
1693 {
1694 /* This record set contains only a tombstone! */
1695 lctx->only_tombstone = GNUNET_YES;
1696 }
1697 if (GNUNET_OK !=
1699 rd,
1700 rd_count,
1701 rd_pub,
1702 &rd_pub_count,
1703 &lctx->exp,
1705 &emsg))
1706 {
1708 "%s\n", emsg);
1709 GNUNET_free (emsg);
1710 }
1711}
1712
1713
1714static enum GNUNET_ErrorCode
1716 const struct GNUNET_CRYPTO_BlindablePrivateKey *private_key,
1717 const struct RecordSet *rd_set,
1718 ssize_t *len)
1719{
1720 size_t name_len;
1721 size_t rd_ser_len;
1722 const char *name_tmp;
1723 const char *rd_ser;
1724 char *emsg;
1725 char *conv_name;
1726 unsigned int rd_count;
1727 int res;
1728 enum GNUNET_ErrorCode ec;
1729 struct GNUNET_TIME_Absolute new_block_exp;
1730 struct LookupExistingRecordsContext lctx;
1731 *len = sizeof (struct RecordSet);
1732
1733 ec = GNUNET_EC_NONE;
1736 new_block_exp = GNUNET_TIME_UNIT_ZERO_ABS;
1737 name_len = ntohs (rd_set->name_len);
1738 *len += name_len;
1739 rd_count = ntohs (rd_set->rd_count);
1740 rd_ser_len = ntohs (rd_set->rd_len);
1741 *len += rd_ser_len;
1742 name_tmp = (const char *) &rd_set[1];
1743 rd_ser = &name_tmp[name_len];
1744 {
1746
1747 /* Extracting and converting private key */
1748 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1749 if (NULL == conv_name)
1750 {
1752 "Error normalizing name `%s'\n",
1753 name_tmp);
1755 }
1756
1757 /* Check name for validity */
1758 if (GNUNET_OK != GNUNET_GNSRECORD_label_check (conv_name, &emsg))
1759 {
1761 "Label invalid: `%s'\n",
1762 emsg);
1763 GNUNET_free (emsg);
1764 GNUNET_free (conv_name);
1766 }
1767
1768 if (GNUNET_OK !=
1770 rd))
1771 {
1772 GNUNET_free (conv_name);
1774 }
1775
1777 "Well-formed store requests received",
1778 1,
1779 GNUNET_NO);
1781 "Creating %u records for name `%s'\n",
1782 (unsigned int) rd_count,
1783 conv_name);
1784 if ((0 == rd_count) &&
1785 (GNUNET_NO == nc->GSN_database->lookup_records (nc->GSN_database->cls,
1786 private_key,
1787 conv_name,
1789 &lctx)))
1790 {
1791 /* This name does not exist, so cannot be removed */
1793 "Name `%s' does not exist, no deletion required\n",
1794 conv_name);
1795 res = GNUNET_NO;
1797 }
1798 else
1799 {
1800 /* remove "NICK" records, unless this is for the
1801 #GNUNET_GNS_EMPTY_LABEL_AT label
1802 We may need one additional record later for tombstone.
1803 FIXME: Since we must normalize the record set (check for
1804 consistency etc) we have to iterate the set twice.
1805 May be inefficient.
1806 We cannot really move the nick caching into GNSRECORD.
1807 */
1808 struct GNUNET_GNSRECORD_Data rd_clean[GNUNET_NZL (rd_count)];
1809 struct GNUNET_GNSRECORD_Data rd_nf[GNUNET_NZL (rd_count) + 1];
1810 unsigned int rd_clean_off;
1811 unsigned int rd_nf_count;
1812 int have_nick;
1813
1814 rd_clean_off = 0;
1815 have_nick = GNUNET_NO;
1816 for (unsigned int i = 0; i < rd_count; i++)
1817 {
1818 rd_clean[rd_clean_off] = rd[i];
1819
1820 if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) ||
1822 rd_clean_off++;
1823
1824 if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) &&
1826 {
1827 cache_nick (private_key, &rd[i]);
1828 have_nick = GNUNET_YES;
1829 }
1830 }
1831 if (GNUNET_OK !=
1833 rd_clean,
1834 rd_clean_off,
1835 rd_nf,
1836 &rd_nf_count,
1837 &new_block_exp,
1839 &emsg))
1840 {
1841 GNUNET_free (conv_name);
1843 "Error normalizing record set: `%s'\n",
1844 emsg);
1845 GNUNET_free (emsg);
1847 }
1849 "%u/%u records before tombstone\n", rd_nf_count,
1850 rd_clean_off);
1851 /*
1852 * If existing_block_exp is 0, then there was no record set
1853 * and no tombstone.
1854 * Otherwise, if the existing block expiration is after the
1855 * new block expiration would be, we need to add a tombstone
1856 * or update it.
1857 */
1858 if (GNUNET_TIME_absolute_cmp (new_block_exp, <=, lctx.exp))
1859 {
1860 rd_nf[rd_nf_count].record_type = GNUNET_GNSRECORD_TYPE_TOMBSTONE;
1861 rd_nf[rd_nf_count].expiration_time =
1862 lctx.exp.abs_value_us;
1863 rd_nf[rd_nf_count].data = NULL;
1864 rd_nf[rd_nf_count].data_size = 0;
1865 rd_nf[rd_nf_count].flags = GNUNET_GNSRECORD_RF_PRIVATE
1867 rd_nf_count++;
1868 }
1869 if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) &&
1870 (GNUNET_NO == have_nick))
1871 {
1872 cache_nick (private_key, NULL);
1873 }
1874 res = nc->GSN_database->store_records (nc->GSN_database->cls,
1875 private_key,
1876 conv_name,
1877 rd_nf_count,
1878 rd_nf);
1879 /* If after a store there is only a TOMBSTONE left, and
1880 * there was >1 record under this label found (the tombstone; indicated
1881 * through res != GNUNET_NO) then we should return "NOT FOUND" == GNUNET_NO
1882 */
1883 if ((GNUNET_SYSERR != res) &&
1884 (0 == rd_count) &&
1885 (1 == rd_nf_count) &&
1887 (GNUNET_YES == lctx.only_tombstone))
1888 {
1890 "Client tried to remove non-existent record\n");
1892 }
1893 }
1894
1895 if (GNUNET_SYSERR == res)
1896 {
1897 /* store not successful, no need to tell monitors */
1898 GNUNET_free (conv_name);
1900 }
1901 }
1902 return ec;
1903}
1904
1905
1912static void
1913handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1914{
1916 struct NamestoreClient *nc = cls;
1917 uint32_t rid;
1918 uint16_t rd_set_count;
1919 const char *buf;
1920 ssize_t read;
1921 size_t key_len;
1922 size_t kb_read;
1923 size_t rp_msg_len;
1924 size_t rs_len;
1925 size_t rs_off;
1926 struct StoreActivity *sa;
1927 struct RecordSet *rs;
1928 enum GNUNET_ErrorCode res;
1929
1930 key_len = ntohs (rp_msg->key_len);
1931 rp_msg_len = ntohs (rp_msg->gns_header.header.size);
1932 rs_off = sizeof (*rp_msg) + key_len;
1933 rs_len = rp_msg_len - rs_off;
1934 if ((GNUNET_SYSERR ==
1936 key_len,
1937 &zone,
1938 &kb_read)) ||
1939 (kb_read != key_len))
1940 {
1942 "Error reading private key\n");
1944 return;
1945 }
1947 "Received NAMESTORE_RECORD_STORE message\n");
1948 rid = ntohl (rp_msg->gns_header.r_id);
1949 rd_set_count = ntohs (rp_msg->rd_set_count);
1950 buf = (const char *) rp_msg + rs_off;
1951 if (GNUNET_YES == ntohs (rp_msg->single_tx))
1952 nc->GSN_database->begin_tx (nc->GSN_database->cls);
1953 for (int i = 0; i < rd_set_count; i++)
1954 {
1955 rs = (struct RecordSet *) buf;
1956 res = store_record_set (nc, &zone,
1957 rs, &read);
1958 if (GNUNET_EC_NONE != res)
1959 {
1960 if (GNUNET_YES == ntohs (rp_msg->single_tx))
1961 nc->GSN_database->rollback_tx (nc->GSN_database->cls);
1962 send_store_response (nc, res, rid);
1964 return;
1965 }
1966 buf += read;
1967 }
1968 if (GNUNET_YES == ntohs (rp_msg->single_tx))
1969 nc->GSN_database->commit_tx (nc->GSN_database->cls);
1970 sa = GNUNET_malloc (sizeof(struct StoreActivity) + rs_len);
1972 sa->nc = nc;
1973 sa->rs = (struct RecordSet *) &sa[1];
1974 sa->rd_set_count = rd_set_count;
1975 GNUNET_memcpy (&sa[1], (char *) rp_msg + rs_off, rs_len);
1976 sa->rid = rid;
1977 sa->rd_set_pos = 0;
1978 sa->private_key = zone;
1979 sa->zm_pos = monitor_head;
1981}
1982
1983
1989{
1994
1998 uint32_t rid;
1999
2006};
2007
2008
2019static void
2021 uint64_t seq,
2022 const char *editor_hint,
2023 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key
2024 ,
2025 const char *name,
2026 unsigned int rd_count,
2027 const struct GNUNET_GNSRECORD_Data *rd)
2028{
2029 struct ZoneToNameCtx *ztn_ctx = cls;
2030 struct GNUNET_MQ_Envelope *env;
2031 struct ZoneToNameResponseMessage *ztnr_msg;
2032 size_t name_len;
2033 size_t key_len;
2034 ssize_t rd_ser_len;
2035 size_t msg_size;
2036 char *name_tmp;
2037 char *rd_tmp;
2038
2039 GNUNET_assert (0 != seq);
2041 "Found result for zone-to-name lookup: `%s'\n",
2042 name);
2043 ztn_ctx->ec = GNUNET_EC_NONE;
2044 name_len = (NULL == name) ? 0 : strlen (name) + 1;
2046 if (rd_ser_len < 0)
2047 {
2048 GNUNET_break (0);
2049 ztn_ctx->ec = htonl (GNUNET_EC_NAMESTORE_UNKNOWN);
2050 return;
2051 }
2053 msg_size = sizeof(struct ZoneToNameResponseMessage)
2054 + name_len + rd_ser_len + key_len;
2055 if (msg_size >= GNUNET_MAX_MESSAGE_SIZE)
2056 {
2057 GNUNET_break (0);
2059 return;
2060 }
2061 env =
2062 GNUNET_MQ_msg_extra (ztnr_msg,
2063 key_len + name_len + rd_ser_len,
2065 ztnr_msg->gns_header.header.size = htons (msg_size);
2066 ztnr_msg->gns_header.r_id = htonl (ztn_ctx->rid);
2067 ztnr_msg->ec = htonl (ztn_ctx->ec);
2068 ztnr_msg->rd_len = htons (rd_ser_len);
2069 ztnr_msg->rd_count = htons (rd_count);
2070 ztnr_msg->name_len = htons (name_len);
2071 ztnr_msg->key_len = htons (key_len);
2073 &ztnr_msg[1],
2074 key_len);
2075 name_tmp = (char *) &ztnr_msg[1] + key_len;
2076 GNUNET_memcpy (name_tmp, name, name_len);
2077 rd_tmp = &name_tmp[name_len];
2079 rd_ser_len ==
2080 GNUNET_GNSRECORD_records_serialize (rd_count, rd, rd_ser_len, rd_tmp));
2081 ztn_ctx->ec = GNUNET_EC_NONE;
2082 GNUNET_MQ_send (ztn_ctx->nc->mq, env);
2083}
2084
2085
2086static enum GNUNET_GenericReturnValue
2088 const struct ZoneToNameMessage *zis_msg)
2089{
2090 return GNUNET_OK;
2091}
2092
2093
2100static void
2101handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg)
2102{
2104 struct GNUNET_CRYPTO_BlindablePublicKey value_zone;
2105 struct NamestoreClient *nc = cls;
2106 struct ZoneToNameCtx ztn_ctx;
2107 struct GNUNET_MQ_Envelope *env;
2108 struct ZoneToNameResponseMessage *ztnr_msg;
2109 size_t key_len;
2110 size_t pkey_len;
2111 size_t kb_read;
2112
2113 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME message\n");
2114 ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id);
2115 ztn_ctx.nc = nc;
2117 key_len = ntohs (ztn_msg->key_len);
2118 if ((GNUNET_SYSERR ==
2120 key_len,
2121 &zone,
2122 &kb_read)) ||
2123 (kb_read != key_len))
2124 {
2126 "Error parsing private key.\n");
2128 GNUNET_break (0);
2129 return;
2130 }
2131 pkey_len = ntohs (ztn_msg->pkey_len);
2132 if ((GNUNET_SYSERR ==
2134 + key_len,
2135 pkey_len,
2136 &value_zone,
2137 &kb_read)) ||
2138 (kb_read != pkey_len))
2139 {
2141 "Error parsing public key.\n");
2143 GNUNET_break (0);
2144 return;
2145 }
2146 if (GNUNET_SYSERR == nc->GSN_database->zone_to_name (nc->GSN_database->cls,
2147 &zone,
2148 &value_zone,
2150 &ztn_ctx))
2151 {
2152 /* internal error, hang up instead of signalling something
2153 that might be wrong */
2154 GNUNET_break (0);
2156 return;
2157 }
2159 {
2160 /* no result found, send empty response */
2162 "Found no result for zone-to-name lookup.\n");
2163 env = GNUNET_MQ_msg (ztnr_msg,
2165 ztnr_msg->gns_header.r_id = ztn_msg->gns_header.r_id;
2166 ztnr_msg->ec = htonl (GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND);
2167 GNUNET_MQ_send (nc->mq, env);
2168 }
2170}
2171
2172
2178{
2183
2187 uint64_t limit;
2188
2193};
2194
2195
2206static void
2208 uint64_t seq,
2209 const char *editor_hint,
2210 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key,
2211 const char *name,
2212 unsigned int rd_count,
2213 const struct GNUNET_GNSRECORD_Data *rd)
2214{
2215 struct ZoneIterationProcResult *proc = cls;
2216
2217 GNUNET_assert (0 != seq);
2218 if ((NULL == zone_key) && (NULL == name))
2219 {
2220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iteration done\n");
2221 return;
2222 }
2223 if ((NULL == zone_key) || (NULL == name))
2224 {
2225 /* what is this!? should never happen */
2226 GNUNET_break (0);
2227 return;
2228 }
2229 if (0 == proc->limit)
2230 {
2231 /* what is this!? should never happen */
2232 GNUNET_break (0);
2233 return;
2234 }
2235 proc->zi->seq = seq;
2236 if (0 < send_lookup_response_with_filter (proc->zi->nc,
2237 proc->zi->request_id,
2238 zone_key,
2239 name,
2240 rd_count,
2241 rd,
2242 proc->zi->filter))
2243 proc->limit--;
2244 else
2245 proc->run_again = GNUNET_YES;
2246}
2247
2248
2255static void
2257{
2258 struct ZoneIterationProcResult proc;
2261 struct NamestoreClient *nc = zi->nc;
2262
2263 memset (&proc, 0, sizeof(proc));
2265 "Asked to return up to %llu records at position %llu\n",
2266 (unsigned long long) limit,
2267 (unsigned long long) zi->seq);
2268 proc.zi = zi;
2269 proc.limit = limit;
2270 proc.run_again = GNUNET_YES;
2272 while (GNUNET_YES == proc.run_again)
2273 {
2274 proc.run_again = GNUNET_NO;
2276 nc->GSN_database->iterate_records (nc->GSN_database->cls,
2277 (GNUNET_YES ==
2279 &zi->zone))
2280 ? NULL
2281 : &zi->zone,
2282 zi->seq,
2283 proc.limit,
2285 &proc));
2286 }
2290 "NAMESTORE iteration delay (μs/record)",
2292 GNUNET_NO);
2293 if (0 == proc.limit)
2295 "Returned %llu results, more results available\n",
2296 (unsigned long long) limit);
2297 zi->send_end = (0 != proc.limit);
2299}
2300
2301
2302static enum GNUNET_GenericReturnValue
2304 const struct ZoneIterationStartMessage *zis_msg)
2305{
2306 uint16_t size;
2307 size_t key_len;
2308
2309 size = ntohs (zis_msg->gns_header.header.size);
2310 key_len = ntohs (zis_msg->key_len);
2311
2312 if (size < key_len + sizeof(*zis_msg))
2313 {
2314 GNUNET_break (0);
2315 return GNUNET_SYSERR;
2316 }
2317 return GNUNET_OK;
2318}
2319
2320
2327static void
2329 const struct ZoneIterationStartMessage *zis_msg)
2330{
2332 struct NamestoreClient *nc = cls;
2333 struct ZoneIteration *zi;
2334 size_t key_len;
2335 size_t kb_read;
2336
2338 "Received ZONE_ITERATION_START message\n");
2339 key_len = ntohs (zis_msg->key_len);
2340 zi = GNUNET_new (struct ZoneIteration);
2341 if (0 < key_len)
2342 {
2343 if ((GNUNET_SYSERR ==
2345 key_len,
2346 &zone,
2347 &kb_read)) ||
2348 (kb_read != key_len))
2349 {
2351 GNUNET_free (zi);
2352 return;
2353 }
2354 zi->zone = zone;
2355 }
2356 zi->request_id = ntohl (zis_msg->gns_header.r_id);
2357 zi->filter = ntohs (zis_msg->filter);
2358 zi->offset = 0;
2359 zi->nc = nc;
2360 GNUNET_CONTAINER_DLL_insert (nc->op_head, nc->op_tail, zi);
2362}
2363
2364
2371static void
2373 const struct ZoneIterationStopMessage *zis_msg)
2374{
2375 struct NamestoreClient *nc = cls;
2376 struct ZoneIteration *zi;
2377 uint32_t rid;
2378
2380 "Received ZONE_ITERATION_STOP message\n");
2381 rid = ntohl (zis_msg->gns_header.r_id);
2382 for (zi = nc->op_head; NULL != zi; zi = zi->next)
2383 if (zi->request_id == rid)
2384 break;
2385 if (NULL == zi)
2386 {
2387 GNUNET_break (0);
2389 return;
2390 }
2391 GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, zi);
2392 GNUNET_free (zi);
2394}
2395
2396
2403static void
2405 const struct ZoneIterationNextMessage *zis_msg)
2406{
2407 struct NamestoreClient *nc = cls;
2408 struct ZoneIteration *zi;
2409 uint32_t rid;
2410 uint64_t limit;
2411
2413 "Received ZONE_ITERATION_NEXT message\n");
2415 "Iteration NEXT messages received",
2416 1,
2417 GNUNET_NO);
2418 rid = ntohl (zis_msg->gns_header.r_id);
2419 limit = GNUNET_ntohll (zis_msg->limit);
2420 for (zi = nc->op_head; NULL != zi; zi = zi->next)
2421 if (zi->request_id == rid)
2422 break;
2423 if (NULL == zi)
2424 {
2425 GNUNET_break (0);
2427 return;
2428 }
2429 run_zone_iteration_round (zi, limit);
2430}
2431
2432
2438static void
2440{
2441 struct StoreActivity *sa = sa_head;
2442
2444 "Unblocking zone monitor %p\n", zm);
2445 while ((NULL != sa) && (zm->limit > zm->iteration_cnt))
2446 {
2447 struct StoreActivity *sn = sa->next;
2448
2449 if (sa->zm_pos == zm)
2451 sa = sn;
2452 }
2453 if (zm->limit > zm->iteration_cnt)
2454 {
2455 zm->sa_waiting = GNUNET_NO;
2456 if (NULL != zm->sa_wait_warning)
2457 {
2458 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
2459 zm->sa_wait_warning = NULL;
2460 }
2461 }
2462 else if (GNUNET_YES == zm->sa_waiting)
2463 {
2464 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
2465 if (NULL != zm->sa_wait_warning)
2466 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
2467 zm->sa_wait_warning =
2470 zm);
2471 }
2472}
2473
2474
2480static void
2482{
2483 struct GNUNET_MQ_Envelope *env;
2484 struct GNUNET_MessageHeader *sync;
2486 "Syncing zone monitor %p\n", zm);
2487
2489 GNUNET_MQ_send (zm->nc->mq, env);
2490 /* mark iteration done */
2491 zm->in_first_iteration = GNUNET_NO;
2492 zm->iteration_cnt = 0;
2493 if ((zm->limit > 0) && (zm->sa_waiting))
2495}
2496
2497
2503static void
2504monitor_iteration_next (void *cls);
2505
2506
2517static void
2519 uint64_t seq,
2520 const char *editor_hint,
2521 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key,
2522 const char *name,
2523 unsigned int rd_count,
2524 const struct GNUNET_GNSRECORD_Data *rd)
2525{
2526 struct ZoneMonitor *zm = cls;
2527
2528 GNUNET_assert (0 != seq);
2529 zm->seq = seq;
2530 GNUNET_assert (NULL != name);
2532 "Monitor notifications sent",
2533 1,
2534 GNUNET_NO);
2535 if (0 < send_lookup_response_with_filter (zm->nc, 0, zone_key, name,
2536 rd_count, rd, zm->filter))
2537 {
2539 "Sent records.\n");
2540 zm->limit--;
2541 zm->iteration_cnt--;
2542 }
2543 else
2544 zm->run_again = GNUNET_YES;
2545 if ((0 == zm->iteration_cnt) && (0 != zm->limit))
2546 {
2547 /* We are done with the current iteration batch, AND the
2548 client would right now accept more, so go again! */
2549 GNUNET_assert (NULL == zm->task);
2551 }
2552}
2553
2554
2555static enum GNUNET_GenericReturnValue
2557 const struct ZoneMonitorStartMessage *zis_msg)
2558{
2559 uint16_t size;
2560 size_t key_len;
2561
2562 size = ntohs (zis_msg->header.size);
2563 key_len = ntohs (zis_msg->key_len);
2564
2565 if (size < key_len + sizeof(*zis_msg))
2566 {
2567 GNUNET_break (0);
2568 return GNUNET_SYSERR;
2569 }
2570 return GNUNET_OK;
2571}
2572
2573
2580static void
2581handle_monitor_start (void *cls, const struct
2582 ZoneMonitorStartMessage *zis_msg)
2583{
2585 struct NamestoreClient *nc = cls;
2586 struct ZoneMonitor *zm;
2587 size_t key_len;
2588 size_t kb_read;
2589
2591 "Received ZONE_MONITOR_START message\n");
2592 zm = GNUNET_new (struct ZoneMonitor);
2593 zm->nc = nc;
2594 key_len = ntohs (zis_msg->key_len);
2595 if (0 < key_len)
2596 {
2597 if ((GNUNET_SYSERR ==
2599 key_len,
2600 &zone,
2601 &kb_read)) ||
2602 (kb_read != key_len))
2603 {
2605 "Error reading private key\n");
2607 GNUNET_free (zm);
2608 return;
2609 }
2610 zm->zone = zone;
2611 }
2612 zm->limit = 1;
2613 zm->filter = ntohs (zis_msg->filter);
2614 zm->in_first_iteration = (GNUNET_YES == ntohl (zis_msg->iterate_first));
2619 if (zm->in_first_iteration)
2621 else
2622 monitor_sync (zm);
2623}
2624
2625
2631static void
2633{
2634 struct ZoneMonitor *zm = cls;
2635 struct NamestoreClient *nc = zm->nc;
2636 int ret;
2637
2638 zm->task = NULL;
2639 GNUNET_assert (0 == zm->iteration_cnt);
2640 if (zm->limit > 16)
2641 zm->iteration_cnt = zm->limit / 2; /* leave half for monitor events */
2642 else
2643 zm->iteration_cnt = zm->limit; /* use it all */
2644 zm->run_again = GNUNET_YES;
2645 while (GNUNET_YES == zm->run_again)
2646 {
2648 "Running iteration\n");
2649 zm->run_again = GNUNET_NO;
2650 ret = nc->GSN_database->iterate_records (nc->GSN_database->cls,
2652 &zm->zone)) ? NULL : &zm->zone,
2653 zm->seq,
2654 zm->iteration_cnt,
2656 zm);
2657 }
2658 if (GNUNET_SYSERR == ret)
2659 {
2660 GNUNET_SERVICE_client_drop (zm->nc->client);
2661 return;
2662 }
2663 if (GNUNET_NO == ret)
2664 {
2666 "Zone empty... syncing\n");
2667 /* empty zone */
2668 monitor_sync (zm);
2669 return;
2670 }
2671}
2672
2673
2680static void
2681handle_monitor_next (void *cls, const struct ZoneMonitorNextMessage *nm)
2682{
2683 struct NamestoreClient *nc = cls;
2684 struct ZoneMonitor *zm;
2685 uint64_t inc;
2686
2687 inc = GNUNET_ntohll (nm->limit);
2689 "Received ZONE_MONITOR_NEXT message with limit %llu\n",
2690 (unsigned long long) inc);
2691 for (zm = monitor_head; NULL != zm; zm = zm->next)
2692 if (zm->nc == nc)
2693 break;
2694 if (NULL == zm)
2695 {
2696 GNUNET_break (0);
2698 return;
2699 }
2701 if (zm->limit + inc < zm->limit)
2702 {
2703 GNUNET_break (0);
2705 return;
2706 }
2707 zm->limit += inc;
2708 if ((zm->in_first_iteration) && (zm->limit == inc))
2709 {
2710 /* We are still iterating, and the previous iteration must
2711 have stopped due to the client's limit, so continue it! */
2712 GNUNET_assert (NULL == zm->task);
2714 }
2715 GNUNET_assert (zm->iteration_cnt <= zm->limit);
2716 if ((zm->limit > zm->iteration_cnt) && (zm->sa_waiting))
2717 {
2719 }
2720 else if (GNUNET_YES == zm->sa_waiting)
2721 {
2722 if (NULL != zm->sa_wait_warning)
2723 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
2724 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
2725 zm->sa_wait_warning =
2728 zm);
2729 }
2730}
2731
2732
2740static void
2741run (void *cls,
2742 const struct GNUNET_CONFIGURATION_Handle *cfg,
2744{
2745 char *database;
2746 (void) cls;
2747 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting namestore service\n");
2749 "namestore",
2750 "RETURN_ORPHANED");
2751 GSN_cfg = cfg;
2753 statistics = GNUNET_STATISTICS_create ("namestore", cfg);
2754 /* Loading database plugin */
2756 "namestore",
2757 "database",
2758 &database))
2759 {
2760 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
2762 return;
2763 }
2765 "libgnunet_plugin_namestore_%s",
2766 database);
2768 "Loading %s\n",
2769 db_lib_name);
2772 (void *) cfg);
2773 GNUNET_free (database);
2774 if (NULL == GSN_database)
2775 {
2777 "Could not load database backend `%s'\n",
2778 db_lib_name);
2781 return;
2782 }
2784}
2785
2786
2792 "namestore",
2794 &run,
2797 NULL,
2798 GNUNET_MQ_hd_var_size (record_store,
2800 struct RecordStoreMessage,
2801 NULL),
2802 GNUNET_MQ_hd_var_size (edit_record_set,
2804 struct EditRecordSetMessage,
2805 NULL),
2806 GNUNET_MQ_hd_var_size (edit_record_set_cancel,
2809 NULL),
2810 GNUNET_MQ_hd_var_size (record_lookup,
2812 struct LabelLookupMessage,
2813 NULL),
2816 struct ZoneToNameMessage,
2817 NULL),
2818 GNUNET_MQ_hd_var_size (iteration_start,
2821 NULL),
2822 GNUNET_MQ_hd_fixed_size (iteration_next,
2825 NULL),
2826 GNUNET_MQ_hd_fixed_size (iteration_stop,
2829 NULL),
2830 GNUNET_MQ_hd_var_size (monitor_start,
2833 NULL),
2834 GNUNET_MQ_hd_fixed_size (monitor_next,
2837 NULL),
2839
2840
2841/* end of gnunet-service-namestore.c */
struct GNUNET_MQ_Envelope * env
Definition 005.c:1
#define GNUNET_GNSRECORD_TYPE_NICK
GNS zone nickname.
#define GNUNET_GNSRECORD_TYPE_TOMBSTONE
Record type to indicate a previously delete record (PRIVATE only)
static int start
Set if we are to start default services (including ARM).
Definition gnunet-arm.c:38
static int ret
Final status code.
Definition gnunet-arm.c:93
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static char * data
The data to insert into the dht.
static char * name
Name (label) of the records to list.
static unsigned int rd_count
Number of records for currently parsed set.
static char * res
Currently read line or NULL on EOF.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static size_t data_size
Number of bytes in data.
static struct GNUNET_SCHEDULER_Task * cleanup_task
Cleanup task.
static struct GNUNET_CRYPTO_EddsaPublicKey pub
static struct GNUNET_SERVICE_Handle * service
Handle to our service instance.
static struct GNUNET_NotificationContext * nc
Notification context for broadcasting to monitors.
static struct GNUNET_CONTAINER_BloomFilter * filter
Bloomfilter to quickly tell if we don't have the content.
static int check_edit_record_set(void *cls, const struct EditRecordSetMessage *er_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT message.
static enum GNUNET_GenericReturnValue check_iteration_start(void *cls, const struct ZoneIterationStartMessage *zis_msg)
static struct GNUNET_GNSRECORD_Data * get_nick_record(const struct GNUNET_CRYPTO_BlindablePrivateKey *zone)
Return the NICK record for the zone (if it exists).
static int return_orphaned
Returned orphaned records?
static void handle_iteration_start(void *cls, const struct ZoneIterationStartMessage *zis_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START message.
static struct StoreActivity * sa_tail
Tail of DLL of monitor-blocked store activities.
static void handle_iteration_stop(void *cls, const struct ZoneIterationStopMessage *zis_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP message.
static void run_zone_iteration_round(struct ZoneIteration *zi, uint64_t limit)
Perform the next round of the zone iteration.
static void monitor_unblock(struct ZoneMonitor *zm)
Function called when the monitor is ready for more data, and we should thus unblock PUT operations th...
static void handle_record_store(void *cls, const struct RecordStoreMessage *rp_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message.
static void monitor_sync(struct ZoneMonitor *zm)
Send 'sync' message to zone monitor, we're now in sync.
static void handle_monitor_next(void *cls, const struct ZoneMonitorNextMessage *nm)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT message.
static struct GNUNET_NotificationContext * monitor_nc
Notification context shared by all monitors.
struct GNUNET_NAMESTORE_PluginFunctions * GSN_database
Database handle for service.
static const struct GNUNET_CRYPTO_BlindablePrivateKey zero
Public key of all zeros.
static char * db_lib_name
Name of the database plugin.
static int check_record_store(void *cls, const struct RecordStoreMessage *rp_msg)
Checks a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message.
static void get_existing_rd_exp(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_BlindablePrivateKey *private_key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Check if set contains a tombstone, store if necessary.
static struct GNUNET_STATISTICS_Handle * statistics
Handle to the statistics service.
static void * client_connect_cb(void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
Add a client to our list of active clients.
static void merge_with_nick_records(const struct GNUNET_GNSRECORD_Data *nick_rd, unsigned int rd2_length, const struct GNUNET_GNSRECORD_Data *rd2, unsigned int *rdc_res, struct GNUNET_GNSRECORD_Data **rd_res)
Merge the nick record nick_rd with the rest of the record set given in rd2.
static struct StoreActivity * sa_head
Head of DLL of monitor-blocked store activities.
static void handle_record_lookup(void *cls, const struct LabelLookupMessage *ll_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.
static void free_store_activity(struct StoreActivity *sa)
Release memory used by sa.
static void lookup_it(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_BlindablePrivateKey *private_key, const char *label, unsigned int rd_count_nf, const struct GNUNET_GNSRECORD_Data *rd_nf)
Function called by the namestore plugin when we are trying to lookup a record as part of handle_recor...
static void handle_zone_to_name(void *cls, const struct ZoneToNameMessage *ztn_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME message.
static int continue_store_activity(struct StoreActivity *sa, int call_continue)
Continue processing the sa.
static void lookup_nick_it(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_BlindablePrivateKey *private_key, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Function called with the records for the GNUNET_GNS_EMPTY_LABEL_AT label in the zone.
static struct ZoneMonitor * monitor_head
First active zone monitor.
static int check_record_lookup(void *cls, const struct LabelLookupMessage *ll_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.
static void zone_iteration_done_client_continue(struct ZoneIteration *zi)
Function called once we are done with the zone iteration and allow the zone iteration client to send ...
static void zone_iterate_proc(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process results for zone iteration from database.
#define MONITOR_STALL_WARN_DELAY
If a monitor takes more than 1 minute to process an event, print a warning.
static enum GNUNET_GenericReturnValue check_zone_to_name(void *cls, const struct ZoneToNameMessage *zis_msg)
static void cache_nick(const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const struct GNUNET_GNSRECORD_Data *nick)
Add entry to the cache for zone and nick.
static void monitor_iteration_next(void *cls)
Obtain the next datum during the zone monitor's zone initial iteration.
static int send_lookup_response_with_filter(struct NamestoreClient *nc, uint32_t request_id, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, enum GNUNET_GNSRECORD_Filter filter)
Generate a struct LookupNameResponseMessage and send it to the given client using the given notificat...
static void handle_edit_record_set_cancel(void *cls, const struct EditRecordSetCancelMessage *er_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL message.
static const struct GNUNET_CONFIGURATION_Handle * GSN_cfg
Configuration handle.
static void send_store_response(struct NamestoreClient *nc, enum GNUNET_ErrorCode ec, uint32_t rid)
Send response to the store request to the client.
static void handle_monitor_start(void *cls, const struct ZoneMonitorStartMessage *zis_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START message.
static enum GNUNET_ErrorCode store_record_set(struct NamestoreClient *nc, const struct GNUNET_CRYPTO_BlindablePrivateKey *private_key, const struct RecordSet *rd_set, ssize_t *len)
#define NC_SIZE
Size of the cache used by get_nick_record()
static struct ZoneMonitor * monitor_tail
Last active zone monitor.
static void monitor_iterate_cb(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
A GNUNET_NAMESTORE_RecordIterator for monitors.
static void client_disconnect_cb(void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
Called whenever a client is disconnected.
static struct NickCache nick_cache[16]
We cache nick records to reduce DB load.
static void handle_zone_to_name_it(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Zone to name iterator.
static void handle_iteration_next(void *cls, const struct ZoneIterationNextMessage *zis_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT message.
static void handle_edit_record_set(void *cls, const struct EditRecordSetMessage *er_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT message.
static void warn_monitor_slow(void *cls)
Print a warning that one of our monitors is no longer reacting.
static int check_edit_record_set_cancel(void *cls, const struct EditRecordSetCancelMessage *er_msg)
Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL message.
static enum GNUNET_GenericReturnValue check_monitor_start(void *cls, const struct ZoneMonitorStartMessage *zis_msg)
static void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Process namestore requests.
static struct GNUNET_TIME_Relative duration
Option '-d': duration of the mapping.
Definition gnunet-vpn.c:90
GNUNET_ErrorCode
Taler error codes.
@ GNUNET_EC_NAMESTORE_NO_RESULTS
No results given.
@ GNUNET_EC_NAMESTORE_LABEL_INVALID
Label invalid or malformed.
@ GNUNET_EC_NAMESTORE_BACKEND_FAILED
There was an error in the database backend.
@ GNUNET_EC_NAMESTORE_RECORD_TOO_BIG
Record size exceeds maximum limit.
@ GNUNET_EC_NAMESTORE_STORE_FAILED
Failed to store the given records.
@ GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID
Record data invalid.
@ GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND
Zone not found.
@ GNUNET_EC_NONE
No error (success).
@ GNUNET_EC_NAMESTORE_UNKNOWN
Unknown namestore error.
@ GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND
Record not found.
API that can be used to manipulate GNS record data.
Plugin API for the namestore database backend.
Constants for network protocols.
API to create, modify and access statistics.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_yesno(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Get a configuration value that should be in a set of "YES" or "NO".
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_label_check(const char *label, char **emsg)
Check label for invalid characters.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
ssize_t GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, size_t dest_size, char *dest)
Serialize the given records to the given destination buffer.
const char * GNUNET_GNSRECORD_z2s(const struct GNUNET_CRYPTO_BlindablePublicKey *z)
Convert a zone to a string (for printing debug messages).
ssize_t GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Calculate how many bytes we will need to serialize the given records.
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
char * GNUNET_GNSRECORD_string_normalize(const char *src)
Normalize a UTF-8 string to a GNS name.
GNUNET_GNSRECORD_Filter
Filter for GNUNET_GNSRECORD_normalize_record_set().
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_normalize_record_set(const char *label, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *rd_public, unsigned int *rd_count_public, struct GNUNET_TIME_Absolute *min_expiry, enum GNUNET_GNSRECORD_Filter filter, char **emsg)
Normalize namestore records: Check for consistency and expirations.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_SUPPLEMENTAL
This is a supplemental record.
@ GNUNET_GNSRECORD_RF_MAINTENANCE
Maintenance records.
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
@ GNUNET_GNSRECORD_FILTER_NONE
No filter flags set.
@ GNUNET_GNSRECORD_FILTER_INCLUDE_MAINTENANCE
Include maintenance records (TOMBSTONE etc).
@ GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE
Filter private records.
#define GNUNET_is_zero(a)
Check that memory in a is all zeros.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_key_get_public(const struct GNUNET_CRYPTO_BlindablePrivateKey *privkey, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Retrieves the public key representation of a private key.
#define GNUNET_log(kind,...)
#define GNUNET_NZL(l)
Macro used to avoid using 0 for the length of a variable-size array (Non-Zero-Length).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_blindable_pk_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_BlindablePublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePublicKey from a compact buffer.
ssize_t GNUNET_CRYPTO_write_blindable_sk_to_buffer(const struct GNUNET_CRYPTO_BlindablePrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_BlindablePrivateKey to a compact buffer.
#define GNUNET_LOG_CALL_STATUS
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
int GNUNET_get_log_call_status(int caller_level, const char *comp, const char *file, const char *function, int line)
Decides whether a particular logging call should or should not be allowed to be made.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_BlindablePrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_BlindablePrivateKey from a compact buffer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
ssize_t GNUNET_CRYPTO_blindable_sk_get_length(const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePrivateKey.
Definition crypto_pkey.c:64
GNUNET_GenericReturnValue
Named constants for return values.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_BULK
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_notification_context_destroy(struct GNUNET_NotificationContext *nc)
Destroy the context, force disconnect for all subscribers.
Definition nc.c:138
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition mq.c:305
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
struct GNUNET_NotificationContext * GNUNET_notification_context_create(unsigned int queue_length)
Create a new notification context.
Definition nc.c:122
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
#define GNUNET_MQ_hd_fixed_size(name, code, str, ctx)
void GNUNET_notification_context_add(struct GNUNET_NotificationContext *nc, struct GNUNET_MQ_Handle *mq)
Add a subscriber to the notification context.
Definition nc.c:161
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
void * GNUNET_PLUGIN_load(const struct GNUNET_OS_ProjectData *pd, const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition plugin.c:221
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition plugin.c:277
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END
Service to client: end of list of results.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT
Service to client: here is a (plaintext) record you requested.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT
Message type for start of record edit with advisory lock.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE
Service to client: result of zone-to-name lookup.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE
Service to client: result of store operation.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL
Message type for cancellation/reset of editor hint/advisory lock.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT
Client to service: next record(s) in iteration please.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START
Client to service: please start iteration; receives "GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPON...
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP
Client to service: stop iterating.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE
Service to client: lookup label.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE
Return record set to edit with previous editor hint/advisory lock.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE
Client to service: store records (as authority)
#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT
Client to service: I am now ready for the next (set of) monitor events.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START
Client to service: start monitoring (yields sequence of "ZONE_ITERATION_RESPONSES" — forever).
#define GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME
Client to service: "reverse" lookup for zone name based on zone key.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC
Service to client: you're now in sync.
#define GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP
Client to service: lookup label.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition scheduler.c:1345
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:986
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition scheduler.c:1310
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1283
#define GNUNET_SERVICE_MAIN(pd, service_name, service_options, init_cb, connect_cb, disconnect_cb, cls,...)
Creates the "main" function for a GNUnet service.
void GNUNET_SERVICE_client_mark_monitor(struct GNUNET_SERVICE_Client *c)
Set the 'monitor' flag on this client.
Definition service.c:2528
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition service.c:2463
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition service.c:2434
@ GNUNET_SERVICE_OPTION_NONE
Use defaults.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition time.c:438
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
#define GNUNET_TIME_absolute_cmp(t1, op, t2)
Compare two absolute times.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Definition time.c:548
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition time.c:636
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition strings.c:671
common internal definitions for namestore service
static unsigned int size
Size of the "table".
Definition peer.c:68
static int zone_to_name(void *cls, const struct GNUNET_HashCode *key, void *value)
static struct GNUNET_MQ_Handle * mq
Our connection to the resolver service, created on-demand, but then persists until error or shutdown.
Edit a record set and set editor hint/advisory lock.
Definition namestore.h:253
struct GNUNET_NAMESTORE_Header gns_header
Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_EDIT_RECORD_SET_CANCEL.
Definition namestore.h:257
uint16_t editor_hint_len
Unused.
Definition namestore.h:267
uint16_t label_len
Length of the name.
Definition namestore.h:262
uint16_t key_len
Length of the zone key.
Definition namestore.h:277
Edit a record set and set editor hint/advisory lock.
Definition namestore.h:215
struct GNUNET_NAMESTORE_Header gns_header
Type will be #GNUNET_MESSAGE_TYPE_NAMESTORE_EDIT_RECORD_SET.
Definition namestore.h:219
uint16_t editor_hint_len
Unused.
Definition namestore.h:229
uint16_t label_len
Length of the name.
Definition namestore.h:224
uint16_t key_len
Length of the zone key.
Definition namestore.h:239
Response to RecordSetEditMessage.
Definition namestore.h:142
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE.
Definition namestore.h:146
uint16_t editor_hint_len
Length of the editor hint.
Definition namestore.h:151
uint16_t rd_count
Number of records contained.
Definition namestore.h:166
uint16_t rd_len
Length of serialized record data.
Definition namestore.h:161
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
Handle to a message queue.
Definition mq.c:87
Header for all communications.
Generic namestore message with op id.
Definition namestore.h:41
uint32_t r_id
Request ID in NBO.
Definition namestore.h:51
struct GNUNET_MessageHeader header
header.type will be GNUNET_MESSAGE_TYPE_NAMESTORE_* header.size will be message size
Definition namestore.h:46
struct returned by the initialization function of the plugin
enum GNUNET_GenericReturnValue(* lookup_records)(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls)
Lookup records in the datastore for which we are the authority.
void * cls
Closure to pass to all plugin functions.
struct GNUNET_CRYPTO_BlindablePrivateKey zone
Monitored zone.
struct GNUNET_MQ_Handle * mq
Handle to namestore service.
enum GNUNET_GNSRECORD_Filter filter
Record set filter for this monitor.
The notification context is the key datastructure for a convenience API used for transmission of noti...
Definition nc.c:77
Entry in list of pending tasks.
Definition scheduler.c:141
Handle to a client that is connected to a service.
Definition service.c:249
Handle to a service.
Definition service.c:116
Handle for the service.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Lookup a label.
Definition namestore.h:179
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP.
Definition namestore.h:183
uint16_t key_len
Length of the zone key.
Definition namestore.h:203
uint16_t filter
The record filter.
Definition namestore.h:198
uint16_t label_len
Length of the name.
Definition namestore.h:188
uint16_t rd_len
Length of serialized record data.
Definition namestore.h:306
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE.
Definition namestore.h:296
uint16_t reserved
Reserved (alignment)
Definition namestore.h:322
uint16_t key_len
Length of the zone key.
Definition namestore.h:327
uint16_t rd_count
Number of records contained.
Definition namestore.h:311
uint16_t name_len
Name length.
Definition namestore.h:301
int16_t found
Was the label found in the database?? GNUNET_YES or GNUNET_NO.
Definition namestore.h:317
struct GNUNET_TIME_Absolute exp
The expiration of the existing records or tombstone.
int only_tombstone
Whether the existing record set consists only of a tombstone (e.g.
A namestore client.
struct ZoneIteration * op_head
Head of the DLL of Zone iteration operations in progress initiated by this client.
struct GNUNET_NAMESTORE_PluginFunctions * GSN_database
Database handle for client.
char * db_lib_name
Name of loaded plugin (needed for cleanup)
struct GNUNET_MQ_Handle * mq
Message queue for transmission to client.
struct GNUNET_SERVICE_Client * client
The client.
struct ZoneIteration * op_tail
Tail of the DLL of Zone iteration operations in progress initiated by this client.
Response to a record storage request.
Definition namestore.h:125
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE.
Definition namestore.h:129
uint32_t ec
GNUNET_ErrorCode.
Definition namestore.h:134
Entry in list of cached nick resolutions.
struct GNUNET_GNSRECORD_Data * rd
Cached record data.
struct GNUNET_TIME_Absolute last_used
Timestamp when this cache entry was used last.
struct GNUNET_CRYPTO_BlindablePrivateKey zone
Zone the cache entry is for.
Closure for lookup_it().
char * editor_hint
The editor hint for set.
struct GNUNET_GNSRECORD_Data * nick
The nick for the zone.
char * res_rd
The record result.
const char * label
The label to look up.
int found
If a record set was found or not.
unsigned int res_rd_count
The number of found records.
ssize_t rd_ser_len
The length of the serialized records.
enum GNUNET_GNSRECORD_Filter filter
The record filter.
Record is returned from the namestore (as authority).
Definition namestore.h:415
uint16_t rd_len
Length of serialized record data.
Definition namestore.h:435
uint16_t name_len
Name length.
Definition namestore.h:430
uint16_t rd_count
Number of records contained.
Definition namestore.h:440
struct GNUNET_TIME_AbsoluteNBO expire
Expiration time if the record result (if any).
Definition namestore.h:425
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT.
Definition namestore.h:419
uint16_t key_len
Length of the zone key.
Definition namestore.h:445
uint16_t rd_len
Length of serialized record data.
Definition namestore.h:64
uint16_t rd_count
Number of records contained.
Definition namestore.h:69
uint16_t name_len
Name length.
Definition namestore.h:59
Store a record to the namestore (as authority).
Definition namestore.h:87
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE.
Definition namestore.h:91
uint16_t rd_set_count
Number of record sets.
Definition namestore.h:107
uint16_t single_tx
GNUNET_YES if all sets should be stored in a single transaction (e.g.
Definition namestore.h:102
uint16_t key_len
Length of the zone key.
Definition namestore.h:112
Information for an ongoing handle_record_store() operation.
struct StoreActivity * next
Kept in a DLL.
uint32_t rid
The request ID.
const struct RecordSet * rs
Copy of the original record set (as data fields in rd will point into it!).
uint16_t rd_set_count
The number of records in this activity.
struct NamestoreClient * nc
Which client triggered the store activity?
struct GNUNET_CRYPTO_BlindablePrivateKey private_key
The zone private key.
uint16_t rd_set_pos
The currently processed record.
struct StoreActivity * prev
Kept in a DLL.
struct ZoneMonitor * zm_pos
Next zone monitor that still needs to be notified about this PUT.
Ask for next result of zone iteration for the given operation.
Definition namestore.h:583
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT.
Definition namestore.h:587
uint64_t limit
Number of records to return to the iterator in one shot (before GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_IT...
Definition namestore.h:594
Context for record remove operations passed from run_zone_iteration_round to zone_iterate_proc as clo...
struct ZoneIteration * zi
The zone iteration handle.
int run_again
Skip a result and run again unless GNUNET_NO.
uint64_t limit
Number of results left to be returned in this iteration.
Start a zone iteration for the given zone.
Definition namestore.h:556
uint16_t key_len
Length of the zone key.
Definition namestore.h:571
uint16_t filter
Record set filter control flags.
Definition namestore.h:566
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START.
Definition namestore.h:560
Stop zone iteration for the given operation.
Definition namestore.h:602
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP.
Definition namestore.h:606
A namestore iteration operation.
struct NamestoreClient * nc
Namestore client which initiated this zone iteration.
struct GNUNET_CRYPTO_BlindablePrivateKey zone
Key of the zone we are iterating over.
uint64_t seq
Last sequence number in the zone iteration used to address next result of the zone iteration in the s...
struct GNUNET_GNSRECORD_Data * nick
The nick to add to the records.
enum GNUNET_GNSRECORD_Filter filter
The record set filter.
int send_end
Set to GNUNET_YES if the last iteration exhausted the limit set by the client and we should send the ...
uint32_t request_id
The operation id for the zone iteration in the response for the client.
struct ZoneIteration * prev
Previous element in the DLL.
uint32_t offset
Offset of the zone iteration used to address next result of the zone iteration in the store.
struct ZoneIteration * next
Next element in the DLL.
Ask for next result of zone iteration for the given operation.
Definition namestore.h:532
uint64_t limit
Number of records to return to the iterator in one shot (before #GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_M...
Definition namestore.h:548
Start monitoring a zone.
Definition namestore.h:499
uint32_t iterate_first
GNUNET_YES to first iterate over all records, GNUNET_NO to only monitor changes.o
Definition namestore.h:509
uint16_t filter
Record set filter control flags.
Definition namestore.h:515
uint16_t key_len
Length of the zone key.
Definition namestore.h:520
struct GNUNET_MessageHeader header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START.
Definition namestore.h:503
A namestore monitor.
struct GNUNET_SCHEDULER_Task * sa_wait_warning
Task to warn about slow monitors.
struct GNUNET_CRYPTO_BlindablePrivateKey zone
Private key of the zone.
struct GNUNET_TIME_Absolute sa_waiting_start
Since when are we blocked on this monitor?
int in_first_iteration
Are we (still) in the initial iteration pass?
enum GNUNET_GNSRECORD_Filter filter
The record set filter.
struct ZoneMonitor * prev
Previous element in the DLL.
int sa_waiting
Is there a store activity waiting for this monitor? We only raise the flag when it happens and search...
uint64_t iteration_cnt
How many more requests may we receive from the iterator before it is at the limit we gave it?...
uint64_t limit
Current limit of how many more messages we are allowed to queue to this monitor.
uint64_t seq
Last sequence number in the zone iteration used to address next result of the zone iteration in the s...
struct GNUNET_SCHEDULER_Task * task
Task active during initial iteration.
struct NamestoreClient * nc
Namestore client which initiated this zone monitor.
int run_again
Run again because we skipped an orphan.
struct ZoneMonitor * next
Next element in the DLL.
Context for record remove operations passed from handle_zone_to_name to handle_zone_to_name_it as clo...
struct NamestoreClient * nc
Namestore client.
uint32_t rid
Request id (to be used in the response to the client).
enum GNUNET_ErrorCode ec
Set to GNUNET_OK on success, GNUNET_SYSERR on error.
Lookup a name for a zone hash.
Definition namestore.h:341
uint16_t pkey_len
Length of the public value zone key.
Definition namestore.h:355
uint16_t key_len
Length of the zone key.
Definition namestore.h:350
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME.
Definition namestore.h:345
Response for zone to name lookup.
Definition namestore.h:369
uint16_t name_len
Length of the name.
Definition namestore.h:386
int32_t ec
result in NBO: GNUNET_EC_NONE on success, GNUNET_EC_NAMESTORE_NO_RESULTS if there were no results.
Definition namestore.h:381
uint16_t key_len
Length of the zone key.
Definition namestore.h:401
struct GNUNET_NAMESTORE_Header gns_header
Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE.
Definition namestore.h:373
uint16_t rd_count
Number of records contained.
Definition namestore.h:396
uint16_t rd_len
Length of serialized record data.
Definition namestore.h:391