GNUnet debian-0.24.3-29-g453fda2cf
 
Loading...
Searching...
No Matches
gnunet-service-namestore.c File Reference

namestore for the GNUnet naming system More...

Include dependency graph for gnunet-service-namestore.c:

Go to the source code of this file.

Data Structures

struct  ZoneIteration
 A namestore iteration operation. More...
 
struct  NamestoreClient
 A namestore client. More...
 
struct  ZoneMonitor
 A namestore monitor. More...
 
struct  StoreActivity
 Information for an ongoing handle_record_store() operation. More...
 
struct  NickCache
 Entry in list of cached nick resolutions. More...
 
struct  RecordLookupContext
 Closure for lookup_it(). More...
 
struct  LookupExistingRecordsContext
 
struct  ZoneToNameCtx
 Context for record remove operations passed from handle_zone_to_name to handle_zone_to_name_it as closure. More...
 
struct  ZoneIterationProcResult
 Context for record remove operations passed from run_zone_iteration_round to zone_iterate_proc as closure. More...
 

Macros

#define LOG_STRERROR_FILE(kind, syscall, filename)    GNUNET_log_from_strerror_file (kind, "util", syscall, filename)
 
#define MONITOR_STALL_WARN_DELAY   GNUNET_TIME_UNIT_MINUTES
 If a monitor takes more than 1 minute to process an event, print a warning.
 
#define NC_SIZE   16
 Size of the cache used by get_nick_record()
 

Functions

static void cleanup_task (void *cls)
 Task run during shutdown.
 
static void free_store_activity (struct StoreActivity *sa)
 Release memory used by sa.
 
