GNUnet 0.25.2-11-g84e94e98c
 
Loading...
Searching...
No Matches
gnunet-namestore.c File Reference

command line tool to manipulate the local zone More...

#include "platform.h"
#include "gnunet_common.h"
#include <gnunet_util_lib.h>
#include <gnunet_identity_service.h>
#include <gnunet_gnsrecord_lib.h>
#include <gnunet_gns_service.h>
#include <gnunet_namestore_service.h>
#include <inttypes.h>
Include dependency graph for gnunet-namestore.c:

Go to the source code of this file.

Data Structures

struct  RecordSetEntry
 Entry in record set for bulk processing. More...
 
struct  MarkedRecord
 The record marked for deletion. More...
 
struct  EgoEntry
 The default namestore ego. More...
 

Macros

#define WARN_RELATIVE_EXPIRATION_LIMIT
 The upper bound for the zone iteration interval (per record).
 
#define INITIAL_RI_BUFFER_SIZE   5000
 
#define MAX_LINE_LEN   4086
 
#define MAX_ARGS   20
 

Functions

static int parse_expiration (const char *exp_str, int *is_rel, uint64_t *exptime)
 Parse expiration time.
 
static int parse_recordline (const char *line)
 
static void clear_recordset ()
 
static void reset_handles (void)
 
static void do_shutdown (void *cls)
 Task run on shutdown.
 
static void process_command_stdin (void)
 
static void batch_insert_recordinfo (const struct GNUNET_CONFIGURATION_Handle *cfg)
 We have obtained the zone's private key, so now process the main commands using it.
 
static void finish_command (void)
 
static void add_continuation (void *cls, enum GNUNET_ErrorCode ec)
 
static void del_continuation (void *cls, enum GNUNET_ErrorCode ec)
 
static void purge_next_record (void *cls)
 
static void marked_deleted (void *cls, enum GNUNET_ErrorCode ec)
 
static void zone_iteration_finished (void *cls)
 Function called when we are done with a zone iteration.
 
static void zone_iteration_error_cb (void *cls)
 Function called when we encountered an error in a zone iteration.
 
