GNUnet 0.25.0
 
Loading...
Searching...
No Matches
gnunet-namestore-zonefile.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2012, 2013, 2014, 2019, 2022 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
26#include "platform.h"
27#include <gnunet_util_lib.h>
29
30#if HAVE_LIBIDN2
31#if HAVE_IDN2_H
32#include <idn2.h>
33#elif HAVE_IDN2_IDN2_H
34#include <idn2/idn2.h>
35#endif
36#elif HAVE_LIBIDN
37#if HAVE_IDNA_H
38#include <idna.h>
39#elif HAVE_IDN_IDNA_H
40#include <idn/idna.h>
41#endif
42#endif
43
44#define MAX_RECORDS_PER_NAME 50
45
49#define MAX_ZONEFILE_LINE_LEN 4096
50
54#define MAX_ZONEFILE_RECORD_DATA_LEN 2048
55
59#define THRESH 100
60
65#define TIME_THRESH 10
66
70#define SERIES_DELAY \
71 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 10)
72
76struct Zone
77{
81 struct Zone *next;
82
86 struct Zone *prev;
87
91 char *domain;
92
97};
98
103{
104 // DLL
106
107 // DLL
109
110 // Operation
112
113 // NS Operation
115
116 // Request
117 struct Job *job;
118
119 // Name
120 char *name;
121};
122
128struct Job
129{
134
138 struct Job *next;
139
143 struct Job *prev;
144
150
156
161
166
170 const struct Zone *zone;
171
178
186
187 // Records to store in job
189
190 // Number of records to store in job
191 uint32_t rd_count;
192};
193
199
203static struct Job *req_head;
204
208static struct Job *req_tail;
209
210
214static struct Zone *zone_head;
215
219static struct Zone *zone_tail;
220
221
227
232
237
241static unsigned int rd_count = 0;
242
246static int ret = 0;
247
251static char *ego_name = NULL;
252
256static char *res;
257
261static unsigned int published_sets = 0;
262
266static unsigned int published_records = 0;
267
268
272static struct Zone *current_zone;
273
278
283
288
293
297static const struct GNUNET_CONFIGURATION_Handle *cfg;
298
303
307static unsigned int pending;
308
312static unsigned int pending_rs;
313
314
318static int state;
319
324
326{
327
328 /* Uninitialized */
330
331 /* The initial state */
333
334 /* The $ORIGIN has changed */
336
337 /* The record name/label has changed */
339
341
342
348static void
349do_shutdown (void *cls)
350{
351 (void) cls;
352 if (NULL != ego_name)
354 if (NULL != ns_qe)
356 if (NULL != id_op)
358 if (NULL != ns)
360 if (NULL != id)
362 for (int i = 0; i < rd_count; i++)
363 {
364 void *rd_ptr = (void*) rd[i].data;
365 GNUNET_free (rd_ptr);
366 }
367 if (NULL != t)
369}
370
371
372static void
373parse (void *cls);
374
375static char*
376trim (char *line)
377{
378 char *ltrimmed = line;
379 int ltrimmed_len;
380 int quoted = 0;
381
382 // Trim all whitespace to the left
383 while (*ltrimmed == ' ')
384 ltrimmed++;
385 ltrimmed_len = strlen (ltrimmed);
386 // Find the first occurrence of an unqoted ';', which is our comment
387 for (int i = 0; i < ltrimmed_len; i++)
388 {
389 if (ltrimmed[i] == '"')
390 quoted = ! quoted;
391 if ((ltrimmed[i] != ';') || quoted)
392 continue;
393 ltrimmed[i] = '\0';
394 }
395 ltrimmed_len = strlen (ltrimmed);
396 // Remove trailing whitespace
397 for (int i = ltrimmed_len; i > 0; i--)
398 {
399 if (ltrimmed[i - 1] != ' ')
400 break;
401 ltrimmed[i - 1] = '\0';
402 }
403 ltrimmed_len = strlen (ltrimmed);
404 if (ltrimmed[ltrimmed_len - 1] == '\n')
405 ltrimmed[ltrimmed_len - 1] = ' ';
406 return ltrimmed;
407}
408
409
410static char*
411next_token (char *token)
412{
413 char *next = token;
414 while (*next == ' ')
415 next++;
416 return next;
417}
418
419
420static int
421parse_ttl (char *token, struct GNUNET_TIME_Relative *pttl)
422{
423 char *next;
424 unsigned int ttl_tmp;
425
426 next = strchr (token, ';');
427 if (NULL != next)
428 next[0] = '\0';
429 next = strchr (token, ' ');
430 if (NULL != next)
431 next[0] = '\0';
432 if (1 != sscanf (token, "%u", &ttl_tmp))
433 {
434 fprintf (stderr, "Unable to parse TTL `%s'\n", token);
435 return GNUNET_SYSERR;
436 }
437 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TTL is: %u\n", ttl_tmp);
438 pttl->rel_value_us = ttl_tmp * 1000 * 1000;
439 return GNUNET_OK;
440}
441
442
443static int
444parse_origin (char *token, char *porigin)
445{
446 char *next;
447 next = strchr (token, ';');
448 if (NULL != next)
449 next[0] = '\0';
450 next = strchr (token, ' ');
451 if (NULL != next)
452 next[0] = '\0';
453 strcpy (porigin, token);
454 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Origin is: %s\n", porigin);
455 return GNUNET_OK;
456}
457
458
459static void
461 const struct GNUNET_CRYPTO_PrivateKey *pk,
462 enum GNUNET_ErrorCode ec)
463{
464 struct Zone *zone;
465 id_op = NULL;
466 if (GNUNET_EC_NONE != ec)
467 {
468 fprintf (stderr, "Error: %s\n", GNUNET_ErrorCode_get_hint (ec));
469 ret = 1;
471 return;
472 }
474 "Created missing ego `%s'\n",
475 ego_name);
476 zone = GNUNET_new (struct Zone);
477 zone->key = *pk;
478 zone->domain = GNUNET_strdup (ego_name);
480 // FIXME add delegation to parent zone
482 current_zone = zone;
484}
485
486
487static void
489{
490 struct Zone *zone;
491 for (zone = zone_head; NULL != zone; zone = zone->next)
492 if (0 == strcmp (zone->domain, ego_name))
493 break;
494 if (NULL == zone)
495 {
497 "$ORIGIN %s does not exist, creating...\n", ego_name);
499 GNUNET_PUBLIC_KEY_TYPE_EDDSA, // FIXME make configurable
501 NULL);
502 return;
503 }
505 current_zone = zone;
507}
508
509
510static void
512{
513 ns_qe = NULL;
514 if (GNUNET_EC_NONE != ec)
515 {
516 fprintf (stderr,
517 _ ("Failed to store records...\n"));
519 ret = -1;
520 }
522 {
523 if (NULL != ego_name)
526 if (ego_name[strlen (ego_name) - 1] == '.')
527 ego_name[strlen (ego_name) - 1] = '\0';
529 "Changing origin to %s\n", ego_name);
531 return;
532 }
534}
535
536
542static void
543process_queue (void *cls)
544{
545 struct Job *job;
546
547 (void) cls;
548 t = NULL;
549 while (pending + pending_rs < THRESH)
550 {
552 if (NULL == job)
553 break;
554 if (NULL != job->qe)
555 return; /* namestore op still pending */
557 break;
559 job->hn = NULL;
562 "Requesting store for `%s'\n",
563 job->label);
564 job->op_start_time = GNUNET_TIME_absolute_get ();
566 &job->zone->key,
567 job->label,
568 job->rd_count,
569 job->rd,
571 job);
572 GNUNET_assert (NULL != job->qe);
573 pending++;
574 }
575 if (pending + pending_rs >= THRESH)
576 {
578 "Stopped processing queue (%u+%u/%u)]\n",
579 pending,
581 THRESH);
582 return; /* wait for replies */
583 }
585 if (NULL == job)
586 {
588 "Stopped processing queue: empty queue\n");
589 return;
590 }
591 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Throttling\n");
592 if (NULL != t)
596}
597
598
604static void
606{
607 job->hn =
608 GNUNET_CONTAINER_heap_insert (req_heap, job, job->expires.abs_value_us);
609}
610
611
617static void
618queue (const char *label,
619 uint32_t rd_count,
621 const struct Zone *zone)
622{
623 struct Job *job;
624 struct GNUNET_HashContext *hctx;
625 struct GNUNET_HashCode hc;
626 size_t hlen;
627
628 hlen = strlen (label) + 1;
629 job = GNUNET_new (struct Job);
630 job->rd = rd;
631 job->rd_count = rd_count;
632 GNUNET_assert (NULL != zone);
633 job->zone = zone;
634 GNUNET_memcpy (job->label, label, hlen);
636 GNUNET_CRYPTO_hash_context_read (hctx, job->label, hlen);
637 GNUNET_CRYPTO_hash_context_read (hctx, job->zone, sizeof *zone);
640}
641
642
659static void
660parse (void *cls)
661{
662 char buf[MAX_ZONEFILE_LINE_LEN];
664 char *next;
665 char *token;
666 char *payload_pos;
667 static char lastname[GNUNET_DNSPARSER_MAX_LABEL_LENGTH];
669 void *data;
670 size_t data_size;
671 int ttl_line = 0;
672 int type;
673 int bracket_unclosed = 0;
674 int quoted = 0;
675 int ln = 0;
676
677 t = NULL;
678 /* use filename provided as 1st argument (stdin by default) */
679 while ((res = fgets (buf, sizeof(buf), stdin))) /* read each line of input */
680 {
681 ln++;
682 ttl_line = 0;
683 token = trim (buf);
685 "Trimmed line (bracket %s): `%s'\n",
686 (bracket_unclosed > 0) ? "unclosed" : "closed",
687 token);
688 if ((0 == strlen (token)) ||
689 ((1 == strlen (token)) && (' ' == *token)))
690 continue; // I guess we can safely ignore blank lines
691 if (bracket_unclosed == 0)
692 {
693 /* Payload is already parsed */
694 payload_pos = payload;
695 /* Find space */
696 next = strchr (token, ' ');
697 if (NULL == next)
698 {
699 fprintf (stderr, "Error at line %u: %s\n", ln, token);
700 ret = 1;
702 return;
703 }
704 next[0] = '\0';
705 next++;
706 if (0 == (strcmp (token, "$ORIGIN")))
707 {
709 token = next_token (next);
710 }
711 else if (0 == (strcmp (token, "$TTL")))
712 {
713 ttl_line = 1;
714 token = next_token (next);
715 }
716 else
717 {
718 if (0 == strcmp (token, "IN")) // Inherit name from before
719 {
721 "Old name: %s\n", lastname);
722 strcpy (newname, lastname);
723 token[strlen (token)] = ' ';
724 }
725 else if (token[strlen (token) - 1] != '.') // no fqdn
726 {
727 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New name: %s\n", token);
728 if (GNUNET_DNSPARSER_MAX_LABEL_LENGTH < strlen (token))
729 {
730 fprintf (stderr,
731 _ ("Name `%s' is too long\n"),
732 token);
733 ret = 1;
735 return;
736 }
737 strcpy (newname, token);
738 token = next_token (next);
739 }
740 else if (0 == strcmp (token, origin))
741 {
742 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New name: @\n");
743 strcpy (newname, "@");
744 token = next_token (next);
745 }
746 else
747 {
748 if (strlen (token) < strlen (origin))
749 {
750 fprintf (stderr, "Wrong origin: %s (expected %s)\n", token, origin);
751 break; // FIXME error?
752 }
753 if (0 != strcmp (token + (strlen (token) - strlen (origin)), origin))
754 {
755 fprintf (stderr, "Wrong origin: %s (expected %s)\n", token, origin);
756 break;
757 }
758 token[strlen (token) - strlen (origin) - 1] = '\0';
759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New name: %s\n", token);
760 if (GNUNET_DNSPARSER_MAX_LABEL_LENGTH < strlen (token))
761 {
762 fprintf (stderr,
763 _ ("Name `%s' is too long\n"),
764 token);
765 ret = 1;
767 return;
768 }
769 strcpy (newname, token);
770 token = next_token (next);
771 }
772 if (0 != strcmp (newname, lastname) &&
773 (0 < rd_count))
774 {
776 "Name changed %s->%s, storing record set of %u elements\n",
777 lastname, newname,
778 rd_count);
780 }
781 else
782 {
783 strcpy (lastname, newname);
784 }
785 }
786
787 if (ttl_line)
788 {
789 if (GNUNET_SYSERR == parse_ttl (token, &ttl))
790 {
791 fprintf (stderr, _ ("Failed to parse $TTL\n"));
792 ret = 1;
794 return;
795 }
796 continue;
797 }
799 {
800 if (GNUNET_SYSERR == parse_origin (token, origin))
801 {
802 fprintf (stderr, _ ("Failed to parse $ORIGIN from %s\n"), token);
803 ret = 1;
805 return;
806 }
807 break;
808 }
809 if (ZS_READY == state)
810 {
811 fprintf (stderr,
812 _ (
813 "You must provide $ORIGIN in your zonefile or via arguments (--zone)!\n"));
814 ret = 1;
816 return;
817 }
818 // This is a record, let's go
820 {
821 fprintf (stderr,
822 _ ("Only %u records per unique name supported.\n"),
824 ret = 1;
826 return;
827 }
830 next = strchr (token, ' ');
831 if (NULL == next)
832 {
833 fprintf (stderr, "Error, last token: %s\n", token);
834 ret = 1;
836 break;
837 }
838 next[0] = '\0';
839 next++;
840 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "class is: %s\n", token);
841 while (*next == ' ')
842 next++;
843 token = next;
844 next = strchr (token, ' ');
845 if (NULL == next)
846 {
847 fprintf (stderr, "Error\n");
848 break;
849 }
850 next[0] = '\0';
851 next++;
852 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "type is: %s\n", token);
855 while (*next == ' ')
856 next++;
857 token = next;
858 }
859 for (int i = 0; i < strlen (token); i++)
860 {
861 if (token[i] == '"')
862 quoted = ! quoted;
863 if ((token[i] == '(') && ! quoted)
864 bracket_unclosed++;
865 if ((token[i] == ')') && ! quoted)
866 bracket_unclosed--;
867 }
868 GNUNET_assert (strlen (token) < sizeof payload - (payload_pos - payload));
869 memcpy (payload_pos, token, strlen (token));
870 payload_pos += strlen (token);
871 if (bracket_unclosed > 0)
872 {
873 *payload_pos = ' ';
874 payload_pos++;
875 continue;
876 }
877 *payload_pos = '\0';
878 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "data is: %s\n\n", payload);
879 if (GNUNET_OK !=
881 &data,
882 &data_size))
883 {
884 fprintf (stderr,
885 _ ("Data `%s' invalid\n"),
886 payload);
887 ret = 1;
889 return;
890 }
891 rd[rd_count].data = data;
893 if (ZS_NAME_CHANGED == state)
894 break;
895 rd_count++;
896 }
897 if (rd_count > 0)
898 {
899 // We need to encode the lastname from punycode potentially.
900 // FIXME we want to probably queue this request here.
901 char *lastname_utf8;
902 idna_to_unicode_8z8z (lastname,
903 &lastname_utf8,
904 IDNA_ALLOW_UNASSIGNED);
906 "Queueing %d records\n",
907 rd_count);
908 queue (lastname_utf8,
909 rd_count,
910 rd,
914 for (int i = 0; i < rd_count; i++)
915 {
916 data = (void*) rd[i].data;
918 }
919 if (ZS_NAME_CHANGED == state)
920 {
921 rd[0] = rd[rd_count]; // recover last rd parsed.
922 rd_count = 1;
923 strcpy (lastname, newname);
925 }
926 else
927 rd_count = 0;
929 {
930 if (NULL != ego_name)
933 if (ego_name[strlen (ego_name) - 1] == '.')
934 ego_name[strlen (ego_name) - 1] = '\0';
936 "Changing origin to %s\n", ego_name);
938 return;
939 }
940 if (NULL != t)
943 return;
944 }
946 {
947 if (NULL != ego_name)
950 if (ego_name[strlen (ego_name) - 1] == '.')
951 ego_name[strlen (ego_name) - 1] = '\0';
953 "Changing origin to %s\n", ego_name);
955 return;
956 }
959 printf ("Published %u records sets with total %u records\n",
962}
963
964
965static void
966identity_cb (void *cls,
967 struct GNUNET_IDENTITY_Ego *ego,
968 void **ctx,
969 const char *name)
970{
971 (void) cls;
972 (void) ctx;
973 static int initial_iteration = GNUNET_YES;
974 static int ego_zone_found = GNUNET_NO;
975
976 if (GNUNET_NO == initial_iteration)
977 return;
978 if (NULL == ego)
979 {
980 if (NULL == zone_head)
981 {
982 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No zones found\n");
983 ret = 1;
985 return;
986 }
987 if ((NULL != ego_name) &&
988 (GNUNET_NO == ego_zone_found))
989 {
991 "Zone `%s' not found\n",
992 ego_name);
993 ret = 2;
995 }
996 initial_iteration = GNUNET_NO;
998 return;
999 }
1000 if (NULL != name)
1001 {
1002 struct Zone *zone;
1003
1004 zone = GNUNET_new (struct Zone);
1006 zone->domain = GNUNET_strdup (name);
1008
1009 if ((NULL != ego_name) &&
1010 (0 == strcmp (name,
1011 ego_name)))
1012 {
1013 ego_zone_found = GNUNET_YES;
1014 sprintf (origin, "%s.", ego_name);
1016 }
1017 }
1018}
1019
1020
1021static void
1022run (void *cls,
1023 char *const *args,
1024 const char *cfgfile,
1025 const struct GNUNET_CONFIGURATION_Handle *_cfg)
1026{
1027 cfg = _cfg;
1031 if (NULL == ns)
1032 {
1033 fprintf (stderr,
1034 _ ("Failed to connect to NAMESTORE\n"));
1035 return;
1036 }
1038 if (NULL == id)
1039 {
1040 fprintf (stderr,
1041 _ ("Failed to connect to IDENTITY\n"));
1042 return;
1043 }
1044 state = ZS_READY;
1045}
1046
1047
1055int
1056main (int argc, char *const *argv)
1057{
1060 "zone",
1061 "EGO",
1062 gettext_noop (
1063 "name of the ego controlling the zone"),
1064 &ego_name),
1066 };
1067 int lret;
1068
1069 GNUNET_log_setup ("gnunet-namestore-dbtool", "WARNING", NULL);
1070 if (GNUNET_OK !=
1072 argc,
1073 argv,
1074 "gnunet-namestore-zonefile",
1075 _ (
1076 "GNUnet namestore database manipulation tool"),
1077 options,
1078 &run,
1079 NULL)))
1080 {
1081 return lret;
1082 }
1083 return ret;
1084}
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
static int do_shutdown
Set to GNUNET_YES if we are shutting down.
static struct GNUNET_SCHEDULER_Task * job
Task for main job.
static char * line
Desired phone line (string to be converted to a hash).
static char * data
The data to insert into the dht.
static struct GNUNET_FS_Handle * ctx
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static char * name
Name (label) of the records to list.
static struct GNUNET_NAMESTORE_QueueEntry * ns_qe
Queue entry for the 'add' operation.
#define THRESH
Maximum number of queries pending at the same time.
static struct GNUNET_IDENTITY_Operation * id_op
Origin create operations.
static void insert_sorted(struct Job *job)
Insert req into DLL sorted by next fetch time.
static struct Job * req_tail
Active requests are kept in a DLL.
static struct Zone * zone_tail
Tail of list of zones we are managing.
static struct GNUNET_CONTAINER_Heap * req_heap
Heap of all requests to perform, sorted by the time we should next do the request (i....
static void process_queue(void *cls)
Process as many requests as possible from the queue.
static void parse(void *cls)
Main function that will be run.
static unsigned int published_records
Statistics, how many records published in aggregate.
static unsigned int pending
The number of DNS queries that are outstanding.
static void queue(const char *label, uint32_t rd_count, struct GNUNET_GNSRECORD_Data *rd, const struct Zone *zone)
Add hostname to the list of requests to be made.
static void origin_create_cb(void *cls, const struct GNUNET_CRYPTO_PrivateKey *pk, enum GNUNET_ErrorCode ec)
static const struct GNUNET_CONFIGURATION_Handle * cfg
Current configurataion.
static struct GNUNET_TIME_Relative ttl
Current record $TTL to use.
#define MAX_RECORDS_PER_NAME
static struct GNUNET_TIME_Absolute sleep_time_reg_proc
Last time we worked before going idle.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static struct Zone * zone_head
Head of list of zones we are managing.
static int ret
Return code.
static char * ego_name
Name of the ego.
#define MAX_ZONEFILE_LINE_LEN
Maximum length of a zonefile line.
static char origin[GNUNET_DNSPARSER_MAX_NAME_LENGTH]
Current origin.
#define MAX_ZONEFILE_RECORD_DATA_LEN
FIXME: Soft limit this?
static int state
The current state of the parser.
static void add_continuation(void *cls, enum GNUNET_ErrorCode ec)
static unsigned int rd_count
Number of records for currently parsed set.
static int parse_origin(char *token, char *porigin)
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *_cfg)
static struct GNUNET_NAMESTORE_Handle * ns
Handle to the namestore.
static struct Job * req_head
Active requests are kept in a DLL.
static char * res
Currently read line or NULL on EOF.
static struct Zone * current_zone
Private key for the our zone.
static struct GNUNET_IDENTITY_Handle * id
Handle to IDENTITY.
static unsigned int pending_rs
The number of NAMESTORE record store operations that are outstanding.
static char * trim(char *line)
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
static void ensure_ego_and_continue(const char *ego_name)
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static int parse_ttl(char *token, struct GNUNET_TIME_Relative *pttl)
static char * next_token(char *token)
#define SERIES_DELAY
How long do we wait at least between series of requests?
static unsigned int published_sets
Statistics, how many published record sets.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static unsigned long long payload
How much data are we currently storing in the database?
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).
Plugin API for the namestore database backend.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_DNSPARSER_MAX_LABEL_LENGTH
Maximum length of a label in DNS.
#define GNUNET_DNSPARSER_MAX_NAME_LENGTH
Maximum length of a name in DNS.
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
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.
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
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
void * GNUNET_CONTAINER_heap_peek(const struct GNUNET_CONTAINER_Heap *heap)
Get element stored at the root of heap.
void * GNUNET_CONTAINER_heap_remove_root(struct GNUNET_CONTAINER_Heap *heap)
Remove root of the heap.
struct GNUNET_CONTAINER_HeapNode * GNUNET_CONTAINER_heap_insert(struct GNUNET_CONTAINER_Heap *heap, void *element, GNUNET_CONTAINER_HeapCostType cost)
Inserts a new element into the heap.
struct GNUNET_CONTAINER_Heap * GNUNET_CONTAINER_heap_create(enum GNUNET_CONTAINER_HeapOrder order)
Create a new heap.
@ GNUNET_CONTAINER_HEAP_ORDER_MIN
Heap with the minimum cost at the root.
struct GNUNET_IDENTITY_Operation * GNUNET_IDENTITY_create(struct GNUNET_IDENTITY_Handle *id, const char *name, const struct GNUNET_CRYPTO_PrivateKey *privkey, enum GNUNET_CRYPTO_KeyType ktype, GNUNET_IDENTITY_CreateContinuation cont, void *cont_cls)
Create a new ego with the given name.
const struct GNUNET_CRYPTO_PrivateKey * GNUNET_IDENTITY_ego_get_private_key(const struct GNUNET_IDENTITY_Ego *ego)
Obtain the ECC key associated with a 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_cancel(struct GNUNET_IDENTITY_Operation *op)
Cancel an identity operation.
void GNUNET_IDENTITY_disconnect(struct GNUNET_IDENTITY_Handle *h)
Disconnect from identity service.
#define GNUNET_log(kind,...)
void GNUNET_CRYPTO_hash_context_read(struct GNUNET_HashContext *hc, const void *buf, size_t size)
Add data to be hashed.
void GNUNET_CRYPTO_hash_context_finish(struct GNUNET_HashContext *hc, struct GNUNET_HashCode *r_hash)
Finish the hash computation.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
struct GNUNET_HashContext * GNUNET_CRYPTO_hash_context_start(void)
Start incremental hashing operation.
@ GNUNET_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_NAMESTORE_QueueEntry * GNUNET_NAMESTORE_record_set_store(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *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.
void GNUNET_NAMESTORE_disconnect(struct GNUNET_NAMESTORE_Handle *h)
Disconnect from the namestore service (and free associated resources).
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_NAMESTORE_Handle * GNUNET_NAMESTORE_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the namestore service.
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
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition scheduler.c:1277
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
Definition time.c:406
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
#define _(String)
GNU gettext support macro.
Definition platform.h:179
Handle to a node in a heap.
A private key for an identity 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.
A 512-bit hashcode.
Handle for an ego.
Definition identity.h:37
Handle for the service.
Handle for an operation with the identity service.
Connection to the NAMESTORE service.
An QueueEntry used to store information for a pending NAMESTORE record operation.
Entry in list of pending tasks.
Definition scheduler.c:136
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Request we should make.
struct Job * next
Active requests are kept in a DLL.
struct GNUNET_GNSRECORD_Data * rd
struct GNUNET_TIME_Absolute op_start_time
While we are fetching the record, the value is set to the starting time of the DNS operation.
struct Record * rec_tail
Tail of records that should be published in GNS for this hostname.
struct Job * prev
Active requests are kept in a DLL.
const struct Zone * zone
Zone responsible for this request.
struct Record * rec_head
Head of records that should be published in GNS for this hostname.
struct GNUNET_NAMESTORE_QueueEntry * qe
Namestore operation pending for this record.
char label[GNUNET_DNSPARSER_MAX_NAME_LENGTH]
Hostname we are resolving.
struct GNUNET_TIME_Absolute expires
At what time does the (earliest) of the returned records for this name expire? At this point,...
struct GNUNET_CONTAINER_HeapNode * hn
Requests are kept in a heap while waiting to be resolved.
Missing identity creation context.
struct MissingZoneCreationCtx * prev
struct MissingZoneCreationCtx * next
struct GNUNET_IDENTITY_Operation * id_op
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
Record for the request to be stored by GNS.
Egos / Zones.
struct Zone * prev
Kept in a DLL.
struct GNUNET_CRYPTO_PrivateKey key
Private key of the zone.
struct Zone * next
Kept in a DLL.
char * domain
Domain of the zone (i.e.