static void lookup_nick_it (void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *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 void cache_nick (const struct GNUNET_CRYPTO_PrivateKey *zone, const struct GNUNET_GNSRECORD_Data *nick)
 Add entry to the cache for zone and nick.
 
static struct GNUNET_GNSRECORD_Dataget_nick_record (const struct GNUNET_CRYPTO_PrivateKey *zone)
 Return the NICK record for the zone (if it exists).
 
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 int send_lookup_response_with_filter (struct NamestoreClient *nc, uint32_t request_id, const struct GNUNET_CRYPTO_PrivateKey *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 notification context.
 
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 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 us more messages.
 
static void warn_monitor_slow (void *cls)
 Print a warning that one of our monitors is no longer reacting.
 
static int continue_store_activity (struct StoreActivity *sa, int call_continue)
 Continue processing the sa.
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 Called whenever a client is disconnected.
 
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 lookup_it (void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *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_record_lookup().
 
static int check_edit_record_set (void *cls, const struct EditRecordSetMessage *er_msg)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT 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 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 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 int check_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.
 
static void handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.
 
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_PrivateKey *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 enum GNUNET_ErrorCode store_record_set (struct NamestoreClient *nc, const struct GNUNET_CRYPTO_PrivateKey *private_key, const struct RecordSet *rd_set, ssize_t *len)
 
static void handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message.
 
static void handle_zone_to_name_it (void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Zone to name iterator.
 
static enum GNUNET_GenericReturnValue check_zone_to_name (void *cls, const struct ZoneToNameMessage *zis_msg)
 
static void handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME message.
 
static void zone_iterate_proc (void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Process results for zone iteration from database.
 
static void run_zone_iteration_round (struct ZoneIteration *zi, uint64_t limit)
 Perform the next round of the zone iteration.
 
static enum GNUNET_GenericReturnValue check_iteration_start (void *cls, const struct ZoneIterationStartMessage *zis_msg)
 
static void handle_iteration_start (void *cls, const struct ZoneIterationStartMessage *zis_msg)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START message.
 
static void handle_iteration_stop (void *cls, const struct ZoneIterationStopMessage *zis_msg)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP message.
 
static void handle_iteration_next (void *cls, const struct ZoneIterationNextMessage *zis_msg)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT message.
 
static void monitor_unblock (struct ZoneMonitor *zm)
 Function called when the monitor is ready for more data, and we should thus unblock PUT operations that were blocked on the monitor not being ready.
 
static void monitor_sync (struct ZoneMonitor *zm)
 Send 'sync' message to zone monitor, we're now in sync.
 
static void monitor_iteration_next (void *cls)
 Obtain the next datum during the zone monitor's zone initial iteration.
 
static void monitor_iterate_cb (void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 A GNUNET_NAMESTORE_RecordIterator for monitors.
 
static enum GNUNET_GenericReturnValue check_monitor_start (void *cls, const struct ZoneMonitorStartMessage *zis_msg)
 
static void handle_monitor_start (void *cls, const struct ZoneMonitorStartMessage *zis_msg)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START message.
 
static void handle_monitor_next (void *cls, const struct ZoneMonitorNextMessage *nm)
 Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT message.
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
 Process namestore requests.
 
 GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "namestore", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(record_store, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE, struct RecordStoreMessage, NULL), GNUNET_MQ_hd_var_size(edit_record_set, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT, struct EditRecordSetMessage, NULL), GNUNET_MQ_hd_var_size(edit_record_set_cancel, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL, struct EditRecordSetCancelMessage, NULL), GNUNET_MQ_hd_var_size(record_lookup, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP, struct LabelLookupMessage, NULL), GNUNET_MQ_hd_var_size(zone_to_name, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, struct ZoneToNameMessage, NULL), GNUNET_MQ_hd_var_size(iteration_start, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, struct ZoneIterationStartMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_next, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, struct ZoneIterationNextMessage, NULL), GNUNET_MQ_hd_fixed_size(iteration_stop, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, struct ZoneIterationStopMessage, NULL), GNUNET_MQ_hd_var_size(monitor_start, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START, struct ZoneMonitorStartMessage, NULL), GNUNET_MQ_hd_fixed_size(monitor_next, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT, struct ZoneMonitorNextMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro.
 

Variables

static struct NickCache nick_cache [16]
 We cache nick records to reduce DB load.
 
static const struct GNUNET_CRYPTO_PrivateKey zero
 Public key of all zeros.
 
static const struct GNUNET_CONFIGURATION_HandleGSN_cfg
 Configuration handle.
 
static struct GNUNET_STATISTICS_Handlestatistics
 Handle to the statistics service.
 
static char * db_lib_name
 Name of the database plugin.
 
struct GNUNET_NAMESTORE_PluginFunctionsGSN_database
 Database handle for service.
 
static struct ZoneMonitormonitor_head
 First active zone monitor.
 
static struct ZoneMonitormonitor_tail
 Last active zone monitor.
 
static struct StoreActivitysa_head
 Head of DLL of monitor-blocked store activities.
 
static struct StoreActivitysa_tail
 Tail of DLL of monitor-blocked store activities.
 
static struct GNUNET_NotificationContextmonitor_nc
 Notification context shared by all monitors.
 
static int return_orphaned
 Returned orphaned records?
 

Detailed Description

namestore for the GNUnet naming system

Author
Matthias Wachs
Christian Grothoff

Definition in file gnunet-service-namestore.c.

Macro Definition Documentation

◆ LOG_STRERROR_FILE

#define LOG_STRERROR_FILE (   kind,
  syscall,
  filename 
)     GNUNET_log_from_strerror_file (kind, "util", syscall, filename)

Definition at line 35 of file gnunet-service-namestore.c.

57{
61 struct ZoneIteration *next;
62
66 struct ZoneIteration *prev;
67
71 struct NamestoreClient *nc;
72
76 struct GNUNET_GNSRECORD_Data *nick;
77
81 struct GNUNET_CRYPTO_PrivateKey zone;
82
87
95 uint64_t seq;
96
100 uint32_t request_id;
101
109 uint32_t offset;
110
116 int send_end;
117};
118
122struct NamestoreClient
123{
128
133
137 char *db_lib_name;
138
142 struct GNUNET_MQ_Handle *mq;
143
148 struct ZoneIteration *op_head;
149
154 struct ZoneIteration *op_tail;
155};
156
157
161struct ZoneMonitor
162{
166 struct ZoneMonitor *next;
167
171 struct ZoneMonitor *prev;
172
176 struct NamestoreClient *nc;
177
182
187
192
197
202
210 uint64_t seq;
211
216 uint64_t limit;
217
224 uint64_t iteration_cnt;
225
230
234 int run_again;
235
242 int sa_waiting;
243};
244
245
250struct StoreActivity
251{
255 struct StoreActivity *next;
256
260 struct StoreActivity *prev;
261
265 struct NamestoreClient *nc;
266
270 uint32_t rid;
271
275 uint16_t rd_set_pos;
276
280 uint16_t rd_set_count;
281
286
291 const struct RecordSet *rs;
292
296 struct ZoneMonitor *zm_pos;
297
298};
299
300
304struct NickCache
305{
310
315
320};
321
325static struct NickCache nick_cache[NC_SIZE];
326
330static const struct GNUNET_CRYPTO_PrivateKey zero;
331
335static const struct GNUNET_CONFIGURATION_Handle *GSN_cfg;
336
341
345static char *db_lib_name;
346
351
352
356static struct ZoneMonitor *monitor_head;
357
361static struct ZoneMonitor *monitor_tail;
362
366static struct StoreActivity *sa_head;
367
371static struct StoreActivity *sa_tail;
372
377
381static int return_orphaned;
382
388static void
389cleanup_task (void *cls)
390{
391 (void) cls;
392 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n");
393 if (NULL != monitor_nc)
394 {
396 monitor_nc = NULL;
397 }
398 if (NULL != statistics)
399 {
401 statistics = NULL;
402 }
405 db_lib_name = NULL;
406}
407
408
414static void
416{
418 GNUNET_free (sa);
419}
420
421
434static void
435lookup_nick_it (void *cls,
436 uint64_t seq,
437 const char *editor_hint,
438 const struct GNUNET_CRYPTO_PrivateKey *private_key,
439 const char *label,
440 unsigned int rd_count,
441 const struct GNUNET_GNSRECORD_Data *rd)
442{
443 struct GNUNET_GNSRECORD_Data **res = cls;
444
445 (void) private_key;
446 GNUNET_assert (0 != seq);
447 if (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT))
448 {
449 GNUNET_break (0);
450 return;
451 }
452 for (unsigned int c = 0; c < rd_count; c++)
453 {
455 {
456 (*res) =
457 GNUNET_malloc (rd[c].data_size + sizeof(struct GNUNET_GNSRECORD_Data));
458 (*res)->data = &(*res)[1];
459 GNUNET_memcpy ((void *) (*res)->data, rd[c].data, rd[c].data_size);
460 (*res)->data_size = rd[c].data_size;
461 (*res)->expiration_time = rd[c].expiration_time;
462 (*res)->flags = rd[c].flags;
463 (*res)->record_type = GNUNET_GNSRECORD_TYPE_NICK;
464 return;
465 }
466 }
467 (*res) = NULL;
468}
469
470
477static void
478cache_nick (const struct GNUNET_CRYPTO_PrivateKey *zone,
479 const struct GNUNET_GNSRECORD_Data *nick)
480{
481 struct NickCache *oldest;
482
483 oldest = NULL;
484 for (unsigned int i = 0; i < NC_SIZE; i++)
485 {
486 struct NickCache *pos = &nick_cache[i];
487
488 if ((NULL == oldest) ||
490 oldest = pos;
491 if (0 == GNUNET_memcmp (zone, &pos->zone))
492 {
493 oldest = pos;
494 break;
495 }
496 }
497 GNUNET_free (oldest->rd);
498 oldest->zone = *zone;
499 if (NULL != nick)
500 {
501 oldest->rd = GNUNET_malloc (sizeof(*nick) + nick->data_size);
502 *oldest->rd = *nick;
503 oldest->rd->data = &oldest->rd[1];
504 memcpy (&oldest->rd[1], nick->data, nick->data_size);
505 }
506 else
507 {
508 oldest->rd = NULL;
509 }
511}
512
513
521static struct GNUNET_GNSRECORD_Data *
522get_nick_record (const struct GNUNET_CRYPTO_PrivateKey *zone)
523{
525 struct GNUNET_GNSRECORD_Data *nick;
526 int res;
527
528 /* check cache first */
529 for (unsigned int i = 0; i < NC_SIZE; i++)
530 {
531 struct NickCache *pos = &nick_cache[i];
532 if ((NULL != pos->rd) && (0 == GNUNET_memcmp (zone, &pos->zone)))
533 {
534 if (NULL == pos->rd)
535 return NULL;
536 nick = GNUNET_malloc (sizeof(*nick) + pos->rd->data_size);
537 *nick = *pos->rd;
538 nick->data = &nick[1];
539 memcpy (&nick[1], pos->rd->data, pos->rd->data_size);
541 return nick;
542 }
543 }
544
545 nick = NULL;
547 zone,
550 &nick);
551 if ((GNUNET_OK != res) || (NULL == nick))
552 {
553#if ! defined(GNUNET_CULL_LOGGING)
554 static int do_log = GNUNET_LOG_CALL_STATUS;
555
556 if (0 == do_log)
558 "namestore",
559 __FILE__,
560 __FUNCTION__,
561 __LINE__);
562 if (1 == do_log)
563 {
566 "No nick name set for zone `%s'\n",
568 }
569#endif
570 /* update cache */
571 cache_nick (zone, NULL);
572 return NULL;
573 }
574
575 /* update cache */
576 cache_nick (zone, nick);
577 return nick;
578}
579
580
596static void
598 unsigned int rd2_length,
599 const struct GNUNET_GNSRECORD_Data *rd2,
600 unsigned int *rdc_res,
601 struct GNUNET_GNSRECORD_Data **rd_res)
602{
603 uint64_t latest_expiration;
604 size_t req;
605 char *data;
606 size_t data_offset;
607 struct GNUNET_GNSRECORD_Data *target;
608
609 (*rdc_res) = 1 + rd2_length;
610 if (0 == 1 + rd2_length)
611 {
612 GNUNET_break (0);
613 (*rd_res) = NULL;
614 return;
615 }
616 req = sizeof(struct GNUNET_GNSRECORD_Data) + nick_rd->data_size;
617 for (unsigned int i = 0; i < rd2_length; i++)
618 {
619 const struct GNUNET_GNSRECORD_Data *orig = &rd2[i];
620
621 if (req + sizeof(struct GNUNET_GNSRECORD_Data) + orig->data_size < req)
622 {
623 GNUNET_break (0);
624 (*rd_res) = NULL;
625 return;
626 }
627 req += sizeof(struct GNUNET_GNSRECORD_Data) + orig->data_size;
628 }
629 target = GNUNET_malloc (req);
630 (*rd_res) = target;
631 data = (char *) &target[1 + rd2_length];
632 data_offset = 0;
633 latest_expiration = 0;
634 for (unsigned int i = 0; i < rd2_length; i++)
635 {
636 const struct GNUNET_GNSRECORD_Data *orig = &rd2[i];
637
639 {
640 if ((GNUNET_TIME_absolute_get ().abs_value_us + orig->expiration_time) >
641 latest_expiration)
642 latest_expiration = orig->expiration_time;
643 }
644 else if (orig->expiration_time > latest_expiration)
645 latest_expiration = orig->expiration_time;
646 target[i] = *orig;
647 target[i].data = (void *) &data[data_offset];
648 GNUNET_memcpy (&data[data_offset], orig->data, orig->data_size);
649 data_offset += orig->data_size;
650 }
651 /* append nick */
652 target[rd2_length] = *nick_rd;
653 /* Mark as supplemental */
654 target[rd2_length].flags = nick_rd->flags | GNUNET_GNSRECORD_RF_SUPPLEMENTAL;
655 target[rd2_length].expiration_time = latest_expiration;
656 target[rd2_length].data = (void *) &data[data_offset];
657 GNUNET_memcpy (&data[data_offset], nick_rd->data, nick_rd->data_size);
658 data_offset += nick_rd->data_size;
659 GNUNET_assert (req == (sizeof(struct GNUNET_GNSRECORD_Data)) * (*rdc_res)
660 + data_offset);
661}
662
663
676static int
678 uint32_t request_id,
679 const struct
680 GNUNET_CRYPTO_PrivateKey *zone_key,
681 const char *name,
682 unsigned int rd_count,
683 const struct GNUNET_GNSRECORD_Data *rd,
685{
686 struct GNUNET_MQ_Envelope *env;
687 struct RecordResultMessage *zir_msg;
688 struct GNUNET_GNSRECORD_Data *nick;
690 struct GNUNET_GNSRECORD_Data rd_nf[rd_count];
691 struct GNUNET_TIME_Absolute block_exp;
692 unsigned int res_count;
693 unsigned int rd_nf_count;
694 size_t name_len;
695 size_t key_len;
696 ssize_t rd_ser_len;
697 char *name_tmp;
698 char *rd_ser;
699 char *emsg;
700
701 block_exp = GNUNET_TIME_UNIT_ZERO_ABS;
702 nick = get_nick_record (zone_key);
704
706 rd,
707 rd_count,
708 rd_nf,
709 &rd_nf_count,
710 &block_exp,
711 filter,
712 &emsg))
713 {
714 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
715 GNUNET_free (emsg);
716 GNUNET_assert (0);
717 }
718
723 if ((NULL != nick) && (0 != strcmp (name, GNUNET_GNS_EMPTY_LABEL_AT)))
724 {
725 nick->flags =
727 merge_with_nick_records (nick, rd_nf_count, rd_nf, &res_count, &res);
728 }
729 else
730 {
731 res_count = rd_nf_count;
732 res = (struct GNUNET_GNSRECORD_Data *) rd_nf;
733 }
734 if (NULL != nick)
735 GNUNET_free (nick);
736
737 if (0 == res_count)
738 {
739 if (rd_nf != res)
741 return 0;
742 }
744
745
746 name_len = strlen (name) + 1;
747 rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res);
748 if (rd_ser_len < 0)
749 {
750 if (rd_nf != res)
752 GNUNET_break (0);
754 return 0;
755 }
756 if (((size_t) rd_ser_len) >= UINT16_MAX - name_len - sizeof(*zir_msg))
757 {
758 if (rd_nf != res)
760 GNUNET_break (0);
762 return 0;
763 }
764 key_len = GNUNET_CRYPTO_private_key_get_length (zone_key);
765 env = GNUNET_MQ_msg_extra (zir_msg,
766 name_len + rd_ser_len + key_len,
768 zir_msg->gns_header.r_id = htonl (request_id);
769 zir_msg->name_len = htons (name_len);
770 zir_msg->rd_count = htons (res_count);
771 zir_msg->rd_len = htons ((uint16_t) rd_ser_len);
772 zir_msg->key_len = htons (key_len);
774 &zir_msg[1],
775 key_len);
776 zir_msg->expire = GNUNET_TIME_absolute_hton (block_exp);
777 name_tmp = (char *) &zir_msg[1] + key_len;
778 GNUNET_memcpy (name_tmp, name, name_len);
779 rd_ser = &name_tmp[name_len];
781 rd_ser_len ==
782 GNUNET_GNSRECORD_records_serialize (res_count, res, rd_ser_len, rd_ser));
784 "Sending RECORD_RESULT message with %u records\n",
785 res_count);
787 "Record sets sent to clients",
788 1,
789 GNUNET_NO);
790 GNUNET_MQ_send (nc->mq, env);
791 if (rd_nf != res)
793 return res_count;
794}
795
796
804static void
806 enum GNUNET_ErrorCode ec,
807 uint32_t rid)
808{
809 struct GNUNET_MQ_Envelope *env;
810 struct NamestoreResponseMessage *rcr_msg;
811
812 GNUNET_assert (NULL != nc);
814 "Sending GENERIC_RESPONSE message\n");
816 "Store requests completed",
817 1,
818 GNUNET_NO);
819 env = GNUNET_MQ_msg (rcr_msg,
821 rcr_msg->gns_header.r_id = htonl (rid);
822 rcr_msg->ec = htonl (ec);
823 GNUNET_MQ_send (nc->mq, env);
824}
825
826
833static void
835{
836 struct GNUNET_MQ_Envelope *env;
837 struct GNUNET_NAMESTORE_Header *em;
838
840 if (! zi->send_end)
841 return;
842 /* send empty response to indicate end of list */
844 em->r_id = htonl (zi->request_id);
845 GNUNET_MQ_send (zi->nc->mq, env);
846
848 GNUNET_free (zi);
849}
850
851
857static void
858warn_monitor_slow (void *cls)
859{
860 struct ZoneMonitor *zm = cls;
861
863 "No response from monitor since %s\n",
864 GNUNET_STRINGS_absolute_time_to_string (zm->sa_waiting_start));
867 zm);
868}
869
870
876static int
878 int call_continue)
879{
880 const struct RecordSet *rd_set = sa->rs;
881 unsigned int rd_count;
882 size_t name_len;
883 size_t rd_ser_len;
884 const char *name;
885 const char *rd_ser;
886 const char *buf;
887
888 buf = (const char *) &sa[1];
889 for (int i = sa->rd_set_pos; i < sa->rd_set_count; i++)
890 {
891 rd_set = (struct RecordSet *) buf;
892 name_len = ntohs (rd_set->name_len);
893 rd_count = ntohs (rd_set->rd_count);
894 rd_ser_len = ntohs (rd_set->rd_len);
895 name = (const char *) &rd_set[1];
896 buf += sizeof (struct RecordSet) + name_len + rd_ser_len;
897 rd_ser = &name[name_len];
898 {
900
901 /* We did this before, must succeed again */
903 GNUNET_OK ==
905 rd));
906
908 "Checking monitors watching for `%s'\n",
909 name);
910 for (struct ZoneMonitor *zm = sa->zm_pos; NULL != zm; zm = sa->zm_pos)
911 {
912 if ((0 != GNUNET_memcmp (&sa->private_key, &zm->zone)) &&
913 (0 != GNUNET_memcmp (&zm->zone, &zero)))
914 {
915 sa->zm_pos = zm->next; /* not interesting to this monitor */
916 continue;
917 }
918 if (zm->limit == zm->iteration_cnt)
919 {
920 zm->sa_waiting = GNUNET_YES;
921 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
922 if (NULL != zm->sa_wait_warning)
923 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
924 zm->sa_wait_warning =
927 zm);
929 "Monitor is blocking client for `%s'\n",
930 name);
931 return GNUNET_NO; /* blocked on zone monitor */
932 }
934 "Notifying monitor about changes under label `%s'\n",
935 name);
937 0,
938 &sa->private_key,
939 name,
940 rd_count,
941 rd,
942 zm->filter))
943 zm->limit--;
944 sa->zm_pos = zm->next;
945 }
946 sa->rd_set_pos++;
947 }
948 }
949 if (GNUNET_YES == call_continue)
953 return GNUNET_OK;
954}
955
956
965static void
966client_disconnect_cb (void *cls,
967 struct GNUNET_SERVICE_Client *client,
968 void *app_ctx)
969{
970 struct NamestoreClient *nc = app_ctx;
971 struct ZoneIteration *no;
972 struct StoreActivity *sa = sa_head;
973 struct StoreActivity *sn;
974
975 (void) cls;
976 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
977 for (struct ZoneMonitor *zm = monitor_head; NULL != zm; zm = zm->next)
978 {
979 if (nc != zm->nc)
980 continue;
982 if (NULL != zm->task)
983 {
985 zm->task = NULL;
986 }
987 if (NULL != zm->sa_wait_warning)
988 {
989 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
990 zm->sa_wait_warning = NULL;
991 }
992 for (sa = sa_head; NULL != sa; sa = sn)
993 {
994 sn = sa->next;
995 if (zm == sa->zm_pos)
996 {
997 sa->zm_pos = zm->next;
998 /* this may free sa */
1000 }
1001 }
1002 GNUNET_free (zm);
1003 break;
1004 }
1005 sa = sa_head;
1006 while (NULL != sa)
1007 {
1008 if (nc != sa->nc)
1009 {
1010 sa = sa->next;
1011 continue;
1012 }
1013 sn = sa->next;
1015 sa = sn;
1016 }
1017 while (NULL != (no = nc->op_head))
1018 {
1019 GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no);
1020 GNUNET_free (no);
1021 }
1022 GNUNET_break (NULL == GNUNET_PLUGIN_unload (nc->db_lib_name,
1023 nc->GSN_database));
1024 GNUNET_free (nc->db_lib_name);
1025 GNUNET_free (nc);
1026}
1027
1028
1037static void *
1038client_connect_cb (void *cls,
1039 struct GNUNET_SERVICE_Client *client,
1040 struct GNUNET_MQ_Handle *mq)
1041{
1042 struct NamestoreClient *nc;
1043 char *database;
1044
1045 (void) cls;
1046 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1047 nc = GNUNET_new (struct NamestoreClient);
1048 nc->client = client;
1049 nc->mq = mq;
1050 /* Loading database plugin */
1052 "namestore",
1053 "database",
1054 &database))
1055 {
1056 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
1057 GNUNET_free (nc);
1058 return NULL;
1059 }
1061 "Loading %s\n",
1062 db_lib_name);
1065 (void *) GSN_cfg);
1066 GNUNET_free (database);
1067 if (NULL == nc->GSN_database)
1068 {
1070 "Could not load database backend `%s'\n",
1071 db_lib_name);
1072 GNUNET_free (nc);
1073 return NULL;
1074 }
1075 nc->db_lib_name = GNUNET_strdup (db_lib_name);
1077 "Loaded %s\n",
1078 db_lib_name);
1079 return nc;
1080}
1081
1082
1087{
1091 const char *label;
1092
1096 char *editor_hint;
1097
1101 char *res_rd;
1102
1107
1111 int found;
1112
1117
1121 unsigned int res_rd_count;
1122
1126 ssize_t rd_ser_len;
1127};
1128
1129
1142static void
1143lookup_it (void *cls,
1144 uint64_t seq,
1145 const char *editor_hint,
1146 const struct GNUNET_CRYPTO_PrivateKey *private_key,
1147 const char *label,
1148 unsigned int rd_count_nf,
1149 const struct GNUNET_GNSRECORD_Data *rd_nf)
1150{
1151 struct RecordLookupContext *rlc = cls;
1152 struct GNUNET_GNSRECORD_Data rd[rd_count_nf];
1153 struct GNUNET_TIME_Absolute block_exp;
1154 unsigned int rd_count = 0;
1155 char *emsg;
1156
1157 (void) private_key;
1158 GNUNET_assert (0 != seq);
1159 if (0 != strcmp (label, rlc->label))
1160 return;
1161 rlc->found = GNUNET_YES;
1162 if (NULL == rlc->editor_hint)
1163 rlc->editor_hint = GNUNET_strdup (editor_hint);
1165 rd_nf,
1166 rd_count_nf,
1167 rd,
1168 &rd_count,
1169 &block_exp,
1170 rlc->filter,
1171 &emsg))
1172 {
1173 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
1174 GNUNET_free (emsg);
1175 GNUNET_assert (0);
1176 }
1177
1178 if (0 == rd_count)
1179 {
1180 rlc->rd_ser_len = 0;
1181 rlc->res_rd_count = 0;
1182 rlc->res_rd = NULL;
1183 return;
1184 }
1185 if ((NULL != rlc->nick) && (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT)))
1186 {
1187 /* Merge */
1188 struct GNUNET_GNSRECORD_Data *rd_res;
1189 unsigned int rdc_res;
1190
1191 rd_res = NULL;
1192 rdc_res = 0;
1195 merge_with_nick_records (rlc->nick, rd_count, rd, &rdc_res, &rd_res);
1196 rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rdc_res, rd_res);
1197 if (rlc->rd_ser_len < 0)
1198 {
1199 GNUNET_break (0);
1200 GNUNET_free (rd_res);
1201 rlc->found = GNUNET_NO;
1202 rlc->rd_ser_len = 0;
1203 return;
1204 }
1205 rlc->res_rd_count = rdc_res;
1206 rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len);
1208 rd_res,
1209 rlc->rd_ser_len,
1210 rlc->res_rd))
1211 {
1212 GNUNET_break (0);
1213 GNUNET_free (rlc->res_rd);
1214 rlc->res_rd = NULL;
1215 rlc->res_rd_count = 0;
1216 rlc->rd_ser_len = 0;
1217 GNUNET_free (rd_res);
1218 rlc->found = GNUNET_NO;
1219 return;
1220 }
1221 GNUNET_free (rd_res);
1222 GNUNET_free (rlc->nick);
1223 rlc->nick = NULL;
1224 }
1225 else
1226 {
1228 if (rlc->rd_ser_len < 0)
1229 {
1230 GNUNET_break (0);
1231 rlc->found = GNUNET_NO;
1232 rlc->rd_ser_len = 0;
1233 return;
1234 }
1235 rlc->res_rd_count = rd_count;
1236 rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len);
1238 rd,
1239 rlc->rd_ser_len,
1240 rlc->res_rd))
1241 {
1242 GNUNET_break (0);
1243 GNUNET_free (rlc->res_rd);
1244 rlc->res_rd = NULL;
1245 rlc->res_rd_count = 0;
1246 rlc->rd_ser_len = 0;
1247 rlc->found = GNUNET_NO;
1248 return;
1249 }
1250 }
1251}
1252
1253
1261static int
1262check_edit_record_set (void *cls, const struct EditRecordSetMessage *er_msg)
1263{
1264 uint16_t name_len;
1265 uint16_t editor_hint_len;
1266 size_t src_size;
1267 size_t key_len;
1268
1269 (void) cls;
1270 name_len = ntohs (er_msg->label_len);
1271 editor_hint_len = ntohs (er_msg->editor_hint_len);
1272 key_len = ntohs (er_msg->key_len);
1273 src_size = ntohs (er_msg->gns_header.header.size);
1274 if (name_len + editor_hint_len + key_len != src_size - sizeof(struct
1276 {
1277 GNUNET_break (0);
1278 return GNUNET_SYSERR;
1279 }
1280 return GNUNET_OK;
1281}
1282
1283
1290static void
1291handle_edit_record_set (void *cls, const struct EditRecordSetMessage *er_msg)
1292{
1293 struct GNUNET_CRYPTO_PrivateKey zone;
1294 struct NamestoreClient *nc = cls;
1295 struct GNUNET_MQ_Envelope *env;
1296 struct EditRecordSetResponseMessage *rer_msg;
1297 struct RecordLookupContext rlc;
1298 const char *name_tmp;
1299 const char *editor_hint;
1300 char *conv_name;
1301 uint16_t name_len;
1302 uint16_t old_editor_hint_len;
1303 int res;
1304 size_t key_len;
1305 size_t kb_read;
1306
1307 key_len = ntohs (er_msg->key_len);
1308 name_len = ntohs (er_msg->label_len);
1309 if ((GNUNET_SYSERR ==
1311 key_len,
1312 &zone,
1313 &kb_read)) ||
1314 (kb_read != key_len))
1315 {
1317 "Error reading private key\n");
1319 return;
1320 }
1321 name_tmp = (const char *) &er_msg[1] + key_len;
1322 editor_hint = (const char *) name_tmp + name_len;
1325 "Received NAMESTORE_RECORD_SET_EDIT message for name `%s'\n",
1326 name_tmp);
1327
1328 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1329 if (NULL == conv_name)
1330 {
1332 "Error converting name `%s'\n",
1333 name_tmp);
1335 return;
1336 }
1337 name_len = strlen (conv_name) + 1;
1338 rlc.editor_hint = NULL;
1339 rlc.label = conv_name;
1341 "Looking up without filter\n");
1343 rlc.found = GNUNET_NO;
1344 rlc.res_rd_count = 0;
1345 rlc.res_rd = NULL;
1346 rlc.rd_ser_len = 0;
1347 rlc.nick = get_nick_record (&zone);
1348 res = nc->GSN_database->edit_records (nc->GSN_database->cls,
1350 &zone,
1351 conv_name,
1352 &lookup_it,
1353 &rlc);
1354
1355 old_editor_hint_len = 0;
1356 if (NULL != rlc.editor_hint)
1357 old_editor_hint_len = strlen (rlc.editor_hint) + 1;
1358 env =
1359 GNUNET_MQ_msg_extra (rer_msg,
1360 rlc.rd_ser_len + old_editor_hint_len,
1362 ;
1363 rer_msg->editor_hint_len = htons (old_editor_hint_len);
1364 rer_msg->gns_header.r_id = er_msg->gns_header.r_id;
1365 rer_msg->rd_count = htons (rlc.res_rd_count);
1366 rer_msg->rd_len = htons (rlc.rd_ser_len);
1367 if (GNUNET_YES == rlc.found)
1368 rer_msg->ec = htons (GNUNET_EC_NONE);
1369 else if (GNUNET_SYSERR == res)
1370 rer_msg->ec = htons (GNUNET_EC_NAMESTORE_UNKNOWN);
1371 else
1372 rer_msg->ec = htons (GNUNET_EC_NAMESTORE_NO_RESULTS);
1373 GNUNET_memcpy (&rer_msg[1], rlc.editor_hint, old_editor_hint_len);
1374 GNUNET_memcpy ((char*) &rer_msg[1] + old_editor_hint_len, rlc.res_rd,
1375 rlc.rd_ser_len);
1376 GNUNET_MQ_send (nc->mq, env);
1378 GNUNET_free (rlc.res_rd);
1379 GNUNET_free (conv_name);
1380}
1381
1382
1390static int
1391check_edit_record_set_cancel (void *cls, const struct
1393{
1394 uint16_t name_len;
1395 uint16_t editor_hint_len;
1396 uint16_t editor_hint_repl_len;
1397 size_t src_size;
1398 size_t key_len;
1399
1400 (void) cls;
1401 name_len = ntohs (er_msg->label_len);
1402 editor_hint_len = ntohs (er_msg->editor_hint_len);
1403 editor_hint_repl_len = ntohs (er_msg->editor_hint_len);
1404 key_len = ntohs (er_msg->key_len);
1405 src_size = ntohs (er_msg->gns_header.header.size);
1406 if (name_len + editor_hint_len + editor_hint_repl_len + key_len != src_size
1407 - sizeof(struct
1409 {
1410 GNUNET_break (0);
1411 return GNUNET_SYSERR;
1412 }
1413 return GNUNET_OK;
1414}
1415
1416
1423static void
1424handle_edit_record_set_cancel (void *cls, const struct
1426{
1427 struct GNUNET_CRYPTO_PrivateKey zone;
1428 struct NamestoreClient *nc = cls;
1429 struct GNUNET_MQ_Envelope *env;
1430 struct NamestoreResponseMessage *rer_msg;
1431 const char *name_tmp;
1432 const char *editor_hint;
1433 const char *editor_hint_repl;
1434 char *conv_name;
1435 uint16_t name_len;
1436 uint16_t editor_hint_len;
1437 int res;
1438 size_t key_len;
1439 size_t kb_read;
1440
1441 key_len = ntohs (er_msg->key_len);
1442 name_len = ntohs (er_msg->label_len);
1443 editor_hint_len = ntohs (er_msg->editor_hint_len);
1444 if ((GNUNET_SYSERR ==
1446 key_len,
1447 &zone,
1448 &kb_read)) ||
1449 (kb_read != key_len))
1450 {
1452 "Error reading private key\n");
1454 return;
1455 }
1456 name_tmp = (const char *) &er_msg[1] + key_len;
1457 editor_hint = (const char *) name_tmp + name_len;
1458 editor_hint_repl = (const char *) name_tmp + name_len + editor_hint_len;
1461 "Received NAMESTORE_RECORD_SET_EDIT message for name `%s'\n",
1462 name_tmp);
1463
1464 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1465 if (NULL == conv_name)
1466 {
1468 "Error converting name `%s'\n",
1469 name_tmp);
1471 return;
1472 }
1473 name_len = strlen (conv_name) + 1;
1475 "Clearing editor hint\n");
1476 res = nc->GSN_database->clear_editor_hint (nc->GSN_database->cls,
1477 editor_hint,
1478 editor_hint_repl,
1479 &zone,
1480 conv_name);
1482 "Clearing editor hint %s\n", (GNUNET_SYSERR == res) ? "failed." :
1483 "successful.");
1484
1485 env =
1486 GNUNET_MQ_msg (rer_msg,
1488 rer_msg->gns_header.r_id = er_msg->gns_header.r_id;
1489 rer_msg->ec = htons ((GNUNET_OK == res) ? GNUNET_EC_NONE :
1491 GNUNET_MQ_send (nc->mq, env);
1492 GNUNET_free (conv_name);
1493}
1494
1495
1503static int
1504check_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
1505{
1506 uint32_t name_len;
1507 size_t src_size;
1508 size_t key_len;
1509
1510 (void) cls;
1511 name_len = ntohs (ll_msg->label_len);
1512 key_len = ntohs (ll_msg->key_len);
1513 src_size = ntohs (ll_msg->gns_header.header.size);
1514 if (name_len + key_len != src_size - sizeof(struct LabelLookupMessage))
1515 {
1516 GNUNET_break (0);
1517 return GNUNET_SYSERR;
1518 }
1519 return GNUNET_OK;
1520}
1521
1522
1529static void
1530handle_record_lookup (void *cls, const struct LabelLookupMessage *ll_msg)
1531{
1532 struct GNUNET_CRYPTO_PrivateKey zone;
1533 struct NamestoreClient *nc = cls;
1534 struct GNUNET_MQ_Envelope *env;
1535 struct LabelLookupResponseMessage *llr_msg;
1536 struct RecordLookupContext rlc;
1537 const char *name_tmp;
1538 char *res_name;
1539 char *conv_name;
1540 uint32_t name_len;
1541 int res;
1542 size_t key_len;
1543 size_t kb_read;
1544
1545 key_len = ntohs (ll_msg->key_len);
1546 if ((GNUNET_SYSERR ==
1548 key_len,
1549 &zone,
1550 &kb_read)) ||
1551 (kb_read != key_len))
1552 {
1554 "Error reading private key\n");
1556 return;
1557 }
1558 name_tmp = (const char *) &ll_msg[1] + key_len;
1561 "Received NAMESTORE_RECORD_LOOKUP message for name `%s'\n",
1562 name_tmp);
1563
1564 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1565 if (NULL == conv_name)
1566 {
1568 "Error converting name `%s'\n",
1569 name_tmp);
1571 return;
1572 }
1573 name_len = strlen (conv_name) + 1;
1574 rlc.editor_hint = NULL;
1575 rlc.label = conv_name;
1577 "Looking up with filter %u\n", ntohs (ll_msg->filter));
1578 rlc.filter = ntohs (ll_msg->filter);
1579 rlc.found = GNUNET_NO;
1580 rlc.res_rd_count = 0;
1581 rlc.res_rd = NULL;
1582 rlc.rd_ser_len = 0;
1583 rlc.nick = get_nick_record (&zone);
1584 res = nc->GSN_database->lookup_records (nc->GSN_database->cls,
1585 &zone,
1586 conv_name,
1587 &lookup_it,
1588 &rlc);
1589 env =
1590 GNUNET_MQ_msg_extra (llr_msg,
1591 key_len + name_len + rlc.rd_ser_len,
1593 llr_msg->gns_header.r_id = ll_msg->gns_header.r_id;
1594 GNUNET_memcpy (&llr_msg[1], &ll_msg[1], key_len);
1595 llr_msg->key_len = ll_msg->key_len;
1596 llr_msg->name_len = htons (name_len);
1597 llr_msg->rd_count = htons (rlc.res_rd_count);
1598 llr_msg->rd_len = htons (rlc.rd_ser_len);
1599 llr_msg->reserved = htons (0);
1600 res_name = ((char *) &llr_msg[1]) + key_len;
1601 if (GNUNET_YES == rlc.found)
1602 llr_msg->found = htons (GNUNET_YES);
1603 else if (GNUNET_SYSERR == res)
1604 llr_msg->found = htons (GNUNET_SYSERR);
1605 else
1606 llr_msg->found = htons (GNUNET_NO);
1607 GNUNET_memcpy (res_name, conv_name, name_len);
1608 GNUNET_memcpy (&res_name[name_len], rlc.res_rd, rlc.rd_ser_len);
1609 GNUNET_MQ_send (nc->mq, env);
1611 GNUNET_free (rlc.res_rd);
1612 GNUNET_free (conv_name);
1613}
1614
1615
1623static int
1624check_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1625{
1626 size_t msg_size;
1627 size_t min_size_exp;
1628 size_t rd_set_count;
1629 size_t key_len;
1630
1631 (void) cls;
1632 msg_size = ntohs (rp_msg->gns_header.header.size);
1633 rd_set_count = ntohs (rp_msg->rd_set_count);
1634 key_len = ntohs (rp_msg->key_len);
1635
1636 min_size_exp = sizeof(*rp_msg) + key_len + sizeof (struct RecordSet)
1637 * rd_set_count;
1638 if (msg_size < min_size_exp)
1639 {
1640 GNUNET_break (0);
1641 return GNUNET_SYSERR;
1642 }
1643 return GNUNET_OK;
1644}
1645
1646
1648{
1649
1654
1659 int only_tombstone;
1660
1661};
1662
1663
1674static void
1675get_existing_rd_exp (void *cls,
1676 uint64_t seq,
1677 const char *editor_hint,
1678 const struct
1679 GNUNET_CRYPTO_PrivateKey *private_key,
1680 const char *label,
1681 unsigned int rd_count,
1682 const struct GNUNET_GNSRECORD_Data *rd)
1683{
1684 struct LookupExistingRecordsContext *lctx = cls;
1685 struct GNUNET_GNSRECORD_Data rd_pub[rd_count];
1686 unsigned int rd_pub_count;
1687 char *emsg;
1688
1689 if ((1 == rd_count) &&
1691 {
1692 /* This record set contains only a tombstone! */
1693 lctx->only_tombstone = GNUNET_YES;
1694 }
1695 if (GNUNET_OK !=
1697 rd,
1698 rd_count,
1699 rd_pub,
1700 &rd_pub_count,
1701 &lctx->exp,
1703 &emsg))
1704 {
1706 "%s\n", emsg);
1707 GNUNET_free (emsg);
1708 }
1709}
1710
1711
1712static enum GNUNET_ErrorCode
1714 const struct GNUNET_CRYPTO_PrivateKey *private_key,
1715 const struct RecordSet *rd_set,
1716 ssize_t *len)
1717{
1718 size_t name_len;
1719 size_t rd_ser_len;
1720 const char *name_tmp;
1721 const char *rd_ser;
1722 char *emsg;
1723 char *conv_name;
1724 unsigned int rd_count;
1725 int res;
1726 enum GNUNET_ErrorCode ec;
1727 struct GNUNET_TIME_Absolute new_block_exp;
1728 struct LookupExistingRecordsContext lctx;
1729 *len = sizeof (struct RecordSet);
1730
1731 ec = GNUNET_EC_NONE;
1734 new_block_exp = GNUNET_TIME_UNIT_ZERO_ABS;
1735 name_len = ntohs (rd_set->name_len);
1736 *len += name_len;
1737 rd_count = ntohs (rd_set->rd_count);
1738 rd_ser_len = ntohs (rd_set->rd_len);
1739 *len += rd_ser_len;
1740 name_tmp = (const char *) &rd_set[1];
1741 rd_ser = &name_tmp[name_len];
1742 {
1744
1745 /* Extracting and converting private key */
1746 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1747 if (NULL == conv_name)
1748 {
1750 "Error normalizing name `%s'\n",
1751 name_tmp);
1753 }
1754
1755 /* Check name for validity */
1756 if (GNUNET_OK != GNUNET_GNSRECORD_label_check (conv_name, &emsg))
1757 {
1759 "Label invalid: `%s'\n",
1760 emsg);
1761 GNUNET_free (emsg);
1762 GNUNET_free (conv_name);
1764 }
1765
1766 if (GNUNET_OK !=
1768 rd))
1769 {
1770 GNUNET_free (conv_name);
1772 }
1773
1775 "Well-formed store requests received",
1776 1,
1777 GNUNET_NO);
1779 "Creating %u records for name `%s'\n",
1780 (unsigned int) rd_count,
1781 conv_name);
1782 if ((0 == rd_count) &&
1783 (GNUNET_NO == nc->GSN_database->lookup_records (nc->GSN_database->cls,
1784 private_key,
1785 conv_name,
1787 &lctx)))
1788 {
1789 /* This name does not exist, so cannot be removed */
1791 "Name `%s' does not exist, no deletion required\n",
1792 conv_name);
1793 res = GNUNET_NO;
1795 }
1796 else
1797 {
1798 /* remove "NICK" records, unless this is for the
1799 #GNUNET_GNS_EMPTY_LABEL_AT label
1800 We may need one additional record later for tombstone.
1801 FIXME: Since we must normalize the record set (check for
1802 consistency etc) we have to iterate the set twice.
1803 May be inefficient.
1804 We cannot really move the nick caching into GNSRECORD.
1805 */
1806 struct GNUNET_GNSRECORD_Data rd_clean[GNUNET_NZL (rd_count)];
1807 struct GNUNET_GNSRECORD_Data rd_nf[GNUNET_NZL (rd_count) + 1];
1808 unsigned int rd_clean_off;
1809 unsigned int rd_nf_count;
1810 int have_nick;
1811
1812 rd_clean_off = 0;
1813 have_nick = GNUNET_NO;
1814 for (unsigned int i = 0; i < rd_count; i++)
1815 {
1816 rd_clean[rd_clean_off] = rd[i];
1817
1818 if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) ||
1820 rd_clean_off++;
1821
1822 if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) &&
1824 {
1825 cache_nick (private_key, &rd[i]);
1826 have_nick = GNUNET_YES;
1827 }
1828 }
1829 if (GNUNET_OK !=
1831 rd_clean,
1832 rd_clean_off,
1833 rd_nf,
1834 &rd_nf_count,
1835 &new_block_exp,
1837 &emsg))
1838 {
1839 GNUNET_free (conv_name);
1841 "Error normalizing record set: `%s'\n",
1842 emsg);
1843 GNUNET_free (emsg);
1845 }
1847 "%u/%u records before tombstone\n", rd_nf_count,
1848 rd_clean_off);
1849 /*
1850 * If existing_block_exp is 0, then there was no record set
1851 * and no tombstone.
1852 * Otherwise, if the existing block expiration is after the
1853 * new block expiration would be, we need to add a tombstone
1854 * or update it.
1855 */
1856 if (GNUNET_TIME_absolute_cmp (new_block_exp, <=, lctx.exp))
1857 {
1858 rd_nf[rd_nf_count].record_type = GNUNET_GNSRECORD_TYPE_TOMBSTONE;
1859 rd_nf[rd_nf_count].expiration_time =
1860 lctx.exp.abs_value_us;
1861 rd_nf[rd_nf_count].data = NULL;
1862 rd_nf[rd_nf_count].data_size = 0;
1863 rd_nf[rd_nf_count].flags = GNUNET_GNSRECORD_RF_PRIVATE
1865 rd_nf_count++;
1866 }
1867 if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) &&
1868 (GNUNET_NO == have_nick))
1869 {
1870 cache_nick (private_key, NULL);
1871 }
1872 res = nc->GSN_database->store_records (nc->GSN_database->cls,
1873 private_key,
1874 conv_name,
1875 rd_nf_count,
1876 rd_nf);
1877 /* If after a store there is only a TOMBSTONE left, and
1878 * there was >1 record under this label found (the tombstone; indicated
1879 * through res != GNUNET_NO) then we should return "NOT FOUND" == GNUNET_NO
1880 */
1881 if ((GNUNET_SYSERR != res) &&
1882 (0 == rd_count) &&
1883 (1 == rd_nf_count) &&
1885 (GNUNET_YES == lctx.only_tombstone))
1886 {
1888 "Client tried to remove non-existent record\n");
1890 }
1891 }
1892
1893 if (GNUNET_SYSERR == res)
1894 {
1895 /* store not successful, no need to tell monitors */
1896 GNUNET_free (conv_name);
1898 }
1899 }
1900 return ec;
1901}
1902
1903
1910static void
1911handle_record_store (void *cls, const struct RecordStoreMessage *rp_msg)
1912{
1913 struct GNUNET_CRYPTO_PrivateKey zone;
1914 struct NamestoreClient *nc = cls;
1915 uint32_t rid;
1916 uint16_t rd_set_count;
1917 const char *buf;
1918 ssize_t read;
1919 size_t key_len;
1920 size_t kb_read;
1921 size_t rp_msg_len;
1922 size_t rs_len;
1923 size_t rs_off;
1924 struct StoreActivity *sa;
1925 struct RecordSet *rs;
1926 enum GNUNET_ErrorCode res;
1927
1928 key_len = ntohs (rp_msg->key_len);
1929 rp_msg_len = ntohs (rp_msg->gns_header.header.size);
1930 rs_off = sizeof (*rp_msg) + key_len;
1931 rs_len = rp_msg_len - rs_off;
1932 if ((GNUNET_SYSERR ==
1934 key_len,
1935 &zone,
1936 &kb_read)) ||
1937 (kb_read != key_len))
1938 {
1940 "Error reading private key\n");
1942 return;
1943 }
1945 "Received NAMESTORE_RECORD_STORE message\n");
1946 rid = ntohl (rp_msg->gns_header.r_id);
1947 rd_set_count = ntohs (rp_msg->rd_set_count);
1948 buf = (const char *) rp_msg + rs_off;
1949 if (GNUNET_YES == ntohs (rp_msg->single_tx))
1950 nc->GSN_database->begin_tx (nc->GSN_database->cls);
1951 for (int i = 0; i < rd_set_count; i++)
1952 {
1953 rs = (struct RecordSet *) buf;
1954 res = store_record_set (nc, &zone,
1955 rs, &read);
1956 if (GNUNET_EC_NONE != res)
1957 {
1958 if (GNUNET_YES == ntohs (rp_msg->single_tx))
1959 nc->GSN_database->rollback_tx (nc->GSN_database->cls);
1960 send_store_response (nc, res, rid);
1962 return;
1963 }
1964 buf += read;
1965 }
1966 if (GNUNET_YES == ntohs (rp_msg->single_tx))
1967 nc->GSN_database->commit_tx (nc->GSN_database->cls);
1968 sa = GNUNET_malloc (sizeof(struct StoreActivity) + rs_len);
1970 sa->nc = nc;
1971 sa->rs = (struct RecordSet *) &sa[1];
1972 sa->rd_set_count = rd_set_count;
1973 GNUNET_memcpy (&sa[1], (char *) rp_msg + rs_off, rs_len);
1974 sa->rid = rid;
1975 sa->rd_set_pos = 0;
1976 sa->private_key = zone;
1977 sa->zm_pos = monitor_head;
1979}
1980
1981
1986struct ZoneToNameCtx
1987{
1991 struct NamestoreClient *nc;
1992
1996 uint32_t rid;
1997
2003 enum GNUNET_ErrorCode ec;
2004};
2005
2006
2017static void
2018handle_zone_to_name_it (void *cls,
2019 uint64_t seq,
2020 const char *editor_hint,
2021 const struct GNUNET_CRYPTO_PrivateKey *zone_key,
2022 const char *name,
2023 unsigned int rd_count,
2024 const struct GNUNET_GNSRECORD_Data *rd)
2025{
2026 struct ZoneToNameCtx *ztn_ctx = cls;
2027 struct GNUNET_MQ_Envelope *env;
2028 struct ZoneToNameResponseMessage *ztnr_msg;
2029 size_t name_len;
2030 size_t key_len;
2031 ssize_t rd_ser_len;
2032 size_t msg_size;
2033 char *name_tmp;
2034 char *rd_tmp;
2035
2036 GNUNET_assert (0 != seq);
2038 "Found result for zone-to-name lookup: `%s'\n",
2039 name);
2040 ztn_ctx->ec = GNUNET_EC_NONE;
2041 name_len = (NULL == name) ? 0 : strlen (name) + 1;
2043 if (rd_ser_len < 0)
2044 {
2045 GNUNET_break (0);
2046 ztn_ctx->ec = htonl (GNUNET_EC_NAMESTORE_UNKNOWN);
2047 return;
2048 }
2050 msg_size = sizeof(struct ZoneToNameResponseMessage)
2051 + name_len + rd_ser_len + key_len;
2052 if (msg_size >= GNUNET_MAX_MESSAGE_SIZE)
2053 {
2054 GNUNET_break (0);
2056 return;
2057 }
2058 env =
2059 GNUNET_MQ_msg_extra (ztnr_msg,
2060 key_len + name_len + rd_ser_len,
2062 ztnr_msg->gns_header.header.size = htons (msg_size);
2063 ztnr_msg->gns_header.r_id = htonl (ztn_ctx->rid);
2064 ztnr_msg->ec = htonl (ztn_ctx->ec);
2065 ztnr_msg->rd_len = htons (rd_ser_len);
2066 ztnr_msg->rd_count = htons (rd_count);
2067 ztnr_msg->name_len = htons (name_len);
2068 ztnr_msg->key_len = htons (key_len);
2070 &ztnr_msg[1],
2071 key_len);
2072 name_tmp = (char *) &ztnr_msg[1] + key_len;
2073 GNUNET_memcpy (name_tmp, name, name_len);
2074 rd_tmp = &name_tmp[name_len];
2076 rd_ser_len ==
2077 GNUNET_GNSRECORD_records_serialize (rd_count, rd, rd_ser_len, rd_tmp));
2078 ztn_ctx->ec = GNUNET_EC_NONE;
2079 GNUNET_MQ_send (ztn_ctx->nc->mq, env);
2080}
2081
2082
2083static enum GNUNET_GenericReturnValue
2084check_zone_to_name (void *cls,
2085 const struct ZoneToNameMessage *zis_msg)
2086{
2087 return GNUNET_OK;
2088}
2089
2090
2097static void
2098handle_zone_to_name (void *cls, const struct ZoneToNameMessage *ztn_msg)
2099{
2100 struct GNUNET_CRYPTO_PrivateKey zone;
2101 struct GNUNET_CRYPTO_PublicKey value_zone;
2102 struct NamestoreClient *nc = cls;
2103 struct ZoneToNameCtx ztn_ctx;
2104 struct GNUNET_MQ_Envelope *env;
2105 struct ZoneToNameResponseMessage *ztnr_msg;
2106 size_t key_len;
2107 size_t pkey_len;
2108 size_t kb_read;
2109
2110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME message\n");
2111 ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id);
2112 ztn_ctx.nc = nc;
2114 key_len = ntohs (ztn_msg->key_len);
2115 if ((GNUNET_SYSERR ==
2117 key_len,
2118 &zone,
2119 &kb_read)) ||
2120 (kb_read != key_len))
2121 {
2123 "Error parsing private key.\n");
2125 GNUNET_break (0);
2126 return;
2127 }
2128 pkey_len = ntohs (ztn_msg->pkey_len);
2129 if ((GNUNET_SYSERR ==
2131 + key_len,
2132 pkey_len,
2133 &value_zone,
2134 &kb_read)) ||
2135 (kb_read != pkey_len))
2136 {
2138 "Error parsing public key.\n");
2140 GNUNET_break (0);
2141 return;
2142 }
2143 if (GNUNET_SYSERR == nc->GSN_database->zone_to_name (nc->GSN_database->cls,
2144 &zone,
2145 &value_zone,
2147 &ztn_ctx))
2148 {
2149 /* internal error, hang up instead of signalling something
2150 that might be wrong */
2151 GNUNET_break (0);
2153 return;
2154 }
2156 {
2157 /* no result found, send empty response */
2159 "Found no result for zone-to-name lookup.\n");
2160 env = GNUNET_MQ_msg (ztnr_msg,
2162 ztnr_msg->gns_header.r_id = ztn_msg->gns_header.r_id;
2163 ztnr_msg->ec = htonl (GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND);
2164 GNUNET_MQ_send (nc->mq, env);
2165 }
2167}
2168
2169
2175{
2179 struct ZoneIteration *zi;
2180
2184 uint64_t limit;
2185
2189 int run_again;
2190};
2191
2192
2203static void
2204zone_iterate_proc (void *cls,
2205 uint64_t seq,
2206 const char *editor_hint,
2207 const struct GNUNET_CRYPTO_PrivateKey *zone_key,
2208 const char *name,
2209 unsigned int rd_count,
2210 const struct GNUNET_GNSRECORD_Data *rd)
2211{
2212 struct ZoneIterationProcResult *proc = cls;
2213
2214 GNUNET_assert (0 != seq);
2215 if ((NULL == zone_key) && (NULL == name))
2216 {
2217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iteration done\n");
2218 return;
2219 }
2220 if ((NULL == zone_key) || (NULL == name))
2221 {
2222 /* what is this!? should never happen */
2223 GNUNET_break (0);
2224 return;
2225 }
2226 if (0 == proc->limit)
2227 {
2228 /* what is this!? should never happen */
2229 GNUNET_break (0);
2230 return;
2231 }
2232 proc->zi->seq = seq;
2233 if (0 < send_lookup_response_with_filter (proc->zi->nc,
2234 proc->zi->request_id,
2235 zone_key,
2236 name,
2237 rd_count,
2238 rd,
2239 proc->zi->filter))
2240 proc->limit--;
2241 else
2242 proc->run_again = GNUNET_YES;
2243}
2244
2245
2252static void
2254{
2255 struct ZoneIterationProcResult proc;
2258 struct NamestoreClient *nc = zi->nc;
2259
2260 memset (&proc, 0, sizeof(proc));
2262 "Asked to return up to %llu records at position %llu\n",
2263 (unsigned long long) limit,
2264 (unsigned long long) zi->seq);
2265 proc.zi = zi;
2266 proc.limit = limit;
2267 proc.run_again = GNUNET_YES;
2269 while (GNUNET_YES == proc.run_again)
2270 {
2271 proc.run_again = GNUNET_NO;
2273 nc->GSN_database->iterate_records (nc->GSN_database->cls,
2274 (GNUNET_YES ==
2276 &zi->zone))
2277 ? NULL
2278 : &zi->zone,
2279 zi->seq,
2280 proc.limit,
2282 &proc));
2283 }
2287 "NAMESTORE iteration delay (μs/record)",
2289 GNUNET_NO);
2290 if (0 == proc.limit)
2292 "Returned %llu results, more results available\n",
2293 (unsigned long long) limit);
2294 zi->send_end = (0 != proc.limit);
2296}
2297
2298
2299static enum GNUNET_GenericReturnValue
2300check_iteration_start (void *cls,
2301 const struct ZoneIterationStartMessage *zis_msg)
2302{
2303 uint16_t size;
2304 size_t key_len;
2305
2306 size = ntohs (zis_msg->gns_header.header.size);
2307 key_len = ntohs (zis_msg->key_len);
2308
2309 if (size < key_len + sizeof(*zis_msg))
2310 {
2311 GNUNET_break (0);
2312 return GNUNET_SYSERR;
2313 }
2314 return GNUNET_OK;
2315}
2316
2317
2324static void
2325handle_iteration_start (void *cls,
2326 const struct ZoneIterationStartMessage *zis_msg)
2327{
2328 struct GNUNET_CRYPTO_PrivateKey zone;
2329 struct NamestoreClient *nc = cls;
2330 struct ZoneIteration *zi;
2331 size_t key_len;
2332 size_t kb_read;
2333
2335 "Received ZONE_ITERATION_START message\n");
2336 key_len = ntohs (zis_msg->key_len);
2337 zi = GNUNET_new (struct ZoneIteration);
2338 if (0 < key_len)
2339 {
2340 if ((GNUNET_SYSERR ==
2342 key_len,
2343 &zone,
2344 &kb_read)) ||
2345 (kb_read != key_len))
2346 {
2348 GNUNET_free (zi);
2349 return;
2350 }
2351 zi->zone = zone;
2352 }
2353 zi->request_id = ntohl (zis_msg->gns_header.r_id);
2354 zi->filter = ntohs (zis_msg->filter);
2355 zi->offset = 0;
2356 zi->nc = nc;
2357 GNUNET_CONTAINER_DLL_insert (nc->op_head, nc->op_tail, zi);
2359}
2360
2361
2368static void
2369handle_iteration_stop (void *cls,
2370 const struct ZoneIterationStopMessage *zis_msg)
2371{
2372 struct NamestoreClient *nc = cls;
2373 struct ZoneIteration *zi;
2374 uint32_t rid;
2375
2377 "Received ZONE_ITERATION_STOP message\n");
2378 rid = ntohl (zis_msg->gns_header.r_id);
2379 for (zi = nc->op_head; NULL != zi; zi = zi->next)
2380 if (zi->request_id == rid)
2381 break;
2382 if (NULL == zi)
2383 {
2384 GNUNET_break (0);
2386 return;
2387 }
2388 GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, zi);
2389 GNUNET_free (zi);
2391}
2392
2393
2400static void
2401handle_iteration_next (void *cls,
2402 const struct ZoneIterationNextMessage *zis_msg)
2403{
2404 struct NamestoreClient *nc = cls;
2405 struct ZoneIteration *zi;
2406 uint32_t rid;
2407 uint64_t limit;
2408
2410 "Received ZONE_ITERATION_NEXT message\n");
2412 "Iteration NEXT messages received",
2413 1,
2414 GNUNET_NO);
2415 rid = ntohl (zis_msg->gns_header.r_id);
2416 limit = GNUNET_ntohll (zis_msg->limit);
2417 for (zi = nc->op_head; NULL != zi; zi = zi->next)
2418 if (zi->request_id == rid)
2419 break;
2420 if (NULL == zi)
2421 {
2422 GNUNET_break (0);
2424 return;
2425 }
2426 run_zone_iteration_round (zi, limit);
2427}
2428
2429
2435static void
2437{
2438 struct StoreActivity *sa = sa_head;
2439
2441 "Unblocking zone monitor %p\n", zm);
2442 while ((NULL != sa) && (zm->limit > zm->iteration_cnt))
2443 {
2444 struct StoreActivity *sn = sa->next;
2445
2446 if (sa->zm_pos == zm)
2448 sa = sn;
2449 }
2450 if (zm->limit > zm->iteration_cnt)
2451 {
2452 zm->sa_waiting = GNUNET_NO;
2453 if (NULL != zm->sa_wait_warning)
2454 {
2455 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
2456 zm->sa_wait_warning = NULL;
2457 }
2458 }
2459 else if (GNUNET_YES == zm->sa_waiting)
2460 {
2461 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
2462 if (NULL != zm->sa_wait_warning)
2463 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
2464 zm->sa_wait_warning =
2467 zm);
2468 }
2469}
2470
2471
2477static void
2478monitor_sync (struct ZoneMonitor *zm)
2479{
2480 struct GNUNET_MQ_Envelope *env;
2481 struct GNUNET_MessageHeader *sync;
2483 "Syncing zone monitor %p\n", zm);
2484
2486 GNUNET_MQ_send (zm->nc->mq, env);
2487 /* mark iteration done */
2488 zm->in_first_iteration = GNUNET_NO;
2489 zm->iteration_cnt = 0;
2490 if ((zm->limit > 0) && (zm->sa_waiting))
2492}
2493
2494
2500static void
2501monitor_iteration_next (void *cls);
2502
2503
2514static void
2515monitor_iterate_cb (void *cls,
2516 uint64_t seq,
2517 const char *editor_hint,
2518 const struct GNUNET_CRYPTO_PrivateKey *zone_key,
2519 const char *name,
2520 unsigned int rd_count,
2521 const struct GNUNET_GNSRECORD_Data *rd)
2522{
2523 struct ZoneMonitor *zm = cls;
2524
2525 GNUNET_assert (0 != seq);
2526 zm->seq = seq;
2527 GNUNET_assert (NULL != name);
2529 "Monitor notifications sent",
2530 1,
2531 GNUNET_NO);
2532 if (0 < send_lookup_response_with_filter (zm->nc, 0, zone_key, name,
2533 rd_count, rd, zm->filter))
2534 {
2536 "Sent records.\n");
2537 zm->limit--;
2538 zm->iteration_cnt--;
2539 }
2540 else
2541 zm->run_again = GNUNET_YES;
2542 if ((0 == zm->iteration_cnt) && (0 != zm->limit))
2543 {
2544 /* We are done with the current iteration batch, AND the
2545 client would right now accept more, so go again! */
2546 GNUNET_assert (NULL == zm->task);
2548 }
2549}
2550
2551
2552static enum GNUNET_GenericReturnValue
2553check_monitor_start (void *cls,
2554 const struct ZoneMonitorStartMessage *zis_msg)
2555{
2556 uint16_t size;
2557 size_t key_len;
2558
2559 size = ntohs (zis_msg->header.size);
2560 key_len = ntohs (zis_msg->key_len);
2561
2562 if (size < key_len + sizeof(*zis_msg))
2563 {
2564 GNUNET_break (0);
2565 return GNUNET_SYSERR;
2566 }
2567 return GNUNET_OK;
2568}
2569
2570
2577static void
2578handle_monitor_start (void *cls, const struct
2579 ZoneMonitorStartMessage *zis_msg)
2580{
2581 struct GNUNET_CRYPTO_PrivateKey zone;
2582 struct NamestoreClient *nc = cls;
2583 struct ZoneMonitor *zm;
2584 size_t key_len;
2585 size_t kb_read;
2586
2588 "Received ZONE_MONITOR_START message\n");
2589 zm = GNUNET_new (struct ZoneMonitor);
2590 zm->nc = nc;
2591 key_len = ntohs (zis_msg->key_len);
2592 if (0 < key_len)
2593 {
2594 if ((GNUNET_SYSERR ==
2596 key_len,
2597 &zone,
2598 &kb_read)) ||
2599 (kb_read != key_len))
2600 {
2602 "Error reading private key\n");
2604 GNUNET_free (zm);
2605 return;
2606 }
2607 zm->zone = zone;
2608 }
2609 zm->limit = 1;
2610 zm->filter = ntohs (zis_msg->filter);
2611 zm->in_first_iteration = (GNUNET_YES == ntohl (zis_msg->iterate_first));
2616 if (zm->in_first_iteration)
2618 else
2619 monitor_sync (zm);
2620}
2621
2622
2628static void
2629monitor_iteration_next (void *cls)
2630{
2631 struct ZoneMonitor *zm = cls;
2632 struct NamestoreClient *nc = zm->nc;
2633 int ret;
2634
2635 zm->task = NULL;
2636 GNUNET_assert (0 == zm->iteration_cnt);
2637 if (zm->limit > 16)
2638 zm->iteration_cnt = zm->limit / 2; /* leave half for monitor events */
2639 else
2640 zm->iteration_cnt = zm->limit; /* use it all */
2641 zm->run_again = GNUNET_YES;
2642 while (GNUNET_YES == zm->run_again)
2643 {
2645 "Running iteration\n");
2646 zm->run_again = GNUNET_NO;
2647 ret = nc->GSN_database->iterate_records (nc->GSN_database->cls,
2649 &zm->zone)) ? NULL : &zm->zone,
2650 zm->seq,
2651 zm->iteration_cnt,
2653 zm);
2654 }
2655 if (GNUNET_SYSERR == ret)
2656 {
2657 GNUNET_SERVICE_client_drop (zm->nc->client);
2658 return;
2659 }
2660 if (GNUNET_NO == ret)
2661 {
2663 "Zone empty... syncing\n");
2664 /* empty zone */
2665 monitor_sync (zm);
2666 return;
2667 }
2668}
2669
2670
2677static void
2678handle_monitor_next (void *cls, const struct ZoneMonitorNextMessage *nm)
2679{
2680 struct NamestoreClient *nc = cls;
2681 struct ZoneMonitor *zm;
2682 uint64_t inc;
2683
2684 inc = GNUNET_ntohll (nm->limit);
2686 "Received ZONE_MONITOR_NEXT message with limit %llu\n",
2687 (unsigned long long) inc);
2688 for (zm = monitor_head; NULL != zm; zm = zm->next)
2689 if (zm->nc == nc)
2690 break;
2691 if (NULL == zm)
2692 {
2693 GNUNET_break (0);
2695 return;
2696 }
2698 if (zm->limit + inc < zm->limit)
2699 {
2700 GNUNET_break (0);
2702 return;
2703 }
2704 zm->limit += inc;
2705 if ((zm->in_first_iteration) && (zm->limit == inc))
2706 {
2707 /* We are still iterating, and the previous iteration must
2708 have stopped due to the client's limit, so continue it! */
2709 GNUNET_assert (NULL == zm->task);
2711 }
2712 GNUNET_assert (zm->iteration_cnt <= zm->limit);
2713 if ((zm->limit > zm->iteration_cnt) && (zm->sa_waiting))
2714 {
2716 }
2717 else if (GNUNET_YES == zm->sa_waiting)
2718 {
2719 if (NULL != zm->sa_wait_warning)
2720 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
2721 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
2722 zm->sa_wait_warning =
2725 zm);
2726 }
2727}
2728
2729
2737static void
2738run (void *cls,
2739 const struct GNUNET_CONFIGURATION_Handle *cfg,
2741{
2742 char *database;
2743 (void) cls;
2744 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting namestore service\n");
2746 "namestore",
2747 "RETURN_ORPHANED");
2748 GSN_cfg = cfg;
2750 statistics = GNUNET_STATISTICS_create ("namestore", cfg);
2751 /* Loading database plugin */
2753 "namestore",
2754 "database",
2755 &database))
2756 {
2757 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
2759 return;
2760 }
2762 "libgnunet_plugin_namestore_%s",
2763 database);
2765 "Loading %s\n",
2766 db_lib_name);
2769 (void *) cfg);
2770 GNUNET_free (database);
2771 if (NULL == GSN_database)
2772 {
2774 "Could not load database backend `%s'\n",
2775 db_lib_name);
2778 return;
2779 }
2781}
2782
2783
2789 "namestore",
2791 &run,
2794 NULL,
2795 GNUNET_MQ_hd_var_size (record_store,
2797 struct RecordStoreMessage,
2798 NULL),
2799 GNUNET_MQ_hd_var_size (edit_record_set,
2801 struct EditRecordSetMessage,
2802 NULL),
2803 GNUNET_MQ_hd_var_size (edit_record_set_cancel,
2806 NULL),
2807 GNUNET_MQ_hd_var_size (record_lookup,
2809 struct LabelLookupMessage,
2810 NULL),
2813 struct ZoneToNameMessage,
2814 NULL),
2815 GNUNET_MQ_hd_var_size (iteration_start,
2818 NULL),
2819 GNUNET_MQ_hd_fixed_size (iteration_next,
2822 NULL),
2823 GNUNET_MQ_hd_fixed_size (iteration_stop,
2826 NULL),
2827 GNUNET_MQ_hd_var_size (monitor_start,
2830 NULL),
2831 GNUNET_MQ_hd_fixed_size (monitor_next,
2834 NULL),
2836
2837
2838/* 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 struct GNUNET_GNSRECORD_Data * get_nick_record(const struct GNUNET_CRYPTO_PrivateKey *zone)
Return the NICK record for the zone (if it exists).
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 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 monitor_iterate_cb(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
A GNUNET_NAMESTORE_RecordIterator for monitors.
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 const struct GNUNET_CRYPTO_PrivateKey zero
Public key of all zeros.
static void monitor_sync(struct ZoneMonitor *zm)
Send 'sync' message to zone monitor, we're now in sync.
static void handle_zone_to_name_it(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Zone to name iterator.
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 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 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 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 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_iterate_proc(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *zone_key, const char *name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process results for zone iteration from database.
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 ...
#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 enum GNUNET_ErrorCode store_record_set(struct NamestoreClient *nc, const struct GNUNET_CRYPTO_PrivateKey *private_key, const struct RecordSet *rd_set, ssize_t *len)
static void monitor_iteration_next(void *cls)
Obtain the next datum during the zone monitor's zone initial iteration.
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 cache_nick(const struct GNUNET_CRYPTO_PrivateKey *zone, const struct GNUNET_GNSRECORD_Data *nick)
Add entry to the cache for zone and nick.
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.
#define NC_SIZE
Size of the cache used by get_nick_record()
static struct ZoneMonitor * monitor_tail
Last active zone monitor.
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_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 void get_existing_rd_exp(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *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 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 int send_lookup_response_with_filter(struct NamestoreClient *nc, uint32_t request_id, const struct GNUNET_CRYPTO_PrivateKey *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 enum GNUNET_GenericReturnValue check_monitor_start(void *cls, const struct ZoneMonitorStartMessage *zis_msg)
static void lookup_nick_it(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *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 void run(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
Process namestore requests.
static void lookup_it(void *cls, uint64_t seq, const char *editor_hint, const struct GNUNET_CRYPTO_PrivateKey *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 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.
#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.
const char * GNUNET_GNSRECORD_z2s(const struct GNUNET_CRYPTO_PublicKey *z)
Convert a zone to a string (for printing debug messages).
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.
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.
#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).
#define GNUNET_LOG_CALL_STATUS
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a private key.
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.
ssize_t GNUNET_CRYPTO_private_key_get_length(const struct GNUNET_CRYPTO_PrivateKey *key)
Get the compacted length of a GNUNET_CRYPTO_PrivateKey.
Definition crypto_pkey.c:64
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
ssize_t GNUNET_CRYPTO_write_private_key_to_buffer(const struct GNUNET_CRYPTO_PrivateKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PrivateKey to a compact buffer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_public_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PublicKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PublicKey from a compact buffer.
GNUNET_GenericReturnValue
Named constants for return values.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_read_private_key_from_buffer(const void *buffer, size_t len, struct GNUNET_CRYPTO_PrivateKey *key, size_t *read)
Reads a GNUNET_CRYPTO_PrivateKey from a compact buffer.
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:1339
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition scheduler.c:980
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:1304
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:1277
#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:2527
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition service.c:2462
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition service.c:2433
@ 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:552
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition time.c:640
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition strings.c:660
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_PrivateKey *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_MQ_Handle * mq
Handle to namestore service.
enum GNUNET_GNSRECORD_Filter filter
Record set filter for this monitor.
struct GNUNET_CRYPTO_PrivateKey zone
Monitored zone.
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:136
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_PrivateKey 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?
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.
struct GNUNET_CRYPTO_PrivateKey private_key
The zone private key.
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.
uint64_t seq
Last sequence number in the zone iteration used to address next result of the zone iteration in the s...
enum GNUNET_GNSRECORD_Filter filter
The record set filter.
struct GNUNET_CRYPTO_PrivateKey zone
Key of the zone we are iterating over.
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_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_CRYPTO_PrivateKey zone
Private key of the zone.
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

◆ MONITOR_STALL_WARN_DELAY

#define MONITOR_STALL_WARN_DELAY   GNUNET_TIME_UNIT_MINUTES

If a monitor takes more than 1 minute to process an event, print a warning.

Definition at line 41 of file gnunet-service-namestore.c.

◆ NC_SIZE

#define NC_SIZE   16

Size of the cache used by get_nick_record()

Definition at line 46 of file gnunet-service-namestore.c.

Function Documentation

◆ cleanup_task()

static void cleanup_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 390 of file gnunet-service-namestore.c.

391{
392 (void) cls;
393 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping namestore service\n");
394 if (NULL != monitor_nc)
395 {
397 monitor_nc = NULL;
398 }
399 if (NULL != statistics)
400 {
402 statistics = NULL;
403 }
406 db_lib_name = NULL;
407}

References db_lib_name, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_notification_context_destroy(), GNUNET_PLUGIN_unload(), GNUNET_STATISTICS_destroy(), GSN_database, monitor_nc, and statistics.

Here is the call graph for this function:

◆ free_store_activity()

static void free_store_activity ( struct StoreActivity sa)
static

Release memory used by sa.

Parameters
saactivity to free

Definition at line 416 of file gnunet-service-namestore.c.

417{
419 GNUNET_free (sa);
420}

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, sa_head, and sa_tail.

Referenced by client_disconnect_cb(), and continue_store_activity().

Here is the caller graph for this function:

◆ lookup_nick_it()

static void lookup_nick_it ( void *  cls,
uint64_t  seq,
const char *  editor_hint,
const struct GNUNET_CRYPTO_PrivateKey private_key,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Function called with the records for the GNUNET_GNS_EMPTY_LABEL_AT label in the zone.

Used to locate the GNUNET_GNSRECORD_TYPE_NICK record, which (if found) is then copied to cls for future use.

Parameters
clsa struct GNUNET_GNSRECORD_Data ** for storing the nick (if found)
seqsequence number of the record, MUST NOT BE ZERO
private_keythe private key of the zone (unused)
labelshould be GNUNET_GNS_EMPTY_LABEL_AT
rd_countnumber of records in rd
rdrecords stored under label in the zone

Definition at line 436 of file gnunet-service-namestore.c.

443{
444 struct GNUNET_GNSRECORD_Data **res = cls;
445
446 (void) private_key;
447 GNUNET_assert (0 != seq);
448 if (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT))
449 {
450 GNUNET_break (0);
451 return;
452 }
453 for (unsigned int c = 0; c < rd_count; c++)
454 {
456 {
457 (*res) =
458 GNUNET_malloc (rd[c].data_size + sizeof(struct GNUNET_GNSRECORD_Data));
459 (*res)->data = &(*res)[1];
460 GNUNET_memcpy ((void *) (*res)->data, rd[c].data, rd[c].data_size);
461 (*res)->data_size = rd[c].data_size;
462 (*res)->expiration_time = rd[c].expiration_time;
463 (*res)->flags = rd[c].flags;
464 (*res)->record_type = GNUNET_GNSRECORD_TYPE_NICK;
465 return;
466 }
467 }
468 (*res) = NULL;
469}

References GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_assert, GNUNET_break, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_TYPE_NICK, GNUNET_malloc, GNUNET_memcpy, rd, rd_count, GNUNET_GNSRECORD_Data::record_type, and res.

Referenced by get_nick_record().

Here is the caller graph for this function:

◆ cache_nick()

static void cache_nick ( const struct GNUNET_CRYPTO_PrivateKey zone,
const struct GNUNET_GNSRECORD_Data nick 
)
static

Add entry to the cache for zone and nick.

Parameters
zonezone key to cache under
nicknick entry to cache

Definition at line 479 of file gnunet-service-namestore.c.

481{
482 struct NickCache *oldest;
483
484 oldest = NULL;
485 for (unsigned int i = 0; i < NC_SIZE; i++)
486 {
487 struct NickCache *pos = &nick_cache[i];
488
489 if ((NULL == oldest) ||
491 oldest = pos;
492 if (0 == GNUNET_memcmp (zone, &pos->zone))
493 {
494 oldest = pos;
495 break;
496 }
497 }
498 GNUNET_free (oldest->rd);
499 oldest->zone = *zone;
500 if (NULL != nick)
501 {
502 oldest->rd = GNUNET_malloc (sizeof(*nick) + nick->data_size);
503 *oldest->rd = *nick;
504 oldest->rd->data = &oldest->rd[1];
505 memcpy (&oldest->rd[1], nick->data, nick->data_size);
506 }
507 else
508 {
509 oldest->rd = NULL;
510 }
512}

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_free, GNUNET_malloc, GNUNET_memcmp, GNUNET_TIME_absolute_get(), NickCache::last_used, NC_SIZE, nick_cache, NickCache::rd, and NickCache::zone.

Referenced by get_nick_record(), and store_record_set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_nick_record()

static struct GNUNET_GNSRECORD_Data * get_nick_record ( const struct GNUNET_CRYPTO_PrivateKey zone)
static

Return the NICK record for the zone (if it exists).

Parameters
ncthe namestore client
zoneprivate key for the zone to look for nick
Returns
NULL if no NICK record was found

Definition at line 523 of file gnunet-service-namestore.c.

524{
526 struct GNUNET_GNSRECORD_Data *nick;
527 int res;
528
529 /* check cache first */
530 for (unsigned int i = 0; i < NC_SIZE; i++)
531 {
532 struct NickCache *pos = &nick_cache[i];
533 if ((NULL != pos->rd) && (0 == GNUNET_memcmp (zone, &pos->zone)))
534 {
535 if (NULL == pos->rd)
536 return NULL;
537 nick = GNUNET_malloc (sizeof(*nick) + pos->rd->data_size);
538 *nick = *pos->rd;
539 nick->data = &nick[1];
540 memcpy (&nick[1], pos->rd->data, pos->rd->data_size);
542 return nick;
543 }
544 }
545
546 nick = NULL;
548 zone,
551 &nick);
552 if ((GNUNET_OK != res) || (NULL == nick))
553 {
554#if ! defined(GNUNET_CULL_LOGGING)
555 static int do_log = GNUNET_LOG_CALL_STATUS;
556
557 if (0 == do_log)
559 "namestore",
560 __FILE__,
561 __FUNCTION__,
562 __LINE__);
563 if (1 == do_log)
564 {
567 "No nick name set for zone `%s'\n",
569 }
570#endif
571 /* update cache */
572 cache_nick (zone, NULL);
573 return NULL;
574 }
575
576 /* update cache */
577 cache_nick (zone, nick);
578 return nick;
579}