static void collect_zone_records_to_purge (const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
 
static void collect_orphans (const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
 
static void display_record (const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore.
 
static void purge_zone_iterator (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
 
static void purge_orphans_iterator (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
 
static void display_record_iterator (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
 Process a record that was stored in the namestore.
 
static void display_record_monitor (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
 Process a record that was stored in the namestore.
 
static void display_record_lookup (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore.
 
static void sync_cb (void *cls)
 Function called once we are in sync in monitor mode.
 
static void monitor_error_cb (void *cls)
 Function called on errors while monitoring.
 
static void lookup_error_cb (void *cls)
 Function called on errors while monitoring.
 
static void add_error_cb (void *cls)
 Function called if lookup fails.
 
static void get_existing_record (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 We're storing a record; this function is given the existing record so that we can merge the information.
 
static void reverse_error_cb (void *cls)
 Function called if we encountered an error in zone-to-name.
 
static void handle_reverse_lookup (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Function called with the result of our attempt to obtain a name for a given public key.
 
static void del_lookup_error_cb (void *cls)
 Function called if lookup for deletion fails.
 
static void del_monitor (void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 We were asked to delete something; this function is called with the existing records.
 
static void schedule_finish (void *cls)
 
static void replace_cont (void *cls, enum GNUNET_ErrorCode ec)
 
static void run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg_)
 We have obtained the zone's private key, so now process the main commands using it.
 
static int get_identity_for_string (const char *str, struct GNUNET_CRYPTO_BlindablePrivateKey *zk)
 
static void id_connect_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *ego_name_tmp)
 Function called with ALL of the egos known to the identity service, used on startup if the user did not specify a zone on the command-line.
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *_cfg)
 Main function that will be run.
 
int main (int argc, char *const *argv)
 The main function for gnunet-namestore.
 

Variables

static struct GNUNET_NAMESTORE_Handlens
 Handle to the namestore.
 
static struct GNUNET_CRYPTO_BlindablePrivateKey zone_pkey
 Private key for the our zone.
 
static struct GNUNET_IDENTITY_Handleidh
 Identity service handle.
 
static char * ego_name
 Name of the ego controlling the zone.
 
static struct GNUNET_NAMESTORE_QueueEntryadd_qe_uri
 Queue entry for the 'add-uri' operation.
 
static struct GNUNET_NAMESTORE_QueueEntryadd_qe
 Queue entry for the 'add' operation.
 
static struct GNUNET_NAMESTORE_QueueEntryget_qe
 Queue entry for the 'lookup' operation.
 
static struct GNUNET_NAMESTORE_QueueEntryreverse_qe
 Queue entry for the 'reverse lookup' operation (in combination with a name).
 
static struct MarkedRecordmarked_head
 Marked record list.
 
static struct MarkedRecordmarked_tail
 Marked record list.
 
const struct GNUNET_CONFIGURATION_Handlecfg
 Configuration handle.
 
static struct EgoEntryego_head
 Ego list.
 
static struct EgoEntryego_tail
 Ego list.
 
static struct GNUNET_NAMESTORE_ZoneIteratorlist_it
 List iterator for the 'list' operation.
 
static int read_from_stdin
 Run in read from stdin mode.
 
static int list
 Desired action is to list records.
 
static int add
 Desired action is to add a record.
 
static int del
 Desired action is to remove a record.
 
static int is_public
 Is record public (opposite of GNUNET_GNSRECORD_RF_PRIVATE)
 
static int is_shadow
 Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW)
 
static int is_maintenance
 Is record a maintenance record (GNUNET_GNSRECORD_RF_MAINTENANCE)
 
static int omit_private
 Filter private records.
 
static int output_recordline
 Output in recordline format.
 
static int purge_zone
 Purge zone contents.
 
static int include_maintenance
 Do not filter maintenance records.
 
static int purge_orphaned
 Purge orphaned records.
 
static int list_orphaned
 List records and zone keys of orphaned records.
 
static struct GNUNET_NAMESTORE_QueueEntrydel_qe
 Queue entry for the 'del' operation.
 
static struct GNUNET_NAMESTORE_QueueEntryset_qe
 Queue entry for the 'set/replace' operation.
 
static struct GNUNET_NAMESTORE_QueueEntryns_qe
 Queue entry for begin/commit.
 
static char * name
 Name of the records to add/list/remove.
 
static char * value
 Value of the record to add/remove.
 
static char * uri
 URI to import.
 
static char * reverse_pkey
 Reverse lookup to perform.
 
static char * typestring
 Type of the record to add/remove, NULL to remove all.
 
static char * expirationstring
 Desired expiration time.
 
static char * nickstring
 Desired nick name.
 
static int ret
 Global return value.
 
static uint32_t type
 Type string converted to DNS type value.
 
static void * data
 Value in binary format.
 
static size_t data_size
 Number of bytes in data.
 
static uint64_t etime
 Expiration string converted to numeric value.
 
static int etime_is_rel = GNUNET_SYSERR
 Is expiration time relative or absolute time?
 
static struct GNUNET_NAMESTORE_ZoneMonitorzm
 Monitor handle.
 
static int monitor
 Enables monitor mode.
 
static struct RecordSetEntryrecordset
 Entry in record set for processing records in bulk.
 
static struct GNUNET_SCHEDULER_Taskpurge_task
 Purge task.
 
static unsigned int ri_count = 0
 
static struct GNUNET_NAMESTORE_RecordInforecord_info
 
static unsigned int record_info_capacity = 0
 Maximum capacity of record_info array.
 
static unsigned int max_batch_size = 1000
 
static unsigned int ri_sent = 0
 

Detailed Description

command line tool to manipulate the local zone

Author
Christian Grothoff

TODO:

  • test

Definition in file gnunet-namestore.c.

Macro Definition Documentation

◆ WARN_RELATIVE_EXPIRATION_LIMIT

#define WARN_RELATIVE_EXPIRATION_LIMIT
Value:
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
Definition time.c:486

The upper bound for the zone iteration interval (per record).

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

47{
51 struct RecordSetEntry *next;
52
57};
58
62struct MarkedRecord
63{
67 struct MarkedRecord *next;
68
72 struct MarkedRecord *prev;
73
77 char *name;
78
83};
84
88struct EgoEntry
89{
93 struct EgoEntry *next;
94
98 struct EgoEntry *prev;
99
103 char *identifier;
104
108 struct GNUNET_IDENTITY_Ego *ego;
109};
110
114static struct GNUNET_NAMESTORE_Handle *ns;
115
120
124static struct GNUNET_IDENTITY_Handle *idh;
125
129static char *ego_name;
130
135
140
145
150
154static struct MarkedRecord *marked_head;
155
159static struct MarkedRecord *marked_tail;
160
164const struct GNUNET_CONFIGURATION_Handle *cfg;
165
169static struct EgoEntry *ego_head;
170
174static struct EgoEntry *ego_tail;
175
180
184static int read_from_stdin;
185
189static int list;
190
194static int add;
195
199static int del;
200
204static int is_public;
205
209static int is_shadow;
210
214static int is_maintenance;
215
219static int omit_private;
220
224static int output_recordline;
225
226
230static int purge_zone;
231
235static int include_maintenance;
236
240static int purge_orphaned;
241
245static int list_orphaned;
246
251
256
261
265static char *name;
266
270static char *value;
271
275static char *uri;
276
280static char *reverse_pkey;
281
285static char *typestring;
286
290static char *expirationstring;
291
295static char *nickstring;
296
300static int ret;
301
305static uint32_t type;
306
310static void *data;
311
315static size_t data_size;
316
320static uint64_t etime;
321
325static int etime_is_rel = GNUNET_SYSERR;
326
330static struct GNUNET_NAMESTORE_ZoneMonitor *zm;
331
335static int monitor;
336
340static struct RecordSetEntry *recordset;
341
345static struct GNUNET_SCHEDULER_Task *purge_task;
346
347/* FIXME: Make array and grow as needed */
348#define INITIAL_RI_BUFFER_SIZE 5000
349
350static unsigned int ri_count = 0;
351
353
355static unsigned int record_info_capacity = 0;
356
357/* How many records to put simulatneously */
358static unsigned int max_batch_size = 1000;
359
368static int
369parse_expiration (const char *exp_str,
370 int *is_rel,
371 uint64_t *exptime)
372{
373 struct GNUNET_TIME_Relative etime_rel;
374 struct GNUNET_TIME_Absolute etime_abs;
375
376 if (0 == strcmp (exp_str, "never"))
377 {
379 *is_rel = GNUNET_NO;
380 return GNUNET_OK;
381 }
382 if (GNUNET_OK ==
383 GNUNET_STRINGS_fancy_time_to_relative (exp_str, &etime_rel))
384 {
385 *is_rel = GNUNET_YES;
386 *exptime = etime_rel.rel_value_us;
388 {
390 "Relative expiration times of less than %s are not recommended. To improve availability, consider increasing this value.\n",
393 }
395 "Storing record with relative expiration time of %s\n",
397 return GNUNET_OK;
398 }
399 if (GNUNET_OK ==
400 GNUNET_STRINGS_fancy_time_to_absolute (exp_str, &etime_abs))
401 {
402 *is_rel = GNUNET_NO;
403 *exptime = etime_abs.abs_value_us;
405 "Storing record with absolute expiration time of %s\n",
407 return GNUNET_OK;
408 }
409 return GNUNET_SYSERR;
410}
411
412
413static int
414parse_recordline (const char *line)
415{
416 struct RecordSetEntry *r;
418 char *cp;
419 char *tok;
420 char *saveptr;
421 void *raw_data;
422
423 cp = GNUNET_strdup (line);
424 tok = strtok_r (cp, " ", &saveptr);
425 if (NULL == tok)
426 {
428 _ ("Missing entries in record line `%s'.\n"),
429 line);
430 GNUNET_free (cp);
431 return GNUNET_SYSERR;
432 }
434 if (UINT32_MAX == record.record_type)
435 {
436 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Unknown record type `%s'\n"), tok);
437 GNUNET_free (cp);
438 return GNUNET_SYSERR;
439 }
440 tok = strtok_r (NULL, " ", &saveptr);
441 if (NULL == tok)
442 {
444 _ ("Empty record line argument is not allowed.\n"));
445 GNUNET_free (cp);
446 return GNUNET_SYSERR;
447 }
448 if (1 != sscanf (tok, "%" SCNu64, &record.expiration_time))
449 {
450 fprintf (stderr,
451 _ ("Error parsing expiration time %s.\n"), tok);
452 GNUNET_free (cp);
453 return GNUNET_SYSERR;
454 }
455 tok = strtok_r (NULL, " ", &saveptr);
456 if (NULL == tok)
457 {
459 _ ("Empty record line argument is not allowed.\n"));
460 GNUNET_free (cp);
461 return GNUNET_SYSERR;
462 }
464 if (NULL != strchr (tok, (unsigned char) 'r'))
466 if (NULL == strchr (tok, (unsigned char) 'p')) /* p = public */
468 if (NULL != strchr (tok, (unsigned char) 'S'))
470 if (NULL != strchr (tok, (unsigned char) 's'))
472 if (NULL != strchr (tok, (unsigned char) 'C'))
474 tok += strlen (tok) + 1;
476 tok,
477 &raw_data,
478 &record.data_size))
479 {
481 _ ("Invalid record data for type %s: `%s'.\n"),
483 tok);
484 GNUNET_free (cp);
485 return GNUNET_SYSERR;
486 }
487 GNUNET_free (cp);
488
489 r = GNUNET_malloc (sizeof(struct RecordSetEntry) + record.data_size);
490 r->next = recordset;
491 record.data = &r[1];
492 memcpy (&r[1], raw_data, record.data_size);
493 GNUNET_free (raw_data);
494 r->record = record;
495 recordset = r;
496 return GNUNET_OK;
497}
498
499
500static void
502{
503 struct RecordSetEntry *rs_entry;
504
505 while (NULL != (rs_entry = recordset))
506 {
508 GNUNET_free (rs_entry);
509 }
510 recordset = NULL;
511}
512
513
514static void
515reset_handles (void)
516{
517 struct MarkedRecord *mrec;
518 struct MarkedRecord *mrec_tmp;
520 if (NULL != ego_name)
521 {
523 ego_name = NULL;
524 }
525 if (NULL != name)
526 {
528 name = NULL;
529 }
530 if (NULL != value)
531 {
533 value = NULL;
534 }
535 if (NULL != uri)
536 {
538 uri = NULL;
539 }
540 if (NULL != expirationstring)
541 {
543 expirationstring = NULL;
544 }
545 if (NULL != purge_task)
546 {
548 purge_task = NULL;
549 }
550 for (mrec = marked_head; NULL != mrec;)
551 {
552 mrec_tmp = mrec;
553 mrec = mrec->next;
554 GNUNET_free (mrec_tmp->name);
555 GNUNET_free (mrec_tmp);
556 }
557 if (NULL != list_it)
558 {
560 list_it = NULL;
561 }
562 if (NULL != add_qe)
563 {
565 add_qe = NULL;
566 }
567 if (NULL != set_qe)
568 {
570 set_qe = NULL;
571 }
572 if (NULL != add_qe_uri)
573 {
575 add_qe_uri = NULL;
576 }
577 if (NULL != get_qe)
578 {
580 get_qe = NULL;
581 }
582 if (NULL != del_qe)
583 {
585 del_qe = NULL;
586 }
587 if (NULL != reverse_qe)
588 {
590 reverse_qe = NULL;
591 }
592 memset (&zone_pkey, 0, sizeof(zone_pkey));
593 if (NULL != zm)
594 {
596 zm = NULL;
597 }
598 if (NULL != data)
599 {
601 data = NULL;
602 }
603 if (NULL != typestring)
604 {
606 typestring = NULL;
607 }
608 list = 0;
609 is_public = 0;
610 is_shadow = 0;
611 is_maintenance = 0;
612 purge_zone = 0;
613}
614
615
621static void
622do_shutdown (void *cls)
623{
624 struct EgoEntry *ego_entry;
625 struct EgoEntry *ego_tmp;
626 (void) cls;
627
628 reset_handles ();
629 if (NULL != record_info)
631 record_info = NULL;
632 if (NULL != ns_qe)
633 {
635 ns_qe = NULL;
636 }
637 if (NULL != ns)
638 {
640 ns = NULL;
641 }
642 if (NULL != idh)
643 {
645 idh = NULL;
646 }
647 for (ego_entry = ego_head; NULL != ego_entry;)
648 {
649 ego_tmp = ego_entry;
650 ego_entry = ego_entry->next;
651 GNUNET_free (ego_tmp->identifier);
652 GNUNET_free (ego_tmp);
653 }
654}
655
656
657static void
659
660static unsigned int ri_sent = 0;
661
668static void
670
671static void
672finish_command (void)
673{
674 // if (ri_sent < ri_count)
675 // {
676 // batch_insert_recordinfo (cfg);
677 // return;
678 // }
679 // reset_handles ();
680 if (read_from_stdin)
681 {
683 return;
684 }
686}
687
688
689static void
690add_continuation (void *cls, enum GNUNET_ErrorCode ec)
691{
692 struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
693
694 *qe = NULL;
695 if (GNUNET_EC_NONE != ec)
696 {
697 fprintf (stderr,
698 _ ("Adding record failed: %s\n"),
701 ret = 1;
703 return;
704 }
705 ret = 0;
707}
708
709
710static void
711del_continuation (void *cls, enum GNUNET_ErrorCode ec)
712{
713 (void) cls;
714 del_qe = NULL;
716 {
717 fprintf (stderr,
718 _ ("Deleting record failed: %s\n"), GNUNET_ErrorCode_get_hint (
719 ec));
720 }
722}
723
724
725static void
726purge_next_record (void *cls);
727
728static void
729marked_deleted (void *cls, enum GNUNET_ErrorCode ec)
730{
731 del_qe = NULL;
732 if (GNUNET_EC_NONE != ec)
733 {
734 fprintf (stderr,
735 _ ("Deleting record failed: %s\n"),
737 }
739}
740
741
742static void
743purge_next_record (void *cls)
744{
745 struct MarkedRecord *mrec;
746 purge_task = NULL;
747
748 if (NULL == marked_head)
749 {
750 ret = 0;
752 return;
753 }
754 mrec = marked_head;
757 mrec);
759 &mrec->key,
760 mrec->name,
761 0, NULL,
763 NULL);
764 GNUNET_free (mrec->name);
765 GNUNET_free (mrec);
766}
767
768
772static void
773zone_iteration_finished (void *cls)
774{
775 (void) cls;
776 list_it = NULL;
778 {
780 return;
781 }
782 ret = 0;
784}
785
786
790static void
791zone_iteration_error_cb (void *cls)
792{
793 (void) cls;
794 list_it = NULL;
795 fprintf (stderr, "Error iterating over zone\n");
796 ret = 1;
798}
799
800
801static void
804 const char *rname,
805 unsigned int rd_len,
806 const struct GNUNET_GNSRECORD_Data *rd)
807{
808 struct MarkedRecord *mrec;
809
810 mrec = GNUNET_new (struct MarkedRecord);
811 mrec->key = *zone_key;
812 mrec->name = GNUNET_strdup (rname);
815 mrec);
816}
817
818
819static void
821 const char *rname,
822 unsigned int rd_len,
823 const struct GNUNET_GNSRECORD_Data *rd)
824{
825 struct EgoEntry *ego;
826 struct MarkedRecord *orphan;
827 int is_orphaned = 1;
828
829 for (ego = ego_head; NULL != ego; ego = ego->next)
830 {
831 if (0 == memcmp (GNUNET_IDENTITY_ego_get_private_key (ego->ego),
832 zone_key,
833 sizeof (*zone_key)))
834 {
835 is_orphaned = 0;
836 break;
837 }
838 }
839 if (is_orphaned)
840 {
841 orphan = GNUNET_new (struct MarkedRecord);
842 orphan->key = *zone_key;
843 orphan->name = GNUNET_strdup (rname);
846 orphan);
847 }
848}
849
850
858static void
860 const char *rname,
861 unsigned int rd_len,
862 const struct GNUNET_GNSRECORD_Data *rd)
863{
864 const char *typestr;
865 char *s;
866 const char *ets;
867 struct GNUNET_TIME_Absolute at;
868 struct GNUNET_TIME_Relative rt;
869 struct EgoEntry *ego;
870 int have_record;
871 int is_orphaned = 1;
872 char *orphaned_str;
873
874 if ((NULL != name) && (0 != strcmp (name, rname)))
875 return;
876 have_record = GNUNET_NO;
877 for (unsigned int i = 0; i < rd_len; i++)
878 {
879 if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
880 (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
881 continue;
882 if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
883 continue;
884 have_record = GNUNET_YES;
885 break;
886 }
887 if (GNUNET_NO == have_record)
888 return;
889 for (ego = ego_head; NULL != ego; ego = ego->next)
890 {
891 if (0 == memcmp (GNUNET_IDENTITY_ego_get_private_key (ego->ego),
892 zone_key,
893 sizeof (*zone_key)))
894 {
895 is_orphaned = 0;
896 break;
897 }
898 }
899 if (list_orphaned && ! is_orphaned)
900 return;
901 if (! list_orphaned && is_orphaned)
902 return;
903 orphaned_str = GNUNET_CRYPTO_blindable_private_key_to_string (zone_key);
904 fprintf (stdout, "%s.%s:\n", rname, is_orphaned ? orphaned_str :
905 ego->identifier);
906 GNUNET_free (orphaned_str);
907 if (NULL != typestring)
909 else
911 for (unsigned int i = 0; i < rd_len; i++)
912 {
913 if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
914 (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
915 continue;
916 if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
917 continue;
918 typestr = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
919 s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
920 rd[i].data,
921 rd[i].data_size);
922 if (NULL == s)
923 {
924 fprintf (stdout,
925 _ ("\tCorrupt or unsupported record of type %u\n"),
926 (unsigned int) rd[i].record_type);
927 continue;
928 }
929 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
930 {
931 rt.rel_value_us = rd[i].expiration_time;
933 }
934 else
935 {
936 at.abs_value_us = rd[i].expiration_time;
938 }
939 {
940 char flgstr[16];
941 sprintf (flgstr, "[%s%s%s%s%s]",
942 (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE) ? "" : "p",
943 (rd[i].flags & GNUNET_GNSRECORD_RF_SUPPLEMENTAL) ? "S" : "",
945 "",
946 (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW) ? "S" : "",
947 (rd[i].flags & GNUNET_GNSRECORD_RF_CRITICAL) ? "C" : "");
949 fprintf (stdout,
950 " %s %" PRIu64 " %s %s\n",
951 typestr,
952 rd[i].expiration_time,
953 flgstr,
954 s);
955 else
956 fprintf (stdout,
957 "\t%s: %s (%s)\t%s\t%s\t%s\n",
958 typestr,
959 s,
960 ets,
961 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE"
962 : "PUBLIC",
963 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW)) ? "SHADOW"
964 : "",
965 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_MAINTENANCE)) ?
966 "MAINTENANCE"
967 : "");
968 GNUNET_free (s);
969 }
970 }
971 // fprintf (stdout, "%s", "\n");
972}
973
974
975static void
976purge_zone_iterator (void *cls,
977 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key,
978 const char *rname,
979 unsigned int rd_len,
980 const struct GNUNET_GNSRECORD_Data *rd,
981 struct GNUNET_TIME_Absolute expiry)
982{
983 (void) cls;
984 (void) zone_key;
985 (void) expiry;
986 collect_zone_records_to_purge (zone_key, rname, rd_len, rd);
988}
989
990
991static void
992purge_orphans_iterator (void *cls,
993 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key
994 ,
995 const char *rname,
996 unsigned int rd_len,
997 const struct GNUNET_GNSRECORD_Data *rd,
998 struct GNUNET_TIME_Absolute expiry)
999{
1000 (void) cls;
1001 (void) zone_key;
1002 (void) expiry;
1003 collect_orphans (zone_key, rname, rd_len, rd);
1005}
1006
1007
1017static void
1018display_record_iterator (void *cls,
1020 zone_key,
1021 const char *rname,
1022 unsigned int rd_len,
1023 const struct GNUNET_GNSRECORD_Data *rd,
1024 struct GNUNET_TIME_Absolute expiry)
1025{
1026 (void) cls;
1027 (void) zone_key;
1028 (void) expiry;
1029 display_record (zone_key, rname, rd_len, rd);
1031}
1032
1033
1043static void
1044display_record_monitor (void *cls,
1045 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key
1046 ,
1047 const char *rname,
1048 unsigned int rd_len,
1049 const struct GNUNET_GNSRECORD_Data *rd,
1050 struct GNUNET_TIME_Absolute expiry)
1051{
1052 (void) cls;
1053 (void) zone_key;
1054 (void) expiry;
1055 display_record (zone_key, rname, rd_len, rd);
1057}
1058
1059
1069static void
1070display_record_lookup (void *cls,
1071 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key,
1072 const char *rname,
1073 unsigned int rd_len,
1074 const struct GNUNET_GNSRECORD_Data *rd)
1075{
1076 (void) cls;
1077 (void) zone_key;
1078 get_qe = NULL;
1079 display_record (zone_key, rname, rd_len, rd);
1080 finish_command ();
1081}
1082
1083
1089static void
1090sync_cb (void *cls)
1091{
1092 (void) cls;
1093 fprintf (stdout, "%s", "Monitor is now in sync.\n");
1094}
1095
1096
1102static void
1103monitor_error_cb (void *cls)
1104{
1105 (void) cls;
1106 fprintf (stderr, "%s", "Monitor disconnected and out of sync.\n");
1107}
1108
1109
1115static void
1116lookup_error_cb (void *cls)
1117{
1118 (void) cls;
1119 get_qe = NULL;
1120 fprintf (stderr, "%s", "Failed to lookup record.\n");
1121 finish_command ();
1122}
1123
1124
1128static void
1129add_error_cb (void *cls)
1130{
1131 (void) cls;
1132 add_qe = NULL;
1133 GNUNET_break (0);
1134 ret = 1;
1135 finish_command ();
1136}
1137
1138
1149static void
1150get_existing_record (void *cls,
1151 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key,
1152 const char *rec_name,
1153 unsigned int rd_count,
1154 const struct GNUNET_GNSRECORD_Data *rd)
1155{
1156 struct GNUNET_GNSRECORD_Data rdn[rd_count + 1];
1157 struct GNUNET_GNSRECORD_Data *rde;
1158
1159 (void) cls;
1160 (void) zone_key;
1161 add_qe = NULL;
1162 if (0 != strcmp (rec_name, name))
1163 {
1164 GNUNET_break (0);
1165 ret = 1;
1166 finish_command ();
1167 return;
1168 }
1169
1171 "Received %u records for name `%s'\n",
1172 rd_count,
1173 rec_name);
1174 for (unsigned int i = 0; i < rd_count; i++)
1175 {
1176 switch (rd[i].record_type)
1177 {
1180 {
1181 fprintf (
1182 stderr,
1183 _ (
1184 "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"),
1185 rec_name);
1186 ret = 1;
1187 finish_command ();
1188 return;
1189 }
1190 break;
1191 }
1192 }
1193 memset (rdn, 0, sizeof(struct GNUNET_GNSRECORD_Data));
1194 GNUNET_memcpy (&rdn[1], rd, rd_count * sizeof(struct GNUNET_GNSRECORD_Data));
1195 rde = &rdn[0];
1196 rde->data = data;
1197 rde->data_size = data_size;
1198 rde->record_type = type;
1199 if (1 == is_shadow)
1201 if (1 == is_maintenance)
1203 if (1 != is_public)
1205 rde->expiration_time = etime;
1206 if (GNUNET_YES == etime_is_rel)
1208 else if (GNUNET_NO != etime_is_rel)
1210 GNUNET_assert (NULL != name);
1212 &zone_pkey,
1213 name,
1214 rd_count + 1,
1215 rde,
1217 &add_qe);
1218}
1219
1220
1224static void
1225reverse_error_cb (void *cls)
1226{
1227 (void) cls;
1228 reverse_qe = NULL;
1229 fprintf (stdout, "%s.zkey\n", reverse_pkey);
1230}
1231
1232
1243static void
1244handle_reverse_lookup (void *cls,
1245 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone,
1246 const char *label,
1247 unsigned int rd_count,
1248 const struct GNUNET_GNSRECORD_Data *rd)
1249{
1250 (void) cls;
1251 (void) zone;
1252 (void) rd_count;
1253 (void) rd;
1254 reverse_qe = NULL;
1255 if (NULL == label)
1256 fprintf (stdout, "%s\n", reverse_pkey);
1257 else
1258 fprintf (stdout, "%s.%s\n", label, ego_name);
1259 finish_command ();
1260}
1261
1262
1266static void
1267del_lookup_error_cb (void *cls)
1268{
1269 (void) cls;
1270 del_qe = NULL;
1271 GNUNET_break (0);
1272 ret = 1;
1273 finish_command ();
1274}
1275
1276
1288static void
1289del_monitor (void *cls,
1290 const struct GNUNET_CRYPTO_BlindablePrivateKey *zone,
1291 const char *label,
1292 unsigned int rd_count,
1293 const struct GNUNET_GNSRECORD_Data *rd)
1294{
1295 struct GNUNET_GNSRECORD_Data rdx[rd_count];
1296 unsigned int rd_left;
1297 uint32_t del_type;
1298 char *vs;
1299
1300 (void) cls;
1301 (void) zone;
1302 del_qe = NULL;
1303 if (0 == rd_count)
1304 {
1305 fprintf (stderr,
1306 _ (
1307 "There are no records under label `%s' that could be deleted.\n")
1308 ,
1309 label);
1310 ret = 1;
1311 finish_command ();
1312 return;
1313 }
1314 if ((NULL == value) && (NULL == typestring))
1315 {
1316 /* delete everything */
1318 &zone_pkey,
1319 name,
1320 0,
1321 NULL,
1323 NULL);
1324 return;
1325 }
1326 rd_left = 0;
1327 if (NULL != typestring)
1329 else
1330 del_type = GNUNET_GNSRECORD_TYPE_ANY;
1331 for (unsigned int i = 0; i < rd_count; i++)
1332 {
1333 vs = NULL;
1334 if (! (((GNUNET_GNSRECORD_TYPE_ANY == del_type) ||
1335 (rd[i].record_type == del_type)) &&
1336 ((NULL == value) ||
1337 (NULL ==
1339 rd[i].data,
1340 rd[i].data_size)))) ||
1341 (0 == strcmp (vs, value)))))
1342 rdx[rd_left++] = rd[i];
1343 GNUNET_free (vs);
1344 }
1345 if (rd_count == rd_left)
1346 {
1347 /* nothing got deleted */
1348 fprintf (
1349 stderr,
1350 _ (
1351 "There are no records under label `%s' that match the request for deletion.\n"),
1352 label);
1353 finish_command ();
1354 return;
1355 }
1356 /* delete everything but what we copied to 'rdx' */
1358 &zone_pkey,
1359 name,
1360 rd_left,
1361 rdx,
1363 NULL);
1364}
1365
1366
1367static void
1368schedule_finish (void*cls)
1369{
1370 finish_command ();
1371}
1372
1373
1374static void
1375replace_cont (void *cls, enum GNUNET_ErrorCode ec)
1376{
1377 (void) cls;
1378
1379 set_qe = NULL;
1380 if (GNUNET_EC_NONE != ec)
1381 {
1383 _ ("%s\n"),
1385 ret = 1; /* fail from 'main' */
1386 }
1388}
1389
1390
1397static void
1399{
1400 unsigned int sent_here;
1401
1402 GNUNET_assert (0 != ri_count);
1404 &zone_pkey,
1405 ri_count - ri_sent,
1407 &sent_here,
1408 &replace_cont,
1409 NULL);
1410 ri_sent += sent_here;
1411 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d/%d record infos\n", ri_sent,
1412 ri_count);
1413 if (ri_sent == ri_count)
1414 {
1415 for (int i = 0; i < ri_count; i++)
1416 {
1417 GNUNET_free (record_info[i].a_rd);
1418 record_info[i].a_rd = NULL;
1419 }
1420 ri_count = 0;
1421 ri_sent = 0;
1422 }
1423 return;
1424}
1425
1426
1433static void
1435{
1438
1439 if (omit_private)
1443 if (! (add | del | list | (NULL != nickstring) | (NULL != uri)
1444 | (NULL != reverse_pkey) | (NULL != recordset) | (monitor)
1446 {
1447 /* nothing more to be done */
1448 fprintf (stderr, _ ("No options given\n"));
1449 finish_command ();
1450 return;
1451 }
1452
1453 if (NULL != recordset)
1454 {
1455 /* replace entire record set */
1456 unsigned int rd_count;
1457 struct GNUNET_GNSRECORD_Data *rd_tmp;
1458
1459 /* FIXME: We could easily support append and delete with this as well */
1460 if (! add)
1461 {
1462 fprintf (stderr, _ ("Recordlines only work with option `%s'\n"),
1463 "-a");
1464 ret = 1;
1465 finish_command ();
1466 return;
1467 }
1468 if (NULL == name)
1469 {
1470 fprintf (stderr,
1471 _ ("Missing option `%s' for operation `%s'\n"),
1472 "-n",
1473 _ ("name"));
1474 ret = 1;
1475 finish_command ();
1476 return;
1477 }
1478 rd_count = 0;
1479 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1480 rd_count++;
1482 rd_count = 0;
1483 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1484 {
1485 rd_tmp[rd_count] = e->record;
1486 rd_count++;
1487 }
1489 &zone_pkey,
1490 name,
1491 rd_count,
1492 rd_tmp,
1493 &replace_cont,
1494 NULL);
1495 GNUNET_free (rd_tmp);
1496 return;
1497 }
1498 if (NULL != nickstring)
1499 {
1500 if (0 == strlen (nickstring))
1501 {
1502 fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
1503 ret = 1;
1504 finish_command ();
1505 return;
1506 }
1507 add = 1;
1512 is_public = 0;
1513 expirationstring = GNUNET_strdup ("never");
1515 nickstring = NULL;
1516 }
1517
1518 if (add)
1519 {
1520 if (NULL == ego_name)
1521 {
1522 fprintf (stderr,
1523 _ ("Missing option `%s' for operation `%s'\n"),
1524 "-z",
1525 _ ("add"));
1526 ret = 1;
1527 finish_command ();
1528 return;
1529 }
1530 if (NULL == name)
1531 {
1532 fprintf (stderr,
1533 _ ("Missing option `%s' for operation `%s'\n"),
1534 "-n",
1535 _ ("add"));
1536 ret = 1;
1537 finish_command ();
1538 return;
1539 }
1540 if (NULL == typestring)
1541 {
1542 fprintf (stderr,
1543 _ ("Missing option `%s' for operation `%s'\n"),
1544 "-t",
1545 _ ("add"));
1546 ret = 1;
1547 finish_command ();
1548 return;
1549 }
1551 if (UINT32_MAX == type)
1552 {
1553 fprintf (stderr, _ ("Unsupported type `%s'\n"), typestring);
1554 ret = 1;
1555 finish_command ();
1556 return;
1557 }
1562 {
1563 fprintf (stderr,
1564 _ (
1565 "For DNS record types `SRV', `TLSA', `SMIMEA' and `OPENPGPKEY'"));
1566 fprintf (stderr, ", please use a `BOX' record instead\n");
1567 ret = 1;
1568 finish_command ();
1569 return;
1570 }
1571 if (NULL == value)
1572 {
1573 fprintf (stderr,
1574 _ ("Missing option `%s' for operation `%s'\n"),
1575 "-V",
1576 _ ("add"));
1577 ret = 1;
1578 finish_command ();
1579 return;
1580 }
1581 if (GNUNET_OK !=
1583 {
1584 fprintf (stderr,
1585 _ ("Value `%s' invalid for record type `%s'\n"),
1586 value,
1587 typestring);
1588 ret = 1;
1589 finish_command ();
1590 return;
1591 }
1592 if (NULL == expirationstring)
1593 {
1594 fprintf (stderr,
1595 _ ("Missing option `%s' for operation `%s'\n"),
1596 "-e",
1597 _ ("add"));
1598 ret = 1;
1599 finish_command ();
1600 return;
1601 }
1603 {
1604 fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1605 ret = 1;
1606 finish_command ();
1607 return;
1608 }
1610 &zone_pkey,
1611 name,
1612 &add_error_cb,
1613 NULL,
1615 NULL);
1616 }
1617 if (del)
1618 {
1619 if (NULL == ego_name)
1620 {
1621 fprintf (stderr,
1622 _ ("Missing option `%s' for operation `%s'\n"),
1623 "-z",
1624 _ ("del"));
1625 ret = 1;
1626 finish_command ();
1627 return;
1628 }
1629 if (NULL == name)
1630 {
1631 fprintf (stderr,
1632 _ ("Missing option `%s' for operation `%s'\n"),
1633 "-n",
1634 _ ("del"));
1635 ret = 1;
1636 finish_command ();
1637 return;
1638 }
1640 &zone_pkey,
1641 name,
1643 NULL,
1644 &del_monitor,
1645 NULL,
1646 filter_flags);
1647 }
1648 if (purge_orphaned)
1649 {
1651 NULL,
1653 NULL,
1655 NULL,
1657 NULL,
1658 filter_flags);
1659
1660 }
1661 else if (purge_zone)
1662 {
1663 if (NULL == ego_name)
1664 {
1665 fprintf (stderr,
1666 _ ("Missing option `%s' for operation `%s'\n"),
1667 "-z",
1668 _ ("purge-zone"));
1669 ret = 1;
1670 finish_command ();
1671 return;
1672 }
1674 &zone_pkey,
1676 NULL,
1678 NULL,
1680 NULL,
1681 filter_flags);
1682
1683 }
1684 else if (list || list_orphaned)
1685 {
1686 if (NULL != name)
1687 {
1688 if (NULL == ego_name)
1689 {
1690 fprintf (stderr,
1691 _ ("Missing option `%s' for operation `%s'\n"),
1692 "-z",
1693 _ ("list"));
1694 ret = 1;
1695 finish_command ();
1696 return;
1697 }
1699 &zone_pkey,
1700 name,
1702 NULL,
1704 NULL);
1705 }
1706 else
1708 (NULL == ego_name) ?
1709 NULL : &zone_pkey,
1711 ,
1712 NULL,
1714 ,
1715 NULL,
1717 ,
1718 NULL,
1719 filter_flags);
1720 }
1721 if (NULL != reverse_pkey)
1722 {
1724
1725 if (NULL == ego_name)
1726 {
1727 fprintf (stderr,
1728 _ ("Missing option `%s' for operation `%s'\n"),
1729 "-z",
1730 _ ("reverse-pkey"));
1731 ret = 1;
1732 finish_command ();
1733 return;
1734 }
1735 if (GNUNET_OK !=
1737 &pubkey))
1738 {
1739 fprintf (stderr,
1740 _ ("Invalid public key for reverse lookup `%s'\n"),
1741 reverse_pkey);
1742 ret = 1;
1743 finish_command ();
1744 return;
1745 }
1747 &zone_pkey,
1748 &pubkey,
1750 NULL,
1752 NULL);
1753 }
1754 if (NULL != uri)
1755 {
1756 char sh[105];
1757 char sname[64];
1759 if (NULL == ego_name)
1760 {
1761 fprintf (stderr,
1762 _ ("Missing option `%s' for operation `%s'\n"),
1763 "-z",
1764 _ ("uri"));
1765 ret = 1;
1766 finish_command ();
1767 return;
1768 }
1769
1770 memset (sh, 0, 105);
1771 memset (sname, 0, 64);
1772
1773 if ((2 != (sscanf (uri, "gnunet://gns/%58s/%63s", sh, sname))) ||
1774 (GNUNET_OK !=
1776 {
1777 fprintf (stderr, _ ("Invalid URI `%s'\n"), uri);
1778 ret = 1;
1779 finish_command ();
1780 return;
1781 }
1782 if (NULL == expirationstring)
1783 {
1784 fprintf (stderr,
1785 _ ("Missing option `%s' for operation `%s'\n"),
1786 "-e",
1787 _ ("add"));
1788 ret = 1;
1789 finish_command ();
1790 return;
1791 }
1793 {
1794 fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1795 ret = 1;
1796 finish_command ();
1797 return;
1798 }
1799 memset (&rd, 0, sizeof(rd));
1800 rd.data = &pkey;
1802 rd.record_type = ntohl (pkey.type);
1804 if (GNUNET_YES == etime_is_rel)
1806 if (1 == is_shadow)
1808 if (1 == is_maintenance)
1811 &zone_pkey,
1812 sname,
1813 1,
1814 &rd,
1816 &add_qe_uri);
1817 }
1818 if (monitor)
1819 {
1821 (NULL != ego_name) ?
1822 &zone_pkey : NULL,
1823 GNUNET_YES,
1825 NULL,
1827 NULL,
1828 &sync_cb,
1829 NULL,
1830 filter_flags);
1831 }
1832}
1833
1834
1835#define MAX_LINE_LEN 4086
1836
1837#define MAX_ARGS 20
1838
1839static int
1840get_identity_for_string (const char *str,
1842{
1843 const struct GNUNET_CRYPTO_BlindablePrivateKey *privkey;
1845 struct GNUNET_CRYPTO_BlindablePublicKey ego_pubkey;
1846 struct EgoEntry *ego_entry;
1847
1849 &pubkey))
1850 {
1851 for (ego_entry = ego_head;
1852 NULL != ego_entry; ego_entry = ego_entry->next)
1853 {
1854 privkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1855 GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &ego_pubkey);
1856 if (0 == memcmp (&ego_pubkey, &pubkey, sizeof (pubkey)))
1857 {
1858 *zk = *privkey;
1859 return GNUNET_OK;
1860 }
1861 }
1862 }
1863 else
1864 {
1865 for (ego_entry = ego_head; NULL != ego_entry; ego_entry = ego_entry->next)
1866 {
1868 if (0 != strcmp (str, ego_entry->identifier))
1869 continue;
1870 *zk = *GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1871 return GNUNET_OK;
1872 }
1873 }
1874 return GNUNET_NO;
1875}
1876
1877
1878static void
1880{
1881 char buf[MAX_LINE_LEN];
1882 static struct GNUNET_CRYPTO_BlindablePrivateKey next_zone_key;
1883 static char next_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
1884 static int finished = GNUNET_NO;
1885 static int have_next_recordline = GNUNET_NO;
1886 int zonekey_set = GNUNET_NO;
1887 char *tmp;
1888 char *current_name = NULL;
1889
1890
1891 if (GNUNET_YES == have_next_recordline)
1892 {
1893 zone_pkey = next_zone_key;
1894 if (NULL != current_name)
1895 GNUNET_free (current_name);
1896 current_name = GNUNET_strdup (next_name);
1897 zonekey_set = GNUNET_YES;
1898 }
1899 while (NULL != fgets (buf, sizeof (buf), stdin))
1900 {
1901 if (1 >= strlen (buf))
1902 continue;
1903 if (buf[strlen (buf) - 1] == '\n')
1904 buf[strlen (buf) - 1] = '\0';
1908 if (buf[strlen (buf) - 1] == ':')
1909 {
1910 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Switching to %s\n", buf);
1911 memset (next_name, 0, sizeof (next_name));
1912 strncpy (next_name, buf, strlen (buf) - 1);
1913 tmp = strchr (next_name, '.');
1914 if (NULL == tmp)
1915 {
1916 fprintf (stderr, "Error parsing name `%s'\n", next_name);
1918 ret = 1;
1919 return;
1920 }
1921 if (GNUNET_OK != get_identity_for_string (tmp + 1, &next_zone_key))
1922 {
1923 fprintf (stderr, "Error parsing zone name `%s'\n", tmp + 1);
1924 ret = 1;
1926 return;
1927 }
1928 *tmp = '\0';
1929 have_next_recordline = GNUNET_YES;
1930 /* Run a command for the previous record set */
1931 if (NULL != recordset)
1932 {
1934 {
1939 "Recordinfo array grown to %u bytes!\n",
1941 }
1942 record_info[ri_count].a_label = GNUNET_strdup (current_name);
1943 {
1944 int rd_count = 0;
1945 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1946 rd_count++;
1948 struct
1950 rd_count = 0;
1951 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1952 {
1953 record_info[ri_count].a_rd[rd_count] = e->record;
1955 record.
1956 data_size);
1958 data_size;
1959 memcpy ((void*) record_info[ri_count].a_rd[rd_count].data,
1960 e->record.data, e->record.data_size);
1961 rd_count++;
1962 }
1964 ri_count++;
1966 "Added %d records to record info\n", rd_count);
1967 clear_recordset ();
1968 }
1969 /* If the zone has changed, insert */
1970 /* If we have reached batch size, insert */
1971 if (0 != GNUNET_memcmp (&next_zone_key, &zone_pkey) ||
1973 {
1974 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Batch inserting %d RI\n",
1975 ri_count);
1977 return;
1978 }
1979 }
1980 zone_pkey = next_zone_key;
1981 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Switching from %s to %s\n",
1982 current_name, next_name);
1983 if (NULL != current_name)
1984 GNUNET_free (current_name);
1985 current_name = GNUNET_strdup (next_name);
1986 zonekey_set = GNUNET_YES;
1987 continue;
1988 }
1989 if (GNUNET_NO == zonekey_set)
1990 {
1991 fprintf (stderr, "Warning, encountered recordline without zone\n");
1992 continue;
1993 }
1994 parse_recordline (buf);
1995 }
1996 if (GNUNET_NO == finished)
1997 {
1998 if (NULL != recordset)
1999 {
2000 if (GNUNET_YES == zonekey_set)
2001 {
2002 record_info[ri_count].a_label = GNUNET_strdup (current_name);
2003 {
2004 int rd_count = 0;
2005 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
2006 rd_count++;
2008 struct
2010 rd_count = 0;
2011 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
2012 {
2013 record_info[ri_count].a_rd[rd_count] = e->record;
2015 .
2016 data_size);
2017 record_info[ri_count].a_rd[rd_count].data_size = e->record.data_size
2018 ;
2019 memcpy ((void*) record_info[ri_count].a_rd[rd_count].data,
2020 e->record.data, e->record.data_size);
2021 rd_count++;
2022 }
2024 }
2025 ri_count++;
2028 return;
2029 }
2030 fprintf (stderr, "Warning, encountered recordline without zone\n");
2031 }
2032 }
2033 if (ri_sent < ri_count)
2034 {
2036 return;
2037 }
2039 return;
2040}
2041
2042
2055static void
2056id_connect_cb (void *cls,
2057 struct GNUNET_IDENTITY_Ego *ego,
2058 void **ctx,
2059 const char *ego_name_tmp)
2060{
2062 struct EgoEntry *ego_entry;
2063
2064 (void) ctx;
2065 (void) ego_name_tmp;
2066 if ((NULL != ego_name_tmp) && (NULL != ego))
2067 {
2068 ego_entry = GNUNET_new (struct EgoEntry);
2070 ego_entry->ego = ego;
2071 ego_entry->identifier = GNUNET_strdup (ego_name_tmp);
2073 ego_tail,
2074 ego_entry);
2075 if ((NULL != ego_name) && (NULL != ego_name_tmp) &&
2076 (0 == strcmp (ego_name, ego_name_tmp)))
2078 return;
2079 }
2080 if (NULL != ego)
2081 return;
2082 if (read_from_stdin)
2083 {
2085 return;
2086 }
2088}
2089
2090
2099static void
2100run (void *cls,
2101 char *const *args,
2102 const char *cfgfile,
2103 const struct GNUNET_CONFIGURATION_Handle *_cfg)
2104{
2105 (void) cls;
2106 (void) args;
2107 (void) cfgfile;
2108 cfg = _cfg;
2109 if (NULL != args[0])
2110 GNUNET_log (
2112 _ ("Superfluous command line arguments (starting with `%s') ignored\n"),
2113 args[0]);
2114
2117 if (NULL == ns)
2118 {
2119 fprintf (stderr, _ ("Failed to connect to namestore\n"));
2121 return;
2122 }
2124 if (NULL == idh)
2125 {
2126 ret = -1;
2127 fprintf (stderr, _ ("Cannot connect to identity service\n"));
2129 }
2130}
2131
2132
2140int
2141main (int argc, char *const *argv)
2142{
2143 int lret;
2145 { GNUNET_GETOPT_option_flag ('a', "add", gettext_noop ("add record"), &add),
2147 "delete",
2148 gettext_noop ("delete record"),
2149 &del),
2151 "display",
2152 gettext_noop ("display records"),
2153 &list),
2155 "from-stdin",
2156 gettext_noop ("read commands from stdin"),
2159 'e',
2160 "expiration",
2161 "TIME",
2162 gettext_noop (
2163 "expiration time for record to use (for adding only), \"never\" is possible"),
2166 "nick",
2167 "NICKNAME",
2168 gettext_noop (
2169 "set the desired nick name for the zone"),
2170 &nickstring),
2172 "monitor",
2173 gettext_noop (
2174 "monitor changes in the namestore"),
2175 &monitor),
2177 "name",
2178 "NAME",
2179 gettext_noop (
2180 "name of the record to add/delete/display"),
2181 &name),
2183 "recordline",
2184 gettext_noop ("Output in recordline format"),
2187 "zone-to-name",
2188 "KEY",
2189 gettext_noop (
2190 "determine our name for the given KEY"),
2191 &reverse_pkey),
2193 "type",
2194 "TYPE",
2195 gettext_noop (
2196 "type of the record to add/delete/display"),
2197 &typestring),
2199 "uri",
2200 "URI",
2201 gettext_noop ("URI to import into our zone"),
2202 &uri),
2204 "value",
2205 "VALUE",
2206 gettext_noop (
2207 "value of the record to add/delete"),
2208 &value),
2210 "public",
2211 gettext_noop ("create or list public record"),
2212 &is_public),
2214 "omit-private",
2215 gettext_noop ("omit private records"),
2216 &omit_private),
2218 "include-maintenance",
2219 gettext_noop (
2220 "do not filter maintenance records"),
2223 "purge-orphans",
2224 gettext_noop (
2225 "purge namestore of all orphans"),
2228 "list-orphans",
2229 gettext_noop (
2230 "show private key for orphaned records for recovery using `gnunet-identity -C -P <key>'. Use in combination with --display"),
2231 &list_orphaned),
2233 "purge-zone-records",
2234 gettext_noop (
2235 "delete all records in specified zone"),
2236 &purge_zone),
2238 "batch-size",
2239 "NUMBER",
2240 gettext_noop (
2241 "number of records to buffer and send as batch (for use with --from-stdin)"),
2244 's',
2245 "shadow",
2246 gettext_noop (
2247 "create shadow record (only valid if all other records of the same type have expired)"),
2248 &is_shadow),
2250 'M',
2251 "maintenance",
2252 gettext_noop (
2253 "create maintenance record (e.g TOMBSTONEs)"),
2256 "zone",
2257 "EGO",
2258 gettext_noop (
2259 "name of the ego controlling the zone"),
2260 &ego_name),
2262
2263
2264 is_public = -1;
2265 is_shadow = -1;
2266 is_maintenance = -1;
2267 GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
2268 if (GNUNET_OK !=
2270 argc,
2271 argv,
2272 "gnunet-namestore",
2273 _ ("GNUnet zone manipulation tool"),
2274 options,
2275 &run,
2276 NULL)))
2277 {
2278 // FIXME
2279 // GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
2280 return lret;
2281 }
2282 // FIXME
2283 // GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
2284 return ret;
2285}
2286
2287
2288/* end of gnunet-namestore.c */
struct GNUNET_GETOPT_CommandLineOption options[]
Definition 002.c:5
int main()
Program to simulate results from GCP_get_desirability_of_path() for various plausible inputs.
#define gettext_noop(String)
Definition gettext.h:74
#define GNUNET_GNSRECORD_TYPE_NICK
GNS zone nickname.
static int do_shutdown
Set to GNUNET_YES if we are shutting down.
static bool finished
Set to true once we are finished and should exit after sending our final message to the parent.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static char * line
Desired phone line (string to be converted to a hash).
static struct GNUNET_DATASTORE_QueueEntry * qe
Current operation.
static struct GNUNET_FS_Handle * ctx
static struct GNUNET_IDENTITY_Handle * sh
Handle to IDENTITY service.
struct GNUNET_CRYPTO_BlindablePrivateKey pk
Private key from command line option, or NULL.
static struct GNUNET_CRYPTO_BlindablePublicKey pubkey
Public key of the zone to look in.
static char * pkey
Public key of the zone to look in, in ASCII.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static struct EgoEntry * ego_tail
Ego list.
static struct GNUNET_NAMESTORE_QueueEntry * ns_qe
Queue entry for begin/commit.
#define MAX_LINE_LEN
static struct GNUNET_CRYPTO_BlindablePrivateKey zone_pkey
Private key for the our zone.
static int output_recordline
Output in recordline format.
static int omit_private
Filter private records.
static void zone_iteration_finished(void *cls)
Function called when we are done with a zone iteration.
static void replace_cont(void *cls, enum GNUNET_ErrorCode ec)
static void sync_cb(void *cls)
Function called once we are in sync in monitor mode.
static struct GNUNET_NAMESTORE_QueueEntry * get_qe
Queue entry for the 'lookup' operation.
static void del_lookup_error_cb(void *cls)
Function called if lookup for deletion fails.
static struct GNUNET_NAMESTORE_ZoneMonitor * zm
Monitor handle.
static void run_with_zone_pkey(const struct GNUNET_CONFIGURATION_Handle *cfg_)
We have obtained the zone's private key, so now process the main commands using it.
static int parse_recordline(const char *line)
static void del_monitor(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We were asked to delete something; this function is called with the existing records.
static void del_continuation(void *cls, enum GNUNET_ErrorCode ec)
static void get_existing_record(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rec_name, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
We're storing a record; this function is given the existing record so that we can merge the informati...
static int list_orphaned
List records and zone keys of orphaned records.
#define WARN_RELATIVE_EXPIRATION_LIMIT
The upper bound for the zone iteration interval (per record).
static void purge_next_record(void *cls)
static int purge_orphaned
Purge orphaned records.
static struct GNUNET_NAMESTORE_QueueEntry * add_qe
Queue entry for the 'add' operation.
static void display_record_lookup(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
static void display_record_monitor(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
Process a record that was stored in the namestore.
static void id_connect_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *ego_name_tmp)
Function called with ALL of the egos known to the identity service, used on startup if the user did n...
static char * nickstring
Desired nick name.
static int monitor
Enables monitor mode.
static char * value
Value of the record to add/remove.
static int list
Desired action is to list records.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle.
static struct GNUNET_NAMESTORE_QueueEntry * del_qe
Queue entry for the 'del' operation.
static void batch_insert_recordinfo(const struct GNUNET_CONFIGURATION_Handle *cfg)
We have obtained the zone's private key, so now process the main commands using it.
static int purge_zone
Purge zone contents.
static char * name
Name of the records to add/list/remove.
static int include_maintenance
Do not filter maintenance records.
static struct GNUNET_NAMESTORE_QueueEntry * set_qe
Queue entry for the 'set/replace' operation.
static void collect_zone_records_to_purge(const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
static int ret
Global return value.
static void reset_handles(void)
static unsigned int max_batch_size
static void * data
Value in binary format.
static void lookup_error_cb(void *cls)
Function called on errors while monitoring.
static void clear_recordset()
static void display_record(const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
static struct GNUNET_IDENTITY_Handle * idh
Identity service handle.
static void handle_reverse_lookup(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Function called with the result of our attempt to obtain a name for a given public key.
static struct RecordSetEntry * recordset
Entry in record set for processing records in bulk.
static char * ego_name
Name of the ego controlling the zone.
static void reverse_error_cb(void *cls)
Function called if we encountered an error in zone-to-name.
static struct MarkedRecord * marked_head
Marked record list.
static void purge_zone_iterator(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
static void display_record_iterator(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
Process a record that was stored in the namestore.
static struct EgoEntry * ego_head
Ego list.
static int parse_expiration(const char *exp_str, int *is_rel, uint64_t *exptime)
Parse expiration time.
static int is_shadow
Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW)
static void add_continuation(void *cls, enum GNUNET_ErrorCode ec)
static struct GNUNET_SCHEDULER_Task * purge_task
Purge task.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *_cfg)
Main function that will be run.
static unsigned int ri_sent
static void finish_command(void)
static int del
Desired action is to remove a record.
static int etime_is_rel
Is expiration time relative or absolute time?
static void add_error_cb(void *cls)
Function called if lookup fails.
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
static void marked_deleted(void *cls, enum GNUNET_ErrorCode ec)
static struct GNUNET_NAMESTORE_ZoneIterator * list_it
List iterator for the 'list' operation.
static int is_maintenance
Is record a maintenance record (GNUNET_GNSRECORD_RF_MAINTENANCE)
static struct MarkedRecord * marked_tail
Marked record list.
static void monitor_error_cb(void *cls)
Function called on errors while monitoring.
static int read_from_stdin
Run in read from stdin mode.
static void process_command_stdin(void)
static void collect_orphans(const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd)
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static void purge_orphans_iterator(void *cls, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone_key, const char *rname, unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute expiry)
static char * expirationstring
Desired expiration time.
static unsigned int record_info_capacity
Maximum capacity of record_info array.
static struct GNUNET_NAMESTORE_RecordInfo * record_info
static struct GNUNET_NAMESTORE_QueueEntry * add_qe_uri
Queue entry for the 'add-uri' operation.
static void schedule_finish(void *cls)
static int get_identity_for_string(const char *str, struct GNUNET_CRYPTO_BlindablePrivateKey *zk)
static int add
Desired action is to add a record.
static struct GNUNET_NAMESTORE_QueueEntry * reverse_qe
Queue entry for the 'reverse lookup' operation (in combination with a name).
static void zone_iteration_error_cb(void *cls)
Function called when we encountered an error in a zone iteration.
static char * typestring
Type of the record to add/remove, NULL to remove all.
static char * uri
URI to import.
static uint64_t etime
Expiration string converted to numeric value.
static char * reverse_pkey
Reverse lookup to perform.
static unsigned int ri_count
static int is_public
Is record public (opposite of GNUNET_GNSRECORD_RF_PRIVATE)
const char * GNUNET_ErrorCode_get_hint(enum GNUNET_ErrorCode ec)
Returns a hint for a given error code.
GNUNET_ErrorCode
Taler error codes.
@ GNUNET_EC_NONE
No error (success).
@ GNUNET_EC_NAMESTORE_RECORD_EXISTS
Record already exists.
@ GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND
Record not found.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_DNSPARSER_TYPE_OPENPGPKEY
#define GNUNET_DNSPARSER_TYPE_TLSA
#define GNUNET_DNSPARSER_TYPE_SRV
#define GNUNET_DNSPARSER_TYPE_SOA
#define GNUNET_DNSPARSER_TYPE_SMIMEA
#define GNUNET_DNSPARSER_MAX_NAME_LENGTH
Maximum length of a name in DNS.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string (e.g.
Definition gnsrecord.c:219
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (e.g.
Definition gnsrecord.c:192
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of the value s of a record of type type to the respective binary repre...
Definition gnsrecord.c:169
#define GNUNET_GNS_EMPTY_LABEL_AT
String we use to indicate an empty label (top-level entry in the zone).
GNUNET_GNSRECORD_Filter
Filter for GNUNET_GNSRECORD_normalize_record_set().
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/'*'.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the binary value data of a record of type type to a human-readable string.
Definition gnsrecord.c:147
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_CRITICAL
This record is critical.
@ GNUNET_GNSRECORD_RF_SUPPLEMENTAL
This is a supplemental record.
@ GNUNET_GNSRECORD_RF_MAINTENANCE
Maintenance records.
@ GNUNET_GNSRECORD_RF_SHADOW
This record should not be used unless all (other) records in the set with an absolute expiration time...
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
@ GNUNET_GNSRECORD_RF_NONE
Entry for no flags / cleared flags.
@ 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.
void GNUNET_IDENTITY_ego_get_public_key(struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CRYPTO_BlindablePublicKey *pk)
Get the identifier (public key) of an ego.
struct GNUNET_IDENTITY_Handle * GNUNET_IDENTITY_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_IDENTITY_Callback cb, void *cb_cls)
Connect to the identity service.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
const struct GNUNET_CRYPTO_BlindablePrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a ego.
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_BlindablePublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_BlindablePublicKey.
Definition crypto_pkey.c:85
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blindable_public_key_from_string(const char *str, struct GNUNET_CRYPTO_BlindablePublicKey *key)
Parses a (Base32) string representation of the public key.
char * GNUNET_CRYPTO_blindable_private_key_to_string(const struct GNUNET_CRYPTO_BlindablePrivateKey *key)
Creates a (Base32) string representation of the private key.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ 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.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_MESSAGE
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_new_array(n, type)
Allocate a size n array with structs or unions of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, unsigned int rd_set_count, const struct GNUNET_NAMESTORE_RecordInfo *record_info, unsigned int *rds_sent, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store one or more record sets in the namestore.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, GNUNET_NAMESTORE_ContinuationWithStatus cont, void *cont_cls)
Store an item in the namestore.
struct GNUNET_NAMESTORE_ZoneMonitor * GNUNET_NAMESTORE_zone_monitor_start2(const struct GNUNET_CONFIGURATION_Handle *cfg, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, int iterate_first, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor monitor, void *monitor_cls, GNUNET_SCHEDULER_TaskCallback sync_cb, void *sync_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
Begin monitoring a zone for changes.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_zone_to_name(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, const struct GNUNET_CRYPTO_BlindablePublicKey *value_zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls)
Look for an existing PKEY delegation record for a given public key.
void GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it, uint64_t limit)
Calls the record processor specified in GNUNET_NAMESTORE_zone_iteration_start for the next record.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup2(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls, enum GNUNET_GNSRECORD_Filter filter)
Lookup an item in the namestore with GNSRECORD filter.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
void GNUNET_NAMESTORE_zone_monitor_stop(struct GNUNET_NAMESTORE_ZoneMonitor *zm)
Stop monitoring a zone for changes.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start2(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordSetMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls, enum GNUNET_GNSRECORD_Filter filter)
Starts a new zone iteration (used to periodically PUT all of our records into our DHT).
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_records_lookup(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_BlindablePrivateKey *pkey, const char *label, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor rm, void *rm_cls)
Lookup an item in the namestore.
void GNUNET_NAMESTORE_zone_monitor_next(struct GNUNET_NAMESTORE_ZoneMonitor *zm, uint64_t limit)
Calls the monitor processor specified in GNUNET_NAMESTORE_zone_monitor_start for the next record(s).
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
void GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
Stops iteration and releases the namestore handle for further calls.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition program.c:407
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition scheduler.c:567
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
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
Definition strings.c:259
#define GNUNET_TIME_relative_cmp(t1, op, t2)
Compare two relative times.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition strings.c:599
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
Definition strings.c:660
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
enum GNUNET_GenericReturnValue GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
Definition strings.c:303
#define _(String)
GNU gettext support macro.
Definition platform.h:179
The default namestore ego.
char * identifier
Ego Identifier.
struct EgoEntry * prev
DLL.
struct EgoEntry * next
DLL.
struct GNUNET_IDENTITY_Ego * ego
The Ego.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
Definition of a command line option.
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 for an ego.
Definition identity.h:37
Handle for the service.
Connection to the NAMESTORE service.
An QueueEntry used to store information for a pending NAMESTORE record operation.
A struct for record bulk import.
struct GNUNET_GNSRECORD_Data * a_rd
Handle for a zone iterator operation.
Handle for a monitoring activity.
Entry in list of pending tasks.
Definition scheduler.c:136
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.
The record marked for deletion.
struct GNUNET_CRYPTO_BlindablePrivateKey key
The zone key.
struct MarkedRecord * next
DLL.
char * name
Ego Identifier.
struct MarkedRecord * prev
DLL.
Entry in record set for bulk processing.
struct GNUNET_GNSRECORD_Data record
The record to add/remove.
struct RecordSetEntry * next
Kept in a linked list.
const char * str
Definition time.c:1252

◆ INITIAL_RI_BUFFER_SIZE

#define INITIAL_RI_BUFFER_SIZE   5000

Definition at line 349 of file gnunet-namestore.c.

◆ MAX_LINE_LEN

#define MAX_LINE_LEN   4086

Definition at line 1836 of file gnunet-namestore.c.

◆ MAX_ARGS

#define MAX_ARGS   20

Definition at line 1838 of file gnunet-namestore.c.

Function Documentation

◆ parse_expiration()

static int parse_expiration ( const char *  exp_str,
int *  is_rel,
uint64_t *  exptime 
)
static

Parse expiration time.

Parameters
expirationstringtext to parse
[out]etime_is_relset to GNUNET_YES if time is relative
[out]etimeset to expiration time (abs or rel)
Returns
GNUNET_OK on success

Definition at line 370 of file gnunet-namestore.c.

373{
374 struct GNUNET_TIME_Relative etime_rel;
375 struct GNUNET_TIME_Absolute etime_abs;
376
377 if (0 == strcmp (exp_str, "never"))
378 {
380 *is_rel = GNUNET_NO;
381 return GNUNET_OK;
382 }
383 if (GNUNET_OK ==
384 GNUNET_STRINGS_fancy_time_to_relative (exp_str, &etime_rel))
385 {
386 *is_rel = GNUNET_YES;
387 *exptime = etime_rel.rel_value_us;
389 {
391 "Relative expiration times of less than %s are not recommended. To improve availability, consider increasing this value.\n",
394 }
396 "Storing record with relative expiration time of %s\n",
398 return GNUNET_OK;
399 }
400 if (GNUNET_OK ==
401 GNUNET_STRINGS_fancy_time_to_absolute (exp_str, &etime_abs))
402 {
403 *is_rel = GNUNET_NO;
404 *exptime = etime_abs.abs_value_us;
406 "Storing record with absolute expiration time of %s\n",
408 return GNUNET_OK;
409 }
410 return GNUNET_SYSERR;
411}

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_fancy_time_to_absolute(), GNUNET_STRINGS_fancy_time_to_relative(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, GNUNET_TIME_relative_cmp, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_YES, GNUNET_TIME_Relative::rel_value_us, and WARN_RELATIVE_EXPIRATION_LIMIT.

Referenced by run_with_zone_pkey().

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

◆ parse_recordline()

static int parse_recordline ( const char *  line)
static

Definition at line 415 of file gnunet-namestore.c.

416{
417 struct RecordSetEntry *r;
419 char *cp;
420 char *tok;
421 char *saveptr;
422 void *raw_data;
423
424 cp = GNUNET_strdup (line);
425 tok = strtok_r (cp, " ", &saveptr);
426 if (NULL == tok)
427 {
429 _ ("Missing entries in record line `%s'.\n"),
430 line);
431 GNUNET_free (cp);
432 return GNUNET_SYSERR;
433 }
435 if (UINT32_MAX == record.record_type)
436 {
437 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Unknown record type `%s'\n"), tok);
438 GNUNET_free (cp);
439 return GNUNET_SYSERR;
440 }
441 tok = strtok_r (NULL, " ", &saveptr);
442 if (NULL == tok)
443 {
445 _ ("Empty record line argument is not allowed.\n"));
446 GNUNET_free (cp);
447 return GNUNET_SYSERR;
448 }
449 if (1 != sscanf (tok, "%" SCNu64, &record.expiration_time))
450 {
451 fprintf (stderr,
452 _ ("Error parsing expiration time %s.\n"), tok);
453 GNUNET_free (cp);
454 return GNUNET_SYSERR;
455 }
456 tok = strtok_r (NULL, " ", &saveptr);
457 if (NULL == tok)
458 {
460 _ ("Empty record line argument is not allowed.\n"));
461 GNUNET_free (cp);
462 return GNUNET_SYSERR;
463 }
465 if (NULL != strchr (tok, (unsigned char) 'r'))
467 if (NULL == strchr (tok, (unsigned char) 'p')) /* p = public */
469 if (NULL != strchr (tok, (unsigned char) 'S'))
471 if (NULL != strchr (tok, (unsigned char) 's'))
473 if (NULL != strchr (tok, (unsigned char) 'C'))
475 tok += strlen (tok) + 1;
477 tok,
478 &raw_data,
479 &record.data_size))
480 {
482 _ ("Invalid record data for type %s: `%s'.\n"),
484 tok);
485 GNUNET_free (cp);
486 return GNUNET_SYSERR;
487 }
488 GNUNET_free (cp);
489
490 r = GNUNET_malloc (sizeof(struct RecordSetEntry) + record.data_size);
491 r->next = recordset;
492 record.data = &r[1];
493 memcpy (&r[1], raw_data, record.data_size);
494 GNUNET_free (raw_data);
495 r->record = record;
496 recordset = r;
497 return GNUNET_OK;
498}

References _, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_RF_CRITICAL, GNUNET_GNSRECORD_RF_NONE, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW, GNUNET_GNSRECORD_RF_SUPPLEMENTAL, GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_typename_to_number(), GNUNET_log, GNUNET_malloc, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, line, RecordSetEntry::next, RecordSetEntry::record, record(), and recordset.

Referenced by process_command_stdin().

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

◆ clear_recordset()

static void clear_recordset ( )
static

Definition at line 502 of file gnunet-namestore.c.

503{
504 struct RecordSetEntry *rs_entry;
505
506 while (NULL != (rs_entry = recordset))
507 {
509 GNUNET_free (rs_entry);
510 }
511 recordset = NULL;
512}

References GNUNET_free, RecordSetEntry::next, and recordset.

Referenced by process_command_stdin(), and reset_handles().

Here is the caller graph for this function:

◆ reset_handles()

static void reset_handles ( void  )
static

Definition at line 516 of file gnunet-namestore.c.

517{
518 struct MarkedRecord *mrec;
519 struct MarkedRecord *mrec_tmp;
521 if (NULL != ego_name)
522 {
524 ego_name = NULL;
525 }
526 if (NULL != name)
527 {
529 name = NULL;
530 }
531 if (NULL != value)
532 {
534 value = NULL;
535 }
536 if (NULL != uri)
537 {
539 uri = NULL;
540 }
541 if (NULL != expirationstring)
542 {
544 expirationstring = NULL;
545 }
546 if (NULL != purge_task)
547 {
549 purge_task = NULL;
550 }
551 for (mrec = marked_head; NULL != mrec;)
552 {
553 mrec_tmp = mrec;
554 mrec = mrec->next;
555 GNUNET_free (mrec_tmp->name);
556 GNUNET_free (mrec_tmp);
557 }
558 if (NULL != list_it)
559 {
561 list_it = NULL;
562 }
563 if (NULL != add_qe)
564 {
566 add_qe = NULL;
567 }
568 if (NULL != set_qe)
569 {
571 set_qe = NULL;
572 }
573 if (NULL != add_qe_uri)
574 {
576 add_qe_uri = NULL;
577 }
578 if (NULL != get_qe)
579 {
581 get_qe = NULL;
582 }
583 if (NULL != del_qe)
584 {
586 del_qe = NULL;
587 }
588 if (NULL != reverse_qe)
589 {
591 reverse_qe = NULL;
592 }
593 memset (&zone_pkey, 0, sizeof(zone_pkey));
594 if (NULL != zm)
595 {
597 zm = NULL;
598 }
599 if (NULL != data)
600 {
602 data = NULL;
603 }
604 if (NULL != typestring)
605 {
607 typestring = NULL;
608 }
609 list = 0;
610 is_public = 0;
611 is_shadow = 0;
612 is_maintenance = 0;
613 purge_zone = 0;
614}

References add_qe, add_qe_uri, clear_recordset(), data, del_qe, ego_name, expirationstring, get_qe, GNUNET_free, GNUNET_NAMESTORE_cancel(), GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NAMESTORE_zone_monitor_stop(), GNUNET_SCHEDULER_cancel(), is_maintenance, is_public, is_shadow, list, list_it, marked_head, MarkedRecord::name, name, MarkedRecord::next, purge_task, purge_zone, reverse_qe, set_qe, typestring, uri, value, zm, and zone_pkey.

Referenced by do_shutdown().

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

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Task run on shutdown.

Cleans up everything.

Parameters
clsunused

Definition at line 623 of file gnunet-namestore.c.

624{
625 struct EgoEntry *ego_entry;
626 struct EgoEntry *ego_tmp;
627 (void) cls;
628
629 reset_handles ();
630 if (NULL != record_info)
632 record_info = NULL;
633 if (NULL != ns_qe)
634 {
636 ns_qe = NULL;
637 }
638 if (NULL != ns)
639 {
641 ns = NULL;
642 }
643 if (NULL != idh)
644 {
646 idh = NULL;
647 }
648 for (ego_entry = ego_head; NULL != ego_entry;)
649 {
650 ego_tmp = ego_entry;
651 ego_entry = ego_entry->next;
652 GNUNET_free (ego_tmp->identifier);
653 GNUNET_free (ego_tmp);
654 }
655}

References ego_head, GNUNET_free, GNUNET_IDENTITY_disconnect(), GNUNET_NAMESTORE_cancel(), GNUNET_NAMESTORE_disconnect(), EgoEntry::identifier, idh, EgoEntry::next, ns, ns_qe, record_info, and reset_handles().

Here is the call graph for this function:

◆ process_command_stdin()

static void process_command_stdin ( void  )
static

Check if this is a new name. If yes, and we have records, store them.

One last time

Definition at line 1880 of file gnunet-namestore.c.

1881{
1882 char buf[MAX_LINE_LEN];
1883 static struct GNUNET_CRYPTO_BlindablePrivateKey next_zone_key;
1884 static char next_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
1885 static int finished = GNUNET_NO;
1886 static int have_next_recordline = GNUNET_NO;
1887 int zonekey_set = GNUNET_NO;
1888 char *tmp;
1889 char *current_name = NULL;
1890
1891
1892 if (GNUNET_YES == have_next_recordline)
1893 {
1894 zone_pkey = next_zone_key;
1895 if (NULL != current_name)
1896 GNUNET_free (current_name);
1897 current_name = GNUNET_strdup (next_name);
1898 zonekey_set = GNUNET_YES;
1899 }
1900 while (NULL != fgets (buf, sizeof (buf), stdin))
1901 {
1902 if (1 >= strlen (buf))
1903 continue;
1904 if (buf[strlen (buf) - 1] == '\n')
1905 buf[strlen (buf) - 1] = '\0';
1909 if (buf[strlen (buf) - 1] == ':')
1910 {
1911 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Switching to %s\n", buf);
1912 memset (next_name, 0, sizeof (next_name));
1913 strncpy (next_name, buf, strlen (buf) - 1);
1914 tmp = strchr (next_name, '.');
1915 if (NULL == tmp)
1916 {
1917 fprintf (stderr, "Error parsing name `%s'\n", next_name);
1919 ret = 1;
1920 return;
1921 }
1922 if (GNUNET_OK != get_identity_for_string (tmp + 1, &next_zone_key))
1923 {
1924 fprintf (stderr, "Error parsing zone name `%s'\n", tmp + 1);
1925 ret = 1;
1927 return;
1928 }
1929 *tmp = '\0';
1930 have_next_recordline = GNUNET_YES;
1931 /* Run a command for the previous record set */
1932 if (NULL != recordset)
1933 {
1935 {
1940 "Recordinfo array grown to %u bytes!\n",
1942 }
1943 record_info[ri_count].a_label = GNUNET_strdup (current_name);
1944 {
1945 int rd_count = 0;
1946 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1947 rd_count++;
1949 struct
1951 rd_count = 0;
1952 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1953 {
1954 record_info[ri_count].a_rd[rd_count] = e->record;
1956 record.
1957 data_size);
1959 data_size;
1960 memcpy ((void*) record_info[ri_count].a_rd[rd_count].data,
1961 e->record.data, e->record.data_size);
1962 rd_count++;
1963 }
1965 ri_count++;
1967 "Added %d records to record info\n", rd_count);
1968 clear_recordset ();
1969 }
1970 /* If the zone has changed, insert */
1971 /* If we have reached batch size, insert */
1972 if (0 != GNUNET_memcmp (&next_zone_key, &zone_pkey) ||
1974 {
1975 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Batch inserting %d RI\n",
1976 ri_count);
1978 return;
1979 }
1980 }
1981 zone_pkey = next_zone_key;
1982 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Switching from %s to %s\n",
1983 current_name, next_name);
1984 if (NULL != current_name)
1985 GNUNET_free (current_name);
1986 current_name = GNUNET_strdup (next_name);
1987 zonekey_set = GNUNET_YES;
1988 continue;
1989 }
1990 if (GNUNET_NO == zonekey_set)
1991 {
1992 fprintf (stderr, "Warning, encountered recordline without zone\n");
1993 continue;
1994 }
1995 parse_recordline (buf);
1996 }
1997 if (GNUNET_NO == finished)
1998 {
1999 if (NULL != recordset)
2000 {
2001 if (GNUNET_YES == zonekey_set)
2002 {
2003 record_info[ri_count].a_label = GNUNET_strdup (current_name);
2004 {
2005 int rd_count = 0;
2006 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
2007 rd_count++;
2009 struct
2011 rd_count = 0;
2012 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
2013 {
2014 record_info[ri_count].a_rd[rd_count] = e->record;
2016 .
2017 data_size);
2018 record_info[ri_count].a_rd[rd_count].data_size = e->record.data_size
2019 ;
2020 memcpy ((void*) record_info[ri_count].a_rd[rd_count].data,
2021 e->record.data, e->record.data_size);
2022 rd_count++;
2023 }
2025 }
2026 ri_count++;
2029 return;
2030 }
2031 fprintf (stderr, "Warning, encountered recordline without zone\n");
2032 }
2033 }
2034 if (ri_sent < ri_count)
2035 {
2037 return;
2038 }
2040 return;
2041}

References GNUNET_NAMESTORE_RecordInfo::a_label, GNUNET_NAMESTORE_RecordInfo::a_rd, GNUNET_NAMESTORE_RecordInfo::a_rd_count, batch_insert_recordinfo(), cfg, clear_recordset(), data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, finished, get_identity_for_string(), GNUNET_array_grow, GNUNET_DNSPARSER_MAX_NAME_LENGTH, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_malloc, GNUNET_memcmp, GNUNET_new_array, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), GNUNET_strdup, GNUNET_YES, max_batch_size, MAX_LINE_LEN, RecordSetEntry::next, parse_recordline(), rd_count, record(), record_info, record_info_capacity, recordset, ret, ri_count, ri_sent, and zone_pkey.

Referenced by finish_command(), and id_connect_cb().

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

◆ batch_insert_recordinfo()

static void batch_insert_recordinfo ( const struct GNUNET_CONFIGURATION_Handle batch_cfg)
static

We have obtained the zone's private key, so now process the main commands using it.

Parameters
cfgconfiguration to use

Definition at line 1399 of file gnunet-namestore.c.

1400{
1401 unsigned int sent_here;
1402
1403 GNUNET_assert (0 != ri_count);
1405 &zone_pkey,
1406 ri_count - ri_sent,
1408 &sent_here,
1409 &replace_cont,
1410 NULL);
1411 ri_sent += sent_here;
1412 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d/%d record infos\n", ri_sent,
1413 ri_count);
1414 if (ri_sent == ri_count)
1415 {
1416 for (int i = 0; i < ri_count; i++)
1417 {
1418 GNUNET_free (record_info[i].a_rd);
1419 record_info[i].a_rd = NULL;
1420 }
1421 ri_count = 0;
1422 ri_sent = 0;
1423 }
1424 return;
1425}

References GNUNET_NAMESTORE_RecordInfo::a_rd, GNUNET_assert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_records_store(), ns, record_info, replace_cont(), ri_count, ri_sent, set_qe, and zone_pkey.

Referenced by process_command_stdin().

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