References cache_nick(), GNUNET_NAMESTORE_PluginFunctions::cls, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_CRYPTO_key_get_public(), GNUNET_ERROR_TYPE_BULK, GNUNET_ERROR_TYPE_DEBUG, GNUNET_get_log_call_status(), GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_z2s(), GNUNET_log, GNUNET_LOG_CALL_STATUS, GNUNET_malloc, GNUNET_memcmp, GNUNET_OK, GNUNET_TIME_absolute_get(), GSN_database, NickCache::last_used, lookup_nick_it(), GNUNET_NAMESTORE_PluginFunctions::lookup_records, NC_SIZE, nick_cache, pub, NickCache::rd, res, and NickCache::zone.

Referenced by handle_edit_record_set(), handle_record_lookup(), and send_lookup_response_with_filter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ merge_with_nick_records()

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 
)
static

Merge the nick record nick_rd with the rest of the record set given in rd2.

Store the result in rdc_res and rd_res. The nick_rd's expiration time is set to the maximum expiration time of all of the records in rd2.

Parameters
nick_rdthe nick record to integrate
rd2_lengthlength of the rd2 array
rd2array of records
[out]rdc_reslength of the resulting rd_res array
[out]rd_resset to an array of records, including nick_rd and rd2; all of the variable-size 'data' fields in rd2 are allocated in the same chunk of memory!