◆ finish_command()

static void finish_command ( void  )
static

Definition at line 673 of file gnunet-namestore.c.

674{
675 // if (ri_sent < ri_count)
676 // {
677 // batch_insert_recordinfo (cfg);
678 // return;
679 // }
680 // reset_handles ();
681 if (read_from_stdin)
682 {
684 return;
685 }
687}

References GNUNET_SCHEDULER_shutdown(), process_command_stdin(), and read_from_stdin.

Referenced by add_continuation(), add_error_cb(), del_continuation(), del_lookup_error_cb(), del_monitor(), display_record_lookup(), get_existing_record(), handle_reverse_lookup(), lookup_error_cb(), purge_next_record(), run_with_zone_pkey(), schedule_finish(), zone_iteration_error_cb(), and zone_iteration_finished().

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

◆ add_continuation()

static void add_continuation ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

Definition at line 691 of file gnunet-namestore.c.

692{
693 struct GNUNET_NAMESTORE_QueueEntry **qe = cls;
694
695 *qe = NULL;
696 if (GNUNET_EC_NONE != ec)
697 {
698 fprintf (stderr,
699 _ ("Adding record failed: %s\n"),
702 ret = 1;
704 return;
705 }
706 ret = 0;
708}

References _, finish_command(), GNUNET_EC_NAMESTORE_RECORD_EXISTS, GNUNET_EC_NONE, GNUNET_ErrorCode_get_hint(), GNUNET_SCHEDULER_shutdown(), qe, and ret.

Referenced by get_existing_record(), and run_with_zone_pkey().

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

◆ del_continuation()

static void del_continuation ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

Definition at line 712 of file gnunet-namestore.c.

713{
714 (void) cls;
715 del_qe = NULL;
717 {
718 fprintf (stderr,
719 _ ("Deleting record failed: %s\n"), GNUNET_ErrorCode_get_hint (
720 ec));
721 }
723}

References _, del_qe, finish_command(), GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND, and GNUNET_ErrorCode_get_hint().

Referenced by del_monitor().

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

◆ purge_next_record()

static void purge_next_record ( void *  cls)
static

Definition at line 744 of file gnunet-namestore.c.

745{
746 struct MarkedRecord *mrec;
747 purge_task = NULL;
748
749 if (NULL == marked_head)
750 {
751 ret = 0;
753 return;
754 }
755 mrec = marked_head;
758 mrec);
760 &mrec->key,
761 mrec->name,
762 0, NULL,
764 NULL);
765 GNUNET_free (mrec->name);
766 GNUNET_free (mrec);
767}