Definition at line 598 of file gnunet-service-namestore.c.

603{
604 uint64_t latest_expiration;
605 size_t req;
606 char *data;
607 size_t data_offset;
608 struct GNUNET_GNSRECORD_Data *target;
609
610 (*rdc_res) = 1 + rd2_length;
611 if (0 == 1 + rd2_length)
612 {
613 GNUNET_break (0);
614 (*rd_res) = NULL;
615 return;
616 }
617 req = sizeof(struct GNUNET_GNSRECORD_Data) + nick_rd->data_size;
618 for (unsigned int i = 0; i < rd2_length; i++)
619 {
620 const struct GNUNET_GNSRECORD_Data *orig = &rd2[i];
621
622 if (req + sizeof(struct GNUNET_GNSRECORD_Data) + orig->data_size < req)
623 {
624 GNUNET_break (0);
625 (*rd_res) = NULL;
626 return;
627 }
628 req += sizeof(struct GNUNET_GNSRECORD_Data) + orig->data_size;
629 }
630 target = GNUNET_malloc (req);
631 (*rd_res) = target;
632 data = (char *) &target[1 + rd2_length];
633 data_offset = 0;
634 latest_expiration = 0;
635 for (unsigned int i = 0; i < rd2_length; i++)
636 {
637 const struct GNUNET_GNSRECORD_Data *orig = &rd2[i];
638
640 {
641 if ((GNUNET_TIME_absolute_get ().abs_value_us + orig->expiration_time) >
642 latest_expiration)
643 latest_expiration = orig->expiration_time;
644 }
645 else if (orig->expiration_time > latest_expiration)
646 latest_expiration = orig->expiration_time;
647 target[i] = *orig;
648 target[i].data = (void *) &data[data_offset];
649 GNUNET_memcpy (&data[data_offset], orig->data, orig->data_size);
650 data_offset += orig->data_size;
651 }
652 /* append nick */
653 target[rd2_length] = *nick_rd;
654 /* Mark as supplemental */
655 target[rd2_length].flags = nick_rd->flags | GNUNET_GNSRECORD_RF_SUPPLEMENTAL;
656 target[rd2_length].expiration_time = latest_expiration;
657 target[rd2_length].data = (void *) &data[data_offset];
658 GNUNET_memcpy (&data[data_offset], nick_rd->data, nick_rd->data_size);
659 data_offset += nick_rd->data_size;
660 GNUNET_assert (req == (sizeof(struct GNUNET_GNSRECORD_Data)) * (*rdc_res)
661 + data_offset);
662}

References data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_assert, GNUNET_break, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SUPPLEMENTAL, GNUNET_malloc, GNUNET_memcpy, and GNUNET_TIME_absolute_get().

Referenced by lookup_it(), and send_lookup_response_with_filter().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_lookup_response_with_filter()

static int send_lookup_response_with_filter ( struct NamestoreClient nc,
uint32_t  request_id,
const struct GNUNET_CRYPTO_PrivateKey zone_key,
const char *  name,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd,
enum GNUNET_GNSRECORD_Filter  filter 
)
static

Generate a struct LookupNameResponseMessage and send it to the given client using the given notification context.

Parameters
ncclient to unicast to
request_idrequest ID to use
zone_keyzone key of the zone
namename
rd_countnumber of records in rd
rdarray of records
filterrecord set filter

FIXME if we ever support GNUNET_NAMESTORE_OMIT_PUBLIC, we need to omit adding this public record here

Definition at line 678 of file gnunet-service-namestore.c.

686{
687 struct GNUNET_MQ_Envelope *env;
688 struct RecordResultMessage *zir_msg;
689 struct GNUNET_GNSRECORD_Data *nick;
691 struct GNUNET_GNSRECORD_Data rd_nf[rd_count];
692 struct GNUNET_TIME_Absolute block_exp;
693 unsigned int res_count;
694 unsigned int rd_nf_count;
695 size_t name_len;
696 size_t key_len;
697 ssize_t rd_ser_len;
698 char *name_tmp;
699 char *rd_ser;
700 char *emsg;
701
702 block_exp = GNUNET_TIME_UNIT_ZERO_ABS;
703 nick = get_nick_record (zone_key);
705
707 rd,
708 rd_count,
709 rd_nf,
710 &rd_nf_count,
711 &block_exp,
712 filter,
713 &emsg))
714 {
715 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
716 GNUNET_free (emsg);
717 GNUNET_assert (0);
718 }
719
724 if ((NULL != nick) && (0 != strcmp (name, GNUNET_GNS_EMPTY_LABEL_AT)))
725 {
726 nick->flags =
728 merge_with_nick_records (nick, rd_nf_count, rd_nf, &res_count, &res);
729 }
730 else
731 {
732 res_count = rd_nf_count;
733 res = (struct GNUNET_GNSRECORD_Data *) rd_nf;
734 }
735 if (NULL != nick)
736 GNUNET_free (nick);
737
738 if (0 == res_count)
739 {
740 if (rd_nf != res)
742 return 0;
743 }
745
746
747 name_len = strlen (name) + 1;
748 rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res);
749 if (rd_ser_len < 0)
750 {
751 if (rd_nf != res)
753 GNUNET_break (0);
755 return 0;
756 }
757 if (((size_t) rd_ser_len) >= UINT16_MAX - name_len - sizeof(*zir_msg))
758 {
759 if (rd_nf != res)
761 GNUNET_break (0);
763 return 0;
764 }
765 key_len = GNUNET_CRYPTO_private_key_get_length (zone_key);
766 env = GNUNET_MQ_msg_extra (zir_msg,
767 name_len + rd_ser_len + key_len,
769 zir_msg->gns_header.r_id = htonl (request_id);
770 zir_msg->name_len = htons (name_len);
771 zir_msg->rd_count = htons (res_count);
772 zir_msg->rd_len = htons ((uint16_t) rd_ser_len);
773 zir_msg->key_len = htons (key_len);
775 &zir_msg[1],
776 key_len);
777 zir_msg->expire = GNUNET_TIME_absolute_hton (block_exp);
778 name_tmp = (char *) &zir_msg[1] + key_len;
779 GNUNET_memcpy (name_tmp, name, name_len);
780 rd_ser = &name_tmp[name_len];
782 rd_ser_len ==
783 GNUNET_GNSRECORD_records_serialize (res_count, res, rd_ser_len, rd_ser));
785 "Sending RECORD_RESULT message with %u records\n",
786 res_count);
788 "Record sets sent to clients",
789 1,
790 GNUNET_NO);
791 GNUNET_MQ_send (nc->mq, env);
792 if (rd_nf != res)
794 return res_count;
795}

References env, RecordResultMessage::expire, filter, GNUNET_GNSRECORD_Data::flags, get_nick_record(), RecordResultMessage::gns_header, GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_private_key_get_length(), GNUNET_CRYPTO_write_private_key_to_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_normalize_record_set(), GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_OK, GNUNET_SERVICE_client_drop(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_UNIT_ZERO_ABS, RecordResultMessage::key_len, merge_with_nick_records(), name, RecordResultMessage::name_len, nc, GNUNET_NAMESTORE_Header::r_id, rd, rd_count, RecordResultMessage::rd_count, RecordResultMessage::rd_len, res, and statistics.

Referenced by continue_store_activity(), monitor_iterate_cb(), and zone_iterate_proc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_store_response()

static void send_store_response ( struct NamestoreClient nc,
enum GNUNET_ErrorCode  ec,
uint32_t  rid 
)
static

Send response to the store request to the client.

Parameters
ncclient to talk to
ecstatus of the operation
ridclient's request ID

Definition at line 806 of file gnunet-service-namestore.c.

809{
810 struct GNUNET_MQ_Envelope *env;
811 struct NamestoreResponseMessage *rcr_msg;
812
813 GNUNET_assert (NULL != nc);
815 "Sending GENERIC_RESPONSE message\n");
817 "Store requests completed",
818 1,
819 GNUNET_NO);
820 env = GNUNET_MQ_msg (rcr_msg,
822 rcr_msg->gns_header.r_id = htonl (rid);
823 rcr_msg->ec = htonl (ec);
824 GNUNET_MQ_send (nc->mq, env);
825}

References NamestoreResponseMessage::ec, env, NamestoreResponseMessage::gns_header, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_STATISTICS_update(), nc, GNUNET_NAMESTORE_Header::r_id, and statistics.

Referenced by continue_store_activity(), and handle_record_store().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zone_iteration_done_client_continue()

static void zone_iteration_done_client_continue ( struct ZoneIteration zi)
static

Function called once we are done with the zone iteration and allow the zone iteration client to send us more messages.

Parameters
zizone iteration we are processing

Definition at line 835 of file gnunet-service-namestore.c.

836{
837 struct GNUNET_MQ_Envelope *env;
838 struct GNUNET_NAMESTORE_Header *em;
839
841 if (! zi->send_end)
842 return;
843 /* send empty response to indicate end of list */
845 em->r_id = htonl (zi->request_id);
846 GNUNET_MQ_send (zi->nc->mq, env);
847
849 GNUNET_free (zi);
850}

References NamestoreClient::client, env, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT_END, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), NamestoreClient::mq, ZoneIteration::nc, NamestoreClient::op_head, NamestoreClient::op_tail, GNUNET_NAMESTORE_Header::r_id, ZoneIteration::request_id, and ZoneIteration::send_end.

Referenced by run_zone_iteration_round().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ warn_monitor_slow()

static void warn_monitor_slow ( void *  cls)
static

Print a warning that one of our monitors is no longer reacting.

Parameters
clsa struct ZoneMonitor to warn about

Definition at line 859 of file gnunet-service-namestore.c.

860{
861 struct ZoneMonitor *zm = cls;
862
864 "No response from monitor since %s\n",
865 GNUNET_STRINGS_absolute_time_to_string (zm->sa_waiting_start));
868 zm);
869}

References GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_absolute_time_to_string(), MONITOR_STALL_WARN_DELAY, warn_monitor_slow(), and zm.

Referenced by continue_store_activity(), handle_monitor_next(), monitor_unblock(), and warn_monitor_slow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ continue_store_activity()

static int continue_store_activity ( struct StoreActivity sa,
int  call_continue 
)
static

Continue processing the sa.

Parameters
sastore activity to process

Definition at line 878 of file gnunet-service-namestore.c.

880{
881 const struct RecordSet *rd_set = sa->rs;
882 unsigned int rd_count;
883 size_t name_len;
884 size_t rd_ser_len;
885 const char *name;
886 const char *rd_ser;
887 const char *buf;
888
889 buf = (const char *) &sa[1];
890 for (int i = sa->rd_set_pos; i < sa->rd_set_count; i++)
891 {
892 rd_set = (struct RecordSet *) buf;
893 name_len = ntohs (rd_set->name_len);
894 rd_count = ntohs (rd_set->rd_count);
895 rd_ser_len = ntohs (rd_set->rd_len);
896 name = (const char *) &rd_set[1];
897 buf += sizeof (struct RecordSet) + name_len + rd_ser_len;
898 rd_ser = &name[name_len];
899 {
901
902 /* We did this before, must succeed again */
904 GNUNET_OK ==
906 rd));
907
909 "Checking monitors watching for `%s'\n",
910 name);
911 for (struct ZoneMonitor *zm = sa->zm_pos; NULL != zm; zm = sa->zm_pos)
912 {
913 if ((0 != GNUNET_memcmp (&sa->private_key, &zm->zone)) &&
914 (0 != GNUNET_memcmp (&zm->zone, &zero)))
915 {
916 sa->zm_pos = zm->next; /* not interesting to this monitor */
917 continue;
918 }
919 if (zm->limit == zm->iteration_cnt)
920 {
921 zm->sa_waiting = GNUNET_YES;
922 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
923 if (NULL != zm->sa_wait_warning)
924 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
925 zm->sa_wait_warning =
928 zm);
930 "Monitor is blocking client for `%s'\n",
931 name);
932 return GNUNET_NO; /* blocked on zone monitor */
933 }
935 "Notifying monitor about changes under label `%s'\n",
936 name);
938 0,
939 &sa->private_key,
940 name,
941 rd_count,
942 rd,
943 zm->filter))
944 zm->limit--;
945 sa->zm_pos = zm->next;
946 }
947 sa->rd_set_pos++;
948 }
949 }
950 if (GNUNET_YES == call_continue)
954 return GNUNET_OK;
955}

References NamestoreClient::client, GNUNET_NAMESTORE_ZoneMonitor::filter, free_store_activity(), GNUNET_assert, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_deserialize(), GNUNET_log, GNUNET_memcmp, GNUNET_NO, GNUNET_NZL, GNUNET_OK, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_continue(), GNUNET_TIME_absolute_get(), GNUNET_YES, MONITOR_STALL_WARN_DELAY, name, RecordSet::name_len, StoreActivity::nc, StoreActivity::private_key, rd, rd_count, RecordSet::rd_count, RecordSet::rd_len, StoreActivity::rd_set_count, StoreActivity::rd_set_pos, StoreActivity::rid, StoreActivity::rs, send_lookup_response_with_filter(), send_store_response(), warn_monitor_slow(), zero, zm, StoreActivity::zm_pos, and GNUNET_NAMESTORE_ZoneMonitor::zone.

Referenced by client_disconnect_cb(), handle_record_store(), and monitor_unblock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

Called whenever a client is disconnected.

Frees our resources associated with that client.

Parameters
clsclosure
clientidentification of the client
app_ctxthe struct NamestoreClient of client

Definition at line 967 of file gnunet-service-namestore.c.

970{
971 struct NamestoreClient *nc = app_ctx;
972 struct ZoneIteration *no;
973 struct StoreActivity *sa = sa_head;
974 struct StoreActivity *sn;
975
976 (void) cls;
977 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected\n", client);
978 for (struct ZoneMonitor *zm = monitor_head; NULL != zm; zm = zm->next)
979 {
980 if (nc != zm->nc)
981 continue;
983 if (NULL != zm->task)
984 {
986 zm->task = NULL;
987 }
988 if (NULL != zm->sa_wait_warning)
989 {
990 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
991 zm->sa_wait_warning = NULL;
992 }
993 for (sa = sa_head; NULL != sa; sa = sn)
994 {
995 sn = sa->next;
996 if (zm == sa->zm_pos)
997 {
998 sa->zm_pos = zm->next;
999 /* this may free sa */
1001 }
1002 }
1003 GNUNET_free (zm);
1004 break;
1005 }
1006 sa = sa_head;
1007 while (NULL != sa)
1008 {
1009 if (nc != sa->nc)
1010 {
1011 sa = sa->next;
1012 continue;
1013 }
1014 sn = sa->next;
1016 sa = sn;
1017 }
1018 while (NULL != (no = nc->op_head))
1019 {
1020 GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no);
1021 GNUNET_free (no);
1022 }
1023 GNUNET_break (NULL == GNUNET_PLUGIN_unload (nc->db_lib_name,
1024 nc->GSN_database));
1025 GNUNET_free (nc->db_lib_name);
1026 GNUNET_free (nc);
1027}

References continue_store_activity(), free_store_activity(), GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_PLUGIN_unload(), GNUNET_SCHEDULER_cancel(), GNUNET_YES, monitor_head, monitor_tail, nc, StoreActivity::nc, StoreActivity::next, sa_head, zm, and StoreActivity::zm_pos.

Here is the call graph for this function:

◆ client_connect_cb()

static void * client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

Add a client to our list of active clients.

Parameters
clsNULL
clientclient to add
mqmessage queue for client
Returns
internal namestore client structure for this client

Definition at line 1039 of file gnunet-service-namestore.c.

1042{
1043 struct NamestoreClient *nc;
1044 char *database;
1045
1046 (void) cls;
1047 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", client);
1048 nc = GNUNET_new (struct NamestoreClient);
1049 nc->client = client;
1050 nc->mq = mq;
1051 /* Loading database plugin */
1053 "namestore",
1054 "database",
1055 &database))
1056 {
1057 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
1058 GNUNET_free (nc);
1059 return NULL;
1060 }
1062 "Loading %s\n",
1063 db_lib_name);
1066 (void *) GSN_cfg);
1067 GNUNET_free (database);
1068 if (NULL == nc->GSN_database)
1069 {
1071 "Could not load database backend `%s'\n",
1072 db_lib_name);
1073 GNUNET_free (nc);
1074 return NULL;
1075 }
1076 nc->db_lib_name = GNUNET_strdup (db_lib_name);
1078 "Loaded %s\n",
1079 db_lib_name);
1080 return nc;
1081}

References NamestoreClient::client, db_lib_name, GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PLUGIN_load(), GNUNET_strdup, GSN_cfg, mq, and nc.

Here is the call graph for this function:

◆ lookup_it()

static void lookup_it ( void *  cls,
uint64_t  seq,
const char *  editor_hint,
const struct GNUNET_CRYPTO_PrivateKey private_key,
const char *  label,
unsigned int  rd_count_nf,
const struct GNUNET_GNSRECORD_Data rd_nf 
)
static

Function called by the namestore plugin when we are trying to lookup a record as part of handle_record_lookup().

Merges all results into the context.

Parameters
clsclosure with a struct RecordLookupContext
sequnique serial number of the record, MUST NOT BE ZERO
private_keyprivate key of the zone
labelname that is being mapped (at most 255 characters long)
rd_countnumber of entries in rd array
rdarray of records with data to store

Definition at line 1144 of file gnunet-service-namestore.c.

1151{
1152 struct RecordLookupContext *rlc = cls;
1153 struct GNUNET_GNSRECORD_Data rd[rd_count_nf];
1154 struct GNUNET_TIME_Absolute block_exp;
1155 unsigned int rd_count = 0;
1156 char *emsg;
1157
1158 (void) private_key;
1159 GNUNET_assert (0 != seq);
1160 if (0 != strcmp (label, rlc->label))
1161 return;
1162 rlc->found = GNUNET_YES;
1163 if (NULL == rlc->editor_hint)
1164 rlc->editor_hint = GNUNET_strdup (editor_hint);
1166 rd_nf,
1167 rd_count_nf,
1168 rd,
1169 &rd_count,
1170 &block_exp,
1171 rlc->filter,
1172 &emsg))
1173 {
1174 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
1175 GNUNET_free (emsg);
1176 GNUNET_assert (0);
1177 }
1178
1179 if (0 == rd_count)
1180 {
1181 rlc->rd_ser_len = 0;
1182 rlc->res_rd_count = 0;
1183 rlc->res_rd = NULL;
1184 return;
1185 }
1186 if ((NULL != rlc->nick) && (0 != strcmp (label, GNUNET_GNS_EMPTY_LABEL_AT)))
1187 {
1188 /* Merge */
1189 struct GNUNET_GNSRECORD_Data *rd_res;
1190 unsigned int rdc_res;
1191
1192 rd_res = NULL;
1193 rdc_res = 0;
1196 merge_with_nick_records (rlc->nick, rd_count, rd, &rdc_res, &rd_res);
1197 rlc->rd_ser_len = GNUNET_GNSRECORD_records_get_size (rdc_res, rd_res);
1198 if (rlc->rd_ser_len < 0)
1199 {
1200 GNUNET_break (0);
1201 GNUNET_free (rd_res);
1202 rlc->found = GNUNET_NO;
1203 rlc->rd_ser_len = 0;
1204 return;
1205 }
1206 rlc->res_rd_count = rdc_res;
1207 rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len);
1209 rd_res,
1210 rlc->rd_ser_len,
1211 rlc->res_rd))
1212 {
1213 GNUNET_break (0);
1214 GNUNET_free (rlc->res_rd);
1215 rlc->res_rd = NULL;
1216 rlc->res_rd_count = 0;
1217 rlc->rd_ser_len = 0;
1218 GNUNET_free (rd_res);
1219 rlc->found = GNUNET_NO;
1220 return;
1221 }
1222 GNUNET_free (rd_res);
1223 GNUNET_free (rlc->nick);
1224 rlc->nick = NULL;
1225 }
1226 else
1227 {
1229 if (rlc->rd_ser_len < 0)
1230 {
1231 GNUNET_break (0);
1232 rlc->found = GNUNET_NO;
1233 rlc->rd_ser_len = 0;
1234 return;
1235 }
1236 rlc->res_rd_count = rd_count;
1237 rlc->res_rd = GNUNET_malloc (rlc->rd_ser_len);
1239 rd,
1240 rlc->rd_ser_len,
1241 rlc->res_rd))
1242 {
1243 GNUNET_break (0);
1244 GNUNET_free (rlc->res_rd);
1245 rlc->res_rd = NULL;
1246 rlc->res_rd_count = 0;
1247 rlc->rd_ser_len = 0;
1248 rlc->found = GNUNET_NO;
1249 return;
1250 }
1251 }
1252}