References del_qe, finish_command(), GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_NAMESTORE_record_set_store(), MarkedRecord::key, marked_deleted(), marked_head, marked_tail, MarkedRecord::name, ns, purge_task, and ret.

Referenced by marked_deleted(), and zone_iteration_finished().

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

◆ marked_deleted()

static void marked_deleted ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

Definition at line 730 of file gnunet-namestore.c.

731{
732 del_qe = NULL;
733 if (GNUNET_EC_NONE != ec)
734 {
735 fprintf (stderr,
736 _ ("Deleting record failed: %s\n"),
738 }
740}

References _, del_qe, GNUNET_EC_NONE, GNUNET_ErrorCode_get_hint(), GNUNET_SCHEDULER_add_now(), purge_next_record(), and purge_task.

Referenced by purge_next_record().

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

◆ zone_iteration_finished()

static void zone_iteration_finished ( void *  cls)
static

Function called when we are done with a zone iteration.

Definition at line 774 of file gnunet-namestore.c.

775{
776 (void) cls;
777 list_it = NULL;
779 {
781 return;
782 }
783 ret = 0;
785}

References finish_command(), GNUNET_SCHEDULER_add_now(), list_it, purge_next_record(), purge_orphaned, purge_task, purge_zone, and ret.

Referenced by run_with_zone_pkey().

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

◆ zone_iteration_error_cb()

static void zone_iteration_error_cb ( void *  cls)
static

Function called when we encountered an error in a zone iteration.

Definition at line 792 of file gnunet-namestore.c.

793{
794 (void) cls;
795 list_it = NULL;
796 fprintf (stderr, "Error iterating over zone\n");
797 ret = 1;
799}

References finish_command(), list_it, and ret.

Referenced by run_with_zone_pkey().

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

◆ collect_zone_records_to_purge()

static void collect_zone_records_to_purge ( const struct GNUNET_CRYPTO_BlindablePrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Definition at line 803 of file gnunet-namestore.c.

808{
809 struct MarkedRecord *mrec;
810
811 mrec = GNUNET_new (struct MarkedRecord);
812 mrec->key = *zone_key;
813 mrec->name = GNUNET_strdup (rname);
816 mrec);
817}

References GNUNET_CONTAINER_DLL_insert, GNUNET_new, GNUNET_strdup, MarkedRecord::key, marked_head, marked_tail, and MarkedRecord::name.

Referenced by purge_zone_iterator().

Here is the caller graph for this function:

◆ collect_orphans()

static void collect_orphans ( const struct GNUNET_CRYPTO_BlindablePrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Definition at line 821 of file gnunet-namestore.c.

825{
826 struct EgoEntry *ego;
827 struct MarkedRecord *orphan;
828 int is_orphaned = 1;
829
830 for (ego = ego_head; NULL != ego; ego = ego->next)
831 {
832 if (0 == memcmp (GNUNET_IDENTITY_ego_get_private_key (ego->ego),
833 zone_key,
834 sizeof (*zone_key)))
835 {
836 is_orphaned = 0;
837 break;
838 }
839 }
840 if (is_orphaned)
841 {
842 orphan = GNUNET_new (struct MarkedRecord);
843 orphan->key = *zone_key;
844 orphan->name = GNUNET_strdup (rname);
847 orphan);
848 }
849}

References EgoEntry::ego, ego_head, GNUNET_CONTAINER_DLL_insert, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_new, GNUNET_strdup, MarkedRecord::key, marked_head, marked_tail, MarkedRecord::name, and EgoEntry::next.

Referenced by purge_orphans_iterator().

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

◆ display_record()

static void display_record ( const struct GNUNET_CRYPTO_BlindablePrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Process a record that was stored in the namestore.

Parameters
rnamename that is being mapped (at most 255 characters long)
rd_lennumber of entries in rd array
rdarray of records with data to store

Definition at line 860 of file gnunet-namestore.c.

864{
865 const char *typestr;
866 char *s;
867 const char *ets;
868 struct GNUNET_TIME_Absolute at;
869 struct GNUNET_TIME_Relative rt;
870 struct EgoEntry *ego;
871 int have_record;
872 int is_orphaned = 1;
873 char *orphaned_str;
874
875 if ((NULL != name) && (0 != strcmp (name, rname)))
876 return;
877 have_record = GNUNET_NO;
878 for (unsigned int i = 0; i < rd_len; i++)
879 {
880 if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
881 (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
882 continue;
883 if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
884 continue;
885 have_record = GNUNET_YES;
886 break;
887 }
888 if (GNUNET_NO == have_record)
889 return;
890 for (ego = ego_head; NULL != ego; ego = ego->next)
891 {
892 if (0 == memcmp (GNUNET_IDENTITY_ego_get_private_key (ego->ego),
893 zone_key,
894 sizeof (*zone_key)))
895 {
896 is_orphaned = 0;
897 break;
898 }
899 }
900 if (list_orphaned && ! is_orphaned)
901 return;
902 if (! list_orphaned && is_orphaned)
903 return;
904 orphaned_str = GNUNET_CRYPTO_blindable_private_key_to_string (zone_key);
905 fprintf (stdout, "%s.%s:\n", rname, is_orphaned ? orphaned_str :
906 ego->identifier);
907 GNUNET_free (orphaned_str);
908 if (NULL != typestring)
910 else
912 for (unsigned int i = 0; i < rd_len; i++)
913 {
914 if ((GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
915 (0 != strcmp (rname, GNUNET_GNS_EMPTY_LABEL_AT)))
916 continue;
917 if ((type != rd[i].record_type) && (GNUNET_GNSRECORD_TYPE_ANY != type))
918 continue;
919 typestr = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
920 s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
921 rd[i].data,
922 rd[i].data_size);
923 if (NULL == s)
924 {
925 fprintf (stdout,
926 _ ("\tCorrupt or unsupported record of type %u\n"),
927 (unsigned int) rd[i].record_type);
928 continue;
929 }
930 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
931 {
932 rt.rel_value_us = rd[i].expiration_time;
934 }
935 else
936 {
937 at.abs_value_us = rd[i].expiration_time;
939 }
940 {
941 char flgstr[16];
942 sprintf (flgstr, "[%s%s%s%s%s]",
943 (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE) ? "" : "p",
944 (rd[i].flags & GNUNET_GNSRECORD_RF_SUPPLEMENTAL) ? "S" : "",
946 "",
947 (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW) ? "S" : "",
948 (rd[i].flags & GNUNET_GNSRECORD_RF_CRITICAL) ? "C" : "");
950 fprintf (stdout,
951 " %s %" PRIu64 " %s %s\n",
952 typestr,
953 rd[i].expiration_time,
954 flgstr,
955 s);
956 else
957 fprintf (stdout,
958 "\t%s: %s (%s)\t%s\t%s\t%s\n",
959 typestr,
960 s,
961 ets,
962 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE)) ? "PRIVATE"
963 : "PUBLIC",
964 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW)) ? "SHADOW"
965 : "",
966 (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_MAINTENANCE)) ?
967 "MAINTENANCE"
968 : "");
969 GNUNET_free (s);
970 }
971 }
972 // fprintf (stdout, "%s", "\n");
973}

References _, GNUNET_TIME_Absolute::abs_value_us, data, data_size, EgoEntry::ego, ego_head, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_CRYPTO_blindable_private_key_to_string(), GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_RF_CRITICAL, GNUNET_GNSRECORD_RF_MAINTENANCE, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW, GNUNET_GNSRECORD_RF_SUPPLEMENTAL, GNUNET_GNSRECORD_TYPE_ANY, GNUNET_GNSRECORD_TYPE_NICK, GNUNET_GNSRECORD_typename_to_number(), GNUNET_GNSRECORD_value_to_string(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_NO, GNUNET_STRINGS_absolute_time_to_string(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_YES, list_orphaned, name, output_recordline, rd, GNUNET_TIME_Relative::rel_value_us, type, and typestring.

Referenced by display_record_iterator(), display_record_lookup(), and display_record_monitor().

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

◆ purge_zone_iterator()

static void purge_zone_iterator ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd,
struct GNUNET_TIME_Absolute  expiry 
)
static

Definition at line 977 of file gnunet-namestore.c.

983{
984 (void) cls;
985 (void) zone_key;
986 (void) expiry;
987 collect_zone_records_to_purge (zone_key, rname, rd_len, rd);
989}

References collect_zone_records_to_purge(), GNUNET_NAMESTORE_zone_iterator_next(), list_it, and rd.

Referenced by run_with_zone_pkey().

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

◆ purge_orphans_iterator()

static void purge_orphans_iterator ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd,
struct GNUNET_TIME_Absolute  expiry 
)
static

Definition at line 993 of file gnunet-namestore.c.

1000{
1001 (void) cls;
1002 (void) zone_key;
1003 (void) expiry;
1004 collect_orphans (zone_key, rname, rd_len, rd);
1006}

References collect_orphans(), GNUNET_NAMESTORE_zone_iterator_next(), list_it, and rd.

Referenced by run_with_zone_pkey().

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

◆ display_record_iterator()

static void display_record_iterator ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd,
struct GNUNET_TIME_Absolute  expiry 
)
static

Process a record that was stored in the namestore.

Parameters
clsclosure
zone_keyprivate key of the zone
rnamename that is being mapped (at most 255 characters long)
rd_lennumber of entries in rd array
rdarray of records with data to store

Definition at line 1019 of file gnunet-namestore.c.

1026{
1027 (void) cls;
1028 (void) zone_key;
1029 (void) expiry;
1030 display_record (zone_key, rname, rd_len, rd);
1032}

References display_record(), GNUNET_NAMESTORE_zone_iterator_next(), list_it, and rd.

Referenced by run_with_zone_pkey().

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

◆ display_record_monitor()

static void display_record_monitor ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd,
struct GNUNET_TIME_Absolute  expiry 
)
static

Process a record that was stored in the namestore.

Parameters
clsclosure
zone_keyprivate key of the zone
rnamename that is being mapped (at most 255 characters long)
rd_lennumber of entries in rd array
rdarray of records with data to store

Definition at line 1045 of file gnunet-namestore.c.

1052{
1053 (void) cls;
1054 (void) zone_key;
1055 (void) expiry;
1056 display_record (zone_key, rname, rd_len, rd);
1058}

References display_record(), GNUNET_NAMESTORE_zone_monitor_next(), rd, and zm.

Referenced by run_with_zone_pkey().

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

◆ display_record_lookup()

static void display_record_lookup ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone_key,
const char *  rname,
unsigned int  rd_len,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Process a record that was stored in the namestore.

Parameters
clsclosure
zone_keyprivate key of the zone
rnamename that is being mapped (at most 255 characters long)
rd_lennumber of entries in rd array
rdarray of records with data to store

Definition at line 1071 of file gnunet-namestore.c.

1076{
1077 (void) cls;
1078 (void) zone_key;
1079 get_qe = NULL;
1080 display_record (zone_key, rname, rd_len, rd);
1081 finish_command ();
1082}

References display_record(), finish_command(), get_qe, and rd.

Referenced by run_with_zone_pkey().

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

◆ sync_cb()

static void sync_cb ( void *  cls)
static

Function called once we are in sync in monitor mode.

Parameters
clsNULL

Definition at line 1091 of file gnunet-namestore.c.

1092{
1093 (void) cls;
1094 fprintf (stdout, "%s", "Monitor is now in sync.\n");
1095}

Referenced by GNUNET_NAMESTORE_zone_monitor_start(), GNUNET_NAMESTORE_zone_monitor_start2(), GNUNET_PEERSTORE_monitor_start(), and run_with_zone_pkey().

Here is the caller graph for this function:

◆ monitor_error_cb()

static void monitor_error_cb ( void *  cls)
static

Function called on errors while monitoring.

Parameters
clsNULL

Definition at line 1104 of file gnunet-namestore.c.

1105{
1106 (void) cls;
1107 fprintf (stderr, "%s", "Monitor disconnected and out of sync.\n");
1108}

Referenced by run_with_zone_pkey().

Here is the caller graph for this function:

◆ lookup_error_cb()

static void lookup_error_cb ( void *  cls)
static

Function called on errors while monitoring.

Parameters
clsNULL

Definition at line 1117 of file gnunet-namestore.c.

1118{
1119 (void) cls;
1120 get_qe = NULL;
1121 fprintf (stderr, "%s", "Failed to lookup record.\n");
1122 finish_command ();
1123}

References finish_command(), and get_qe.

Referenced by run_with_zone_pkey().

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

◆ add_error_cb()

static void add_error_cb ( void *  cls)
static

Function called if lookup fails.

Definition at line 1130 of file gnunet-namestore.c.

1131{
1132 (void) cls;
1133 add_qe = NULL;
1134 GNUNET_break (0);
1135 ret = 1;
1136 finish_command ();
1137}

References add_qe, finish_command(), GNUNET_break, and ret.

Referenced by run_with_zone_pkey().

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

◆ get_existing_record()

static void get_existing_record ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone_key,
const char *  rec_name,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

We're storing a record; this function is given the existing record so that we can merge the information.