References RecordLookupContext::editor_hint, RecordLookupContext::filter, GNUNET_GNSRECORD_Data::flags, RecordLookupContext::found, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_normalize_record_set(), GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_log, GNUNET_malloc, GNUNET_NO, GNUNET_OK, GNUNET_strdup, GNUNET_YES, RecordLookupContext::label, merge_with_nick_records(), RecordLookupContext::nick, rd, rd_count, RecordLookupContext::rd_ser_len, RecordLookupContext::res_rd, and RecordLookupContext::res_rd_count.

Referenced by handle_edit_record_set(), and handle_record_lookup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_edit_record_set()

static int check_edit_record_set ( void *  cls,
const struct EditRecordSetMessage er_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT message.

Parameters
clsclient sending the message
er_msgmessage of type struct EditRecordSetMessage
Returns
GNUNET_OK if er_msg is well-formed

Definition at line 1263 of file gnunet-service-namestore.c.

1264{
1265 uint16_t name_len;
1266 uint16_t editor_hint_len;
1267 size_t src_size;
1268 size_t key_len;
1269
1270 (void) cls;
1271 name_len = ntohs (er_msg->label_len);
1272 editor_hint_len = ntohs (er_msg->editor_hint_len);
1273 key_len = ntohs (er_msg->key_len);
1274 src_size = ntohs (er_msg->gns_header.header.size);
1275 if (name_len + editor_hint_len + key_len != src_size - sizeof(struct
1277 {
1278 GNUNET_break (0);
1279 return GNUNET_SYSERR;
1280 }
1281 return GNUNET_OK;
1282}

References EditRecordSetMessage::editor_hint_len, EditRecordSetMessage::gns_header, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_NAMESTORE_Header::header, EditRecordSetMessage::key_len, EditRecordSetMessage::label_len, and GNUNET_MessageHeader::size.

◆ handle_edit_record_set()

static void handle_edit_record_set ( void *  cls,
const struct EditRecordSetMessage er_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT message.

Parameters
clsclient sending the message
ll_msgmessage of type struct EditRecordSetMessage

Definition at line 1292 of file gnunet-service-namestore.c.

1293{
1294 struct GNUNET_CRYPTO_PrivateKey zone;
1295 struct NamestoreClient *nc = cls;
1296 struct GNUNET_MQ_Envelope *env;
1297 struct EditRecordSetResponseMessage *rer_msg;
1298 struct RecordLookupContext rlc;
1299 const char *name_tmp;
1300 const char *editor_hint;
1301 char *conv_name;
1302 uint16_t name_len;
1303 uint16_t old_editor_hint_len;
1304 int res;
1305 size_t key_len;
1306 size_t kb_read;
1307
1308 key_len = ntohs (er_msg->key_len);
1309 name_len = ntohs (er_msg->label_len);
1310 if ((GNUNET_SYSERR ==
1312 key_len,
1313 &zone,
1314 &kb_read)) ||
1315 (kb_read != key_len))
1316 {
1318 "Error reading private key\n");
1320 return;
1321 }
1322 name_tmp = (const char *) &er_msg[1] + key_len;
1323 editor_hint = (const char *) name_tmp + name_len;
1326 "Received NAMESTORE_RECORD_SET_EDIT message for name `%s'\n",
1327 name_tmp);
1328
1329 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1330 if (NULL == conv_name)
1331 {
1333 "Error converting name `%s'\n",
1334 name_tmp);
1336 return;
1337 }
1338 name_len = strlen (conv_name) + 1;
1339 rlc.editor_hint = NULL;
1340 rlc.label = conv_name;
1342 "Looking up without filter\n");
1343 rlc.filter = GNUNET_GNSRECORD_FILTER_NONE;
1344 rlc.found = GNUNET_NO;
1345 rlc.res_rd_count = 0;
1346 rlc.res_rd = NULL;
1347 rlc.rd_ser_len = 0;
1348 rlc.nick = get_nick_record (&zone);
1349 res = nc->GSN_database->edit_records (nc->GSN_database->cls,
1351 &zone,
1352 conv_name,
1353 &lookup_it,
1354 &rlc);
1355
1356 old_editor_hint_len = 0;
1357 if (NULL != rlc.editor_hint)
1358 old_editor_hint_len = strlen (rlc.editor_hint) + 1;
1359 env =
1360 GNUNET_MQ_msg_extra (rer_msg,
1361 rlc.rd_ser_len + old_editor_hint_len,
1363 ;
1364 rer_msg->editor_hint_len = htons (old_editor_hint_len);
1365 rer_msg->gns_header.r_id = er_msg->gns_header.r_id;
1366 rer_msg->rd_count = htons (rlc.res_rd_count);
1367 rer_msg->rd_len = htons (rlc.rd_ser_len);
1368 if (GNUNET_YES == rlc.found)
1369 rer_msg->ec = htons (GNUNET_EC_NONE);
1370 else if (GNUNET_SYSERR == res)
1371 rer_msg->ec = htons (GNUNET_EC_NAMESTORE_UNKNOWN);
1372 else
1373 rer_msg->ec = htons (GNUNET_EC_NAMESTORE_NO_RESULTS);
1374 GNUNET_memcpy (&rer_msg[1], rlc.editor_hint, old_editor_hint_len);
1375 GNUNET_memcpy ((char*) &rer_msg[1] + old_editor_hint_len, rlc.res_rd,
1376 rlc.rd_ser_len);
1377 GNUNET_MQ_send (nc->mq, env);
1378 GNUNET_free (rlc.editor_hint);
1379 GNUNET_free (rlc.res_rd);
1380 GNUNET_free (conv_name);
1381}

References EditRecordSetResponseMessage::ec, RecordLookupContext::editor_hint, EditRecordSetResponseMessage::editor_hint_len, env, RecordLookupContext::filter, RecordLookupContext::found, get_nick_record(), EditRecordSetResponseMessage::gns_header, EditRecordSetMessage::gns_header, GNUNET_CRYPTO_read_private_key_from_buffer(), GNUNET_EC_NAMESTORE_NO_RESULTS, GNUNET_EC_NAMESTORE_UNKNOWN, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_FILTER_NONE, GNUNET_GNSRECORD_string_normalize(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_RESPONSE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, GNUNET_YES, EditRecordSetMessage::key_len, RecordLookupContext::label, EditRecordSetMessage::label_len, lookup_it(), nc, RecordLookupContext::nick, GNUNET_NAMESTORE_Header::r_id, EditRecordSetResponseMessage::rd_count, EditRecordSetResponseMessage::rd_len, RecordLookupContext::rd_ser_len, res, RecordLookupContext::res_rd, and RecordLookupContext::res_rd_count.

Here is the call graph for this function:

◆ check_edit_record_set_cancel()

static int check_edit_record_set_cancel ( void *  cls,
const struct EditRecordSetCancelMessage er_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL message.

Parameters
clsclient sending the message
er_msgmessage of type struct EditRecordSetMessage
Returns
GNUNET_OK if er_msg is well-formed

Definition at line 1392 of file gnunet-service-namestore.c.

1394{
1395 uint16_t name_len;
1396 uint16_t editor_hint_len;
1397 uint16_t editor_hint_repl_len;
1398 size_t src_size;
1399 size_t key_len;
1400
1401 (void) cls;
1402 name_len = ntohs (er_msg->label_len);
1403 editor_hint_len = ntohs (er_msg->editor_hint_len);
1404 editor_hint_repl_len = ntohs (er_msg->editor_hint_len);
1405 key_len = ntohs (er_msg->key_len);
1406 src_size = ntohs (er_msg->gns_header.header.size);
1407 if (name_len + editor_hint_len + editor_hint_repl_len + key_len != src_size
1408 - sizeof(struct
1410 {
1411 GNUNET_break (0);
1412 return GNUNET_SYSERR;
1413 }
1414 return GNUNET_OK;
1415}

References EditRecordSetCancelMessage::editor_hint_len, EditRecordSetCancelMessage::gns_header, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_NAMESTORE_Header::header, EditRecordSetCancelMessage::key_len, EditRecordSetCancelMessage::label_len, and GNUNET_MessageHeader::size.

◆ handle_edit_record_set_cancel()

static void handle_edit_record_set_cancel ( void *  cls,
const struct EditRecordSetCancelMessage er_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_SET_EDIT_CANCEL message.

Parameters
clsclient sending the message
ll_msgmessage of type struct EditRecordSetCancelMessage

Definition at line 1425 of file gnunet-service-namestore.c.

1427{
1428 struct GNUNET_CRYPTO_PrivateKey zone;
1429 struct NamestoreClient *nc = cls;
1430 struct GNUNET_MQ_Envelope *env;
1431 struct NamestoreResponseMessage *rer_msg;
1432 const char *name_tmp;
1433 const char *editor_hint;
1434 const char *editor_hint_repl;
1435 char *conv_name;
1436 uint16_t name_len;
1437 uint16_t editor_hint_len;
1438 int res;
1439 size_t key_len;
1440 size_t kb_read;
1441
1442 key_len = ntohs (er_msg->key_len);
1443 name_len = ntohs (er_msg->label_len);
1444 editor_hint_len = ntohs (er_msg->editor_hint_len);
1445 if ((GNUNET_SYSERR ==
1447 key_len,
1448 &zone,
1449 &kb_read)) ||
1450 (kb_read != key_len))
1451 {
1453 "Error reading private key\n");
1455 return;
1456 }
1457 name_tmp = (const char *) &er_msg[1] + key_len;
1458 editor_hint = (const char *) name_tmp + name_len;
1459 editor_hint_repl = (const char *) name_tmp + name_len + editor_hint_len;
1462 "Received NAMESTORE_RECORD_SET_EDIT message for name `%s'\n",
1463 name_tmp);
1464
1465 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1466 if (NULL == conv_name)
1467 {
1469 "Error converting name `%s'\n",
1470 name_tmp);
1472 return;
1473 }
1474 name_len = strlen (conv_name) + 1;
1476 "Clearing editor hint\n");
1477 res = nc->GSN_database->clear_editor_hint (nc->GSN_database->cls,
1478 editor_hint,
1479 editor_hint_repl,
1480 &zone,
1481 conv_name);
1483 "Clearing editor hint %s\n", (GNUNET_SYSERR == res) ? "failed." :
1484 "successful.");
1485
1486 env =
1487 GNUNET_MQ_msg (rer_msg,
1489 rer_msg->gns_header.r_id = er_msg->gns_header.r_id;
1490 rer_msg->ec = htons ((GNUNET_OK == res) ? GNUNET_EC_NONE :
1492 GNUNET_MQ_send (nc->mq, env);
1493 GNUNET_free (conv_name);
1494}

References NamestoreResponseMessage::ec, EditRecordSetCancelMessage::editor_hint_len, env, NamestoreResponseMessage::gns_header, EditRecordSetCancelMessage::gns_header, GNUNET_CRYPTO_read_private_key_from_buffer(), GNUNET_EC_NAMESTORE_BACKEND_FAILED, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_string_normalize(), GNUNET_log, GNUNET_MESSAGE_TYPE_NAMESTORE_GENERIC_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, EditRecordSetCancelMessage::key_len, EditRecordSetCancelMessage::label_len, nc, GNUNET_NAMESTORE_Header::r_id, and res.

Here is the call graph for this function:

◆ check_record_lookup()

static int check_record_lookup ( void *  cls,
const struct LabelLookupMessage ll_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.

Parameters
clsclient sending the message
ll_msgmessage of type struct LabelLookupMessage
Returns
GNUNET_OK if ll_msg is well-formed

Definition at line 1505 of file gnunet-service-namestore.c.

1506{
1507 uint32_t name_len;
1508 size_t src_size;
1509 size_t key_len;
1510
1511 (void) cls;
1512 name_len = ntohs (ll_msg->label_len);
1513 key_len = ntohs (ll_msg->key_len);
1514 src_size = ntohs (ll_msg->gns_header.header.size);
1515 if (name_len + key_len != src_size - sizeof(struct LabelLookupMessage))
1516 {
1517 GNUNET_break (0);
1518 return GNUNET_SYSERR;
1519 }
1520 return GNUNET_OK;
1521}

References LabelLookupMessage::gns_header, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_NAMESTORE_Header::header, LabelLookupMessage::key_len, LabelLookupMessage::label_len, and GNUNET_MessageHeader::size.

◆ handle_record_lookup()

static void handle_record_lookup ( void *  cls,
const struct LabelLookupMessage ll_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP message.

Parameters
clsclient sending the message
ll_msgmessage of type struct LabelLookupMessage

Definition at line 1531 of file gnunet-service-namestore.c.

1532{
1533 struct GNUNET_CRYPTO_PrivateKey zone;
1534 struct NamestoreClient *nc = cls;
1535 struct GNUNET_MQ_Envelope *env;
1536 struct LabelLookupResponseMessage *llr_msg;
1537 struct RecordLookupContext rlc;
1538 const char *name_tmp;
1539 char *res_name;
1540 char *conv_name;
1541 uint32_t name_len;
1542 int res;
1543 size_t key_len;
1544 size_t kb_read;
1545
1546 key_len = ntohs (ll_msg->key_len);
1547 if ((GNUNET_SYSERR ==
1549 key_len,
1550 &zone,
1551 &kb_read)) ||
1552 (kb_read != key_len))
1553 {
1555 "Error reading private key\n");
1557 return;
1558 }
1559 name_tmp = (const char *) &ll_msg[1] + key_len;
1562 "Received NAMESTORE_RECORD_LOOKUP message for name `%s'\n",
1563 name_tmp);
1564
1565 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1566 if (NULL == conv_name)
1567 {
1569 "Error converting name `%s'\n",
1570 name_tmp);
1572 return;
1573 }
1574 name_len = strlen (conv_name) + 1;
1575 rlc.editor_hint = NULL;
1576 rlc.label = conv_name;
1578 "Looking up with filter %u\n", ntohs (ll_msg->filter));
1579 rlc.filter = ntohs (ll_msg->filter);
1580 rlc.found = GNUNET_NO;
1581 rlc.res_rd_count = 0;
1582 rlc.res_rd = NULL;
1583 rlc.rd_ser_len = 0;
1584 rlc.nick = get_nick_record (&zone);
1585 res = nc->GSN_database->lookup_records (nc->GSN_database->cls,
1586 &zone,
1587 conv_name,
1588 &lookup_it,
1589 &rlc);
1590 env =
1591 GNUNET_MQ_msg_extra (llr_msg,
1592 key_len + name_len + rlc.rd_ser_len,
1594 llr_msg->gns_header.r_id = ll_msg->gns_header.r_id;
1595 GNUNET_memcpy (&llr_msg[1], &ll_msg[1], key_len);
1596 llr_msg->key_len = ll_msg->key_len;
1597 llr_msg->name_len = htons (name_len);
1598 llr_msg->rd_count = htons (rlc.res_rd_count);
1599 llr_msg->rd_len = htons (rlc.rd_ser_len);
1600 llr_msg->reserved = htons (0);
1601 res_name = ((char *) &llr_msg[1]) + key_len;
1602 if (GNUNET_YES == rlc.found)
1603 llr_msg->found = htons (GNUNET_YES);
1604 else if (GNUNET_SYSERR == res)
1605 llr_msg->found = htons (GNUNET_SYSERR);
1606 else
1607 llr_msg->found = htons (GNUNET_NO);
1608 GNUNET_memcpy (res_name, conv_name, name_len);
1609 GNUNET_memcpy (&res_name[name_len], rlc.res_rd, rlc.rd_ser_len);
1610 GNUNET_MQ_send (nc->mq, env);
1611 GNUNET_free (rlc.editor_hint);
1612 GNUNET_free (rlc.res_rd);
1613 GNUNET_free (conv_name);
1614}

References RecordLookupContext::editor_hint, env, RecordLookupContext::filter, LabelLookupMessage::filter, RecordLookupContext::found, LabelLookupResponseMessage::found, get_nick_record(), LabelLookupMessage::gns_header, LabelLookupResponseMessage::gns_header, GNUNET_CRYPTO_read_private_key_from_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_string_normalize(), GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_LOOKUP_RESPONSE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, GNUNET_YES, LabelLookupMessage::key_len, LabelLookupResponseMessage::key_len, RecordLookupContext::label, lookup_it(), LabelLookupResponseMessage::name_len, nc, RecordLookupContext::nick, GNUNET_NAMESTORE_Header::r_id, LabelLookupResponseMessage::rd_count, LabelLookupResponseMessage::rd_len, RecordLookupContext::rd_ser_len, res, RecordLookupContext::res_rd, RecordLookupContext::res_rd_count, and LabelLookupResponseMessage::reserved.

Here is the call graph for this function:

◆ check_record_store()

static int check_record_store ( void *  cls,
const struct RecordStoreMessage rp_msg 
)
static

Checks a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message.

Parameters
clsclient sending the message
rp_msgmessage of type struct RecordStoreMessage
Returns
GNUNET_OK if rp_msg is well-formed

Definition at line 1625 of file gnunet-service-namestore.c.

1626{
1627 size_t msg_size;
1628 size_t min_size_exp;
1629 size_t rd_set_count;
1630 size_t key_len;
1631
1632 (void) cls;
1633 msg_size = ntohs (rp_msg->gns_header.header.size);
1634 rd_set_count = ntohs (rp_msg->rd_set_count);
1635 key_len = ntohs (rp_msg->key_len);
1636
1637 min_size_exp = sizeof(*rp_msg) + key_len + sizeof (struct RecordSet)
1638 * rd_set_count;
1639 if (msg_size < min_size_exp)
1640 {
1641 GNUNET_break (0);
1642 return GNUNET_SYSERR;
1643 }
1644 return GNUNET_OK;
1645}

References RecordStoreMessage::gns_header, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_NAMESTORE_Header::header, RecordStoreMessage::key_len, RecordStoreMessage::rd_set_count, and GNUNET_MessageHeader::size.

◆ get_existing_rd_exp()

static void get_existing_rd_exp ( void *  cls,
uint64_t  seq,
const char *  editor_hint,
const struct GNUNET_CRYPTO_PrivateKey private_key,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Check if set contains a tombstone, store if necessary.

Parameters
clsa struct GNUNET_GNSRECORD_Data ** for storing the nick (if found)
seqsequence number of the record, MUST NOT BE ZERO
private_keythe private key of the zone (unused)
labelshould be GNUNET_GNS_EMPTY_LABEL_AT
rd_countnumber of records in rd
rdrecords stored under label in the zone

Definition at line 1676 of file gnunet-service-namestore.c.

1684{
1685 struct LookupExistingRecordsContext *lctx = cls;
1686 struct GNUNET_GNSRECORD_Data rd_pub[rd_count];
1687 unsigned int rd_pub_count;
1688 char *emsg;
1689
1690 if ((1 == rd_count) &&
1692 {
1693 /* This record set contains only a tombstone! */
1694 lctx->only_tombstone = GNUNET_YES;
1695 }
1696 if (GNUNET_OK !=
1698 rd,
1699 rd_count,
1700 rd_pub,
1701 &rd_pub_count,
1702 &lctx->exp,
1704 &emsg))
1705 {
1707 "%s\n", emsg);
1708 GNUNET_free (emsg);
1709 }
1710}

References LookupExistingRecordsContext::exp, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE, GNUNET_GNSRECORD_normalize_record_set(), GNUNET_GNSRECORD_TYPE_TOMBSTONE, GNUNET_log, GNUNET_OK, GNUNET_YES, LookupExistingRecordsContext::only_tombstone, rd, rd_count, and GNUNET_GNSRECORD_Data::record_type.