Parameters
clsclosure, unused
zone_keyprivate key of the zone
rec_namename 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 1151 of file gnunet-namestore.c.

1156{
1157 struct GNUNET_GNSRECORD_Data rdn[rd_count + 1];
1158 struct GNUNET_GNSRECORD_Data *rde;
1159
1160 (void) cls;
1161 (void) zone_key;
1162 add_qe = NULL;
1163 if (0 != strcmp (rec_name, name))
1164 {
1165 GNUNET_break (0);
1166 ret = 1;
1167 finish_command ();
1168 return;
1169 }
1170
1172 "Received %u records for name `%s'\n",
1173 rd_count,
1174 rec_name);
1175 for (unsigned int i = 0; i < rd_count; i++)
1176 {
1177 switch (rd[i].record_type)
1178 {
1181 {
1182 fprintf (
1183 stderr,
1184 _ (
1185 "A SOA record exists already under `%s', cannot add a second SOA to the same zone.\n"),
1186 rec_name);
1187 ret = 1;
1188 finish_command ();
1189 return;
1190 }
1191 break;
1192 }
1193 }
1194 memset (rdn, 0, sizeof(struct GNUNET_GNSRECORD_Data));
1195 GNUNET_memcpy (&rdn[1], rd, rd_count * sizeof(struct GNUNET_GNSRECORD_Data));
1196 rde = &rdn[0];
1197 rde->data = data;
1198 rde->data_size = data_size;
1199 rde->record_type = type;
1200 if (1 == is_shadow)
1202 if (1 == is_maintenance)
1204 if (1 != is_public)
1206 rde->expiration_time = etime;
1207 if (GNUNET_YES == etime_is_rel)
1209 else if (GNUNET_NO != etime_is_rel)
1211 GNUNET_assert (NULL != name);
1213 &zone_pkey,
1214 name,
1215 rd_count + 1,
1216 rde,
1218 &add_qe);
1219}

References _, add_continuation(), add_qe, data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, etime, etime_is_rel, GNUNET_GNSRECORD_Data::expiration_time, finish_command(), GNUNET_GNSRECORD_Data::flags, GNUNET_assert, GNUNET_break, GNUNET_DNSPARSER_TYPE_SOA, GNUNET_ERROR_TYPE_DEBUG, GNUNET_GNSRECORD_RF_MAINTENANCE, GNUNET_GNSRECORD_RF_PRIVATE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW, GNUNET_log, GNUNET_memcpy, GNUNET_NAMESTORE_record_set_store(), GNUNET_NO, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_YES, is_maintenance, is_public, is_shadow, name, ns, rd, rd_count, GNUNET_GNSRECORD_Data::record_type, ret, type, and zone_pkey.

Referenced by run_with_zone_pkey().

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

◆ reverse_error_cb()

static void reverse_error_cb ( void *  cls)
static

Function called if we encountered an error in zone-to-name.

Definition at line 1226 of file gnunet-namestore.c.

1227{
1228 (void) cls;
1229 reverse_qe = NULL;
1230 fprintf (stdout, "%s.zkey\n", reverse_pkey);
1231}

References reverse_pkey, and reverse_qe.

Referenced by run_with_zone_pkey().

Here is the caller graph for this function:

◆ handle_reverse_lookup()

static void handle_reverse_lookup ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Function called with the result of our attempt to obtain a name for a given public key.

Parameters
clsNULL
zoneprivate key of the zone; NULL on disconnect
labellabel of the records; NULL on disconnect
rd_countnumber of entries in rd array, 0 if label was deleted
rdarray of records with data to store

Definition at line 1245 of file gnunet-namestore.c.

1250{
1251 (void) cls;
1252 (void) zone;
1253 (void) rd_count;
1254 (void) rd;
1255 reverse_qe = NULL;
1256 if (NULL == label)
1257 fprintf (stdout, "%s\n", reverse_pkey);
1258 else
1259 fprintf (stdout, "%s.%s\n", label, ego_name);
1260 finish_command ();
1261}

References ego_name, finish_command(), rd, rd_count, reverse_pkey, and reverse_qe.

Referenced by run_with_zone_pkey().

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

◆ del_lookup_error_cb()

static void del_lookup_error_cb ( void *  cls)
static

Function called if lookup for deletion fails.

Definition at line 1268 of file gnunet-namestore.c.

1269{
1270 (void) cls;
1271 del_qe = NULL;
1272 GNUNET_break (0);
1273 ret = 1;
1274 finish_command ();
1275}

References del_qe, finish_command(), GNUNET_break, and ret.

Referenced by run_with_zone_pkey().

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

◆ del_monitor()

static void del_monitor ( void *  cls,
const struct GNUNET_CRYPTO_BlindablePrivateKey zone,
const char *  label,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

We were asked to delete something; this function is called with the existing records.

Now we should determine what should be deleted and then issue the deletion operation.

Parameters
clsNULL
zoneprivate key of the zone we are deleting from
labelname of the records we are editing
rd_countsize of the rd array
rdexisting records

Definition at line 1290 of file gnunet-namestore.c.

1295{
1296 struct GNUNET_GNSRECORD_Data rdx[rd_count];
1297 unsigned int rd_left;
1298 uint32_t del_type;
1299 char *vs;
1300
1301 (void) cls;
1302 (void) zone;
1303 del_qe = NULL;
1304 if (0 == rd_count)
1305 {
1306 fprintf (stderr,
1307 _ (
1308 "There are no records under label `%s' that could be deleted.\n")
1309 ,
1310 label);
1311 ret = 1;
1312 finish_command ();
1313 return;
1314 }
1315 if ((NULL == value) && (NULL == typestring))
1316 {
1317 /* delete everything */
1319 &zone_pkey,
1320 name,
1321 0,
1322 NULL,
1324 NULL);
1325 return;
1326 }
1327 rd_left = 0;
1328 if (NULL != typestring)
1330 else
1331 del_type = GNUNET_GNSRECORD_TYPE_ANY;
1332 for (unsigned int i = 0; i < rd_count; i++)
1333 {
1334 vs = NULL;
1335 if (! (((GNUNET_GNSRECORD_TYPE_ANY == del_type) ||
1336 (rd[i].record_type == del_type)) &&
1337 ((NULL == value) ||
1338 (NULL ==
1340 rd[i].data,
1341 rd[i].data_size)))) ||
1342 (0 == strcmp (vs, value)))))
1343 rdx[rd_left++] = rd[i];
1344 GNUNET_free (vs);
1345 }
1346 if (rd_count == rd_left)
1347 {
1348 /* nothing got deleted */
1349 fprintf (
1350 stderr,
1351 _ (
1352 "There are no records under label `%s' that match the request for deletion.\n"),
1353 label);
1354 finish_command ();
1355 return;
1356 }
1357 /* delete everything but what we copied to 'rdx' */
1359 &zone_pkey,
1360 name,
1361 rd_left,
1362 rdx,
1364 NULL);
1365}

References _, data, data_size, del_continuation(), del_qe, finish_command(), GNUNET_free, GNUNET_GNSRECORD_TYPE_ANY, GNUNET_GNSRECORD_typename_to_number(), GNUNET_GNSRECORD_value_to_string(), GNUNET_NAMESTORE_record_set_store(), name, ns, rd, rd_count, GNUNET_GNSRECORD_Data::record_type, ret, typestring, value, and zone_pkey.

Referenced by run_with_zone_pkey().

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

◆ schedule_finish()

static void schedule_finish ( void *  cls)
static

Definition at line 1369 of file gnunet-namestore.c.

1370{
1371 finish_command ();
1372}

References finish_command().

Referenced by replace_cont().

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

◆ replace_cont()

static void replace_cont ( void *  cls,
enum GNUNET_ErrorCode  ec 
)
static

Definition at line 1376 of file gnunet-namestore.c.

1377{
1378 (void) cls;
1379
1380 set_qe = NULL;
1381 if (GNUNET_EC_NONE != ec)
1382 {
1384 _ ("%s\n"),
1386 ret = 1; /* fail from 'main' */
1387 }
1389}

References _, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_MESSAGE, GNUNET_ErrorCode_get_hint(), GNUNET_log, GNUNET_SCHEDULER_add_now(), ret, schedule_finish(), and set_qe.

Referenced by batch_insert_recordinfo(), and run_with_zone_pkey().

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

◆ run_with_zone_pkey()

static void run_with_zone_pkey ( const struct GNUNET_CONFIGURATION_Handle cfg_)
static

We have obtained the zone's private key, so now process the main commands using it.

Parameters
cfgconfiguration to use

Definition at line 1435 of file gnunet-namestore.c.

1436{
1439
1440 if (omit_private)
1444 if (! (add | del | list | (NULL != nickstring) | (NULL != uri)
1445 | (NULL != reverse_pkey) | (NULL != recordset) | (monitor)
1447 {
1448 /* nothing more to be done */
1449 fprintf (stderr, _ ("No options given\n"));
1450 finish_command ();
1451 return;
1452 }
1453
1454 if (NULL != recordset)
1455 {
1456 /* replace entire record set */
1457 unsigned int rd_count;
1458 struct GNUNET_GNSRECORD_Data *rd_tmp;
1459
1460 /* FIXME: We could easily support append and delete with this as well */
1461 if (! add)
1462 {
1463 fprintf (stderr, _ ("Recordlines only work with option `%s'\n"),
1464 "-a");
1465 ret = 1;
1466 finish_command ();
1467 return;
1468 }
1469 if (NULL == name)
1470 {
1471 fprintf (stderr,
1472 _ ("Missing option `%s' for operation `%s'\n"),
1473 "-n",
1474 _ ("name"));
1475 ret = 1;
1476 finish_command ();
1477 return;
1478 }
1479 rd_count = 0;
1480 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1481 rd_count++;
1483 rd_count = 0;
1484 for (struct RecordSetEntry *e = recordset; NULL != e; e = e->next)
1485 {
1486 rd_tmp[rd_count] = e->record;
1487 rd_count++;
1488 }
1490 &zone_pkey,
1491 name,
1492 rd_count,
1493 rd_tmp,
1494 &replace_cont,
1495 NULL);
1496 GNUNET_free (rd_tmp);
1497 return;
1498 }
1499 if (NULL != nickstring)
1500 {
1501 if (0 == strlen (nickstring))
1502 {
1503 fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring);
1504 ret = 1;
1505 finish_command ();
1506 return;
1507 }
1508 add = 1;
1513 is_public = 0;
1514 expirationstring = GNUNET_strdup ("never");
1516 nickstring = NULL;
1517 }
1518
1519 if (add)
1520 {
1521 if (NULL == ego_name)
1522 {
1523 fprintf (stderr,
1524 _ ("Missing option `%s' for operation `%s'\n"),
1525 "-z",
1526 _ ("add"));
1527 ret = 1;
1528 finish_command ();
1529 return;
1530 }
1531 if (NULL == name)
1532 {
1533 fprintf (stderr,
1534 _ ("Missing option `%s' for operation `%s'\n"),
1535 "-n",
1536 _ ("add"));
1537 ret = 1;
1538 finish_command ();
1539 return;
1540 }
1541 if (NULL == typestring)
1542 {
1543 fprintf (stderr,
1544 _ ("Missing option `%s' for operation `%s'\n"),
1545 "-t",
1546 _ ("add"));
1547 ret = 1;
1548 finish_command ();
1549 return;
1550 }
1552 if (UINT32_MAX == type)
1553 {
1554 fprintf (stderr, _ ("Unsupported type `%s'\n"), typestring);
1555 ret = 1;
1556 finish_command ();
1557 return;
1558 }
1563 {
1564 fprintf (stderr,
1565 _ (
1566 "For DNS record types `SRV', `TLSA', `SMIMEA' and `OPENPGPKEY'"));
1567 fprintf (stderr, ", please use a `BOX' record instead\n");
1568 ret = 1;
1569 finish_command ();
1570 return;
1571 }
1572 if (NULL == value)
1573 {
1574 fprintf (stderr,
1575 _ ("Missing option `%s' for operation `%s'\n"),
1576 "-V",
1577 _ ("add"));
1578 ret = 1;
1579 finish_command ();
1580 return;
1581 }
1582 if (GNUNET_OK !=
1584 {
1585 fprintf (stderr,
1586 _ ("Value `%s' invalid for record type `%s'\n"),
1587 value,
1588 typestring);
1589 ret = 1;
1590 finish_command ();
1591 return;
1592 }
1593 if (NULL == expirationstring)
1594 {
1595 fprintf (stderr,
1596 _ ("Missing option `%s' for operation `%s'\n"),
1597 "-e",
1598 _ ("add"));
1599 ret = 1;
1600 finish_command ();
1601 return;
1602 }
1604 {
1605 fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1606 ret = 1;
1607 finish_command ();
1608 return;
1609 }
1611 &zone_pkey,
1612 name,
1613 &add_error_cb,
1614 NULL,
1616 NULL);
1617 }
1618 if (del)
1619 {
1620 if (NULL == ego_name)
1621 {
1622 fprintf (stderr,
1623 _ ("Missing option `%s' for operation `%s'\n"),
1624 "-z",
1625 _ ("del"));
1626 ret = 1;
1627 finish_command ();
1628 return;
1629 }
1630 if (NULL == name)
1631 {
1632 fprintf (stderr,
1633 _ ("Missing option `%s' for operation `%s'\n"),
1634 "-n",
1635 _ ("del"));
1636 ret = 1;
1637 finish_command ();
1638 return;
1639 }
1641 &zone_pkey,
1642 name,
1644 NULL,
1645 &del_monitor,
1646 NULL,
1647 filter_flags);
1648 }
1649 if (purge_orphaned)
1650 {
1652 NULL,
1654 NULL,
1656 NULL,
1658 NULL,
1659 filter_flags);
1660
1661 }
1662 else if (purge_zone)
1663 {
1664 if (NULL == ego_name)
1665 {
1666 fprintf (stderr,
1667 _ ("Missing option `%s' for operation `%s'\n"),
1668 "-z",
1669 _ ("purge-zone"));
1670 ret = 1;
1671 finish_command ();
1672 return;
1673 }
1675 &zone_pkey,
1677 NULL,
1679 NULL,
1681 NULL,
1682 filter_flags);
1683
1684 }
1685 else if (list || list_orphaned)
1686 {
1687 if (NULL != name)
1688 {
1689 if (NULL == ego_name)
1690 {
1691 fprintf (stderr,
1692 _ ("Missing option `%s' for operation `%s'\n"),
1693 "-z",
1694 _ ("list"));
1695 ret = 1;
1696 finish_command ();
1697 return;
1698 }
1700 &zone_pkey,
1701 name,
1703 NULL,
1705 NULL);
1706 }
1707 else
1709 (NULL == ego_name) ?
1710 NULL : &zone_pkey,
1712 ,
1713 NULL,
1715 ,
1716 NULL,
1718 ,
1719 NULL,
1720 filter_flags);
1721 }
1722 if (NULL != reverse_pkey)
1723 {
1725
1726 if (NULL == ego_name)
1727 {
1728 fprintf (stderr,
1729 _ ("Missing option `%s' for operation `%s'\n"),
1730 "-z",
1731 _ ("reverse-pkey"));
1732 ret = 1;
1733 finish_command ();
1734 return;
1735 }
1736 if (GNUNET_OK !=
1738 &pubkey))
1739 {
1740 fprintf (stderr,
1741 _ ("Invalid public key for reverse lookup `%s'\n"),
1742 reverse_pkey);
1743 ret = 1;
1744 finish_command ();
1745 return;
1746 }
1748 &zone_pkey,
1749 &pubkey,
1751 NULL,
1753 NULL);
1754 }
1755 if (NULL != uri)
1756 {
1757 char sh[105];
1758 char sname[64];
1760 if (NULL == ego_name)
1761 {
1762 fprintf (stderr,
1763 _ ("Missing option `%s' for operation `%s'\n"),
1764 "-z",
1765 _ ("uri"));
1766 ret = 1;
1767 finish_command ();
1768 return;
1769 }
1770
1771 memset (sh, 0, 105);
1772 memset (sname, 0, 64);
1773
1774 if ((2 != (sscanf (uri, "gnunet://gns/%58s/%63s", sh, sname))) ||
1775 (GNUNET_OK !=
1777 {
1778 fprintf (stderr, _ ("Invalid URI `%s'\n"), uri);
1779 ret = 1;
1780 finish_command ();
1781 return;
1782 }
1783 if (NULL == expirationstring)
1784 {
1785 fprintf (stderr,
1786 _ ("Missing option `%s' for operation `%s'\n"),
1787 "-e",
1788 _ ("add"));
1789 ret = 1;
1790 finish_command ();
1791 return;
1792 }
1794 {
1795 fprintf (stderr, _ ("Invalid time format `%s'\n"), expirationstring);
1796 ret = 1;
1797 finish_command ();
1798 return;
1799 }
1800 memset (&rd, 0, sizeof(rd));
1801 rd.data = &pkey;
1803 rd.record_type = ntohl (pkey.type);
1805 if (GNUNET_YES == etime_is_rel)
1807 if (1 == is_shadow)
1809 if (1 == is_maintenance)
1812 &zone_pkey,
1813 sname,
1814 1,
1815 &rd,
1817 &add_qe_uri);
1818 }
1819 if (monitor)
1820 {
1822 (NULL != ego_name) ?
1823 &zone_pkey : NULL,
1824 GNUNET_YES,
1826 NULL,
1828 NULL,
1829 &sync_cb,
1830 NULL,
1831 filter_flags);
1832 }
1833}

References _, add, add_continuation(), add_error_cb(), add_qe, add_qe_uri, data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, del, del_lookup_error_cb(), del_monitor(), del_qe, display_record_iterator(), display_record_lookup(), display_record_monitor(), ego_name, etime, etime_is_rel, GNUNET_GNSRECORD_Data::expiration_time, expirationstring, finish_command(), GNUNET_GNSRECORD_Data::flags, get_existing_record(), get_qe, GNUNET_CRYPTO_blindable_public_key_from_string(), GNUNET_CRYPTO_public_key_get_length(), GNUNET_DNSPARSER_TYPE_OPENPGPKEY, GNUNET_DNSPARSER_TYPE_SMIMEA, GNUNET_DNSPARSER_TYPE_SRV, GNUNET_DNSPARSER_TYPE_TLSA, GNUNET_free, GNUNET_GNS_EMPTY_LABEL_AT, GNUNET_GNSRECORD_FILTER_INCLUDE_MAINTENANCE, GNUNET_GNSRECORD_FILTER_NONE, GNUNET_GNSRECORD_FILTER_OMIT_PRIVATE, GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_RF_MAINTENANCE, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_GNSRECORD_RF_SHADOW, GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_TYPE_NICK, GNUNET_GNSRECORD_typename_to_number(), GNUNET_NAMESTORE_record_set_store(), GNUNET_NAMESTORE_records_lookup(), GNUNET_NAMESTORE_records_lookup2(), GNUNET_NAMESTORE_zone_iteration_start2(), GNUNET_NAMESTORE_zone_monitor_start2(), GNUNET_NAMESTORE_zone_to_name(), GNUNET_new_array, GNUNET_OK, GNUNET_strdup, GNUNET_YES, handle_reverse_lookup(), include_maintenance, is_maintenance, is_public, is_shadow, list, list_it, list_orphaned, lookup_error_cb(), monitor, monitor_error_cb(), name, RecordSetEntry::next, nickstring, ns, omit_private, parse_expiration(), pkey, pubkey, purge_orphaned, purge_orphans_iterator(), purge_zone, purge_zone_iterator(), rd, rd_count, GNUNET_GNSRECORD_Data::record_type, recordset, replace_cont(), ret, reverse_error_cb(), reverse_pkey, reverse_qe, set_qe, sh, sync_cb(), type, typestring, uri, value, zm, zone_iteration_error_cb(), zone_iteration_finished(), and zone_pkey.