Referenced by store_record_set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ store_record_set()

static enum GNUNET_ErrorCode store_record_set ( struct NamestoreClient nc,
const struct GNUNET_CRYPTO_PrivateKey private_key,
const struct RecordSet rd_set,
ssize_t *  len 
)
static

Definition at line 1714 of file gnunet-service-namestore.c.

1718{
1719 size_t name_len;
1720 size_t rd_ser_len;
1721 const char *name_tmp;
1722 const char *rd_ser;
1723 char *emsg;
1724 char *conv_name;
1725 unsigned int rd_count;
1726 int res;
1727 enum GNUNET_ErrorCode ec;
1728 struct GNUNET_TIME_Absolute new_block_exp;
1729 struct LookupExistingRecordsContext lctx;
1730 *len = sizeof (struct RecordSet);
1731
1732 ec = GNUNET_EC_NONE;
1734 lctx.exp = GNUNET_TIME_UNIT_ZERO_ABS;
1735 new_block_exp = GNUNET_TIME_UNIT_ZERO_ABS;
1736 name_len = ntohs (rd_set->name_len);
1737 *len += name_len;
1738 rd_count = ntohs (rd_set->rd_count);
1739 rd_ser_len = ntohs (rd_set->rd_len);
1740 *len += rd_ser_len;
1741 name_tmp = (const char *) &rd_set[1];
1742 rd_ser = &name_tmp[name_len];
1743 {
1745
1746 /* Extracting and converting private key */
1747 conv_name = GNUNET_GNSRECORD_string_normalize (name_tmp);
1748 if (NULL == conv_name)
1749 {
1751 "Error normalizing name `%s'\n",
1752 name_tmp);
1754 }
1755
1756 /* Check name for validity */
1757 if (GNUNET_OK != GNUNET_GNSRECORD_label_check (conv_name, &emsg))
1758 {
1760 "Label invalid: `%s'\n",
1761 emsg);
1762 GNUNET_free (emsg);
1763 GNUNET_free (conv_name);
1765 }
1766
1767 if (GNUNET_OK !=
1769 rd))
1770 {
1771 GNUNET_free (conv_name);
1773 }
1774
1776 "Well-formed store requests received",
1777 1,
1778 GNUNET_NO);
1780 "Creating %u records for name `%s'\n",
1781 (unsigned int) rd_count,
1782 conv_name);
1783 if ((0 == rd_count) &&
1784 (GNUNET_NO == nc->GSN_database->lookup_records (nc->GSN_database->cls,
1785 private_key,
1786 conv_name,
1788 &lctx)))
1789 {
1790 /* This name does not exist, so cannot be removed */
1792 "Name `%s' does not exist, no deletion required\n",
1793 conv_name);
1794 res = GNUNET_NO;
1796 }
1797 else
1798 {
1799 /* remove "NICK" records, unless this is for the
1800 #GNUNET_GNS_EMPTY_LABEL_AT label
1801 We may need one additional record later for tombstone.
1802 FIXME: Since we must normalize the record set (check for
1803 consistency etc) we have to iterate the set twice.
1804 May be inefficient.
1805 We cannot really move the nick caching into GNSRECORD.
1806 */
1807 struct GNUNET_GNSRECORD_Data rd_clean[GNUNET_NZL (rd_count)];
1808 struct GNUNET_GNSRECORD_Data rd_nf[GNUNET_NZL (rd_count) + 1];
1809 unsigned int rd_clean_off;
1810 unsigned int rd_nf_count;
1811 int have_nick;
1812
1813 rd_clean_off = 0;
1814 have_nick = GNUNET_NO;
1815 for (unsigned int i = 0; i < rd_count; i++)
1816 {
1817 rd_clean[rd_clean_off] = rd[i];
1818
1819 if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) ||
1821 rd_clean_off++;
1822
1823 if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) &&
1825 {
1826 cache_nick (private_key, &rd[i]);
1827 have_nick = GNUNET_YES;
1828 }
1829 }
1830 if (GNUNET_OK !=
1832 rd_clean,
1833 rd_clean_off,
1834 rd_nf,
1835 &rd_nf_count,
1836 &new_block_exp,
1838 &emsg))
1839 {
1840 GNUNET_free (conv_name);
1842 "Error normalizing record set: `%s'\n",
1843 emsg);
1844 GNUNET_free (emsg);
1846 }
1848 "%u/%u records before tombstone\n", rd_nf_count,
1849 rd_clean_off);
1850 /*
1851 * If existing_block_exp is 0, then there was no record set
1852 * and no tombstone.
1853 * Otherwise, if the existing block expiration is after the
1854 * new block expiration would be, we need to add a tombstone
1855 * or update it.
1856 */
1857 if (GNUNET_TIME_absolute_cmp (new_block_exp, <=, lctx.exp))
1858 {
1859 rd_nf[rd_nf_count].record_type = GNUNET_GNSRECORD_TYPE_TOMBSTONE;
1860 rd_nf[rd_nf_count].expiration_time =
1861 lctx.exp.abs_value_us;
1862 rd_nf[rd_nf_count].data = NULL;
1863 rd_nf[rd_nf_count].data_size = 0;
1864 rd_nf[rd_nf_count].flags = GNUNET_GNSRECORD_RF_PRIVATE
1866 rd_nf_count++;
1867 }
1868 if ((0 == strcmp (GNUNET_GNS_EMPTY_LABEL_AT, conv_name)) &&
1869 (GNUNET_NO == have_nick))
1870 {
1871 cache_nick (private_key, NULL);
1872 }
1873 res = nc->GSN_database->store_records (nc->GSN_database->cls,
1874 private_key,
1875 conv_name,
1876 rd_nf_count,
1877 rd_nf);
1878 /* If after a store there is only a TOMBSTONE left, and
1879 * there was >1 record under this label found (the tombstone; indicated
1880 * through res != GNUNET_NO) then we should return "NOT FOUND" == GNUNET_NO
1881 */
1882 if ((GNUNET_SYSERR != res) &&
1883 (0 == rd_count) &&
1884 (1 == rd_nf_count) &&
1886 (GNUNET_YES == lctx.only_tombstone))
1887 {
1889 "Client tried to remove non-existent record\n");
1891 }
1892 }
1893
1894 if (GNUNET_SYSERR == res)
1895 {
1896 /* store not successful, no need to tell monitors */
1897 GNUNET_free (conv_name);
1899 }
1900 }
1901 return ec;
1902}

References GNUNET_TIME_Absolute::abs_value_us, cache_nick(), GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, LookupExistingRecordsContext::exp, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, get_existing_rd_exp(), GNUNET_EC_NAMESTORE_LABEL_INVALID, GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID, GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND, GNUNET_EC_NAMESTORE_STORE_FAILED, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_FILTER_INCLUDE_MAINTENANCE, GNUNET_GNSRECORD_label_check(), GNUNET_GNSRECORD_normalize_record_set(), GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_RF_MAINTENANCE, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_string_normalize(), GNUNET_GNSRECORD_TYPE_NICK, GNUNET_GNSRECORD_TYPE_TOMBSTONE, GNUNET_log, GNUNET_NO, GNUNET_NZL, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_cmp, GNUNET_TIME_UNIT_ZERO_ABS, GNUNET_YES, RecordSet::name_len, nc, LookupExistingRecordsContext::only_tombstone, rd, rd_count, RecordSet::rd_count, RecordSet::rd_len, GNUNET_GNSRECORD_Data::record_type, res, and statistics.

Referenced by handle_record_store().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_record_store()

static void handle_record_store ( void *  cls,
const struct RecordStoreMessage rp_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE message.

Parameters
clsclient sending the message
rp_msgmessage of type struct RecordStoreMessage

Definition at line 1912 of file gnunet-service-namestore.c.

1913{
1914 struct GNUNET_CRYPTO_PrivateKey zone;
1915 struct NamestoreClient *nc = cls;
1916 uint32_t rid;
1917 uint16_t rd_set_count;
1918 const char *buf;
1919 ssize_t read;
1920 size_t key_len;
1921 size_t kb_read;
1922 size_t rp_msg_len;
1923 size_t rs_len;
1924 size_t rs_off;
1925 struct StoreActivity *sa;
1926 struct RecordSet *rs;
1927 enum GNUNET_ErrorCode res;
1928
1929 key_len = ntohs (rp_msg->key_len);
1930 rp_msg_len = ntohs (rp_msg->gns_header.header.size);
1931 rs_off = sizeof (*rp_msg) + key_len;
1932 rs_len = rp_msg_len - rs_off;
1933 if ((GNUNET_SYSERR ==
1935 key_len,
1936 &zone,
1937 &kb_read)) ||
1938 (kb_read != key_len))
1939 {
1941 "Error reading private key\n");
1943 return;
1944 }
1946 "Received NAMESTORE_RECORD_STORE message\n");
1947 rid = ntohl (rp_msg->gns_header.r_id);
1948 rd_set_count = ntohs (rp_msg->rd_set_count);
1949 buf = (const char *) rp_msg + rs_off;
1950 if (GNUNET_YES == ntohs (rp_msg->single_tx))
1951 nc->GSN_database->begin_tx (nc->GSN_database->cls);
1952 for (int i = 0; i < rd_set_count; i++)
1953 {
1954 rs = (struct RecordSet *) buf;
1955 res = store_record_set (nc, &zone,
1956 rs, &read);
1957 if (GNUNET_EC_NONE != res)
1958 {
1959 if (GNUNET_YES == ntohs (rp_msg->single_tx))
1960 nc->GSN_database->rollback_tx (nc->GSN_database->cls);
1961 send_store_response (nc, res, rid);
1963 return;
1964 }
1965 buf += read;
1966 }
1967 if (GNUNET_YES == ntohs (rp_msg->single_tx))
1968 nc->GSN_database->commit_tx (nc->GSN_database->cls);
1969 sa = GNUNET_malloc (sizeof(struct StoreActivity) + rs_len);
1971 sa->nc = nc;
1972 sa->rs = (struct RecordSet *) &sa[1];
1973 sa->rd_set_count = rd_set_count;
1974 GNUNET_memcpy (&sa[1], (char *) rp_msg + rs_off, rs_len);
1975 sa->rid = rid;
1976 sa->rd_set_pos = 0;
1977 sa->private_key = zone;
1978 sa->zm_pos = monitor_head;
1980}

References continue_store_activity(), RecordStoreMessage::gns_header, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_read_private_key_from_buffer(), GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, GNUNET_YES, GNUNET_NAMESTORE_Header::header, RecordStoreMessage::key_len, monitor_head, nc, StoreActivity::nc, StoreActivity::private_key, GNUNET_NAMESTORE_Header::r_id, StoreActivity::rd_set_count, RecordStoreMessage::rd_set_count, StoreActivity::rd_set_pos, res, StoreActivity::rid, StoreActivity::rs, sa_head, sa_tail, send_store_response(), RecordStoreMessage::single_tx, GNUNET_MessageHeader::size, store_record_set(), and StoreActivity::zm_pos.

Here is the call graph for this function:

◆ handle_zone_to_name_it()

static void handle_zone_to_name_it ( void *  cls,
uint64_t  seq,
const char *  editor_hint,
const struct GNUNET_CRYPTO_PrivateKey zone_key,
const char *  name,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Zone to name iterator.

Parameters
clsstruct ZoneToNameCtx *
seqsequence number of the record, MUST NOT BE ZERO
zone_keythe zone key
namename
rd_countnumber of records in rd
rdrecord data

Definition at line 2019 of file gnunet-service-namestore.c.

2026{
2027 struct ZoneToNameCtx *ztn_ctx = cls;
2028 struct GNUNET_MQ_Envelope *env;
2029 struct ZoneToNameResponseMessage *ztnr_msg;
2030 size_t name_len;
2031 size_t key_len;
2032 ssize_t rd_ser_len;
2033 size_t msg_size;
2034 char *name_tmp;
2035 char *rd_tmp;
2036
2037 GNUNET_assert (0 != seq);
2039 "Found result for zone-to-name lookup: `%s'\n",
2040 name);
2041 ztn_ctx->ec = GNUNET_EC_NONE;
2042 name_len = (NULL == name) ? 0 : strlen (name) + 1;
2044 if (rd_ser_len < 0)
2045 {
2046 GNUNET_break (0);
2047 ztn_ctx->ec = htonl (GNUNET_EC_NAMESTORE_UNKNOWN);
2048 return;
2049 }
2051 msg_size = sizeof(struct ZoneToNameResponseMessage)
2052 + name_len + rd_ser_len + key_len;
2053 if (msg_size >= GNUNET_MAX_MESSAGE_SIZE)
2054 {
2055 GNUNET_break (0);
2057 return;
2058 }
2059 env =
2060 GNUNET_MQ_msg_extra (ztnr_msg,
2061 key_len + name_len + rd_ser_len,
2063 ztnr_msg->gns_header.header.size = htons (msg_size);
2064 ztnr_msg->gns_header.r_id = htonl (ztn_ctx->rid);
2065 ztnr_msg->ec = htonl (ztn_ctx->ec);
2066 ztnr_msg->rd_len = htons (rd_ser_len);
2067 ztnr_msg->rd_count = htons (rd_count);
2068 ztnr_msg->name_len = htons (name_len);
2069 ztnr_msg->key_len = htons (key_len);
2071 &ztnr_msg[1],
2072 key_len);
2073 name_tmp = (char *) &ztnr_msg[1] + key_len;
2074 GNUNET_memcpy (name_tmp, name, name_len);
2075 rd_tmp = &name_tmp[name_len];
2077 rd_ser_len ==
2078 GNUNET_GNSRECORD_records_serialize (rd_count, rd, rd_ser_len, rd_tmp));
2079 ztn_ctx->ec = GNUNET_EC_NONE;
2080 GNUNET_MQ_send (ztn_ctx->nc->mq, env);
2081}

References ZoneToNameCtx::ec, ZoneToNameResponseMessage::ec, env, ZoneToNameResponseMessage::gns_header, GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_private_key_get_length(), GNUNET_CRYPTO_write_private_key_to_buffer(), GNUNET_EC_NAMESTORE_RECORD_TOO_BIG, GNUNET_EC_NAMESTORE_UNKNOWN, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_NAMESTORE_Header::header, ZoneToNameResponseMessage::key_len, NamestoreClient::mq, name, ZoneToNameResponseMessage::name_len, ZoneToNameCtx::nc, GNUNET_NAMESTORE_Header::r_id, rd, rd_count, ZoneToNameResponseMessage::rd_count, ZoneToNameResponseMessage::rd_len, ZoneToNameCtx::rid, and GNUNET_MessageHeader::size.

Referenced by handle_zone_to_name().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_zone_to_name()

static enum GNUNET_GenericReturnValue check_zone_to_name ( void *  cls,
const struct ZoneToNameMessage zis_msg 
)
static

Definition at line 2085 of file gnunet-service-namestore.c.

2087{
2088 return GNUNET_OK;
2089}

References GNUNET_OK.

◆ handle_zone_to_name()

static void handle_zone_to_name ( void *  cls,
const struct ZoneToNameMessage ztn_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME message.

Parameters
clsclient client sending the message
ztn_msgmessage of type 'struct ZoneToNameMessage'

Definition at line 2099 of file gnunet-service-namestore.c.

2100{
2101 struct GNUNET_CRYPTO_PrivateKey zone;
2102 struct GNUNET_CRYPTO_PublicKey value_zone;
2103 struct NamestoreClient *nc = cls;
2104 struct ZoneToNameCtx ztn_ctx;
2105 struct GNUNET_MQ_Envelope *env;
2106 struct ZoneToNameResponseMessage *ztnr_msg;
2107 size_t key_len;
2108 size_t pkey_len;
2109 size_t kb_read;
2110
2111 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received ZONE_TO_NAME message\n");
2112 ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id);
2113 ztn_ctx.nc = nc;
2115 key_len = ntohs (ztn_msg->key_len);
2116 if ((GNUNET_SYSERR ==
2118 key_len,
2119 &zone,
2120 &kb_read)) ||
2121 (kb_read != key_len))
2122 {
2124 "Error parsing private key.\n");
2126 GNUNET_break (0);
2127 return;
2128 }
2129 pkey_len = ntohs (ztn_msg->pkey_len);
2130 if ((GNUNET_SYSERR ==
2132 + key_len,
2133 pkey_len,
2134 &value_zone,
2135 &kb_read)) ||
2136 (kb_read != pkey_len))
2137 {
2139 "Error parsing public key.\n");
2141 GNUNET_break (0);
2142 return;
2143 }
2144 if (GNUNET_SYSERR == nc->GSN_database->zone_to_name (nc->GSN_database->cls,
2145 &zone,
2146 &value_zone,
2148 &ztn_ctx))
2149 {
2150 /* internal error, hang up instead of signalling something
2151 that might be wrong */
2152 GNUNET_break (0);
2154 return;
2155 }
2156 if (GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND == ztn_ctx.ec)
2157 {
2158 /* no result found, send empty response */
2160 "Found no result for zone-to-name lookup.\n");
2161 env = GNUNET_MQ_msg (ztnr_msg,
2163 ztnr_msg->gns_header.r_id = ztn_msg->gns_header.r_id;
2164 ztnr_msg->ec = htonl (GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND);
2165 GNUNET_MQ_send (nc->mq, env);
2166 }
2168}

References ZoneToNameCtx::ec, ZoneToNameResponseMessage::ec, env, ZoneToNameMessage::gns_header, ZoneToNameResponseMessage::gns_header, GNUNET_break, GNUNET_CRYPTO_read_private_key_from_buffer(), GNUNET_CRYPTO_read_public_key_from_buffer(), GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, handle_zone_to_name_it(), ZoneToNameMessage::key_len, ZoneToNameResponseMessage::key_len, nc, ZoneToNameCtx::nc, ZoneToNameMessage::pkey_len, GNUNET_NAMESTORE_Header::r_id, and ZoneToNameCtx::rid.

Here is the call graph for this function:

◆ zone_iterate_proc()

static void zone_iterate_proc ( void *  cls,
uint64_t  seq,
const char *  editor_hint,
const struct GNUNET_CRYPTO_PrivateKey zone_key,
const char *  name,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Process results for zone iteration from database.

Parameters
clsstruct ZoneIterationProcResult
seqsequence number of the record, MUST NOT BE ZERO
zone_keythe zone key
namename
rd_countnumber of records for this name
rdrecord data

Definition at line 2205 of file gnunet-service-namestore.c.

2212{
2213 struct ZoneIterationProcResult *proc = cls;
2214
2215 GNUNET_assert (0 != seq);
2216 if ((NULL == zone_key) && (NULL == name))
2217 {
2218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Iteration done\n");
2219 return;
2220 }
2221 if ((NULL == zone_key) || (NULL == name))
2222 {
2223 /* what is this!? should never happen */
2224 GNUNET_break (0);
2225 return;
2226 }
2227 if (0 == proc->limit)
2228 {
2229 /* what is this!? should never happen */
2230 GNUNET_break (0);
2231 return;
2232 }
2233 proc->zi->seq = seq;
2234 if (0 < send_lookup_response_with_filter (proc->zi->nc,
2235 proc->zi->request_id,
2236 zone_key,
2237 name,
2238 rd_count,
2239 rd,
2240 proc->zi->filter))
2241 proc->limit--;
2242 else
2243 proc->run_again = GNUNET_YES;
2244}

References ZoneIteration::filter, GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_YES, ZoneIterationProcResult::limit, name, ZoneIteration::nc, rd, rd_count, ZoneIteration::request_id, ZoneIterationProcResult::run_again, send_lookup_response_with_filter(), ZoneIteration::seq, and ZoneIterationProcResult::zi.

Referenced by run_zone_iteration_round().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_zone_iteration_round()

static void run_zone_iteration_round ( struct ZoneIteration zi,
uint64_t  limit 
)
static

Perform the next round of the zone iteration.

Parameters
zizone iterator to process
limitnumber of results to return in one pass

Definition at line 2254 of file gnunet-service-namestore.c.

2255{
2256 struct ZoneIterationProcResult proc;
2259 struct NamestoreClient *nc = zi->nc;
2260
2261 memset (&proc, 0, sizeof(proc));
2263 "Asked to return up to %llu records at position %llu\n",
2264 (unsigned long long) limit,
2265 (unsigned long long) zi->seq);
2266 proc.zi = zi;
2267 proc.limit = limit;
2268 proc.run_again = GNUNET_YES;
2270 while (GNUNET_YES == proc.run_again)
2271 {
2272 proc.run_again = GNUNET_NO;
2274 nc->GSN_database->iterate_records (nc->GSN_database->cls,
2275 (GNUNET_YES ==
2277 &zi->zone))
2278 ? NULL
2279 : &zi->zone,
2280 zi->seq,
2281 proc.limit,
2283 &proc));
2284 }
2286 duration = GNUNET_TIME_relative_divide (duration, limit - proc.limit);
2288 "NAMESTORE iteration delay (μs/record)",
2290 GNUNET_NO);
2291 if (0 == proc.limit)
2293 "Returned %llu results, more results available\n",
2294 (unsigned long long) limit);
2295 zi->send_end = (0 != proc.limit);
2297}