Referenced by id_connect_cb().

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

◆ get_identity_for_string()

static int get_identity_for_string ( const char *  str,
struct GNUNET_CRYPTO_BlindablePrivateKey zk 
)
static

FIXME: Check for zTLD?

Definition at line 1841 of file gnunet-namestore.c.

1843{
1844 const struct GNUNET_CRYPTO_BlindablePrivateKey *privkey;
1846 struct GNUNET_CRYPTO_BlindablePublicKey ego_pubkey;
1847 struct EgoEntry *ego_entry;
1848
1850 &pubkey))
1851 {
1852 for (ego_entry = ego_head;
1853 NULL != ego_entry; ego_entry = ego_entry->next)
1854 {
1855 privkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1856 GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &ego_pubkey);
1857 if (0 == memcmp (&ego_pubkey, &pubkey, sizeof (pubkey)))
1858 {
1859 *zk = *privkey;
1860 return GNUNET_OK;
1861 }
1862 }
1863 }
1864 else
1865 {
1866 for (ego_entry = ego_head; NULL != ego_entry; ego_entry = ego_entry->next)
1867 {
1869 if (0 != strcmp (str, ego_entry->identifier))
1870 continue;
1871 *zk = *GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
1872 return GNUNET_OK;
1873 }
1874 }
1875 return GNUNET_NO;
1876}

References EgoEntry::ego, ego_head, GNUNET_CRYPTO_blindable_public_key_from_string(), GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_NO, GNUNET_OK, EgoEntry::identifier, EgoEntry::next, pubkey, and str.

Referenced by process_command_stdin().

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

◆ id_connect_cb()

static void id_connect_cb ( void *  cls,
struct GNUNET_IDENTITY_Ego ego,
void **  ctx,
const char *  ego_name_tmp 
)
static

Function called with ALL of the egos known to the identity service, used on startup if the user did not specify a zone on the command-line.

Once the iteration is done (ego is NULL), we ask for the default ego for "namestore".

Parameters
clsa struct GNUNET_CONFIGURATION_Handle
egoan ego, NULL for end of iteration
ctxNULL
namename associated with ego

Definition at line 2057 of file gnunet-namestore.c.

2061{
2063 struct EgoEntry *ego_entry;
2064
2065 (void) ctx;
2066 (void) ego_name_tmp;
2067 if ((NULL != ego_name_tmp) && (NULL != ego))
2068 {
2069 ego_entry = GNUNET_new (struct EgoEntry);
2071 ego_entry->ego = ego;
2072 ego_entry->identifier = GNUNET_strdup (ego_name_tmp);
2074 ego_tail,
2075 ego_entry);
2076 if ((NULL != ego_name) && (NULL != ego_name_tmp) &&
2077 (0 == strcmp (ego_name, ego_name_tmp)))
2079 return;
2080 }
2081 if (NULL != ego)
2082 return;
2083 if (read_from_stdin)
2084 {
2086 return;
2087 }
2089}

References cfg, ctx, EgoEntry::ego, ego_head, ego_name, ego_tail, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_IDENTITY_ego_get_public_key(), GNUNET_new, GNUNET_strdup, EgoEntry::identifier, pk, process_command_stdin(), read_from_stdin, run_with_zone_pkey(), and zone_pkey.

Referenced by run().

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

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle _cfg 
)
static

Main function that will be run.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 2101 of file gnunet-namestore.c.

2105{
2106 (void) cls;
2107 (void) args;
2108 (void) cfgfile;
2109 cfg = _cfg;
2110 if (NULL != args[0])
2111 GNUNET_log (
2113 _ ("Superfluous command line arguments (starting with `%s') ignored\n"),
2114 args[0]);
2115
2118 if (NULL == ns)
2119 {
2120 fprintf (stderr, _ ("Failed to connect to namestore\n"));
2122 return;
2123 }
2125 if (NULL == idh)
2126 {
2127 ret = -1;
2128 fprintf (stderr, _ ("Cannot connect to identity service\n"));
2130 }
2131}

References _, cfg, do_shutdown, GNUNET_ERROR_TYPE_WARNING, GNUNET_IDENTITY_connect(), GNUNET_log, GNUNET_NAMESTORE_connect(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), id_connect_cb(), idh, ns, and ret.

Referenced by main().

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

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function for gnunet-namestore.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 2142 of file gnunet-namestore.c.

2143{
2144 int lret;
2146 { GNUNET_GETOPT_option_flag ('a', "add", gettext_noop ("add record"), &add),
2148 "delete",
2149 gettext_noop ("delete record"),
2150 &del),
2152 "display",
2153 gettext_noop ("display records"),
2154 &list),
2156 "from-stdin",
2157 gettext_noop ("read commands from stdin"),
2160 'e',
2161 "expiration",
2162 "TIME",
2163 gettext_noop (
2164 "expiration time for record to use (for adding only), \"never\" is possible"),
2167 "nick",
2168 "NICKNAME",
2169 gettext_noop (
2170 "set the desired nick name for the zone"),
2171 &nickstring),
2173 "monitor",
2174 gettext_noop (
2175 "monitor changes in the namestore"),
2176 &monitor),
2178 "name",
2179 "NAME",
2180 gettext_noop (
2181 "name of the record to add/delete/display"),
2182 &name),
2184 "recordline",
2185 gettext_noop ("Output in recordline format"),
2188 "zone-to-name",
2189 "KEY",
2190 gettext_noop (
2191 "determine our name for the given KEY"),
2192 &reverse_pkey),
2194 "type",
2195 "TYPE",
2196 gettext_noop (
2197 "type of the record to add/delete/display"),
2198 &typestring),
2200 "uri",
2201 "URI",
2202 gettext_noop ("URI to import into our zone"),
2203 &uri),
2205 "value",
2206 "VALUE",
2207 gettext_noop (
2208 "value of the record to add/delete"),
2209 &value),
2211 "public",
2212 gettext_noop ("create or list public record"),
2213 &is_public),
2215 "omit-private",
2216 gettext_noop ("omit private records"),
2217 &omit_private),
2219 "include-maintenance",
2220 gettext_noop (
2221 "do not filter maintenance records"),
2224 "purge-orphans",
2225 gettext_noop (
2226 "purge namestore of all orphans"),
2229 "list-orphans",
2230 gettext_noop (
2231 "show private key for orphaned records for recovery using `gnunet-identity -C -P <key>'. Use in combination with --display"),
2232 &list_orphaned),
2234 "purge-zone-records",
2235 gettext_noop (
2236 "delete all records in specified zone"),
2237 &purge_zone),
2239 "batch-size",
2240 "NUMBER",
2241 gettext_noop (
2242 "number of records to buffer and send as batch (for use with --from-stdin)"),
2245 's',
2246 "shadow",
2247 gettext_noop (
2248 "create shadow record (only valid if all other records of the same type have expired)"),
2249 &is_shadow),
2251 'M',
2252 "maintenance",
2253 gettext_noop (
2254 "create maintenance record (e.g TOMBSTONEs)"),
2257 "zone",
2258 "EGO",
2259 gettext_noop (
2260 "name of the ego controlling the zone"),
2261 &ego_name),
2263
2264
2265 is_public = -1;
2266 is_shadow = -1;
2267 is_maintenance = -1;
2268 GNUNET_log_setup ("gnunet-namestore", "WARNING", NULL);
2269 if (GNUNET_OK !=
2271 argc,
2272 argv,
2273 "gnunet-namestore",
2274 _ ("GNUnet zone manipulation tool"),
2275 options,
2276 &run,
2277 NULL)))
2278 {
2279 // FIXME
2280 // GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
2281 return lret;
2282 }
2283 // FIXME
2284 // GNUNET_CRYPTO_ecdsa_key_clear (&zone_pkey);
2285 return ret;
2286}

References _, add, del, ego_name, expirationstring, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_log_setup(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), include_maintenance, is_maintenance, is_public, is_shadow, list, list_orphaned, max_batch_size, monitor, name, nickstring, omit_private, options, output_recordline, purge_orphaned, purge_zone, read_from_stdin, ret, reverse_pkey, run(), typestring, uri, and value.

Here is the call graph for this function:

Variable Documentation

◆ ns

struct GNUNET_NAMESTORE_Handle* ns
static

◆ zone_pkey

◆ idh

struct GNUNET_IDENTITY_Handle* idh
static

Identity service handle.

Definition at line 125 of file gnunet-namestore.c.

Referenced by do_shutdown(), and run().

◆ ego_name

char* ego_name
static

Name of the ego controlling the zone.

Definition at line 130 of file gnunet-namestore.c.

Referenced by handle_reverse_lookup(), id_connect_cb(), main(), reset_handles(), and run_with_zone_pkey().

◆ add_qe_uri

struct GNUNET_NAMESTORE_QueueEntry* add_qe_uri
static

Queue entry for the 'add-uri' operation.

Definition at line 135 of file gnunet-namestore.c.

Referenced by reset_handles(), and run_with_zone_pkey().

◆ add_qe

struct GNUNET_NAMESTORE_QueueEntry* add_qe
static

Queue entry for the 'add' operation.

Definition at line 140 of file gnunet-namestore.c.

Referenced by add_error_cb(), get_existing_record(), reset_handles(), and run_with_zone_pkey().

◆ get_qe

struct GNUNET_NAMESTORE_QueueEntry* get_qe
static

Queue entry for the 'lookup' operation.

Definition at line 145 of file gnunet-namestore.c.

Referenced by display_record_lookup(), lookup_error_cb(), reset_handles(), and run_with_zone_pkey().

◆ reverse_qe

struct GNUNET_NAMESTORE_QueueEntry* reverse_qe
static

Queue entry for the 'reverse lookup' operation (in combination with a name).

Definition at line 150 of file gnunet-namestore.c.

Referenced by handle_reverse_lookup(), reset_handles(), reverse_error_cb(), and run_with_zone_pkey().

◆ marked_head

struct MarkedRecord* marked_head
static

Marked record list.

Definition at line 155 of file gnunet-namestore.c.

Referenced by collect_orphans(), collect_zone_records_to_purge(), purge_next_record(), and reset_handles().

◆ marked_tail

struct MarkedRecord* marked_tail
static

Marked record list.

Definition at line 160 of file gnunet-namestore.c.

Referenced by collect_orphans(), collect_zone_records_to_purge(), and purge_next_record().

◆ cfg

const struct GNUNET_CONFIGURATION_Handle* cfg

Configuration handle.

Handle to our configuration.

Definition at line 165 of file gnunet-namestore.c.

Referenced by id_connect_cb(), process_command_stdin(), and run().

◆ ego_head

struct EgoEntry* ego_head
static

◆ ego_tail

struct EgoEntry* ego_tail
static

Ego list.

Definition at line 175 of file gnunet-namestore.c.

Referenced by id_connect_cb().

◆ list_it

◆ read_from_stdin

int read_from_stdin
static

Run in read from stdin mode.

Definition at line 185 of file gnunet-namestore.c.

Referenced by finish_command(), id_connect_cb(), and main().

◆ list

int list
static

Desired action is to list records.

Definition at line 190 of file gnunet-namestore.c.

Referenced by main(), reset_handles(), and run_with_zone_pkey().

◆ add

◆ del

int del
static

Desired action is to remove a record.

Definition at line 200 of file gnunet-namestore.c.

Referenced by forward_resolution(), GNUNET_ABD_delegate_issue(), main(), run_with_zone_pkey(), and send_lookup_response().

◆ is_public

int is_public
static

◆ is_shadow

int is_shadow
static

Is record a shadow record (GNUNET_GNSRECORD_RF_SHADOW)

Definition at line 210 of file gnunet-namestore.c.

Referenced by get_existing_record(), main(), reset_handles(), and run_with_zone_pkey().

◆ is_maintenance

int is_maintenance
static

Is record a maintenance record (GNUNET_GNSRECORD_RF_MAINTENANCE)

Definition at line 215 of file gnunet-namestore.c.

Referenced by get_existing_record(), main(), reset_handles(), and run_with_zone_pkey().

◆ omit_private

int omit_private
static

Filter private records.

Definition at line 220 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().

◆ output_recordline

int output_recordline
static

Output in recordline format.

Definition at line 225 of file gnunet-namestore.c.

Referenced by display_record(), and main().

◆ purge_zone

int purge_zone
static

Purge zone contents.

Definition at line 231 of file gnunet-namestore.c.

Referenced by main(), reset_handles(), run_with_zone_pkey(), and zone_iteration_finished().

◆ include_maintenance

int include_maintenance
static

Do not filter maintenance records.

Definition at line 236 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().

◆ purge_orphaned

int purge_orphaned
static

Purge orphaned records.

Definition at line 241 of file gnunet-namestore.c.

Referenced by main(), run_with_zone_pkey(), and zone_iteration_finished().

◆ list_orphaned

int list_orphaned
static

List records and zone keys of orphaned records.

Definition at line 246 of file gnunet-namestore.c.

Referenced by display_record(), main(), and run_with_zone_pkey().

◆ del_qe

struct GNUNET_NAMESTORE_QueueEntry* del_qe
static

◆ set_qe

struct GNUNET_NAMESTORE_QueueEntry* set_qe
static

Queue entry for the 'set/replace' operation.

Definition at line 256 of file gnunet-namestore.c.

Referenced by batch_insert_recordinfo(), replace_cont(), reset_handles(), and run_with_zone_pkey().

◆ ns_qe

struct GNUNET_NAMESTORE_QueueEntry* ns_qe
static

Queue entry for begin/commit.

Definition at line 261 of file gnunet-namestore.c.

Referenced by do_shutdown().

◆ name

char* name
static

Name of the records to add/list/remove.

Definition at line 266 of file gnunet-namestore.c.

Referenced by del_monitor(), display_record(), get_existing_record(), main(), reset_handles(), and run_with_zone_pkey().

◆ value

char* value
static

Value of the record to add/remove.

Definition at line 271 of file gnunet-namestore.c.