References duration, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_is_zero, GNUNET_log, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_SYSERR, GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_divide(), GNUNET_YES, ZoneIterationProcResult::limit, nc, ZoneIteration::nc, GNUNET_TIME_Relative::rel_value_us, ZoneIterationProcResult::run_again, ZoneIteration::send_end, ZoneIteration::seq, start, statistics, ZoneIterationProcResult::zi, ZoneIteration::zone, zone_iterate_proc(), and zone_iteration_done_client_continue().

Referenced by handle_iteration_next(), and handle_iteration_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_iteration_start()

static enum GNUNET_GenericReturnValue check_iteration_start ( void *  cls,
const struct ZoneIterationStartMessage zis_msg 
)
static

Definition at line 2301 of file gnunet-service-namestore.c.

2303{
2304 uint16_t size;
2305 size_t key_len;
2306
2307 size = ntohs (zis_msg->gns_header.header.size);
2308 key_len = ntohs (zis_msg->key_len);
2309
2310 if (size < key_len + sizeof(*zis_msg))
2311 {
2312 GNUNET_break (0);
2313 return GNUNET_SYSERR;
2314 }
2315 return GNUNET_OK;
2316}

References ZoneIterationStartMessage::gns_header, GNUNET_break, GNUNET_OK, GNUNET_SYSERR, GNUNET_NAMESTORE_Header::header, ZoneIterationStartMessage::key_len, GNUNET_MessageHeader::size, and size.

◆ handle_iteration_start()

static void handle_iteration_start ( void *  cls,
const struct ZoneIterationStartMessage zis_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START message.

Parameters
clsthe client sending the message
zis_msgmessage from the client

Definition at line 2326 of file gnunet-service-namestore.c.

2328{
2329 struct GNUNET_CRYPTO_PrivateKey zone;
2330 struct NamestoreClient *nc = cls;
2331 struct ZoneIteration *zi;
2332 size_t key_len;
2333 size_t kb_read;
2334
2336 "Received ZONE_ITERATION_START message\n");
2337 key_len = ntohs (zis_msg->key_len);
2338 zi = GNUNET_new (struct ZoneIteration);
2339 if (0 < key_len)
2340 {
2341 if ((GNUNET_SYSERR ==
2343 key_len,
2344 &zone,
2345 &kb_read)) ||
2346 (kb_read != key_len))
2347 {
2349 GNUNET_free (zi);
2350 return;
2351 }
2352 zi->zone = zone;
2353 }
2354 zi->request_id = ntohl (zis_msg->gns_header.r_id);
2355 zi->filter = ntohs (zis_msg->filter);
2356 zi->offset = 0;
2357 zi->nc = nc;
2358 GNUNET_CONTAINER_DLL_insert (nc->op_head, nc->op_tail, zi);
2360}

References ZoneIteration::filter, ZoneIterationStartMessage::filter, ZoneIterationStartMessage::gns_header, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_read_private_key_from_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, ZoneIterationStartMessage::key_len, nc, ZoneIteration::nc, ZoneIteration::offset, GNUNET_NAMESTORE_Header::r_id, ZoneIteration::request_id, run_zone_iteration_round(), and ZoneIteration::zone.

Here is the call graph for this function:

◆ handle_iteration_stop()

static void handle_iteration_stop ( void *  cls,
const struct ZoneIterationStopMessage zis_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP message.

Parameters
clsthe client sending the message
zis_msgmessage from the client

Definition at line 2370 of file gnunet-service-namestore.c.

2372{
2373 struct NamestoreClient *nc = cls;
2374 struct ZoneIteration *zi;
2375 uint32_t rid;
2376
2378 "Received ZONE_ITERATION_STOP message\n");
2379 rid = ntohl (zis_msg->gns_header.r_id);
2380 for (zi = nc->op_head; NULL != zi; zi = zi->next)
2381 if (zi->request_id == rid)
2382 break;
2383 if (NULL == zi)
2384 {
2385 GNUNET_break (0);
2387 return;
2388 }
2389 GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, zi);
2390 GNUNET_free (zi);
2392}

References ZoneIterationStopMessage::gns_header, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), nc, ZoneIteration::next, GNUNET_NAMESTORE_Header::r_id, and ZoneIteration::request_id.

Here is the call graph for this function:

◆ handle_iteration_next()

static void handle_iteration_next ( void *  cls,
const struct ZoneIterationNextMessage zis_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT message.

Parameters
clsthe client sending the message
zis_msgmessage from the client

Definition at line 2402 of file gnunet-service-namestore.c.

2404{
2405 struct NamestoreClient *nc = cls;
2406 struct ZoneIteration *zi;
2407 uint32_t rid;
2408 uint64_t limit;
2409
2411 "Received ZONE_ITERATION_NEXT message\n");
2413 "Iteration NEXT messages received",
2414 1,
2415 GNUNET_NO);
2416 rid = ntohl (zis_msg->gns_header.r_id);
2417 limit = GNUNET_ntohll (zis_msg->limit);
2418 for (zi = nc->op_head; NULL != zi; zi = zi->next)
2419 if (zi->request_id == rid)
2420 break;
2421 if (NULL == zi)
2422 {
2423 GNUNET_break (0);
2425 return;
2426 }
2427 run_zone_iteration_round (zi, limit);
2428}

References ZoneIterationNextMessage::gns_header, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_ntohll(), GNUNET_SERVICE_client_drop(), GNUNET_STATISTICS_update(), ZoneIterationNextMessage::limit, nc, ZoneIteration::next, GNUNET_NAMESTORE_Header::r_id, ZoneIteration::request_id, run_zone_iteration_round(), and statistics.

Here is the call graph for this function:

◆ monitor_unblock()

static void monitor_unblock ( struct ZoneMonitor zm)
static

Function called when the monitor is ready for more data, and we should thus unblock PUT operations that were blocked on the monitor not being ready.

Definition at line 2437 of file gnunet-service-namestore.c.

2438{
2439 struct StoreActivity *sa = sa_head;
2440
2442 "Unblocking zone monitor %p\n", zm);
2443 while ((NULL != sa) && (zm->limit > zm->iteration_cnt))
2444 {
2445 struct StoreActivity *sn = sa->next;
2446
2447 if (sa->zm_pos == zm)
2449 sa = sn;
2450 }
2451 if (zm->limit > zm->iteration_cnt)
2452 {
2453 zm->sa_waiting = GNUNET_NO;
2454 if (NULL != zm->sa_wait_warning)
2455 {
2456 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
2457 zm->sa_wait_warning = NULL;
2458 }
2459 }
2460 else if (GNUNET_YES == zm->sa_waiting)
2461 {
2462 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
2463 if (NULL != zm->sa_wait_warning)
2464 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
2465 zm->sa_wait_warning =
2468 zm);
2469 }
2470}

References continue_store_activity(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), GNUNET_YES, MONITOR_STALL_WARN_DELAY, StoreActivity::next, sa_head, warn_monitor_slow(), zm, and StoreActivity::zm_pos.

Referenced by handle_monitor_next(), and monitor_sync().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monitor_sync()

static void monitor_sync ( struct ZoneMonitor zm)
static

Send 'sync' message to zone monitor, we're now in sync.

Parameters
zmmonitor that is now in sync

Definition at line 2479 of file gnunet-service-namestore.c.

2480{
2481 struct GNUNET_MQ_Envelope *env;
2482 struct GNUNET_MessageHeader *sync;
2484 "Syncing zone monitor %p\n", zm);
2485
2487 GNUNET_MQ_send (zm->nc->mq, env);
2488 /* mark iteration done */
2489 zm->in_first_iteration = GNUNET_NO;
2490 zm->iteration_cnt = 0;
2491 if ((zm->limit > 0) && (zm->sa_waiting))
2493}

References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_SYNC, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, monitor_unblock(), GNUNET_NAMESTORE_ZoneMonitor::mq, and zm.

Referenced by handle_monitor_start(), and monitor_iteration_next().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monitor_iteration_next()

static void monitor_iteration_next ( void *  cls)
static

Obtain the next datum during the zone monitor's zone initial iteration.

Parameters
clszone monitor that does its initial iteration

Definition at line 2630 of file gnunet-service-namestore.c.

2631{
2632 struct ZoneMonitor *zm = cls;
2633 struct NamestoreClient *nc = zm->nc;
2634 int ret;
2635
2636 zm->task = NULL;
2637 GNUNET_assert (0 == zm->iteration_cnt);
2638 if (zm->limit > 16)
2639 zm->iteration_cnt = zm->limit / 2; /* leave half for monitor events */
2640 else
2641 zm->iteration_cnt = zm->limit; /* use it all */
2642 zm->run_again = GNUNET_YES;
2643 while (GNUNET_YES == zm->run_again)
2644 {
2646 "Running iteration\n");
2647 zm->run_again = GNUNET_NO;
2648 ret = nc->GSN_database->iterate_records (nc->GSN_database->cls,
2650 &zm->zone)) ? NULL : &zm->zone,
2651 zm->seq,
2652 zm->iteration_cnt,
2654 zm);
2655 }
2656 if (GNUNET_SYSERR == ret)
2657 {
2658 GNUNET_SERVICE_client_drop (zm->nc->client);
2659 return;
2660 }
2661 if (GNUNET_NO == ret)
2662 {
2664 "Zone empty... syncing\n");
2665 /* empty zone */
2666 monitor_sync (zm);
2667 return;
2668 }
2669}

References GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_is_zero, GNUNET_log, GNUNET_NO, GNUNET_SERVICE_client_drop(), GNUNET_SYSERR, GNUNET_YES, monitor_iterate_cb(), monitor_sync(), nc, ret, zm, and GNUNET_NAMESTORE_ZoneMonitor::zone.

Referenced by handle_monitor_next(), handle_monitor_start(), and monitor_iterate_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monitor_iterate_cb()

static void monitor_iterate_cb ( void *  cls,
uint64_t  seq,
const char *  editor_hint,
const struct GNUNET_CRYPTO_PrivateKey zone_key,
const char *  name,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

A GNUNET_NAMESTORE_RecordIterator for monitors.

Parameters
clsa 'struct ZoneMonitor *' with information about the monitor
seqsequence number of the record, MUST NOT BE ZERO
zone_keyzone key of the zone
namename
rd_countnumber of records in rd
rdarray of records

Definition at line 2516 of file gnunet-service-namestore.c.

2523{
2524 struct ZoneMonitor *zm = cls;
2525
2526 GNUNET_assert (0 != seq);
2527 zm->seq = seq;
2528 GNUNET_assert (NULL != name);
2530 "Monitor notifications sent",
2531 1,
2532 GNUNET_NO);
2533 if (0 < send_lookup_response_with_filter (zm->nc, 0, zone_key, name,
2534 rd_count, rd, zm->filter))
2535 {
2537 "Sent records.\n");
2538 zm->limit--;
2539 zm->iteration_cnt--;
2540 }
2541 else
2542 zm->run_again = GNUNET_YES;
2543 if ((0 == zm->iteration_cnt) && (0 != zm->limit))
2544 {
2545 /* We are done with the current iteration batch, AND the
2546 client would right now accept more, so go again! */
2547 GNUNET_assert (NULL == zm->task);
2549 }
2550}

References GNUNET_NAMESTORE_ZoneMonitor::filter, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), GNUNET_YES, monitor_iteration_next(), name, rd, rd_count, send_lookup_response_with_filter(), ZoneMonitor::seq, statistics, and zm.

Referenced by monitor_iteration_next().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_monitor_start()

static enum GNUNET_GenericReturnValue check_monitor_start ( void *  cls,
const struct ZoneMonitorStartMessage zis_msg 
)
static

Definition at line 2554 of file gnunet-service-namestore.c.

2556{
2557 uint16_t size;
2558 size_t key_len;
2559
2560 size = ntohs (zis_msg->header.size);
2561 key_len = ntohs (zis_msg->key_len);
2562
2563 if (size < key_len + sizeof(*zis_msg))
2564 {
2565 GNUNET_break (0);
2566 return GNUNET_SYSERR;
2567 }
2568 return GNUNET_OK;
2569}

References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, ZoneMonitorStartMessage::header, ZoneMonitorStartMessage::key_len, GNUNET_MessageHeader::size, and size.

◆ handle_monitor_start()

static void handle_monitor_start ( void *  cls,
const struct ZoneMonitorStartMessage zis_msg 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START message.

Parameters
clsthe client sending the message
zis_msgmessage from the client

Definition at line 2579 of file gnunet-service-namestore.c.

2581{
2582 struct GNUNET_CRYPTO_PrivateKey zone;
2583 struct NamestoreClient *nc = cls;
2584 struct ZoneMonitor *zm;
2585 size_t key_len;
2586 size_t kb_read;
2587
2589 "Received ZONE_MONITOR_START message\n");
2590 zm = GNUNET_new (struct ZoneMonitor);
2591 zm->nc = nc;
2592 key_len = ntohs (zis_msg->key_len);
2593 if (0 < key_len)
2594 {
2595 if ((GNUNET_SYSERR ==
2597 key_len,
2598 &zone,
2599 &kb_read)) ||
2600 (kb_read != key_len))
2601 {
2603 "Error reading private key\n");
2605 GNUNET_free (zm);
2606 return;
2607 }
2608 zm->zone = zone;
2609 }
2610 zm->limit = 1;
2611 zm->filter = ntohs (zis_msg->filter);
2612 zm->in_first_iteration = (GNUNET_YES == ntohl (zis_msg->iterate_first));
2617 if (zm->in_first_iteration)
2619 else
2620 monitor_sync (zm);
2621}

References ZoneMonitorStartMessage::filter, GNUNET_NAMESTORE_ZoneMonitor::filter, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_read_private_key_from_buffer(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_notification_context_add(), GNUNET_SCHEDULER_add_now(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SERVICE_client_mark_monitor(), GNUNET_SYSERR, GNUNET_YES, ZoneMonitorStartMessage::iterate_first, ZoneMonitorStartMessage::key_len, monitor_head, monitor_iteration_next(), monitor_nc, monitor_sync(), monitor_tail, nc, zm, ZoneMonitor::zone, and GNUNET_NAMESTORE_ZoneMonitor::zone.

Here is the call graph for this function:

◆ handle_monitor_next()

static void handle_monitor_next ( void *  cls,
const struct ZoneMonitorNextMessage nm 
)
static

Handles a GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT message.

Parameters
clsthe client sending the message
nmmessage from the client

Definition at line 2679 of file gnunet-service-namestore.c.

2680{
2681 struct NamestoreClient *nc = cls;
2682 struct ZoneMonitor *zm;
2683 uint64_t inc;
2684
2685 inc = GNUNET_ntohll (nm->limit);
2687 "Received ZONE_MONITOR_NEXT message with limit %llu\n",
2688 (unsigned long long) inc);
2689 for (zm = monitor_head; NULL != zm; zm = zm->next)
2690 if (zm->nc == nc)
2691 break;
2692 if (NULL == zm)
2693 {
2694 GNUNET_break (0);
2696 return;
2697 }
2699 if (zm->limit + inc < zm->limit)
2700 {
2701 GNUNET_break (0);
2703 return;
2704 }
2705 zm->limit += inc;
2706 if ((zm->in_first_iteration) && (zm->limit == inc))
2707 {
2708 /* We are still iterating, and the previous iteration must
2709 have stopped due to the client's limit, so continue it! */
2710 GNUNET_assert (NULL == zm->task);
2712 }
2713 GNUNET_assert (zm->iteration_cnt <= zm->limit);
2714 if ((zm->limit > zm->iteration_cnt) && (zm->sa_waiting))
2715 {
2717 }
2718 else if (GNUNET_YES == zm->sa_waiting)
2719 {
2720 if (NULL != zm->sa_wait_warning)
2721 GNUNET_SCHEDULER_cancel (zm->sa_wait_warning);
2722 zm->sa_waiting_start = GNUNET_TIME_absolute_get ();
2723 zm->sa_wait_warning =
2726 zm);
2727 }
2728}

References GNUNET_assert, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_ntohll(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_TIME_absolute_get(), GNUNET_YES, ZoneMonitor::limit, ZoneMonitorNextMessage::limit, monitor_head, monitor_iteration_next(), MONITOR_STALL_WARN_DELAY, monitor_unblock(), nc, warn_monitor_slow(), and zm.

Here is the call graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_SERVICE_Handle service 
)
static

Process namestore requests.

Parameters
clsclosure
cfgconfiguration to use
servicethe initialized service

Definition at line 2739 of file gnunet-service-namestore.c.

2742{
2743 char *database;
2744 (void) cls;
2745 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting namestore service\n");
2747 "namestore",
2748 "RETURN_ORPHANED");
2749 GSN_cfg = cfg;
2751 statistics = GNUNET_STATISTICS_create ("namestore", cfg);
2752 /* Loading database plugin */
2754 "namestore",
2755 "database",
2756 &database))
2757 {
2758 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n");
2760 return;
2761 }
2763 "libgnunet_plugin_namestore_%s",
2764 database);
2766 "Loading %s\n",
2767 db_lib_name);
2770 (void *) cfg);
2771 GNUNET_free (database);
2772 if (NULL == GSN_database)
2773 {
2775 "Could not load database backend `%s'\n",
2776 db_lib_name);
2779 return;
2780 }
2782}

References cfg, cleanup_task, db_lib_name, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_notification_context_create(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PLUGIN_load(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_STATISTICS_create(), GSN_cfg, GSN_database, monitor_nc, return_orphaned, and statistics.

Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Define "main" method using service macro.

Variable Documentation

◆ nick_cache

struct NickCache nick_cache[16]
static

We cache nick records to reduce DB load.

Definition at line 326 of file gnunet-service-namestore.c.

Referenced by cache_nick(), and get_nick_record().

◆ zero

◆ GSN_cfg

const struct GNUNET_CONFIGURATION_Handle* GSN_cfg
static

Configuration handle.

Definition at line 336 of file gnunet-service-namestore.c.

Referenced by client_connect_cb(), and run().

◆ statistics

◆ db_lib_name

char* db_lib_name
static

Name of the database plugin.

Definition at line 346 of file gnunet-service-namestore.c.

Referenced by cleanup_task(), client_connect_cb(), and run().

◆ GSN_database

struct GNUNET_NAMESTORE_PluginFunctions* GSN_database

Database handle for service.

Definition at line 351 of file gnunet-service-namestore.c.

Referenced by cleanup_task(), get_nick_record(), and run().

◆ monitor_head

struct ZoneMonitor* monitor_head
static

First active zone monitor.

Definition at line 357 of file gnunet-service-namestore.c.

Referenced by client_disconnect_cb(), handle_monitor_next(), handle_monitor_start(), and handle_record_store().

◆ monitor_tail

struct ZoneMonitor* monitor_tail
static

Last active zone monitor.

Definition at line 362 of file gnunet-service-namestore.c.

Referenced by client_disconnect_cb(), and handle_monitor_start().

◆ sa_head

struct StoreActivity* sa_head
static

Head of DLL of monitor-blocked store activities.

Definition at line 367 of file gnunet-service-namestore.c.

Referenced by client_disconnect_cb(), free_store_activity(), handle_record_store(), and monitor_unblock().

◆ sa_tail

struct StoreActivity* sa_tail
static

Tail of DLL of monitor-blocked store activities.

Definition at line 372 of file gnunet-service-namestore.c.

Referenced by free_store_activity(), and handle_record_store().

◆ monitor_nc

struct GNUNET_NotificationContext* monitor_nc
static

Notification context shared by all monitors.

Definition at line 377 of file gnunet-service-namestore.c.

Referenced by cleanup_task(), handle_monitor_start(), and run().

◆ return_orphaned

int return_orphaned
static

Returned orphaned records?

Definition at line 382 of file gnunet-service-namestore.c.

Referenced by run().