Referenced by add_get_request_to_pending(), add_global_addresses(), add_known_to_bloom(), add_section_contents(), add_sections(), add_setter_action(), attr_in_claims_request(), auto_conf_iter(), bandwidth_stats_iterator(), bind_loose_channel(), build_result_set(), bulk_tx_start(), call_iterator(), cancel_pending_request(), change_peer_respect(), channel_destroy_iterator(), check_connection_quality(), check_known_address(), check_known_challenge(), check_validation_request_pending(), check_vectors(), clean_local_client(), clean_request(), cleanup_channel(), cleanup_destination(), cleanup_hashmap(), cleanup_url_map(), clear_linked_hash(), client_release_ports(), close_files_iter(), collector(), compare_entries(), compute_service_response(), compute_square_sum_mpi_elements(), con_val_iter(), consume_cont(), contains_address(), cookie_identity_interpretation(), copy_element_cb(), copy_element_cb(), copy_element_cb(), copy_element_cb(), copy_entry(), create_randomized_element_iterator(), create_response(), debug_channel(), decrementBit(), del_monitor(), delete_linked_hash(), delete_value(), destroy_active_client_request(), destroy_channel_cb(), destroy_elements_iterator(), destroy_elements_iterator(), destroy_elements_iterator(), destroy_it(), destroy_iterator_cb(), destroy_key_to_element_iter(), destroy_key_to_element_iter(), destroy_paths_now(), destroy_port_cb(), destroy_remaining_channels(), destroy_tunnels_now(), determinate_avg_element_size_iterator(), determinate_done_message_iterator(), disconnect_and_free_peer_entry(), dns_string_to_value(), dns_value_to_string(), do_flood(), do_notify(), dv_neighbour_selection(), dv_neighbour_transmission(), escape_name(), execute_get(), expire_blocks(), filter_all(), filter_all(), filtered_map_initialization(), filtered_map_initialization(), find_advertisable_hello(), find_by_message_uuid(), find_by_unique_id(), find_closest(), find_linked_hash(), find_result_set(), find_store_peer(), find_trees(), flush_respect(), format_help(), forward_reply(), free_ack_cummulator_cb(), free_backtalker_cb(), free_carriers_cb(), free_dv_routes_cb(), free_ego(), free_element_cb(), free_element_cb(), free_element_cb(), free_element_cb(), free_entry(), free_item(), free_iterate(), free_neighbour_cb(), free_peer(), free_pending_ack_cb(), free_reassembly_cb(), free_request_it(), free_result(), free_service_record(), free_subnets_cb(), free_sug_handle(), free_validation_state_cb(), free_value(), free_value_cb(), free_values_iter(), free_waiting_entry(), full_sync_plausibility_check(), get_all_peers_iterator(), get_all_tunnels_iterator(), get_cb(), get_connection_delete_it(), get_iterator(), get_lt_delete_it(), get_lt_delete_it(), get_peer_delete_it(), get_queue_delete_it(), get_queue_delete_it(), get_queue_delete_it(), get_rand_peer_iterator(), get_receiver_delete_it(), get_result_present(), get_sender_delete_it(), get_stream_delete_it(), get_url_parameter_copy(), getopt_set_keywords(), getopt_set_metadata(), GNUNET_CONFIGURATION_append_value_filename(), GNUNET_CONFIGURATION_config_tool_run(), GNUNET_CONFIGURATION_deserialize(), GNUNET_CONFIGURATION_get_value_choice(), GNUNET_CONFIGURATION_get_value_filename(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_CONFIGURATION_remove_value_filename(), GNUNET_CONFIGURATION_set_value_string(), GNUNET_CONTAINER_multihashmap32_contains_value(), GNUNET_CONTAINER_multihashmap32_iterator_next(), GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_CONTAINER_multihashmap_contains_value(), GNUNET_CONTAINER_multihashmap_iterator_next(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CONTAINER_multipeermap_contains_value(), GNUNET_CONTAINER_multipeermap_iterator_next(), GNUNET_CONTAINER_multipeermap_put(), GNUNET_CONTAINER_multipeermap_remove(), GNUNET_CONTAINER_multishortmap_contains_value(), GNUNET_CONTAINER_multishortmap_iterator_next(), GNUNET_CONTAINER_multishortmap_put(), GNUNET_CONTAINER_multishortmap_remove(), GNUNET_CONTAINER_multiuuidmap_contains_value(), GNUNET_CONTAINER_multiuuidmap_iterator_next(), GNUNET_CONTAINER_multiuuidmap_put(), GNUNET_CONTAINER_multiuuidmap_remove(), GNUNET_NETWORK_socket_disable_corking(), GNUNET_PEERSTORE_store(), GNUNET_STATISTICS_set(), GNUNET_TESTING_set_label(), GSF_cadet_release_clients(), handle_ack(), handle_ack_by_sender(), handle_alice_client_message(), handle_alice_client_message(), handle_bob_client_message(), handle_bob_client_message(), handle_set(), header_iterator(), header_iterator(), heap_plugin_get_expiration(), heap_plugin_get_replication(), heap_plugin_get_zero_anonymity(), heap_plugin_put(), host_processor(), http_recv_header_cb(), increment_value(), incrementBit(), init_key_to_element_iterator(), init_key_to_element_iterator(), initialize_map_unfiltered(), initialize_map_unfiltered(), inspect_attrs(), it_announcement_store_key(), it_epoch_store_keys(), it_find_announcement_with_most_members(), it_find_group_with_most_members(), it_find_valid_announcement_with_most_members(), it_find_valid_group_with_most_members(), it_group_store_key(), it_iterate_epoch_member(), it_move_epoch_groups_from_previous_epoch(), it_room_store_keys(), it_search_epoch_member(), it_update_epoch_member(), iterate_cancel_action_by(), iterate_channels_cb(), iterate_close_room(), iterate_copy_history(), iterate_destroy_action(), iterate_destroy_announcement(), iterate_destroy_contacts(), iterate_destroy_entries(), iterate_destroy_epoch(), iterate_destroy_group(), iterate_destroy_hashs(), iterate_destroy_link(), iterate_destroy_members(), iterate_destroy_message(), iterate_destroy_messages(), iterate_destroy_operations(), iterate_destroy_peers(), iterate_destroy_room(), iterate_destroy_rooms(), iterate_destroy_session(), iterate_destroy_subscription(), iterate_destroy_subscription(), iterate_destroy_tunnels(), iterate_epoch_announcement_invalidation(), iterate_epoch_group_invalidation(), iterate_find_member(), iterate_find_room(), iterate_flag_for_cleanup_discourse_message(), iterate_free_values(), iterate_load_next_member_sessions(), iterate_load_next_session(), iterate_local_members(), iterate_member_sessions_it(), iterate_message_control(), iterate_next_member_ids(), iterate_reachables(), iterate_reset_room(), iterate_room_epoch_member_invalidation(), iterate_save_entries(), iterate_save_epochs(), iterate_save_links(), iterate_save_member_session_history_hentries(), iterate_save_members(), iterate_save_messages(), iterate_save_operations(), iterate_save_peers(), iterate_save_session(), iterate_search_session(), iterate_send_room_message(), iterate_store_members_it(), iterate_sync_member_contacts(), iterate_sync_session_contact(), iterate_zones(), iterator_bf_create(), iterator_bf_create(), iterator_bf_reduce(), iterator_bf_reduce(), jwt_parse_attributes(), link_room_message(), log_namespaces(), log_nodes(), lookup_queue_it(), main(), make_nv(), migrate_and_drop_keywords(), migrate_and_drop_metadata(), move_to_pending(), move_to_queue(), mpi_to_sexp(), neighbour_delete(), nibble_to_regex(), notify_client_about_session(), notify_client_connect_info(), notify_client_queues(), notify_tunnel_up_cb(), num_to_regex(), op_get_element_iterator(), op_get_element_iterator(), open_port_cb(), parse_record(), parse_record_data(), peermap_clear_iterator(), PEERSTORE_create_record_mq_envelope(), peerstore_sqlite_store_record(), pending_reversals_delete_it(), pending_reversals_delete_it(), prepare_ibf_iterator(), prepare_ibf_iterator(), print_option(), print_version(), printer(), printer_watch(), process(), process_client_result(), process_reply(), process_reply(), process_result_with_request(), process_stat(), process_stat_in(), process_stats(), process_update_node(), put_cb(), reachability_iterator(), read_service_conf(), regex_cancel_dht_get(), regex_free_result(), regex_result_iterator(), register_notify(), remove_all(), remove_by_unique_id(), remove_global_addresses(), remove_iterator(), remove_iterator(), remove_iterator(), reschedule_hellos(), reset_handles(), resume_communicators(), rsa_sign_mpi(), run_with_zone_pkey(), schedule_current_round(), search_result_free(), search_result_freeze_probes(), search_result_resume_probes(), search_result_stop(), search_result_suspend(), send_full_element_iterator(), send_full_element_iterator(), send_missing_full_elements_iter(), send_missing_full_elements_iter(), send_offers_iterator(), send_offers_iterator(), send_simple_cb(), send_simple_cb(), send_simple_cb(), set_absolute_time(), set_attributes_from_idtoken(), set_base32(), set_cont(), set_filename(), set_json(), set_one(), set_relative_time(), set_string(), set_timestamp(), set_timetravel_time(), set_uint(), set_uint16(), set_ulong(), set_value(), signal_result_resume(), socket_set_nodelay(), start_carriers(), start_subnets(), stats_iterator(), stop_peer_request(), store_and_free_entries(), store_and_free_entries(), store_peer_presistently_iterator(), stun_attr2str(), stun_msg2str(), test_exist_cb(), test_result_present(), tld_iter(), transmit_client_response(), transmit_client_response(), transmit_suggestion(), try_add_peers(), try_combine_recent(), update_config(), update_flood_times(), update_iterator(), update_sre_result_maps(), url_iterator(), valid_peer_iterator(), verify_store_peer(), write_item(), and zone_to_name().

◆ uri

char* uri
static

URI to import.

Definition at line 276 of file gnunet-namestore.c.

Referenced by main(), reset_handles(), and run_with_zone_pkey().

◆ reverse_pkey

char* reverse_pkey
static

Reverse lookup to perform.

Definition at line 281 of file gnunet-namestore.c.

Referenced by handle_reverse_lookup(), main(), reverse_error_cb(), and run_with_zone_pkey().

◆ typestring

char* typestring
static

Type of the record to add/remove, NULL to remove all.

Definition at line 286 of file gnunet-namestore.c.

Referenced by del_monitor(), display_record(), display_records_from_block(), main(), reset_handles(), and run_with_zone_pkey().

◆ expirationstring

char* expirationstring
static

Desired expiration time.

Definition at line 291 of file gnunet-namestore.c.

Referenced by main(), reset_handles(), and run_with_zone_pkey().

◆ nickstring

char* nickstring
static

Desired nick name.

Definition at line 296 of file gnunet-namestore.c.

Referenced by main(), and run_with_zone_pkey().

◆ ret

◆ type

uint32_t type
static

Type string converted to DNS type value.

Definition at line 306 of file gnunet-namestore.c.

Referenced by abd_number_to_typename(), abd_string_to_value(), abd_value_to_string(), add_record(), add_setter_action(), add_to_meta_counter(), attr_collect(), auto_config_cb(), basic_number_to_typename(), basic_string_to_value(), basic_value_to_string(), block_plugin_dht_check_block(), block_plugin_dht_check_query(), block_plugin_dht_check_reply(), block_plugin_dht_create_group(), block_plugin_dht_get_key(), block_plugin_dns_check_block(), block_plugin_dns_check_query(), block_plugin_dns_check_reply(), block_plugin_dns_create_group(), block_plugin_dns_get_key(), block_plugin_fs_check_block(), block_plugin_fs_check_query(), block_plugin_fs_check_reply(), block_plugin_fs_create_group(), block_plugin_fs_get_key(), block_plugin_gns_check_block(), block_plugin_gns_check_query(), block_plugin_gns_check_reply(), block_plugin_gns_create_group(), block_plugin_gns_get_key(), block_plugin_regex_check_block(), block_plugin_regex_check_query(), block_plugin_regex_check_reply(), block_plugin_regex_create_group(), block_plugin_regex_get_key(), block_plugin_revocation_check_block(), block_plugin_revocation_check_query(), block_plugin_revocation_check_reply(), block_plugin_revocation_get_key(), block_plugin_seti_test_check_block(), block_plugin_seti_test_check_query(), block_plugin_seti_test_check_reply(), block_plugin_seti_test_get_key(), block_plugin_setu_test_check_block(), block_plugin_setu_test_check_query(), block_plugin_setu_test_check_reply(), block_plugin_setu_test_get_key(), block_plugin_template_create_group(), block_plugin_test_check_block(), block_plugin_test_check_query(), block_plugin_test_check_reply(), block_plugin_test_create_group(), block_plugin_test_get_key(), block_proc(), cadet_reply_proc(), callback_operation(), change_service(), check_key_type(), check_p2p_put(), child_completed_callback(), child_completed_callback(), client_response_handler(), conversation_number_to_typename(), conversation_string_to_value(), conversation_value_to_string(), cred_collect(), display_record(), dns_number_to_typename(), dns_string_to_value(), dns_value_to_string(), ego_create(), execute_get(), expired_processor(), find_full_data(), find_plugin(), for_matching_monitors(), gather_uri_data(), GDS_CLIENTS_process_get(), GDS_DATACACHE_get_closest(), GDS_DATACACHE_handle_get(), GDS_NEIGHBOURS_handle_get(), GDS_ROUTING_add(), get_app(), get_audiobin(), get_callback(), get_cb(), get_coder(), get_existing_record(), get_resp_callback(), get_result_iterator(), get_type(), get_typed(), getopt_set_metadata(), gns_is_critical(), gns_number_to_typename(), gns_string_to_value(), gns_value_to_string(), GNUNET_BLOCK_check_block(), GNUNET_BLOCK_check_query(), GNUNET_BLOCK_check_reply(), GNUNET_BLOCK_get_key(), GNUNET_BLOCK_GROUP_bf_create(), GNUNET_BLOCK_group_create(), GNUNET_CADET_drop_message(), GNUNET_CRYPTO_blinded_key_signature_get_length_by_type(), GNUNET_DATACACHE_get(), GNUNET_DATACACHE_get_closest(), GNUNET_DATASTORE_get_key(), GNUNET_DATASTORE_get_zero_anonymity(), GNUNET_DATASTORE_put(), GNUNET_DHT_get_start(), GNUNET_DHT_monitor_start(), GNUNET_DHT_put(), GNUNET_FS_meta_data_delete(), GNUNET_FS_meta_data_get_by_type(), GNUNET_FS_meta_data_get_first_by_types(), GNUNET_FS_meta_data_insert(), GNUNET_GNS_lookup(), GNUNET_GNS_lookup_limited(), GNUNET_GNS_lookup_with_tld(), GNUNET_GNSRECORD_data_from_identity(), GNUNET_GNSRECORD_identity_from_data(), GNUNET_GNSRECORD_is_critical(), GNUNET_GNSRECORD_is_zonekey_type(), GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_value_to_string(), GNUNET_MQ_msg_(), GNUNET_MQ_msg_nested_mh_(), GNUNET_MQ_preference_to_string(), GNUNET_NETWORK_socket_create(), GNUNET_NT_scanner_get_type(), GNUNET_OS_process_status(), GNUNET_OS_process_wait_status(), GNUNET_PQ_exec_sql(), GNUNET_RECLAIM_attribute_list_add(), GNUNET_RECLAIM_attribute_new(), GNUNET_RECLAIM_attribute_number_to_typename(), GNUNET_RECLAIM_attribute_string_to_value(), GNUNET_RECLAIM_attribute_value_to_string(), GNUNET_RECLAIM_credential_new(), GNUNET_RECLAIM_credential_number_to_typename(), GNUNET_RECLAIM_credential_string_to_value(), GNUNET_RECLAIM_credential_value_to_string(), GNUNET_RECLAIM_presentation_new(), GNUNET_RECLAIM_presentation_number_to_typename(), GNUNET_RECLAIM_presentation_string_to_value(), GNUNET_RECLAIM_presentation_value_to_string(), GSF_cadet_query(), GSF_pending_request_create_(), handle_auto_result(), handle_client_accept(), handle_client_start_search(), handle_datastore_reply(), handle_dht_p2p_get(), handle_dht_reply(), handle_dht_response(), handle_get_zero_anonymity(), handle_local_data(), handle_p2p_put(), handle_p2p_reply(), handle_reply(), handle_result(), heap_plugin_get(), heap_plugin_get_closest(), heap_plugin_get_key(), heap_plugin_get_zero_anonymity(), heap_plugin_put(), initialize_network_handle(), insert_pending_message(), item_printer(), item_printer(), iter_finished(), jwt_number_to_typename(), jwt_string_to_value(), jwt_value_to_string(), main(), maint_child_death(), maint_child_death(), maint_child_death(), match_full_data(), merge_helper(), messenger_number_to_typename(), messenger_string_to_value(), messenger_value_to_string(), meta_printer(), number_to_typename(), pabc_number_to_typename(), pabc_string_to_value(), pabc_value_to_string(), pack(), parse(), parse_attr(), parse_credential(), postgres_plugin_get(), postgres_plugin_get_closest(), postgres_plugin_get_key(), postgres_plugin_get_zero_anonymity(), postgres_plugin_put(), process_client_result(), process_dht_put_content(), process_kblock_for_unindex(), process_local_reply(), process_migration_content(), process_status(), put_callback(), queue_send_msg(), quota_processor(), refresh_bloomfilter(), repl_proc(), repl_proc(), resolve_and_cache(), run_with_zone_pkey(), send_message(), sqlite_plugin_get(), sqlite_plugin_get_closest(), sqlite_plugin_get_key(), sqlite_plugin_get_zero_anonymity(), sqlite_plugin_put(), start_operation(), string_to_value(), stun_get_mapped(), submit_request(), transmit_item(), try_handle_plaintext(), try_handle_plaintext(), try_handle_plaintext(), try_transmission(), type_match(), unindex_process(), union_accept(), use_store_operation(), value_to_string(), and work_test().

◆ data

void* data
static

◆ data_size

size_t data_size
static

Number of bytes in data.

Definition at line 316 of file gnunet-namestore.c.

Referenced by abd_string_to_value(), abd_value_to_string(), add_dns_result(), add_host(), basic_string_to_value(), basic_value_to_string(), buffer_append(), buffer_init(), cadet_reply_proc(), check_pkey(), consistency_iter(), consume_ticket(), conversation_string_to_value(), conversation_value_to_string(), count_and_separate_strings(), create_string_array(), del_monitor(), display_record(), display_records_from_block(), dns_string_to_value(), dns_value_to_string(), dv_hmac(), filter_tickets_cb(), forward_resolution(), GDS_CLIENTS_handle_reply(), GDS_helper_sign_path(), GDS_NEIGHBOURS_handle_reply(), get_existing_record(), get_records_and_call_iterator(), gns_string_to_value(), gns_value_to_string(), GNUNET_ABD_delegate_deserialize(), GNUNET_CONFIGURATION_get_data(), GNUNET_DHT_verify_path(), GNUNET_DNSPARSER_bin_to_hex(), GNUNET_DNSPARSER_hex_to_bin(), GNUNET_FS_meta_data_delete(), GNUNET_FS_meta_data_insert(), GNUNET_GNSRECORD_data_from_identity(), GNUNET_GNSRECORD_identity_from_data(), GNUNET_GNSRECORD_JSON_from_gnsrecord(), GNUNET_GNSRECORD_records_deserialize(), GNUNET_GNSRECORD_records_get_size(), GNUNET_GNSRECORD_records_serialize(), GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_value_to_string(), GNUNET_NAT_stun_handle_packet(), GNUNET_RECLAIM_attribute_deserialize(), GNUNET_RECLAIM_attribute_list_add(), GNUNET_RECLAIM_attribute_list_deserialize(), GNUNET_RECLAIM_attribute_new(), GNUNET_RECLAIM_attribute_serialize(), GNUNET_RECLAIM_attribute_serialize_get_size(), GNUNET_RECLAIM_attribute_string_to_value(), GNUNET_RECLAIM_attribute_value_to_string(), GNUNET_RECLAIM_credential_deserialize(), GNUNET_RECLAIM_credential_list_deserialize(), GNUNET_RECLAIM_credential_new(), GNUNET_RECLAIM_credential_serialize(), GNUNET_RECLAIM_credential_serialize_get_size(), GNUNET_RECLAIM_credential_string_to_value(), GNUNET_RECLAIM_credential_value_to_string(), GNUNET_RECLAIM_presentation_deserialize(), GNUNET_RECLAIM_presentation_list_deserialize(), GNUNET_RECLAIM_presentation_new(), GNUNET_RECLAIM_presentation_serialize(), GNUNET_RECLAIM_presentation_serialize_get_size(), GNUNET_RECLAIM_presentation_string_to_value(), GNUNET_RECLAIM_presentation_value_to_string(), handle_delegate_collection_cb(), handle_gns2dns_result(), handle_gns_resolution_result(), handle_gns_response(), issue_ticket(), item_printer(), item_printer(), iter_finished(), jwt_get_expiration(), jwt_get_issuer(), jwt_parse_attributes(), jwt_string_to_value(), jwt_value_to_string(), lookup_authz_cb(), lookup_nick_it(), lookup_redirect_uri_result(), merge_helper(), merge_with_nick_records(), messenger_string_to_value(), messenger_value_to_string(), missing_zone_creation_cont(), namestore_flat_store_records(), namestore_postgres_store_records(), namestore_sqlite_store_records(), pabc_string_to_value(), pabc_value_to_string(), parse(), parse_attr(), parse_credential(), parse_result_call_iterator(), play(), process_command_stdin(), process_lookup_result(), process_parallel_lookup_result(), read_stdio(), record(), recursive_gns2dns_resolution(), reply_to_dns(), result_processor(), run_with_zone_pkey(), rvk_move_attr_cb(), sqlite_plugin_del(), store_and_free_entries(), string_to_value(), transmit_call_audio(), transmit_phone_audio(), update_tickets(), and value_to_string().

◆ etime

uint64_t etime
static

Expiration string converted to numeric value.

Definition at line 321 of file gnunet-namestore.c.

Referenced by generate_gns_certificate(), get_existing_record(), run(), and run_with_zone_pkey().

◆ etime_is_rel

int etime_is_rel = GNUNET_SYSERR
static

Is expiration time relative or absolute time?

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

Referenced by get_existing_record(), and run_with_zone_pkey().

◆ zm

◆ monitor

int monitor
static

Enables monitor mode.

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

Referenced by main(), and run_with_zone_pkey().

◆ recordset

struct RecordSetEntry* recordset
static

Entry in record set for processing records in bulk.

Definition at line 341 of file gnunet-namestore.c.

Referenced by clear_recordset(), parse_recordline(), process_command_stdin(), and run_with_zone_pkey().

◆ purge_task

struct GNUNET_SCHEDULER_Task* purge_task
static

Purge task.

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

Referenced by marked_deleted(), purge_next_record(), reset_handles(), and zone_iteration_finished().

◆ ri_count

unsigned int ri_count = 0
static

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

Referenced by batch_insert_recordinfo(), and process_command_stdin().

◆ record_info

◆ record_info_capacity

unsigned int record_info_capacity = 0
static

Maximum capacity of record_info array.

Definition at line 356 of file gnunet-namestore.c.

Referenced by process_command_stdin().

◆ max_batch_size

unsigned int max_batch_size = 1000
static

Definition at line 359 of file gnunet-namestore.c.

Referenced by main(), and process_command_stdin().

◆ ri_sent

unsigned int ri_sent = 0
static

Definition at line 661 of file gnunet-namestore.c.

Referenced by batch_insert_recordinfo(), and process_command_stdin().