GNUnet 0.25.0
 
Loading...
Searching...
No Matches
gnunet-zoneimport.c File Reference
Include dependency graph for gnunet-zoneimport.c:

Go to the source code of this file.

Data Structures

struct  Zone
 Egos / Zones. More...
 
struct  Record
 Record for the request to be stored by GNS. More...
 
struct  Request
 Request we should make. More...
 
struct  MissingZoneCreationCtx
 Missing identity creation context. More...
 
struct  GlueClosure
 Closure for check_for_glue. More...
 
struct  ProcessRecordContext
 Closure for process_record(). More...
 

Macros

#define THRESH   100
 Maximum number of queries pending at the same time.
 
#define TIME_THRESH   10
 TIME_THRESH is in usecs.
 
#define MAX_RETRIES   5
 How often do we retry a query before giving up for good?
 
#define MAX_SERIES   10
 How many DNS requests do we at most issue in rapid series?
 
#define SERIES_DELAY    GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 10)
 How long do we wait at least between series of requests?
 
#define NS_BATCH_SIZE   1024
 How many requests do we request from NAMESTORE in one batch during our initial iteration?
 

Typedefs

typedef void(* RecordProcessor) (void *cls, const struct GNUNET_DNSPARSER_Record *rec)
 Callback for for_all_records.
 

Functions

static void for_all_records (const struct GNUNET_DNSPARSER_Packet *p, RecordProcessor rp, void *rp_cls)
 Call rp for each record in p, regardless of what response section it is in.
 
static const char * get_label (struct Request *req)
 Return just the label of the hostname in req.
 
static char * get_label_utf8 (struct Request *req)
 
static void * build_dns_query (struct Request *req, size_t *raw_size)
 Build DNS query for hostname.
 
static void free_records (struct Request *req)
 Free records associated with req.
 
static void free_request (struct Request *req)
 Free req and data structures reachable from it.
 
static void process_queue (void *cls)
 Process as many requests as possible from the queue.
 
static void insert_sorted (struct Request *req)
 Insert req into DLL sorted by next fetch time.
 
static void add_record (struct Request *req, uint32_t type, struct GNUNET_TIME_Absolute expiration_time, const void *data, size_t data_len)
 Add record to the GNS record set for req.
 
static void check_for_glue (void *cls, const struct GNUNET_DNSPARSER_Record *rec)
 Try to find glue records for a given NS record.
 
static void process_record (void *cls, const struct GNUNET_DNSPARSER_Record *rec)
 We received rec for req.
 
static void store_completed_cb (void *cls, enum GNUNET_ErrorCode ec)
 
static void process_result (void *cls, const struct GNUNET_TUN_DnsHeader *dns, size_t dns_len)
 Function called with the result of a DNS resolution.
 
static int free_request_it (void *cls, const struct GNUNET_HashCode *key, void *value)
 Iterator called during do_shutdown() to free requests in the ns_pending map.
 
static void do_shutdown (void *cls)
 Clean up and terminate the process.
 
static void iterate_zones (void *cls)
 Iterate over all of the zones we care about and see which records we may need to re-fetch when.
 
static void ns_lookup_error_cb (void *cls)
 Function called if GNUNET_NAMESTORE_records_lookup() failed.
 
static void ns_lookup_result_cb (void *cls, const struct GNUNET_CRYPTO_PrivateKey *key, const char *label_utf8, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
 Process a record that was stored in the namestore.
 
static void delegation_store_cont (void *cls, enum GNUNET_ErrorCode ec)
 
static void missing_zone_creation_cont (void *cls, const struct GNUNET_CRYPTO_PrivateKey *sk, enum GNUNET_ErrorCode ec)
 
static void queue (const char *hostname)
 Add hostname to the list of requests to be made.
 
static int move_to_queue (void *cls, const struct GNUNET_HashCode *key, void *value)
 We have completed the initial iteration over the namestore's database.
 
static void process_stdin (void *cls)
 Begin processing hostnames from stdin.
 
static void identity_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
 Method called to inform about the egos of this peer.
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Process requests from the queue, then if the queue is not empty, try again.
 
int main (int argc, char *const *argv)
 Call with IP address of resolver to query.
 

Variables

static struct GNUNET_TIME_Relative minimum_expiration_time
 How long do DNS records have to last at least after being imported?
 
static struct MissingZoneCreationCtxmissing_zones_head
 
static struct MissingZoneCreationCtxmissing_zones_tail
 
static uint64_t stdin_lines_read
 
static unsigned int map_size = 1024
 Command-line argument specifying desired size of the hash map with all of our pending names.
 
static struct GNUNET_IDENTITY_Handleid
 Handle to the identity service.
 
static struct GNUNET_NAMESTORE_Handlens
 Namestore handle.
 
static struct GNUNET_STATISTICS_Handlestats
 Handle to the statistics service.
 
static struct GNUNET_DNSSTUB_Contextdns_ctx
 Context for DNS resolution.
 
static unsigned int pending
 The number of DNS queries that are outstanding.
 
static unsigned int pending_rs
 The number of NAMESTORE record store operations that are outstanding.
 
static unsigned int lookups
 Number of lookups we performed overall.
 
static unsigned int cached
 Number of records we had cached.
 
static unsigned int rejects
 How many hostnames did we reject (malformed).
 
static unsigned int failures
 Number of lookups that failed.
 
static unsigned int records
 Number of records we found.
 
static unsigned int record_sets
 Number of record sets given to namestore.
 
static struct GNUNET_CONTAINER_Heapreq_heap
 Heap of all requests to perform, sorted by the time we should next do the request (i.e.
 
static struct Requestreq_head
 Active requests are kept in a DLL.
 
static struct Requestreq_tail
 Active requests are kept in a DLL.
 
static struct GNUNET_SCHEDULER_Taskt
 Main task.
 
static struct GNUNET_CONTAINER_MultiHashMapns_pending
 Hash map of requests for which we may still get a response from the namestore.
 
static struct GNUNET_NAMESTORE_ZoneIteratorzone_it
 Current zone iteration handle.
 
static struct Zonezone_head
 Head of list of zones we are managing.
 
static struct Zonezone_tail
 Tail of list of zones we are managing.
 
static uint64_t ns_iterator_trigger_next
 After how many more results must ns_lookup_result_cb() ask the namestore for more?
 
static uint64_t total_dns_latency_cnt
 Number of DNS requests counted in latency total.
 
static struct GNUNET_TIME_Relative total_dns_latency
 Sum of DNS latencies observed.
 
static uint64_t total_reg_proc_dns
 Number of records processed (DNS lookup, no NAMESTORE) in total.
 
static uint64_t total_reg_proc_dns_ns
 Number of records processed (DNS lookup, with NAMESTORE) in total.
 
static struct GNUNET_TIME_Absolute start_time_reg_proc
 Start time of the regular processing.
 
static struct GNUNET_TIME_Absolute sleep_time_reg_proc
 Last time we worked before going idle.
 
static struct GNUNET_TIME_Relative idle_time
 Time we slept just waiting for work.
 

Macro Definition Documentation

◆ THRESH

#define THRESH   100

Maximum number of queries pending at the same time.

Definition at line 49 of file gnunet-zoneimport.c.

◆ TIME_THRESH

#define TIME_THRESH   10

TIME_THRESH is in usecs.

How quickly do we submit fresh queries. Used as an additional throttle.

Definition at line 55 of file gnunet-zoneimport.c.

◆ MAX_RETRIES

#define MAX_RETRIES   5

How often do we retry a query before giving up for good?

Definition at line 60 of file gnunet-zoneimport.c.

◆ MAX_SERIES

#define MAX_SERIES   10

How many DNS requests do we at most issue in rapid series?

Definition at line 65 of file gnunet-zoneimport.c.

◆ SERIES_DELAY

How long do we wait at least between series of requests?

Definition at line 70 of file gnunet-zoneimport.c.

90{
94 struct Zone *next;
95
99 struct Zone *prev;
100
104 char *domain;
105
110};
111
112
116struct Record
117{
121 struct Record *next;
122
126 struct Record *prev;
127
132};
133
134
140struct Request
141{
146
150 struct Request *next;
151
155 struct Request *prev;
156
161 struct Record *rec_head;
162
167 struct Record *rec_tail;
168
173
179 char *hostname;
180
185
189 const struct Zone *zone;
190
197
205
210 unsigned int issue_num;
211
215 uint16_t id;
216};
217
222{
223 // DLL
225
226 // DLL
228
229 // Operation
231
232 // NS Operation
234
235 // Request
236 struct Request *req;
237};
238
239// Missing zones list
241
242// Missing zones list
244
245// Lines provided on stdin
246static uint64_t stdin_lines_read;
247
254static unsigned int map_size = 1024;
255
259static struct GNUNET_IDENTITY_Handle *id;
260
264static struct GNUNET_NAMESTORE_Handle *ns;
265
269static struct GNUNET_STATISTICS_Handle *stats;
270
274static struct GNUNET_DNSSTUB_Context *dns_ctx;
275
279static unsigned int pending;
280
284static unsigned int pending_rs;
285
289static unsigned int lookups;
290
294static unsigned int cached;
295
299static unsigned int rejects;
300
304static unsigned int failures;
305
309static unsigned int records;
310
314static unsigned int record_sets;
315
320static struct GNUNET_CONTAINER_Heap *req_heap;
321
325static struct Request *req_head;
326
330static struct Request *req_tail;
331
335static struct GNUNET_SCHEDULER_Task *t;
336
343
348
352static struct Zone *zone_head;
353
357static struct Zone *zone_tail;
358
363static uint64_t ns_iterator_trigger_next;
364
368static uint64_t total_dns_latency_cnt;
369
374
378static uint64_t total_reg_proc_dns;
379
383static uint64_t total_reg_proc_dns_ns;
384
389
394
398static struct GNUNET_TIME_Relative idle_time;
399
400
407typedef void (*RecordProcessor) (void *cls,
408 const struct GNUNET_DNSPARSER_Record *rec);
409
410
419static void
422 void *rp_cls)
423{
424 for (unsigned int i = 0; i < p->num_answers; i++)
425 {
426 struct GNUNET_DNSPARSER_Record *rs = &p->answers[i];
427
428 rp (rp_cls, rs);
429 }
430 for (unsigned int i = 0; i < p->num_authority_records; i++)
431 {
432 struct GNUNET_DNSPARSER_Record *rs = &p->authority_records[i];
433
434 rp (rp_cls, rs);
435 }
436 for (unsigned int i = 0; i < p->num_additional_records; i++)
437 {
438 struct GNUNET_DNSPARSER_Record *rs = &p->additional_records[i];
439
440 rp (rp_cls, rs);
441 }
442}
443
444
452static const char *
453get_label (struct Request *req)
454{
455 static char label[64];
456 const char *dot;
457
458 dot = strchr (req->hostname, (unsigned char) '.');
459 if (NULL == dot)
460 {
461 GNUNET_break (0);
462 return NULL;
463 }
464 if (((size_t) (dot - req->hostname)) >= sizeof(label))
465 {
466 GNUNET_break (0);
467 return NULL;
468 }
469 GNUNET_memcpy (label, req->hostname, dot - req->hostname);
470 label[dot - req->hostname] = '\0';
471
472 return label;
473}
474
475
476static char*
477get_label_utf8 (struct Request *req)
478{
479 char *label_utf8;
480 const char *label_ace;
481
482 label_ace = get_label (req);
483 idna_to_unicode_8z8z (label_ace,
484 &label_utf8,
485 IDNA_ALLOW_UNASSIGNED);
486 return label_utf8;
487}
488
489
498static void *
499build_dns_query (struct Request *req, size_t *raw_size)
500{
501 static char raw[512];
502 char *name_ace;
503 char *rawp;
506 int ret;
507
508 if (IDNA_SUCCESS != idna_to_ascii_8z (req->hostname,
509 &name_ace,
510 IDNA_ALLOW_UNASSIGNED))
511 {
513 _ ("Name `%s' cannot be converted to IDNA."),
514 req->hostname);
515 return NULL;
516 }
517 q.name = (char *) name_ace;
519 q.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
520
521 memset (&p, 0, sizeof(p));
522 p.num_queries = 1;
523 p.queries = &q;
524 p.id = req->id;
525 ret = GNUNET_DNSPARSER_pack (&p, UINT16_MAX, &rawp, raw_size);
526 if (GNUNET_OK != ret)
527 {
528 if (GNUNET_NO == ret)
529 GNUNET_free (rawp);
531 "Failed to pack query for hostname `%s'\n",
532 name_ace);
533 rejects++;
534 GNUNET_free (name_ace);
535 return NULL;
536 }
537 if (*raw_size > sizeof(raw))
538 {
540 "Failed to pack query for hostname `%s'\n",
541 name_ace);
542 rejects++;
543 GNUNET_break (0);
544 GNUNET_free (name_ace);
545 GNUNET_free (rawp);
546 return NULL;
547 }
548 GNUNET_memcpy (raw, rawp, *raw_size);
549 GNUNET_free (rawp);
550 return raw;
551}
552
553
559static void
560free_records (struct Request *req)
561{
562 struct Record *rec;
563
564 /* Free records */
565 while (NULL != (rec = req->rec_head))
566 {
568 GNUNET_free (rec);
569 }
570}
571
572
578static void
579free_request (struct Request *req)
580{
581 free_records (req);
582 GNUNET_free (req);
583}
584
585
591static void
592process_queue (void *cls);
593
594
600static void
601insert_sorted (struct Request *req)
602{
603 req->hn =
606 {
607 if (NULL != t)
611 }
612}
613
614
624static void
625add_record (struct Request *req,
626 uint32_t type,
627 struct GNUNET_TIME_Absolute expiration_time,
628 const void *data,
629 size_t data_len)
630{
631 struct Record *rec;
632
633 rec = GNUNET_malloc (sizeof(struct Record) + data_len);
634 rec->grd.data = &rec[1];
635 rec->grd.expiration_time = expiration_time.abs_value_us;
636 rec->grd.data_size = data_len;
637 rec->grd.record_type = type;
639 GNUNET_memcpy (&rec[1], data, data_len);
641}
642
643
647struct GlueClosure
648{
652 struct Request *req;
653
657 const char *ns;
658
662 int found;
663};
664
665
672static void
673check_for_glue (void *cls, const struct GNUNET_DNSPARSER_Record *rec)
674{
675 struct GlueClosure *gc = cls;
676 char dst[65536];
677 size_t rd_len;
678 char ip[INET6_ADDRSTRLEN + 1];
679 socklen_t ip_size = (socklen_t) sizeof(ip);
680 struct GNUNET_TIME_Absolute expiration_time;
681 struct GNUNET_TIME_Relative left;
682
683 if (0 != strcasecmp (rec->name, gc->ns))
684 return;
685 expiration_time = rec->expiration_time;
686 left = GNUNET_TIME_absolute_get_remaining (expiration_time);
687 if (0 == left.rel_value_us)
688 return; /* ignore expired glue records */
689 /* if expiration window is too short, bump it to configured minimum */
690 if (left.rel_value_us < minimum_expiration_time.rel_value_us)
691 expiration_time =
693 rd_len = 0;
694 switch (rec->type)
695 {
697 if (sizeof(struct in_addr) != rec->data.raw.data_len)
698 {
699 GNUNET_break (0);
700 return;
701 }
702 if (NULL == inet_ntop (AF_INET, rec->data.raw.data, ip, ip_size))
703 {
704 GNUNET_break (0);
705 return;
706 }
707 // NAME
708 GNUNET_memcpy (dst,
709 gc->req->hostname,
710 strlen (gc->req->hostname) + 1);
711 rd_len += strlen (gc->req->hostname) + 1;
712 // DNS SERVER NAME
713 GNUNET_memcpy (dst + strlen (gc->req->hostname) + 1,
714 ip,
715 strlen (ip) + 1);
716 rd_len += strlen (ip) + 1;
717 add_record (gc->req,
719 expiration_time,
720 dst,
721 rd_len);
722 gc->found = GNUNET_YES;
723 break;
724
726 if (sizeof(struct in6_addr) != rec->data.raw.data_len)
727 {
728 GNUNET_break (0);
729 return;
730 }
731 if (NULL == inet_ntop (AF_INET6, rec->data.raw.data, ip, ip_size))
732 {
733 GNUNET_break (0);
734 return;
735 }
736 // NAME
737 GNUNET_memcpy (dst,
738 gc->req->hostname,
739 strlen (gc->req->hostname) + 1);
740 rd_len += strlen (gc->req->hostname) + 1;
741 // DNS SERVER NAME
742 GNUNET_memcpy (dst + strlen (gc->req->hostname) + 1,
743 ip,
744 strlen (ip) + 1);
745 rd_len += strlen (ip) + 1;
746 add_record (gc->req,
748 expiration_time,
749 dst,
750 rd_len);
751 gc->found = GNUNET_YES;
752 break;
753
755 // NAME
756 GNUNET_memcpy (dst,
757 gc->req->hostname,
758 strlen (gc->req->hostname) + 1);
759 rd_len += strlen (gc->req->hostname) + 1;
760 // DNS SERVER NAME
761 GNUNET_memcpy (dst + strlen (gc->req->hostname) + 1,
762 rec->data.hostname,
763 strlen (rec->data.hostname) + 1);
764 rd_len += strlen (rec->data.hostname) + 1;
765 add_record (gc->req,
767 expiration_time,
768 dst,
769 rd_len);
770 gc->found = GNUNET_YES;
771 break;
772
773 default:
774 /* useless, do nothing */
775 break;
776 }
777}
778
779
784{
790
794 struct Request *req;
795};
796
797
804static void
805process_record (void *cls, const struct GNUNET_DNSPARSER_Record *rec)
806{
807 struct ProcessRecordContext *prc = cls;
808 struct Request *req = prc->req;
809 char dst[65536];
810 size_t dst_len;
811 size_t off;
812 struct GNUNET_TIME_Absolute expiration_time;
813 struct GNUNET_TIME_Relative left;
814
815 dst_len = sizeof(dst);
816 off = 0;
817 records++;
818 if (0 != strcasecmp (rec->name, req->hostname))
819 {
820 GNUNET_log (
822 "DNS returned record from zone `%s' of type %u while resolving `%s'\n",
823 rec->name,
824 (unsigned int) rec->type,
825 req->hostname);
826 return; /* does not match hostname, might be glue, but
827 not useful for this pass! */
828 }
829 expiration_time = rec->expiration_time;
830 left = GNUNET_TIME_absolute_get_remaining (expiration_time);
831 if (0 == left.rel_value_us)
832 {
834 "DNS returned expired record for `%s'\n",
835 req->hostname);
837 "# expired records obtained from DNS",
838 1,
839 GNUNET_NO);
840 return; /* record expired */
841 }
842
844 "DNS returned record that expires at %s for `%s'\n",
846 req->hostname);
847 /* if expiration window is too short, bump it to configured minimum */
848 if (left.rel_value_us < minimum_expiration_time.rel_value_us)
849 expiration_time =
851 switch (rec->type)
852 {
854 struct GlueClosure gc;
855
856 /* check for glue */
857 gc.req = req;
858 gc.ns = rec->data.hostname;
859 gc.found = GNUNET_NO;
860 for_all_records (prc->p, &check_for_glue, &gc);
861 if (GNUNET_NO == gc.found)
862 {
863 // NAME
864 GNUNET_memcpy (dst,
865 req->hostname,
866 strlen (req->hostname) + 1);
867 off += strlen (req->hostname) + 1;
868 // DNS SERVER NAME
869 GNUNET_memcpy (dst + strlen (req->hostname) + 1,
870 rec->data.hostname,
871 strlen (rec->data.hostname) + 1);
872 off += strlen (rec->data.hostname) + 1;
873 /* FIXME: actually check if this is out-of-bailiwick,
874 and if not request explicit resolution... */
876 "Converted OOB (`%s') NS record for `%s'\n",
877 rec->data.hostname,
878 rec->name);
881 expiration_time,
882 dst,
883 off);
884 }
885 else
886 {
888 "Converted NS record for `%s' using glue\n",
889 rec->name);
890 }
891 break;
892 }
893
896 dst_len,
897 &off,
898 rec->data.hostname))
899 {
901 "Converting CNAME (`%s') record for `%s'\n",
902 rec->data.hostname,
903 rec->name);
904 add_record (req, rec->type, expiration_time, dst, off);
905 }
906 break;
907
909 /* No support for DNAME in GNS yet! FIXME: support later! */
911 "FIXME: not supported: %s DNAME %s\n",
912 rec->name,
913 rec->data.hostname);
914 break;
915
917 if (GNUNET_OK ==
918 GNUNET_DNSPARSER_builder_add_mx (dst, dst_len, &off, rec->data.mx))
919 {
921 "Converting MX (`%s') record for `%s'\n",
922 rec->data.mx->mxhost,
923 rec->name);
924 add_record (req, rec->type, expiration_time, dst, off);
925 }
926 break;
927
929 if (GNUNET_OK ==
930 GNUNET_DNSPARSER_builder_add_soa (dst, dst_len, &off, rec->data.soa))
931 {
932 /* NOTE: GNS does not really use SOAs */
934 "Converting SOA record for `%s'\n",
935 rec->name);
936 add_record (req, rec->type, expiration_time, dst, off);
937 }
938 break;
939
941 if (GNUNET_OK ==
942 GNUNET_DNSPARSER_builder_add_srv (dst, dst_len, &off, rec->data.srv))
943 {
945 "Converting SRV record for `%s'\n",
946 rec->name);
947 add_record (req, rec->type, expiration_time, dst, off);
948 }
949 break;
950
952 if (GNUNET_OK ==
953 GNUNET_DNSPARSER_builder_add_uri (dst, dst_len, &off, rec->data.uri))
954 {
956 "Converting URI record for `%s'\n",
957 rec->name);
958 add_record (req, rec->type, expiration_time, dst, off);
959 }
960 break;
961
964 dst_len,
965 &off,
966 rec->data.hostname))
967 {
968 /* !?: what does a PTR record do in a regular TLD??? */
970 "Converting PTR record for `%s' (weird)\n",
971 rec->name);
972 add_record (req, rec->type, expiration_time, dst, off);
973 }
974 break;
975
977 if (GNUNET_OK ==
978 GNUNET_DNSPARSER_builder_add_cert (dst, dst_len, &off, rec->data.cert))
979 {
981 "Converting CERT record for `%s'\n",
982 rec->name);
983 add_record (req, rec->type, expiration_time, dst, off);
984 }
985 break;
986
987 /* Rest is 'raw' encoded and just needs to be copied IF
988 the hostname matches the requested name; otherwise we
989 simply cannot use it. */
993 default:
995 "Converting record of type %u for `%s'\n",
996 (unsigned int) rec->type,
997 rec->name);
999 rec->type,
1000 expiration_time,
1001 rec->data.raw.data,
1002 rec->data.raw.data_len);
1003 break;
1004 }
1005}
1006
1007
1008static void
1009store_completed_cb (void *cls, enum GNUNET_ErrorCode ec)
1010{
1011 static struct GNUNET_TIME_Absolute last;
1012 struct Request *req = cls;
1013
1014 req->qe = NULL;
1015 if (GNUNET_EC_NONE != ec)
1016 {
1018 "Failed to store zone data for `%s': %s\n",
1019 req->hostname,
1021 }
1022 else
1023 {
1025 "Stored records under `%s' (%d)\n",
1026 req->hostname,
1027 ec);
1028 }
1029 total_reg_proc_dns_ns++; /* finished regular processing */
1030 pending_rs--;
1031 free_records (req);
1032 /* compute NAMESTORE statistics */
1033 {
1034 static uint64_t total_ns_latency_cnt;
1035 static struct GNUNET_TIME_Relative total_ns_latency;
1036 struct GNUNET_TIME_Relative ns_latency;
1037
1039 total_ns_latency = GNUNET_TIME_relative_add (total_ns_latency, ns_latency);
1040 if (0 == total_ns_latency_cnt)
1041 last = GNUNET_TIME_absolute_get ();
1042 total_ns_latency_cnt++;
1043 if (0 == (total_ns_latency_cnt % 1000))
1044 {
1046 struct GNUNET_TIME_Relative est_remaining;
1047
1049 last = GNUNET_TIME_absolute_get ();
1050 est_remaining = GNUNET_TIME_relative_multiply (
1051 delta,
1052 (stdin_lines_read - total_ns_latency_cnt) / 1000);
1053 fprintf (stderr,
1054 "Processed 1000 records in %s. ",
1056 fprintf (stderr,
1057 "Estimated remaining time: %s. ",
1059 est_remaining,
1060 GNUNET_YES));
1061 fprintf (stderr,
1062 "Last domain processed: %s\n",
1063 req->hostname);
1065 "# average NAMESTORE PUT latency (μs)",
1066 total_ns_latency.rel_value_us
1067 / total_ns_latency_cnt,
1068 GNUNET_NO);
1069 }
1070 }
1071 /* compute and publish overall velocity */
1072 if (0 == (total_reg_proc_dns_ns % 100))
1073 {
1074 struct GNUNET_TIME_Relative runtime;
1075
1077 runtime = GNUNET_TIME_relative_subtract (runtime, idle_time);
1078 runtime =
1082 "# Regular processing completed without NAMESTORE",
1084 GNUNET_NO);
1086 "# Regular processing completed with NAMESTORE PUT",
1088 GNUNET_NO);
1090 "# average request processing latency (μs)",
1091 runtime.rel_value_us,
1092 GNUNET_NO);
1094 "# total time spent idle (μs)",
1096 GNUNET_NO);
1097 }
1098
1099 if (NULL == t)
1100 {
1103 }
1104}
1105
1106
1114static void
1115process_result (void *cls,
1116 const struct GNUNET_TUN_DnsHeader *dns,
1117 size_t dns_len)
1118{
1119 struct Request *req = cls;
1120 struct Record *rec;
1121 struct GNUNET_DNSPARSER_Packet *p;
1122 unsigned int rd_count;
1123
1124 GNUNET_assert (NULL == req->hn);
1125 if ((NULL == dns) ||
1127 {
1128 /* stub gave up */
1130 if (NULL != dns)
1131 {
1133 req->rs = NULL;
1134 }
1135 pending--;
1136 if (NULL == t)
1137 {
1140 }
1142 "Stub gave up on DNS reply for `%s'\n",
1143 req->hostname);
1144 GNUNET_STATISTICS_update (stats, "# Unsuccessful DNS lookups", 1, GNUNET_NO)
1145 ;
1146 if (req->issue_num > MAX_RETRIES)
1147 {
1148 failures++;
1149 free_request (req);
1150 GNUNET_STATISTICS_update (stats, "# DNS requests given up on", 1,
1151 GNUNET_NO);
1152 return;
1153 }
1155 req->rs = NULL;
1156 insert_sorted (req);
1157 return;
1158 }
1159 if (req->id != dns->id)
1160 {
1162 "DNS ID did not match request, ignoring reply\n");
1163 GNUNET_STATISTICS_update (stats, "# DNS ID mismatches", 1, GNUNET_NO);
1164 return;
1165 }
1168 req->rs = NULL;
1169 pending--;
1170 p = GNUNET_DNSPARSER_parse ((const char *) dns, dns_len);
1171 if (NULL == p)
1172 {
1174 "Failed to parse DNS reply for `%s'\n",
1175 req->hostname);
1176 GNUNET_STATISTICS_update (stats, "# DNS parser errors", 1, GNUNET_NO);
1177 if (NULL == t)
1178 {
1181 }
1182 if (req->issue_num > MAX_RETRIES)
1183 {
1184 failures++;
1185 free_request (req);
1186 GNUNET_STATISTICS_update (stats, "# requests given up on", 1, GNUNET_NO);
1187 return;
1188 }
1189 insert_sorted (req);
1190 return;
1191 }
1192 /* import new records */
1193 req->issue_num = 0; /* success, reset counter! */
1194 {
1195 struct ProcessRecordContext prc = { .req = req, .p = p };
1196
1198 }
1200 /* count records found, determine minimum expiration time */
1202 {
1203 struct GNUNET_TIME_Relative dns_latency;
1204
1209 if (0 == (total_dns_latency_cnt % 1000))
1210 {
1212 "# average DNS lookup latency (μs)",
1215 GNUNET_NO);
1216 }
1217 }
1218 rd_count = 0;
1219 for (rec = req->rec_head; NULL != rec; rec = rec->next)
1220 {
1221 struct GNUNET_TIME_Absolute at;
1222
1224 req->expires = GNUNET_TIME_absolute_min (req->expires, at);
1225 rd_count++;
1226 }
1228 "Obtained %u records for `%s'\n",
1229 rd_count,
1230 req->hostname);
1231 /* Instead of going for SOA, simplified for now to look each
1232 day in case we got an empty response */
1233 if (0 == rd_count)
1234 {
1237 "# empty DNS replies (usually NXDOMAIN)",
1238 1,
1239 GNUNET_NO);
1240 }
1241 else
1242 {
1243 record_sets++;
1244 }
1245 /* convert records to namestore import format */
1246 {
1248 unsigned int off = 0;
1249 char *label_utf8 = get_label_utf8 (req);
1250
1251 /* convert linked list into array */
1252 for (rec = req->rec_head; NULL != rec; rec = rec->next)
1253 rd[off++] = rec->grd;
1254 pending_rs++;
1257 &req->zone->key,
1258 label_utf8,
1259 rd_count,
1260 rd,
1262 req);
1263 GNUNET_free (label_utf8);
1264 GNUNET_assert (NULL != req->qe);
1265 }
1266 insert_sorted (req);
1267 return;
1268}
1269
1270
1276static void
1277process_queue (void *cls)
1278{
1279 struct Request *req;
1280 unsigned int series;
1281 void *raw;
1282 size_t raw_size;
1283 struct GNUNET_TIME_Relative delay;
1284
1285 (void) cls;
1288 series = 0;
1289 t = NULL;
1290 while (pending + pending_rs < THRESH)
1291 {
1293 if (NULL == req)
1294 break;
1295 if (NULL != req->qe)
1296 return; /* namestore op still pending */
1297 if (NULL != req->rs)
1298 {
1299 GNUNET_break (0);
1300 return; /* already submitted */
1301 }
1303 break;
1305 req->hn = NULL;
1307 GNUNET_assert (NULL == req->rs);
1309 "Requesting resolution for `%s'\n",
1310 req->hostname);
1311 raw = build_dns_query (req, &raw_size);
1312 if (NULL == raw)
1313 {
1314 GNUNET_break (0);
1315 free_request (req);
1316 continue;
1317 }
1319 req->rs = GNUNET_DNSSTUB_resolve (dns_ctx, raw, raw_size, &process_result,
1320 req);
1321 GNUNET_assert (NULL != req->rs);
1322 req->issue_num++;
1323 lookups++;
1324 pending++;
1325 series++;
1326 if (series > MAX_SERIES)
1327 break;
1328 }
1329 if (pending + pending_rs >= THRESH)
1330 {
1332 "Stopped processing queue (%u+%u/%u)]\n",
1333 pending,
1334 pending_rs,
1335 THRESH);
1336 return; /* wait for replies */
1337 }
1339 if (NULL == req)
1340 {
1342 "Stopped processing queue: empty queue\n");
1343 return;
1344 }
1346 {
1348 "Waiting until %s for next record (`%s') to expire\n",
1350 req->hostname);
1351 if (NULL != t)
1355 return;
1356 }
1357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Throttling\n");
1358 if (NULL != t)
1362}
1363
1364
1374static int
1375free_request_it (void *cls, const struct GNUNET_HashCode *key, void *value)
1376{
1377 struct Request *req = value;
1378
1379 (void) cls;
1380 (void) key;
1381 free_request (req);
1382 return GNUNET_OK;
1383}
1384
1385
1391static void
1392do_shutdown (void *cls)
1393{
1394 struct Request *req;
1395 struct Zone *zone;
1396 struct MissingZoneCreationCtx *mzctx;
1397
1398 (void) cls;
1399 while (NULL != (mzctx = missing_zones_head))
1400 {
1403 mzctx);
1404 if (NULL != mzctx->id_op)
1405 {
1407 mzctx->id_op = NULL;
1408 }
1409 if (NULL != mzctx->ns_qe)
1410 {
1412 mzctx->ns_qe = NULL;
1413 }
1414 GNUNET_free (mzctx);
1415 }
1416 if (NULL != id)
1417 {
1419 id = NULL;
1420 }
1421 if (NULL != t)
1422 {
1424 t = NULL;
1425 }
1426 while (NULL != (req = req_head))
1427 {
1429 if (NULL != req->qe)
1431 free_request (req);
1432 }
1433 while (NULL != (req = GNUNET_CONTAINER_heap_remove_root (req_heap)))
1434 {
1435 req->hn = NULL;
1436 if (NULL != req->qe)
1438 free_request (req);
1439 }
1440 if (NULL != zone_it)
1441 {
1443 zone_it = NULL;
1444 }
1445 if (NULL != ns)
1446 {
1448 ns = NULL;
1449 }
1450 if (NULL != dns_ctx)
1451 {
1453 dns_ctx = NULL;
1454 }
1455 if (NULL != req_heap)
1456 {
1458 req_heap = NULL;
1459 }
1460 if (NULL != ns_pending)
1461 {
1464 ns_pending = NULL;
1465 }
1466 while (NULL != (zone = zone_head))
1467 {
1469 GNUNET_free (zone->domain);
1470 GNUNET_free (zone);
1471 }
1472 if (NULL != stats)
1473 {
1475 stats = NULL;
1476 }
1477}
1478
1479
1486static void
1487iterate_zones (void *cls);
1488
1489
1496static void
1497ns_lookup_error_cb (void *cls)
1498{
1499 struct Zone *zone = cls;
1500
1502 "Failed to load data from namestore for zone `%s'\n",
1503 zone->domain);
1504 zone_it = NULL;
1506 iterate_zones (NULL);
1507}
1508
1509
1519static void
1520ns_lookup_result_cb (void *cls,
1521 const struct GNUNET_CRYPTO_PrivateKey *key,
1522 const char *label_utf8,
1523 unsigned int rd_count,
1524 const struct GNUNET_GNSRECORD_Data *rd)
1525{
1526 struct Zone *zone = cls;
1527 struct Request *req;
1528 struct GNUNET_HashCode hc;
1529 char *label_ace;
1530 char *fqdn;
1531
1533 if (0 == ns_iterator_trigger_next)
1534 {
1537 "# NAMESTORE records requested from cache",
1539 GNUNET_NO);
1541 }
1542 if (IDNA_SUCCESS != idna_to_ascii_8z (label_utf8,
1543 &label_ace,
1544 IDNA_ALLOW_UNASSIGNED))
1545 {
1547 _ ("Name `%s' cannot be converted to IDNA."),
1548 label_utf8);
1549 return;
1550 }
1552 "Obtained NAMESTORE reply for %s (Punycode `%s', %llu left in round\n",
1553 label_utf8,
1554 label_ace,
1555 (unsigned long long) ns_iterator_trigger_next);
1556
1557 GNUNET_asprintf (&fqdn, "%s.%s", label_ace, zone->domain);
1558 GNUNET_CRYPTO_hash (fqdn, strlen (fqdn) + 1, &hc);
1559 GNUNET_free (fqdn);
1561 if (NULL == req)
1562 {
1564 "Ignoring record `%s' in zone `%s': not on my list!\n",
1565 label_ace,
1566 zone->domain);
1567 GNUNET_free (label_ace);
1568 return;
1569 }
1572 GNUNET_break (0 == GNUNET_memcmp (key, &req->zone->key));
1573 GNUNET_break (0 == strcasecmp (label_ace, get_label (req)));
1574 GNUNET_free (label_ace);
1575 for (unsigned int i = 0; i < rd_count; i++)
1576 {
1577 struct GNUNET_TIME_Absolute at;
1578
1580 {
1581 struct GNUNET_TIME_Relative rel;
1582
1585 }
1586 else
1587 {
1588 at.abs_value_us = rd->expiration_time;
1589 }
1590 add_record (req, rd->record_type, at, rd->data, rd->data_size);
1591 }
1592 if (0 == rd_count)
1593 {
1595 "Empty record set in namestore for `%s'\n",
1596 req->hostname);
1597 }
1598 else
1599 {
1600 unsigned int pos = 0;
1601
1602 cached++;
1604 for (struct Record *rec = req->rec_head; NULL != rec; rec = rec->next)
1605 {
1606 struct GNUNET_TIME_Absolute at;
1607
1609 req->expires = GNUNET_TIME_absolute_min (req->expires, at);
1610 pos++;
1611 }
1612 if (0 == pos)
1615 "Hot-start with %u existing records for `%s'\n",
1616 pos,
1617 req->hostname);
1618 }
1619 free_records (req);
1620
1622 "Adding `%s' to worklist to start at %s\n",
1623 req->hostname,
1625 insert_sorted (req);
1626}
1627
1628
1629static void
1630delegation_store_cont (void *cls,
1631 enum GNUNET_ErrorCode ec)
1632{
1633 struct MissingZoneCreationCtx *mzctx = cls;
1634
1635 mzctx->ns_qe = NULL;
1636 if (GNUNET_EC_NONE != ec)
1637 {
1639 "Failed to store delegation: `%s'\n",
1642 return;
1643 }
1645 "Added delegation successfully\n");
1648 mzctx);
1649 GNUNET_free (mzctx);
1650 if (NULL == missing_zones_head)
1651 {
1652 iterate_zones (NULL);
1653 }
1654
1655}
1656
1657
1658static void
1660 void *cls,
1661 const struct GNUNET_CRYPTO_PrivateKey *sk,
1662 enum GNUNET_ErrorCode ec)
1663{
1664 struct MissingZoneCreationCtx *mzctx = cls;
1666 struct Zone *parent_zone;
1667 struct Zone *zone;
1668 const char *dot;
1669 const char *expected_parent_zone_name;
1670 char parent_delegation_label[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
1671
1672 if (GNUNET_EC_NONE != ec)
1673 {
1675 "Failed to create zone for `%s': %s\n",
1676 mzctx->req->hostname,
1679 return;
1680 }
1681 mzctx->id_op = NULL;
1682 dot = strchr (mzctx->req->hostname, (unsigned char) '.');
1684 "Created missing ego `%s'\n",
1685 dot + 1);
1686 zone = GNUNET_new (struct Zone);
1687 zone->key = *sk;
1688 zone->domain = GNUNET_strdup (dot + 1);
1689 mzctx->req->zone = zone;
1691
1692 expected_parent_zone_name = strchr (dot + 1,
1693 (unsigned char) '.');
1694 if (NULL == expected_parent_zone_name)
1695 {
1697 "Created identity without parent zone!\n");
1699 return;
1700 }
1701 {
1702 int label_len = strlen (dot + 1) - strlen (expected_parent_zone_name) + 1;
1703 snprintf (parent_delegation_label,
1704 label_len,
1705 "%s",
1706 dot + 1);
1707 parent_delegation_label[label_len] = '\0';
1708 }
1709 for (parent_zone = zone_head;
1710 NULL != parent_zone;
1711 parent_zone = parent_zone->next)
1712 {
1713 if (0 != strcmp (expected_parent_zone_name + 1,
1714 parent_zone->domain))
1715 continue;
1716 break;
1717 }
1718 GNUNET_assert (NULL != parent_zone);
1720 struct GNUNET_GNSRECORD_Data delegation_rd;
1721 char *data;
1722 size_t data_size;
1725 &data,
1726 &data_size,
1727 &delegation_rd.record_type
1728 ));
1729 delegation_rd.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1730 delegation_rd.expiration_time = GNUNET_TIME_UNIT_WEEKS.rel_value_us;
1731 delegation_rd.data = data;
1732 delegation_rd.data_size = data_size;
1734 &parent_zone->key,
1735 parent_delegation_label,
1736 1,
1737 &delegation_rd,
1739 mzctx);
1740 GNUNET_free (data);
1741}
1742
1743
1749static void
1750queue (const char *hostname)
1751{
1752 struct Request *req;
1753 const char *dot;
1754 struct Zone *zone;
1755 size_t hlen;
1756 struct GNUNET_HashCode hc;
1757
1758 if (GNUNET_OK != GNUNET_DNSPARSER_check_name (hostname))
1759 {
1761 "Refusing invalid hostname `%s'\n",
1762 hostname);
1763 rejects++;
1764 return;
1765 }
1766 dot = strchr (hostname, (unsigned char) '.');
1767 if (NULL == dot)
1768 {
1770 "Refusing invalid hostname `%s' (lacks '.')\n",
1771 hostname);
1772 rejects++;
1773 return;
1774 }
1775 for (zone = zone_head; NULL != zone; zone = zone->next)
1776 if (0 == strcmp (zone->domain, dot + 1))
1777 break;
1778 hlen = strlen (hostname) + 1;
1779 req = GNUNET_malloc (sizeof(struct Request) + hlen);
1780 if (NULL == zone)
1781 {
1782 struct MissingZoneCreationCtx *mzctx;
1783
1784 for (mzctx = missing_zones_head;
1785 NULL != mzctx;
1786 mzctx = mzctx->next)
1787 {
1788 const char *tmp_dot;
1789 tmp_dot = strchr (mzctx->req->hostname, (unsigned char) '.');
1790 GNUNET_assert (NULL != tmp_dot);
1791 if (0 != strcmp (dot + 1, tmp_dot + 1))
1792 continue;
1793 break;
1794 }
1795 if (NULL == mzctx)
1796 {
1798 "Domain name `%s' not in ego list! Creating.\n",
1799 dot + 1);
1800 mzctx = GNUNET_new (struct MissingZoneCreationCtx);
1801 mzctx->id_op = GNUNET_IDENTITY_create (id,
1802 dot + 1,
1803 NULL,
1806 mzctx);
1807 mzctx->req = req;
1810 mzctx);
1811 }
1812 }
1813 else
1814 {
1815 req->zone = zone;
1816 }
1817
1818 req->hostname = (char *) &req[1];
1819 GNUNET_memcpy (req->hostname, hostname, hlen);
1821 UINT16_MAX);
1822 GNUNET_CRYPTO_hash (req->hostname, hlen, &hc);
1824 ns_pending,
1825 &hc,
1826 req,
1828 {
1830 "Duplicate hostname `%s' ignored\n",
1831 hostname);
1832 GNUNET_free (req);
1833 return;
1834 }
1835}
1836
1837
1849static int
1850move_to_queue (void *cls, const struct GNUNET_HashCode *key, void *value)
1851{
1852 struct Request *req = value;
1853
1854 (void) cls;
1855 (void) key;
1856 insert_sorted (req);
1857 return GNUNET_OK;
1858}
1859
1860
1867static void
1868iterate_zones (void *cls)
1869{
1870 static struct Zone *last;
1871
1872 (void) cls;
1873 if (NULL != zone_it)
1874 {
1875 zone_it = NULL;
1877 "Finished iteration over zone `%s'!\n",
1878 last->domain);
1879 /* subtract left-overs from previous iteration */
1881 "# NAMESTORE records requested from cache",
1882 (long long) (-ns_iterator_trigger_next),
1883 GNUNET_NO);
1885 }
1886 GNUNET_assert (NULL != zone_tail);
1887 if (zone_tail == last)
1888 {
1889 /* Done iterating over relevant zones in NAMESTORE, move
1890 rest of hash map to work queue as well. */
1892 "Finished all NAMESTORE iterations!\n");
1894 "# Domain names without cached reply",
1896 GNUNET_NO);
1899 ns_pending = NULL;
1903 return;
1904 }
1905 if (NULL == last)
1906 last = zone_head;
1907 else
1908 last = last->next;
1910 "Starting iteration over zone `%s'!\n",
1911 last->domain);
1912 /* subtract left-overs from previous iteration */
1914 "# NAMESTORE records requested from cache",
1915 1,
1916 GNUNET_NO);
1918 GNUNET_STATISTICS_update (stats, "# zones iterated", 1, GNUNET_NO);
1920 &last->key,
1922 NULL,
1924 last,
1926 NULL);
1927}
1928
1929
1935static void
1936process_stdin (void *cls)
1937{
1938 static struct GNUNET_TIME_Absolute last;
1939 char hn[256];
1940 char *hn_utf8;
1941
1942 (void) cls;
1943 t = NULL;
1944 while (NULL != fgets (hn, sizeof(hn), stdin))
1945 {
1946 if (strlen (hn) > 0)
1947 hn[strlen (hn) - 1] = '\0'; /* eat newline */
1948 if (0 == stdin_lines_read)
1949 last = GNUNET_TIME_absolute_get ();
1951 if (0 == stdin_lines_read % 100000)
1952 {
1954
1956 last = GNUNET_TIME_absolute_get ();
1957 fprintf (stderr,
1958 "Read 100000 domain names in %s\n",
1960 GNUNET_STATISTICS_set (stats, "# domain names provided", stdin_lines_read,
1961 GNUNET_NO);
1962 }
1963 idna_to_unicode_8z8z (hn,
1964 &hn_utf8,
1965 IDNA_ALLOW_UNASSIGNED);
1966 queue (hn_utf8);
1967 GNUNET_free (hn_utf8);
1968 }
1969 fprintf (stderr,
1970 "Done reading %llu domain names\n",
1971 (unsigned long long) stdin_lines_read);
1972 GNUNET_STATISTICS_set (stats, "# domain names provided", stdin_lines_read,
1973 GNUNET_NO);
1974 // Only start iteration immediately if no zones are missing.
1975 if (NULL == missing_zones_head)
1976 {
1977 iterate_zones (NULL);
1978 }
1979}
1980
1981
2015static void
2016identity_cb (void *cls,
2017 struct GNUNET_IDENTITY_Ego *ego,
2018 void **ctx,
2019 const char *name)
2020{
2021 (void) cls;
2022 (void) ctx;
2023 static int initial_iteration = GNUNET_YES;
2024
2025 if (GNUNET_NO == initial_iteration)
2026 return;
2027 if (NULL == ego)
2028 {
2029 /* end of iteration */
2030 if (NULL == zone_head)
2031 {
2032 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No zone found\n");
2034 return;
2035 }
2036 initial_iteration = GNUNET_NO;
2037 /* zone_head non-null, process hostnames from stdin */
2039 return;
2040 }
2041 if (NULL != name)
2042 {
2043 struct Zone *zone;
2044
2045 zone = GNUNET_new (struct Zone);
2047 zone->domain = GNUNET_strdup (name);
2049 }
2050}
2051
2052
2062static void
2063run (void *cls,
2064 char *const *args,
2065 const char *cfgfile,
2066 const struct GNUNET_CONFIGURATION_Handle *cfg)
2067{
2068 (void) cls;
2069 (void) args;
2070 (void) cfgfile;
2071 stats = GNUNET_STATISTICS_create ("zoneimport", cfg);
2074 if (NULL == ns_pending)
2075 {
2076 fprintf (stderr, "Failed to allocate memory for main hash map\n");
2077 return;
2078 }
2080 if (NULL == dns_ctx)
2081 {
2082 fprintf (stderr, "Failed to initialize GNUnet DNS STUB\n");
2083 return;
2084 }
2085 if (NULL == args[0])
2086 {
2087 fprintf (stderr,
2088 "You must provide a list of DNS resolvers on the command line\n");
2089 return;
2090 }
2091 for (unsigned int i = 0; NULL != args[i]; i++)
2092 {
2094 {
2095 fprintf (stderr, "Failed to use `%s' for DNS resolver\n", args[i]);
2096 return;
2097 }
2098 }
2099
2100
2103 if (NULL == ns)
2104 {
2106 return;
2107 }
2109}
2110
2111
2119int
2120main (int argc, char *const *argv)
2121{
2124 "size",
2125 "MAPSIZE",
2126 gettext_noop (
2127 "size to use for the main hash map"),
2128 &map_size),
2130 'm',
2131 "minimum-expiration",
2132 "RELATIVETIME",
2133 gettext_noop ("minimum expiration time we assume for imported records"),
2136 int ret;
2137
2138 if (GNUNET_OK !=
2140 argc,
2141 argv,
2142 "gnunet-zoneimport",
2143 "import DNS zone into namestore",
2144 options,
2145 &run,
2146 NULL)))
2147 return 1;
2148 fprintf (stderr,
2149 "Rejected %u names, had %u cached, did %u lookups, stored %u record sets\n"
2150 "Found %u records, %u lookups failed, %u/%u pending on shutdown\n",
2151 rejects,
2152 cached,
2153 lookups,
2155 records,
2156 failures,
2157 pending,
2158 pending_rs);
2159 return 0;
2160}
2161
2162
2163/* end of gnunet-zoneimport.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_GNS2DNS
Delegation to DNS.
static int ret
Final status code.
Definition gnunet-arm.c:93
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition gnunet-arm.c:108
static int do_shutdown
Set to GNUNET_YES if we are shutting down.
static char * data
The data to insert into the dht.
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_Handle * ctx
static int raw
raw output
Definition gnunet-gns.c:78
struct GNUNET_CRYPTO_PrivateKey pk
Private key from command line option, or NULL.
static char * name
Name (label) of the records to list.
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 char * value
Value of the record to add/remove.
static uint32_t type
Type string converted to DNS type value.
static size_t data_size
Number of bytes in data.
static char * rp
Relying party.
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static struct GNUNET_OS_Process * p
Helper process we started.
Definition gnunet-uri.c:38
static void free_records(struct Request *req)
Free records associated with req.
#define THRESH
Maximum number of queries pending at the same time.
static void for_all_records(const struct GNUNET_DNSPARSER_Packet *p, RecordProcessor rp, void *rp_cls)
Call rp for each record in p, regardless of what response section it is in.
static void add_record(struct Request *req, uint32_t type, struct GNUNET_TIME_Absolute expiration_time, const void *data, size_t data_len)
Add record to the GNS record set for req.
static unsigned int map_size
Command-line argument specifying desired size of the hash map with all of our pending names.
#define NS_BATCH_SIZE
How many requests do we request from NAMESTORE in one batch during our initial iteration?
static int move_to_queue(void *cls, const struct GNUNET_HashCode *key, void *value)
We have completed the initial iteration over the namestore's database.
static struct Zone * zone_tail
Tail of list of zones we are managing.
static void delegation_store_cont(void *cls, enum GNUNET_ErrorCode ec)
static unsigned int records
Number of records we found.
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 free_request(struct Request *req)
Free req and data structures reachable from it.
static struct GNUNET_TIME_Absolute start_time_reg_proc
Start time of the regular processing.
static void process_queue(void *cls)
Process as many requests as possible from the queue.
static void store_completed_cb(void *cls, enum GNUNET_ErrorCode ec)
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
static unsigned int pending
The number of DNS queries that are outstanding.
void(* RecordProcessor)(void *cls, const struct GNUNET_DNSPARSER_Record *rec)
Callback for for_all_records.
static int free_request_it(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator called during do_shutdown() to free requests in the ns_pending map.
static struct GNUNET_STATISTICS_Handle * stats
Handle to the statistics service.
static struct GNUNET_NAMESTORE_ZoneIterator * zone_it
Current zone iteration handle.
#define MAX_SERIES
How many DNS requests do we at most issue in rapid series?
static uint64_t total_reg_proc_dns_ns
Number of records processed (DNS lookup, with NAMESTORE) in total.
static char * get_label_utf8(struct Request *req)
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 struct GNUNET_TIME_Relative idle_time
Time we slept just waiting for work.
static struct GNUNET_TIME_Relative minimum_expiration_time
How long do DNS records have to last at least after being imported?
static unsigned int cached
Number of records we had cached.
static struct GNUNET_TIME_Relative total_dns_latency
Sum of DNS latencies observed.
static struct GNUNET_CONTAINER_MultiHashMap * ns_pending
Hash map of requests for which we may still get a response from the namestore.
static uint64_t total_dns_latency_cnt
Number of DNS requests counted in latency total.
static uint64_t stdin_lines_read
static void insert_sorted(struct Request *req)
Insert req into DLL sorted by next fetch time.
static unsigned int lookups
Number of lookups we performed overall.
static void missing_zone_creation_cont(void *cls, const struct GNUNET_CRYPTO_PrivateKey *sk, enum GNUNET_ErrorCode ec)
static uint64_t ns_iterator_trigger_next
After how many more results must ns_lookup_result_cb() ask the namestore for more?
static uint64_t total_reg_proc_dns
Number of records processed (DNS lookup, no NAMESTORE) in total.
static void process_record(void *cls, const struct GNUNET_DNSPARSER_Record *rec)
We received rec for req.
static struct GNUNET_NAMESTORE_Handle * ns
Namestore handle.
static const char * get_label(struct Request *req)
Return just the label of the hostname in req.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Process requests from the queue, then if the queue is not empty, try again.
static struct GNUNET_IDENTITY_Handle * id
Handle to the identity service.
static void iterate_zones(void *cls)
Iterate over all of the zones we care about and see which records we may need to re-fetch when.
static unsigned int pending_rs
The number of NAMESTORE record store operations that are outstanding.
static void identity_cb(void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx, const char *name)
Method called to inform about the egos of this peer.
static void ns_lookup_error_cb(void *cls)
Function called if GNUNET_NAMESTORE_records_lookup() failed.
static void process_result(void *cls, const struct GNUNET_TUN_DnsHeader *dns, size_t dns_len)
Function called with the result of a DNS resolution.
static struct Request * req_tail
Active requests are kept in a DLL.
static struct MissingZoneCreationCtx * missing_zones_head
static void check_for_glue(void *cls, const struct GNUNET_DNSPARSER_Record *rec)
Try to find glue records for a given NS record.
static unsigned int record_sets
Number of record sets given to namestore.
static struct MissingZoneCreationCtx * missing_zones_tail
static unsigned int rejects
How many hostnames did we reject (malformed).
static void ns_lookup_result_cb(void *cls, const struct GNUNET_CRYPTO_PrivateKey *key, const char *label_utf8, unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Process a record that was stored in the namestore.
static void process_stdin(void *cls)
Begin processing hostnames from stdin.
static struct Request * req_head
Active requests are kept in a DLL.
static struct GNUNET_DNSSTUB_Context * dns_ctx
Context for DNS resolution.
#define MAX_RETRIES
How often do we retry a query before giving up for good?
static unsigned int failures
Number of lookups that failed.
#define SERIES_DELAY
How long do we wait at least between series of requests?
static void * build_dns_query(struct Request *req, size_t *raw_size)
Build DNS query for hostname.
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).
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
@ GNUNET_CRYPTO_QUALITY_NONCE
Randomness for IVs etc.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_DNSPARSER_TYPE_URI
int GNUNET_DNSPARSER_builder_add_name(char *dst, size_t dst_len, size_t *off, const char *name)
Add a DNS name to the UDP packet at the given location, converting the name to IDNA notation as neces...
Definition dnsparser.c:985
int GNUNET_DNSPARSER_builder_add_cert(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_CertRecord *cert)
Add CERT record to the UDP packet at the given location.
Definition dnsparser.c:1129
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
Definition dnsparser.c:950
#define GNUNET_DNSPARSER_TYPE_SRV
#define GNUNET_DNSPARSER_TYPE_SOA
#define GNUNET_DNSPARSER_TYPE_CERT
#define GNUNET_DNSPARSER_TYPE_A
#define GNUNET_DNSPARSER_TYPE_PTR
int GNUNET_DNSPARSER_check_name(const char *name)
Check if a hostname in UTF-8 format can be coded into valid IDNA.
Definition dnsparser.c:79
#define GNUNET_DNSPARSER_TYPE_NS
int GNUNET_DNSPARSER_builder_add_soa(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SoaRecord *soa)
Add an SOA record to the UDP packet at the given location.
Definition dnsparser.c:1177
#define GNUNET_DNSPARSER_TYPE_CNAME
#define GNUNET_DNSPARSER_TYPE_DNAME
int GNUNET_DNSPARSER_builder_add_mx(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_MxRecord *mx)
Add an MX record to the UDP packet at the given location.
Definition dnsparser.c:1099
int GNUNET_DNSPARSER_builder_add_srv(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_SrvRecord *srv)
Add an SRV record to the UDP packet at the given location.
Definition dnsparser.c:1218
#define GNUNET_DNSPARSER_TYPE_AAAA
int GNUNET_DNSPARSER_pack(const struct GNUNET_DNSPARSER_Packet *p, uint16_t max, char **buf, size_t *buf_length)
Given a DNS packet p, generate the corresponding UDP payload.
Definition dnsparser.c:1400
int GNUNET_DNSPARSER_builder_add_uri(char *dst, size_t dst_len, size_t *off, const struct GNUNET_DNSPARSER_UriRecord *uri)
Add an URI record to the UDP packet at the given location.
Definition dnsparser.c:1255
#define GNUNET_DNSPARSER_TYPE_MX
#define GNUNET_DNSPARSER_TYPE_TXT
struct GNUNET_DNSPARSER_Packet * GNUNET_DNSPARSER_parse(const char *udp_payload, size_t udp_payload_length)
Parse a UDP payload of a DNS packet in to a nice struct for further processing and manipulation.
Definition dnsparser.c:729
#define GNUNET_DNSPARSER_MAX_NAME_LENGTH
Maximum length of a name in DNS.
struct GNUNET_DNSSTUB_Context * GNUNET_DNSSTUB_start(unsigned int num_sockets)
Start a DNS stub resolver.
Definition dnsstub.c:586
int GNUNET_DNSSTUB_add_dns_ip(struct GNUNET_DNSSTUB_Context *ctx, const char *dns_ip)
Add nameserver for use by the DNSSTUB.
Definition dnsstub.c:613
void GNUNET_DNSSTUB_stop(struct GNUNET_DNSSTUB_Context *ctx)
Cleanup DNSSTUB resolver.
Definition dnsstub.c:705
struct GNUNET_DNSSTUB_RequestSocket * GNUNET_DNSSTUB_resolve(struct GNUNET_DNSSTUB_Context *ctx, const void *request, size_t request_len, GNUNET_DNSSTUB_ResultCallback rc, void *rc_cls)
Perform DNS resolution using our default IP from init.
Definition dnsstub.c:526
void GNUNET_DNSSTUB_resolve_cancel(struct GNUNET_DNSSTUB_RequestSocket *rs)
Cancel DNS resolution.
Definition dnsstub.c:562
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.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time).
#define GNUNET_GETOPT_OPTION_END
Marker for the end of the list of options.
enum GNUNET_GenericReturnValue GNUNET_GNSRECORD_data_from_identity(const struct GNUNET_CRYPTO_PublicKey *key, char **data, size_t *data_size, uint32_t *type)
Create record data and size from an identity key.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_NONE
Entry for no flags / cleared flags.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition crypto_hash.c:41
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_MultiHashMapIteratorCallback it, void *it_cls)
Iterate over all entries in the map.
void * GNUNET_CONTAINER_multihashmap_get(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Given a key find a value in the map matching the key.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_remove(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, const void *value)
Remove the given key-value pair from the map.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
unsigned int GNUNET_CONTAINER_multihashmap_size(const struct GNUNET_CONTAINER_MultiHashMap *map)
Get the number of key-value pairs in the map.
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
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.
void GNUNET_CONTAINER_heap_destroy(struct GNUNET_CONTAINER_Heap *heap)
Destroys the 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,...)
#define GNUNET_NZL(l)
Macro used to avoid using 0 for the length of a variable-size array (Non-Zero-Length).
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_key_get_public(const struct GNUNET_CRYPTO_PrivateKey *privkey, struct GNUNET_CRYPTO_PublicKey *key)
Retrieves the public key representation of a 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_PUBLIC_KEY_TYPE_EDDSA
EDDSA identity.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
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_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.
void GNUNET_NAMESTORE_cancel(struct GNUNET_NAMESTORE_QueueEntry *qe)
Cancel a namestore operation.
struct GNUNET_NAMESTORE_ZoneIterator * GNUNET_NAMESTORE_zone_iteration_start(struct GNUNET_NAMESTORE_Handle *h, const struct GNUNET_CRYPTO_PrivateKey *zone, GNUNET_SCHEDULER_TaskCallback error_cb, void *error_cb_cls, GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls, GNUNET_SCHEDULER_TaskCallback finish_cb, void *finish_cb_cls)
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_at(struct GNUNET_TIME_Absolute at, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run at the specified time.
Definition scheduler.c:1254
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_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_set(struct GNUNET_STATISTICS_Handle *handle, const char *name, uint64_t value, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition time.c:438
struct GNUNET_TIME_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
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
#define GNUNET_TIME_UNIT_DAYS
One day.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_subtract(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Subtract relative timestamp from the other.
Definition time.c:605
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition time.c:111
#define GNUNET_TIME_UNIT_WEEKS
One week.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition time.c:587
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition time.c:316
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
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_min(struct GNUNET_TIME_Absolute t1, struct GNUNET_TIME_Absolute t2)
Return the minimum of two absolute time values.
Definition time.c:360
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_divide(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Divide relative time by a given factor.
Definition time.c:552
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".
#define GNUNET_TUN_DNS_CLASS_INTERNET
A few common DNS classes (ok, only one is common, but I list a couple more to make it clear what we'r...
#define GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR
RFC 1035 codes.
#define _(String)
GNU gettext support macro.
Definition platform.h:179
static struct GNUNET_TIME_Relative delta
Definition speedup.c:36
Handle to a node in a heap.
Internal representation of the hash map.
A private key for an identity as per LSD0001.
An identity key as per LSD0001.
char * mxhost
Name of the mail server.
Easy-to-process, parsed version of a DNS packet.
void * data
Binary record data.
size_t data_len
Number of bytes in data.
A DNS response record.
struct GNUNET_DNSPARSER_SoaRecord * soa
SOA data for SOA records.
struct GNUNET_DNSPARSER_SrvRecord * srv
SRV data for SRV records.
struct GNUNET_DNSPARSER_MxRecord * mx
MX data for MX records.
char * hostname
For NS, CNAME and PTR records, this is the uncompressed 0-terminated hostname.
struct GNUNET_DNSPARSER_CertRecord * cert
CERT data for CERT records.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
struct GNUNET_TIME_Absolute expiration_time
When does the record expire?
char * name
Name of the record that the query is for (0-terminated).
struct GNUNET_DNSPARSER_RawRecord raw
Raw data for all other types.
union GNUNET_DNSPARSER_Record::@20 data
Payload of the record (which one of these is valid depends on the 'type').
struct GNUNET_DNSPARSER_UriRecord * uri
URI data for URI records.
Handle to the stub resolver.
Definition dnsstub.c:125
UDP socket we are using for sending DNS requests to the Internet.
Definition dnsstub.c:46
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.
Handle for a zone iterator operation.
Entry in list of pending tasks.
Definition scheduler.c:136
Handle for the service.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
unsigned int return_code
See GNUNET_TUN_DNS_RETURN_CODE_ defines.
struct GNUNET_TUN_DnsFlags flags
Flags.
uint16_t id
Unique identifier for the request/response.
Closure for check_for_glue.
struct Request * req
Overall request we are processing.
int found
Set to GNUNET_YES if glue was found.
const char * ns
NS name we are looking for glue for.
Missing identity creation context.
struct MissingZoneCreationCtx * prev
struct MissingZoneCreationCtx * next
struct GNUNET_IDENTITY_Operation * id_op
struct GNUNET_NAMESTORE_QueueEntry * ns_qe
Closure for process_record().
struct Request * req
Request we are processing.
struct GNUNET_DNSPARSER_Packet * p
Answer we got back and are currently parsing, or NULL if not active.
Record for the request to be stored by GNS.
struct GNUNET_GNSRECORD_Data grd
GNS record.
struct Record * next
Kept in a DLL.
struct Record * prev
Kept in a DLL.
Request we should make.
const struct Zone * zone
Zone responsible for this request.
struct GNUNET_TIME_Absolute expires
At what time does the (earliest) of the returned records for this name expire? At this point,...
char * hostname
Hostname we are resolving, allocated at the end of this struct (optimizing memory consumption by redu...
struct Request * next
Active requests are kept in a DLL.
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.
struct GNUNET_CONTAINER_HeapNode * hn
Requests are kept in a heap while waiting to be resolved.
struct GNUNET_DNSSTUB_RequestSocket * rs
Socket used to make the request, NULL if not active.
struct Record * rec_tail
Tail of records that should be published in GNS for this hostname.
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.
uint16_t id
random 16-bit DNS query identifier.
struct Request * prev
Active requests are kept in a DLL.
unsigned int issue_num
How often did we issue this query? (And failed, reset to zero once we were successful....
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.

◆ NS_BATCH_SIZE

#define NS_BATCH_SIZE   1024

How many requests do we request from NAMESTORE in one batch during our initial iteration?

Definition at line 82 of file gnunet-zoneimport.c.

Typedef Documentation

◆ RecordProcessor

typedef void(* RecordProcessor) (void *cls, const struct GNUNET_DNSPARSER_Record *rec)

Callback for for_all_records.

Parameters
clsclosure
reca DNS record

Definition at line 408 of file gnunet-zoneimport.c.

Function Documentation

◆ for_all_records()

static void for_all_records ( const struct GNUNET_DNSPARSER_Packet p,
RecordProcessor  rp,
void *  rp_cls 
)
static

Call rp for each record in p, regardless of what response section it is in.

Parameters
ppacket from DNS
rpfunction to call
rp_clsclosure for rp

Definition at line 421 of file gnunet-zoneimport.c.

424{
425 for (unsigned int i = 0; i < p->num_answers; i++)
426 {
427 struct GNUNET_DNSPARSER_Record *rs = &p->answers[i];
428
429 rp (rp_cls, rs);
430 }
431 for (unsigned int i = 0; i < p->num_authority_records; i++)
432 {
433 struct GNUNET_DNSPARSER_Record *rs = &p->authority_records[i];
434
435 rp (rp_cls, rs);
436 }
437 for (unsigned int i = 0; i < p->num_additional_records; i++)
438 {
439 struct GNUNET_DNSPARSER_Record *rs = &p->additional_records[i];
440
441 rp (rp_cls, rs);
442 }
443}

References p, and rp.

Referenced by process_record(), and process_result().

Here is the caller graph for this function:

◆ get_label()

static const char * get_label ( struct Request req)
static

Return just the label of the hostname in req.

Parameters
reqrequest to process hostname of
Returns
statically allocated pointer to the label, overwritten upon the next request!

Definition at line 454 of file gnunet-zoneimport.c.

455{
456 static char label[64];
457 const char *dot;
458
459 dot = strchr (req->hostname, (unsigned char) '.');
460 if (NULL == dot)
461 {
462 GNUNET_break (0);
463 return NULL;
464 }
465 if (((size_t) (dot - req->hostname)) >= sizeof(label))
466 {
467 GNUNET_break (0);
468 return NULL;
469 }
470 GNUNET_memcpy (label, req->hostname, dot - req->hostname);
471 label[dot - req->hostname] = '\0';
472
473 return label;
474}

References GNUNET_break, GNUNET_memcpy, and Request::hostname.

Referenced by get_label_utf8(), and ns_lookup_result_cb().

Here is the caller graph for this function:

◆ get_label_utf8()

static char * get_label_utf8 ( struct Request req)
static

Definition at line 478 of file gnunet-zoneimport.c.

479{
480 char *label_utf8;
481 const char *label_ace;
482
483 label_ace = get_label (req);
484 idna_to_unicode_8z8z (label_ace,
485 &label_utf8,
486 IDNA_ALLOW_UNASSIGNED);
487 return label_utf8;
488}

References get_label().

Referenced by process_result().

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

◆ build_dns_query()

static void * build_dns_query ( struct Request req,
size_t *  raw_size 
)
static

Build DNS query for hostname.

Parameters
hostnamehost to build query for
[out]raw_sizenumber of bytes in the query
Returns
NULL on error, otherwise pointer to statically (!) allocated query buffer

Definition at line 500 of file gnunet-zoneimport.c.

501{
502 static char raw[512];
503 char *name_ace;
504 char *rawp;
507 int ret;
508
509 if (IDNA_SUCCESS != idna_to_ascii_8z (req->hostname,
510 &name_ace,
511 IDNA_ALLOW_UNASSIGNED))
512 {
514 _ ("Name `%s' cannot be converted to IDNA."),
515 req->hostname);
516 return NULL;
517 }
518 q.name = (char *) name_ace;
520 q.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
521
522 memset (&p, 0, sizeof(p));
523 p.num_queries = 1;
524 p.queries = &q;
525 p.id = req->id;
526 ret = GNUNET_DNSPARSER_pack (&p, UINT16_MAX, &rawp, raw_size);
527 if (GNUNET_OK != ret)
528 {
529 if (GNUNET_NO == ret)
530 GNUNET_free (rawp);
532 "Failed to pack query for hostname `%s'\n",
533 name_ace);
534 rejects++;
535 GNUNET_free (name_ace);
536 return NULL;
537 }
538 if (*raw_size > sizeof(raw))
539 {
541 "Failed to pack query for hostname `%s'\n",
542 name_ace);
543 rejects++;
544 GNUNET_break (0);
545 GNUNET_free (name_ace);
546 GNUNET_free (rawp);
547 return NULL;
548 }
549 GNUNET_memcpy (raw, rawp, *raw_size);
550 GNUNET_free (rawp);
551 return raw;
552}

References _, GNUNET_break, GNUNET_DNSPARSER_pack(), GNUNET_DNSPARSER_TYPE_NS, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_TUN_DNS_CLASS_INTERNET, Request::hostname, Request::id, p, q, raw, rejects, and ret.

Referenced by process_queue().

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

◆ free_records()

static void free_records ( struct Request req)
static

Free records associated with req.

Parameters
reqrequest to free records of

Definition at line 561 of file gnunet-zoneimport.c.

562{
563 struct Record *rec;
564
565 /* Free records */
566 while (NULL != (rec = req->rec_head))
567 {
569 GNUNET_free (rec);
570 }
571}

References GNUNET_CONTAINER_DLL_remove, GNUNET_free, Request::rec_head, and Request::rec_tail.

Referenced by free_request(), ns_lookup_result_cb(), and store_completed_cb().

Here is the caller graph for this function:

◆ free_request()

static void free_request ( struct Request req)
static

Free req and data structures reachable from it.

Parameters
reqrequest to free

Definition at line 580 of file gnunet-zoneimport.c.

581{
582 free_records (req);
583 GNUNET_free (req);
584}

References free_records(), and GNUNET_free.

Referenced by do_shutdown(), free_request_it(), process_queue(), and process_result().

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

◆ process_queue()

static void process_queue ( void *  cls)
static

Process as many requests as possible from the queue.

Parameters
clsNULL

Definition at line 1278 of file gnunet-zoneimport.c.

1279{
1280 struct Request *req;
1281 unsigned int series;
1282 void *raw;
1283 size_t raw_size;
1284 struct GNUNET_TIME_Relative delay;
1285
1286 (void) cls;
1289 series = 0;
1290 t = NULL;
1291 while (pending + pending_rs < THRESH)
1292 {
1294 if (NULL == req)
1295 break;
1296 if (NULL != req->qe)
1297 return; /* namestore op still pending */
1298 if (NULL != req->rs)
1299 {
1300 GNUNET_break (0);
1301 return; /* already submitted */
1302 }
1304 break;
1306 req->hn = NULL;
1308 GNUNET_assert (NULL == req->rs);
1310 "Requesting resolution for `%s'\n",
1311 req->hostname);
1312 raw = build_dns_query (req, &raw_size);
1313 if (NULL == raw)
1314 {
1315 GNUNET_break (0);
1316 free_request (req);
1317 continue;
1318 }
1320 req->rs = GNUNET_DNSSTUB_resolve (dns_ctx, raw, raw_size, &process_result,
1321 req);
1322 GNUNET_assert (NULL != req->rs);
1323 req->issue_num++;
1324 lookups++;
1325 pending++;
1326 series++;
1327 if (series > MAX_SERIES)
1328 break;
1329 }
1330 if (pending + pending_rs >= THRESH)
1331 {
1333 "Stopped processing queue (%u+%u/%u)]\n",
1334 pending,
1335 pending_rs,
1336 THRESH);
1337 return; /* wait for replies */
1338 }
1340 if (NULL == req)
1341 {
1343 "Stopped processing queue: empty queue\n");
1344 return;
1345 }
1347 {
1349 "Waiting until %s for next record (`%s') to expire\n",
1351 req->hostname);
1352 if (NULL != t)
1356 return;
1357 }
1358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Throttling\n");
1359 if (NULL != t)
1363}

References build_dns_query(), dns_ctx, Request::expires, free_request(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_heap_peek(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_DNSSTUB_resolve(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_add(), Request::hn, Request::hostname, idle_time, Request::issue_num, lookups, MAX_SERIES, Request::op_start_time, pending, pending_rs, process_queue(), process_result(), Request::qe, raw, GNUNET_TIME_Relative::rel_value_us, req_head, req_heap, req_tail, Request::rs, SERIES_DELAY, sleep_time_reg_proc, t, and THRESH.

Referenced by insert_sorted(), process_queue(), process_result(), and store_completed_cb().

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

◆ insert_sorted()

static void insert_sorted ( struct Request req)
static

Insert req into DLL sorted by next fetch time.

Parameters
reqrequest to insert into req_heap

Definition at line 602 of file gnunet-zoneimport.c.

603{
604 req->hn =
607 {
608 if (NULL != t)
612 }
613}

References GNUNET_TIME_Absolute::abs_value_us, Request::expires, GNUNET_CONTAINER_heap_insert(), GNUNET_CONTAINER_heap_peek(), GNUNET_SCHEDULER_add_at(), GNUNET_SCHEDULER_cancel(), GNUNET_TIME_absolute_get(), Request::hn, process_queue(), req_heap, sleep_time_reg_proc, and t.

Referenced by move_to_queue(), ns_lookup_result_cb(), and process_result().

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

◆ add_record()

static void add_record ( struct Request req,
uint32_t  type,
struct GNUNET_TIME_Absolute  expiration_time,
const void *  data,
size_t  data_len 
)
static

Add record to the GNS record set for req.

Parameters
reqthe request to expand GNS record set for
typetype to use
expiration_timewhen should rec expire
dataraw data to store
data_lennumber of bytes in data

Definition at line 626 of file gnunet-zoneimport.c.

631{
632 struct Record *rec;
633
634 rec = GNUNET_malloc (sizeof(struct Record) + data_len);
635 rec->grd.data = &rec[1];
636 rec->grd.expiration_time = expiration_time.abs_value_us;
637 rec->grd.data_size = data_len;
638 rec->grd.record_type = type;
640 GNUNET_memcpy (&rec[1], data, data_len);
642}

References GNUNET_TIME_Absolute::abs_value_us, data, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_CONTAINER_DLL_insert, GNUNET_GNSRECORD_RF_NONE, GNUNET_malloc, GNUNET_memcpy, Record::grd, Request::rec_head, Request::rec_tail, GNUNET_GNSRECORD_Data::record_type, and type.

Referenced by check_for_glue(), ns_lookup_result_cb(), and process_record().

Here is the caller graph for this function:

◆ check_for_glue()

static void check_for_glue ( void *  cls,
const struct GNUNET_DNSPARSER_Record rec 
)
static

Try to find glue records for a given NS record.

Parameters
clsa struct GlueClosure *
recrecord that may contain glue information

Definition at line 674 of file gnunet-zoneimport.c.

675{
676 struct GlueClosure *gc = cls;
677 char dst[65536];
678 size_t rd_len;
679 char ip[INET6_ADDRSTRLEN + 1];
680 socklen_t ip_size = (socklen_t) sizeof(ip);
681 struct GNUNET_TIME_Absolute expiration_time;
682 struct GNUNET_TIME_Relative left;
683
684 if (0 != strcasecmp (rec->name, gc->ns))
685 return;
686 expiration_time = rec->expiration_time;
687 left = GNUNET_TIME_absolute_get_remaining (expiration_time);
688 if (0 == left.rel_value_us)
689 return; /* ignore expired glue records */
690 /* if expiration window is too short, bump it to configured minimum */
691 if (left.rel_value_us < minimum_expiration_time.rel_value_us)
692 expiration_time =
694 rd_len = 0;
695 switch (rec->type)
696 {
698 if (sizeof(struct in_addr) != rec->data.raw.data_len)
699 {
700 GNUNET_break (0);
701 return;
702 }
703 if (NULL == inet_ntop (AF_INET, rec->data.raw.data, ip, ip_size))
704 {
705 GNUNET_break (0);
706 return;
707 }
708 // NAME
709 GNUNET_memcpy (dst,
710 gc->req->hostname,
711 strlen (gc->req->hostname) + 1);
712 rd_len += strlen (gc->req->hostname) + 1;
713 // DNS SERVER NAME
714 GNUNET_memcpy (dst + strlen (gc->req->hostname) + 1,
715 ip,
716 strlen (ip) + 1);
717 rd_len += strlen (ip) + 1;
718 add_record (gc->req,
720 expiration_time,
721 dst,
722 rd_len);
723 gc->found = GNUNET_YES;
724 break;
725
727 if (sizeof(struct in6_addr) != rec->data.raw.data_len)
728 {
729 GNUNET_break (0);
730 return;
731 }
732 if (NULL == inet_ntop (AF_INET6, rec->data.raw.data, ip, ip_size))
733 {
734 GNUNET_break (0);
735 return;
736 }
737 // NAME
738 GNUNET_memcpy (dst,
739 gc->req->hostname,
740 strlen (gc->req->hostname) + 1);
741 rd_len += strlen (gc->req->hostname) + 1;
742 // DNS SERVER NAME
743 GNUNET_memcpy (dst + strlen (gc->req->hostname) + 1,
744 ip,
745 strlen (ip) + 1);
746 rd_len += strlen (ip) + 1;
747 add_record (gc->req,
749 expiration_time,
750 dst,
751 rd_len);
752 gc->found = GNUNET_YES;
753 break;
754
756 // NAME
757 GNUNET_memcpy (dst,
758 gc->req->hostname,
759 strlen (gc->req->hostname) + 1);
760 rd_len += strlen (gc->req->hostname) + 1;
761 // DNS SERVER NAME
762 GNUNET_memcpy (dst + strlen (gc->req->hostname) + 1,
763 rec->data.hostname,
764 strlen (rec->data.hostname) + 1);
765 rd_len += strlen (rec->data.hostname) + 1;
766 add_record (gc->req,
768 expiration_time,
769 dst,
770 rd_len);
771 gc->found = GNUNET_YES;
772 break;
773
774 default:
775 /* useless, do nothing */
776 break;
777 }
778}

References add_record(), GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_RawRecord::data_len, GNUNET_DNSPARSER_Record::expiration_time, GlueClosure::found, GNUNET_break, GNUNET_DNSPARSER_TYPE_A, GNUNET_DNSPARSER_TYPE_AAAA, GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_GNSRECORD_TYPE_GNS2DNS, GNUNET_memcpy, GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_to_absolute(), GNUNET_YES, Request::hostname, GNUNET_DNSPARSER_Record::hostname, minimum_expiration_time, GNUNET_DNSPARSER_Record::name, GlueClosure::ns, GNUNET_DNSPARSER_Record::raw, GNUNET_TIME_Relative::rel_value_us, GlueClosure::req, and GNUNET_DNSPARSER_Record::type.

Referenced by process_record().

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

◆ process_record()

static void process_record ( void *  cls,
const struct GNUNET_DNSPARSER_Record rec 
)
static

We received rec for req.

Remember the answer.

Parameters
clsa struct ProcessRecordContext
recresponse

Definition at line 806 of file gnunet-zoneimport.c.

807{
808 struct ProcessRecordContext *prc = cls;
809 struct Request *req = prc->req;
810 char dst[65536];
811 size_t dst_len;
812 size_t off;
813 struct GNUNET_TIME_Absolute expiration_time;
814 struct GNUNET_TIME_Relative left;
815
816 dst_len = sizeof(dst);
817 off = 0;
818 records++;
819 if (0 != strcasecmp (rec->name, req->hostname))
820 {
821 GNUNET_log (
823 "DNS returned record from zone `%s' of type %u while resolving `%s'\n",
824 rec->name,
825 (unsigned int) rec->type,
826 req->hostname);
827 return; /* does not match hostname, might be glue, but
828 not useful for this pass! */
829 }
830 expiration_time = rec->expiration_time;
831 left = GNUNET_TIME_absolute_get_remaining (expiration_time);
832 if (0 == left.rel_value_us)
833 {
835 "DNS returned expired record for `%s'\n",
836 req->hostname);
838 "# expired records obtained from DNS",
839 1,
840 GNUNET_NO);
841 return; /* record expired */
842 }
843
845 "DNS returned record that expires at %s for `%s'\n",
847 req->hostname);
848 /* if expiration window is too short, bump it to configured minimum */
849 if (left.rel_value_us < minimum_expiration_time.rel_value_us)
850 expiration_time =
852 switch (rec->type)
853 {
855 struct GlueClosure gc;
856
857 /* check for glue */
858 gc.req = req;
859 gc.ns = rec->data.hostname;
860 gc.found = GNUNET_NO;
861 for_all_records (prc->p, &check_for_glue, &gc);
862 if (GNUNET_NO == gc.found)
863 {
864 // NAME
865 GNUNET_memcpy (dst,
866 req->hostname,
867 strlen (req->hostname) + 1);
868 off += strlen (req->hostname) + 1;
869 // DNS SERVER NAME
870 GNUNET_memcpy (dst + strlen (req->hostname) + 1,
871 rec->data.hostname,
872 strlen (rec->data.hostname) + 1);
873 off += strlen (rec->data.hostname) + 1;
874 /* FIXME: actually check if this is out-of-bailiwick,
875 and if not request explicit resolution... */
877 "Converted OOB (`%s') NS record for `%s'\n",
878 rec->data.hostname,
879 rec->name);
882 expiration_time,
883 dst,
884 off);
885 }
886 else
887 {
889 "Converted NS record for `%s' using glue\n",
890 rec->name);
891 }
892 break;
893 }
894
897 dst_len,
898 &off,
899 rec->data.hostname))
900 {
902 "Converting CNAME (`%s') record for `%s'\n",
903 rec->data.hostname,
904 rec->name);
905 add_record (req, rec->type, expiration_time, dst, off);
906 }
907 break;
908
910 /* No support for DNAME in GNS yet! FIXME: support later! */
912 "FIXME: not supported: %s DNAME %s\n",
913 rec->name,
914 rec->data.hostname);
915 break;
916
918 if (GNUNET_OK ==
919 GNUNET_DNSPARSER_builder_add_mx (dst, dst_len, &off, rec->data.mx))
920 {
922 "Converting MX (`%s') record for `%s'\n",
923 rec->data.mx->mxhost,
924 rec->name);
925 add_record (req, rec->type, expiration_time, dst, off);
926 }
927 break;
928
930 if (GNUNET_OK ==
931 GNUNET_DNSPARSER_builder_add_soa (dst, dst_len, &off, rec->data.soa))
932 {
933 /* NOTE: GNS does not really use SOAs */
935 "Converting SOA record for `%s'\n",
936 rec->name);
937 add_record (req, rec->type, expiration_time, dst, off);
938 }
939 break;
940
942 if (GNUNET_OK ==
943 GNUNET_DNSPARSER_builder_add_srv (dst, dst_len, &off, rec->data.srv))
944 {
946 "Converting SRV record for `%s'\n",
947 rec->name);
948 add_record (req, rec->type, expiration_time, dst, off);
949 }
950 break;
951
953 if (GNUNET_OK ==
954 GNUNET_DNSPARSER_builder_add_uri (dst, dst_len, &off, rec->data.uri))
955 {
957 "Converting URI record for `%s'\n",
958 rec->name);
959 add_record (req, rec->type, expiration_time, dst, off);
960 }
961 break;
962
965 dst_len,
966 &off,
967 rec->data.hostname))
968 {
969 /* !?: what does a PTR record do in a regular TLD??? */
971 "Converting PTR record for `%s' (weird)\n",
972 rec->name);
973 add_record (req, rec->type, expiration_time, dst, off);
974 }
975 break;
976
978 if (GNUNET_OK ==
979 GNUNET_DNSPARSER_builder_add_cert (dst, dst_len, &off, rec->data.cert))
980 {
982 "Converting CERT record for `%s'\n",
983 rec->name);
984 add_record (req, rec->type, expiration_time, dst, off);
985 }
986 break;
987
988 /* Rest is 'raw' encoded and just needs to be copied IF
989 the hostname matches the requested name; otherwise we
990 simply cannot use it. */
994 default:
996 "Converting record of type %u for `%s'\n",
997 (unsigned int) rec->type,
998 rec->name);
1000 rec->type,
1001 expiration_time,
1002 rec->data.raw.data,
1003 rec->data.raw.data_len);
1004 break;
1005 }
1006}

References add_record(), GNUNET_DNSPARSER_Record::cert, check_for_glue(), GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_RawRecord::data_len, GNUNET_DNSPARSER_Record::expiration_time, for_all_records(), GlueClosure::found, GNUNET_DNSPARSER_builder_add_cert(), GNUNET_DNSPARSER_builder_add_mx(), GNUNET_DNSPARSER_builder_add_name(), GNUNET_DNSPARSER_builder_add_soa(), GNUNET_DNSPARSER_builder_add_srv(), GNUNET_DNSPARSER_builder_add_uri(), GNUNET_DNSPARSER_TYPE_A, GNUNET_DNSPARSER_TYPE_AAAA, GNUNET_DNSPARSER_TYPE_CERT, GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSPARSER_TYPE_DNAME, GNUNET_DNSPARSER_TYPE_MX, GNUNET_DNSPARSER_TYPE_NS, GNUNET_DNSPARSER_TYPE_PTR, GNUNET_DNSPARSER_TYPE_SOA, GNUNET_DNSPARSER_TYPE_SRV, GNUNET_DNSPARSER_TYPE_TXT, GNUNET_DNSPARSER_TYPE_URI, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_GNSRECORD_TYPE_GNS2DNS, GNUNET_log, GNUNET_memcpy, GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_get_remaining(), GNUNET_TIME_relative_to_absolute(), Request::hostname, GNUNET_DNSPARSER_Record::hostname, minimum_expiration_time, GNUNET_DNSPARSER_Record::mx, GNUNET_DNSPARSER_MxRecord::mxhost, GNUNET_DNSPARSER_Record::name, GlueClosure::ns, ProcessRecordContext::p, GNUNET_DNSPARSER_Record::raw, records, GNUNET_TIME_Relative::rel_value_us, GlueClosure::req, ProcessRecordContext::req, GNUNET_DNSPARSER_Record::soa, GNUNET_DNSPARSER_Record::srv, stats, GNUNET_DNSPARSER_Record::type, and GNUNET_DNSPARSER_Record::uri.

Referenced by process_result().

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

◆ store_completed_cb()

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

Definition at line 1010 of file gnunet-zoneimport.c.

1011{
1012 static struct GNUNET_TIME_Absolute last;
1013 struct Request *req = cls;
1014
1015 req->qe = NULL;
1016 if (GNUNET_EC_NONE != ec)
1017 {
1019 "Failed to store zone data for `%s': %s\n",
1020 req->hostname,
1022 }
1023 else
1024 {
1026 "Stored records under `%s' (%d)\n",
1027 req->hostname,
1028 ec);
1029 }
1030 total_reg_proc_dns_ns++; /* finished regular processing */
1031 pending_rs--;
1032 free_records (req);
1033 /* compute NAMESTORE statistics */
1034 {
1035 static uint64_t total_ns_latency_cnt;
1036 static struct GNUNET_TIME_Relative total_ns_latency;
1037 struct GNUNET_TIME_Relative ns_latency;
1038
1040 total_ns_latency = GNUNET_TIME_relative_add (total_ns_latency, ns_latency);
1041 if (0 == total_ns_latency_cnt)
1042 last = GNUNET_TIME_absolute_get ();
1043 total_ns_latency_cnt++;
1044 if (0 == (total_ns_latency_cnt % 1000))
1045 {
1047 struct GNUNET_TIME_Relative est_remaining;
1048
1050 last = GNUNET_TIME_absolute_get ();
1051 est_remaining = GNUNET_TIME_relative_multiply (
1052 delta,
1053 (stdin_lines_read - total_ns_latency_cnt) / 1000);
1054 fprintf (stderr,
1055 "Processed 1000 records in %s. ",
1057 fprintf (stderr,
1058 "Estimated remaining time: %s. ",
1060 est_remaining,
1061 GNUNET_YES));
1062 fprintf (stderr,
1063 "Last domain processed: %s\n",
1064 req->hostname);
1066 "# average NAMESTORE PUT latency (μs)",
1067 total_ns_latency.rel_value_us
1068 / total_ns_latency_cnt,
1069 GNUNET_NO);
1070 }
1071 }
1072 /* compute and publish overall velocity */
1073 if (0 == (total_reg_proc_dns_ns % 100))
1074 {
1075 struct GNUNET_TIME_Relative runtime;
1076
1078 runtime = GNUNET_TIME_relative_subtract (runtime, idle_time);
1079 runtime =
1083 "# Regular processing completed without NAMESTORE",
1085 GNUNET_NO);
1087 "# Regular processing completed with NAMESTORE PUT",
1089 GNUNET_NO);
1091 "# average request processing latency (μs)",
1092 runtime.rel_value_us,
1093 GNUNET_NO);
1095 "# total time spent idle (μs)",
1097 GNUNET_NO);
1098 }
1099
1100 if (NULL == t)
1101 {
1104 }
1105}

References delta, free_records(), GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ErrorCode_get_hint(), GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_add(), GNUNET_TIME_relative_divide(), GNUNET_TIME_relative_multiply(), GNUNET_TIME_relative_subtract(), GNUNET_YES, Request::hostname, idle_time, Request::op_start_time, pending_rs, process_queue(), Request::qe, GNUNET_TIME_Relative::rel_value_us, sleep_time_reg_proc, start_time_reg_proc, stats, stdin_lines_read, t, total_reg_proc_dns, and total_reg_proc_dns_ns.

Referenced by process_result().

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

◆ process_result()

static void process_result ( void *  cls,
const struct GNUNET_TUN_DnsHeader dns,
size_t  dns_len 
)
static

Function called with the result of a DNS resolution.

Parameters
clsclosure with the struct Request
dnsdns response, never NULL
dns_lennumber of bytes in dns

Definition at line 1116 of file gnunet-zoneimport.c.

1119{
1120 struct Request *req = cls;
1121 struct Record *rec;
1122 struct GNUNET_DNSPARSER_Packet *p;
1123 unsigned int rd_count;
1124
1125 GNUNET_assert (NULL == req->hn);
1126 if ((NULL == dns) ||
1128 {
1129 /* stub gave up */
1131 if (NULL != dns)
1132 {
1134 req->rs = NULL;
1135 }
1136 pending--;
1137 if (NULL == t)
1138 {
1141 }
1143 "Stub gave up on DNS reply for `%s'\n",
1144 req->hostname);
1145 GNUNET_STATISTICS_update (stats, "# Unsuccessful DNS lookups", 1, GNUNET_NO)
1146 ;
1147 if (req->issue_num > MAX_RETRIES)
1148 {
1149 failures++;
1150 free_request (req);
1151 GNUNET_STATISTICS_update (stats, "# DNS requests given up on", 1,
1152 GNUNET_NO);
1153 return;
1154 }
1156 req->rs = NULL;
1157 insert_sorted (req);
1158 return;
1159 }
1160 if (req->id != dns->id)
1161 {
1163 "DNS ID did not match request, ignoring reply\n");
1164 GNUNET_STATISTICS_update (stats, "# DNS ID mismatches", 1, GNUNET_NO);
1165 return;
1166 }
1169 req->rs = NULL;
1170 pending--;
1171 p = GNUNET_DNSPARSER_parse ((const char *) dns, dns_len);
1172 if (NULL == p)
1173 {
1175 "Failed to parse DNS reply for `%s'\n",
1176 req->hostname);
1177 GNUNET_STATISTICS_update (stats, "# DNS parser errors", 1, GNUNET_NO);
1178 if (NULL == t)
1179 {
1182 }
1183 if (req->issue_num > MAX_RETRIES)
1184 {
1185 failures++;
1186 free_request (req);
1187 GNUNET_STATISTICS_update (stats, "# requests given up on", 1, GNUNET_NO);
1188 return;
1189 }
1190 insert_sorted (req);
1191 return;
1192 }
1193 /* import new records */
1194 req->issue_num = 0; /* success, reset counter! */
1195 {
1196 struct ProcessRecordContext prc = { .req = req, .p = p };
1197
1199 }
1201 /* count records found, determine minimum expiration time */
1203 {
1204 struct GNUNET_TIME_Relative dns_latency;
1205
1210 if (0 == (total_dns_latency_cnt % 1000))
1211 {
1213 "# average DNS lookup latency (μs)",
1216 GNUNET_NO);
1217 }
1218 }
1219 rd_count = 0;
1220 for (rec = req->rec_head; NULL != rec; rec = rec->next)
1221 {
1222 struct GNUNET_TIME_Absolute at;
1223
1225 req->expires = GNUNET_TIME_absolute_min (req->expires, at);
1226 rd_count++;
1227 }
1229 "Obtained %u records for `%s'\n",
1230 rd_count,
1231 req->hostname);
1232 /* Instead of going for SOA, simplified for now to look each
1233 day in case we got an empty response */
1234 if (0 == rd_count)
1235 {
1238 "# empty DNS replies (usually NXDOMAIN)",
1239 1,
1240 GNUNET_NO);
1241 }
1242 else
1243 {
1244 record_sets++;
1245 }
1246 /* convert records to namestore import format */
1247 {
1249 unsigned int off = 0;
1250 char *label_utf8 = get_label_utf8 (req);
1251
1252 /* convert linked list into array */
1253 for (rec = req->rec_head; NULL != rec; rec = rec->next)
1254 rd[off++] = rec->grd;
1255 pending_rs++;
1258 &req->zone->key,
1259 label_utf8,
1260 rd_count,
1261 rd,
1263 req);
1264 GNUNET_free (label_utf8);
1265 GNUNET_assert (NULL != req->qe);
1266 }
1267 insert_sorted (req);
1268 return;
1269}

References GNUNET_TIME_Absolute::abs_value_us, GNUNET_GNSRECORD_Data::expiration_time, Request::expires, failures, GNUNET_TUN_DnsHeader::flags, for_all_records(), free_request(), get_label_utf8(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_DNSPARSER_free_packet(), GNUNET_DNSPARSER_parse(), GNUNET_DNSSTUB_resolve_cancel(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_log, GNUNET_NAMESTORE_record_set_store(), GNUNET_NO, GNUNET_NZL, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_absolute_min(), GNUNET_TIME_relative_add(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_DAYS, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR, Record::grd, Request::hn, Request::hostname, Request::id, GNUNET_TUN_DnsHeader::id, insert_sorted(), Request::issue_num, Zone::key, MAX_RETRIES, Record::next, ns, Request::op_start_time, p, pending, pending_rs, process_queue(), process_record(), Request::qe, rd, rd_count, Request::rec_head, record_sets, GNUNET_TIME_Relative::rel_value_us, ProcessRecordContext::req, req_head, req_tail, GNUNET_TUN_DnsFlags::return_code, Request::rs, sleep_time_reg_proc, stats, store_completed_cb(), t, total_dns_latency, total_dns_latency_cnt, total_reg_proc_dns, and Request::zone.

Referenced by process_queue().

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

◆ free_request_it()

static int free_request_it ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

Iterator called during do_shutdown() to free requests in the ns_pending map.

Parameters
clsNULL
keyunused
valuethe struct Request to free
Returns
GNUNET_OK

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

1377{
1378 struct Request *req = value;
1379
1380 (void) cls;
1381 (void) key;
1382 free_request (req);
1383 return GNUNET_OK;
1384}

References free_request(), GNUNET_OK, key, and value.

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

Clean up and terminate the process.

Parameters
clsNULL

Definition at line 1393 of file gnunet-zoneimport.c.

1394{
1395 struct Request *req;
1396 struct Zone *zone;
1397 struct MissingZoneCreationCtx *mzctx;
1398
1399 (void) cls;
1400 while (NULL != (mzctx = missing_zones_head))
1401 {
1404 mzctx);
1405 if (NULL != mzctx->id_op)
1406 {
1408 mzctx->id_op = NULL;
1409 }
1410 if (NULL != mzctx->ns_qe)
1411 {
1413 mzctx->ns_qe = NULL;
1414 }
1415 GNUNET_free (mzctx);
1416 }
1417 if (NULL != id)
1418 {
1420 id = NULL;
1421 }
1422 if (NULL != t)
1423 {
1425 t = NULL;
1426 }
1427 while (NULL != (req = req_head))
1428 {
1430 if (NULL != req->qe)
1432 free_request (req);
1433 }
1434 while (NULL != (req = GNUNET_CONTAINER_heap_remove_root (req_heap)))
1435 {
1436 req->hn = NULL;
1437 if (NULL != req->qe)
1439 free_request (req);
1440 }
1441 if (NULL != zone_it)
1442 {
1444 zone_it = NULL;
1445 }
1446 if (NULL != ns)
1447 {
1449 ns = NULL;
1450 }
1451 if (NULL != dns_ctx)
1452 {
1454 dns_ctx = NULL;
1455 }
1456 if (NULL != req_heap)
1457 {
1459 req_heap = NULL;
1460 }
1461 if (NULL != ns_pending)
1462 {
1465 ns_pending = NULL;
1466 }
1467 while (NULL != (zone = zone_head))
1468 {
1470 GNUNET_free (zone->domain);
1471 GNUNET_free (zone);
1472 }
1473 if (NULL != stats)
1474 {
1476 stats = NULL;
1477 }
1478}

References dns_ctx, Zone::domain, free_request(), free_request_it(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_heap_destroy(), GNUNET_CONTAINER_heap_remove_root(), GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_DNSSTUB_stop(), GNUNET_free, GNUNET_IDENTITY_cancel(), GNUNET_IDENTITY_disconnect(), GNUNET_NAMESTORE_cancel(), GNUNET_NAMESTORE_disconnect(), GNUNET_NAMESTORE_zone_iteration_stop(), GNUNET_NO, GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_destroy(), Request::hn, MissingZoneCreationCtx::id_op, missing_zones_head, missing_zones_tail, ns, ns_pending, MissingZoneCreationCtx::ns_qe, Request::qe, MissingZoneCreationCtx::req, req_head, req_heap, req_tail, stats, t, zone_head, zone_it, and zone_tail.

Here is the call graph for this function:

◆ iterate_zones()

static void iterate_zones ( void *  cls)
static

Iterate over all of the zones we care about and see which records we may need to re-fetch when.

Parameters
clsNULL

Definition at line 1869 of file gnunet-zoneimport.c.

1870{
1871 static struct Zone *last;
1872
1873 (void) cls;
1874 if (NULL != zone_it)
1875 {
1876 zone_it = NULL;
1878 "Finished iteration over zone `%s'!\n",
1879 last->domain);
1880 /* subtract left-overs from previous iteration */
1882 "# NAMESTORE records requested from cache",
1883 (long long) (-ns_iterator_trigger_next),
1884 GNUNET_NO);
1886 }
1887 GNUNET_assert (NULL != zone_tail);
1888 if (zone_tail == last)
1889 {
1890 /* Done iterating over relevant zones in NAMESTORE, move
1891 rest of hash map to work queue as well. */
1893 "Finished all NAMESTORE iterations!\n");
1895 "# Domain names without cached reply",
1897 GNUNET_NO);
1900 ns_pending = NULL;
1904 return;
1905 }
1906 if (NULL == last)
1907 last = zone_head;
1908 else
1909 last = last->next;
1911 "Starting iteration over zone `%s'!\n",
1912 last->domain);
1913 /* subtract left-overs from previous iteration */
1915 "# NAMESTORE records requested from cache",
1916 1,
1917 GNUNET_NO);
1919 GNUNET_STATISTICS_update (stats, "# zones iterated", 1, GNUNET_NO);
1921 &last->key,
1923 NULL,
1925 last,
1927 NULL);
1928}

References Zone::domain, GNUNET_assert, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NAMESTORE_zone_iteration_start(), GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_STATISTICS_update(), GNUNET_TIME_absolute_get(), iterate_zones(), Zone::key, move_to_queue(), Zone::next, ns, ns_iterator_trigger_next, ns_lookup_error_cb(), ns_lookup_result_cb(), ns_pending, start_time_reg_proc, stats, total_reg_proc_dns, total_reg_proc_dns_ns, zone_head, zone_it, and zone_tail.

Referenced by delegation_store_cont(), iterate_zones(), ns_lookup_error_cb(), and process_stdin().

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

◆ ns_lookup_error_cb()

static void ns_lookup_error_cb ( void *  cls)
static

Function called if GNUNET_NAMESTORE_records_lookup() failed.

Just logs an error.

Parameters
clsa struct Zone

Definition at line 1498 of file gnunet-zoneimport.c.

1499{
1500 struct Zone *zone = cls;
1501
1503 "Failed to load data from namestore for zone `%s'\n",
1504 zone->domain);
1505 zone_it = NULL;
1507 iterate_zones (NULL);
1508}

References Zone::domain, GNUNET_ERROR_TYPE_INFO, GNUNET_log, iterate_zones(), ns_iterator_trigger_next, and zone_it.

Referenced by iterate_zones().

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

◆ ns_lookup_result_cb()

static void ns_lookup_result_cb ( void *  cls,
const struct GNUNET_CRYPTO_PrivateKey key,
const char *  label_utf8,
unsigned int  rd_count,
const struct GNUNET_GNSRECORD_Data rd 
)
static

Process a record that was stored in the namestore.

Parameters
clsa struct Zone *
keyprivate key of the zone
labellabel of the records
rd_countnumber of entries in rd array, 0 if label was deleted
rdarray of records with data to store

Definition at line 1521 of file gnunet-zoneimport.c.

1526{
1527 struct Zone *zone = cls;
1528 struct Request *req;
1529 struct GNUNET_HashCode hc;
1530 char *label_ace;
1531 char *fqdn;
1532
1534 if (0 == ns_iterator_trigger_next)
1535 {
1538 "# NAMESTORE records requested from cache",
1540 GNUNET_NO);
1542 }
1543 if (IDNA_SUCCESS != idna_to_ascii_8z (label_utf8,
1544 &label_ace,
1545 IDNA_ALLOW_UNASSIGNED))
1546 {
1548 _ ("Name `%s' cannot be converted to IDNA."),
1549 label_utf8);
1550 return;
1551 }
1553 "Obtained NAMESTORE reply for %s (Punycode `%s', %llu left in round\n",
1554 label_utf8,
1555 label_ace,
1556 (unsigned long long) ns_iterator_trigger_next);
1557
1558 GNUNET_asprintf (&fqdn, "%s.%s", label_ace, zone->domain);
1559 GNUNET_CRYPTO_hash (fqdn, strlen (fqdn) + 1, &hc);
1560 GNUNET_free (fqdn);
1562 if (NULL == req)
1563 {
1565 "Ignoring record `%s' in zone `%s': not on my list!\n",
1566 label_ace,
1567 zone->domain);
1568 GNUNET_free (label_ace);
1569 return;
1570 }
1573 GNUNET_break (0 == GNUNET_memcmp (key, &req->zone->key));
1574 GNUNET_break (0 == strcasecmp (label_ace, get_label (req)));
1575 GNUNET_free (label_ace);
1576 for (unsigned int i = 0; i < rd_count; i++)
1577 {
1578 struct GNUNET_TIME_Absolute at;
1579
1581 {
1582 struct GNUNET_TIME_Relative rel;
1583
1586 }
1587 else
1588 {
1589 at.abs_value_us = rd->expiration_time;
1590 }
1591 add_record (req, rd->record_type, at, rd->data, rd->data_size);
1592 }
1593 if (0 == rd_count)
1594 {
1596 "Empty record set in namestore for `%s'\n",
1597 req->hostname);
1598 }
1599 else
1600 {
1601 unsigned int pos = 0;
1602
1603 cached++;
1605 for (struct Record *rec = req->rec_head; NULL != rec; rec = rec->next)
1606 {
1607 struct GNUNET_TIME_Absolute at;
1608
1609 at.abs_value_us = rec->grd.expiration_time;
1610 req->expires = GNUNET_TIME_absolute_min (req->expires, at);
1611 pos++;
1612 }
1613 if (0 == pos)
1616 "Hot-start with %u existing records for `%s'\n",
1617 pos,
1618 req->hostname);
1619 }
1620 free_records (req);
1621
1623 "Adding `%s' to worklist to start at %s\n",
1624 req->hostname,
1626 insert_sorted (req);
1627}

References _, GNUNET_TIME_Absolute::abs_value_us, add_record(), cached, GNUNET_GNSRECORD_Data::data, GNUNET_GNSRECORD_Data::data_size, Zone::domain, GNUNET_GNSRECORD_Data::expiration_time, Request::expires, GNUNET_GNSRECORD_Data::flags, free_records(), get_label(), GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_remove(), GNUNET_CRYPTO_hash(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_log, GNUNET_memcmp, GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_NO, GNUNET_OK, GNUNET_STATISTICS_update(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute_min(), GNUNET_TIME_relative_to_absolute(), GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_ZERO_ABS, Request::hostname, insert_sorted(), key, Zone::key, NS_BATCH_SIZE, ns_iterator_trigger_next, ns_pending, rd, rd_count, Request::rec_head, GNUNET_GNSRECORD_Data::record_type, GNUNET_TIME_Relative::rel_value_us, stats, Request::zone, and zone_it.

Referenced by iterate_zones().

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

◆ delegation_store_cont()

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

Definition at line 1631 of file gnunet-zoneimport.c.

1633{
1634 struct MissingZoneCreationCtx *mzctx = cls;
1635
1636 mzctx->ns_qe = NULL;
1637 if (GNUNET_EC_NONE != ec)
1638 {
1640 "Failed to store delegation: `%s'\n",
1643 return;
1644 }
1646 "Added delegation successfully\n");
1649 mzctx);
1650 GNUNET_free (mzctx);
1651 if (NULL == missing_zones_head)
1652 {
1653 iterate_zones (NULL);
1654 }
1655
1656}

References GNUNET_CONTAINER_DLL_remove, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ErrorCode_get_hint(), GNUNET_free, GNUNET_log, GNUNET_SCHEDULER_shutdown(), iterate_zones(), missing_zones_head, missing_zones_tail, and MissingZoneCreationCtx::ns_qe.

Referenced by missing_zone_creation_cont().

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

◆ missing_zone_creation_cont()

static void missing_zone_creation_cont ( void *  cls,
const struct GNUNET_CRYPTO_PrivateKey sk,
enum GNUNET_ErrorCode  ec 
)
static

Definition at line 1660 of file gnunet-zoneimport.c.

1664{
1665 struct MissingZoneCreationCtx *mzctx = cls;
1667 struct Zone *parent_zone;
1668 struct Zone *zone;
1669 const char *dot;
1670 const char *expected_parent_zone_name;
1671 char parent_delegation_label[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
1672
1673 if (GNUNET_EC_NONE != ec)
1674 {
1676 "Failed to create zone for `%s': %s\n",
1677 mzctx->req->hostname,
1680 return;
1681 }
1682 mzctx->id_op = NULL;
1683 dot = strchr (mzctx->req->hostname, (unsigned char) '.');
1685 "Created missing ego `%s'\n",
1686 dot + 1);
1687 zone = GNUNET_new (struct Zone);
1688 zone->key = *sk;
1689 zone->domain = GNUNET_strdup (dot + 1);
1690 mzctx->req->zone = zone;
1692
1693 expected_parent_zone_name = strchr (dot + 1,
1694 (unsigned char) '.');
1695 if (NULL == expected_parent_zone_name)
1696 {
1698 "Created identity without parent zone!\n");
1700 return;
1701 }
1702 {
1703 int label_len = strlen (dot + 1) - strlen (expected_parent_zone_name) + 1;
1704 snprintf (parent_delegation_label,
1705 label_len,
1706 "%s",
1707 dot + 1);
1708 parent_delegation_label[label_len] = '\0';
1709 }
1710 for (parent_zone = zone_head;
1711 NULL != parent_zone;
1712 parent_zone = parent_zone->next)
1713 {
1714 if (0 != strcmp (expected_parent_zone_name + 1,
1715 parent_zone->domain))
1716 continue;
1717 break;
1718 }
1719 GNUNET_assert (NULL != parent_zone);
1721 struct GNUNET_GNSRECORD_Data delegation_rd;
1722 char *data;
1723 size_t data_size;
1726 &data,
1727 &data_size,
1728 &delegation_rd.record_type
1729 ));
1730 delegation_rd.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
1731 delegation_rd.expiration_time = GNUNET_TIME_UNIT_WEEKS.rel_value_us;
1732 delegation_rd.data = data;
1733 delegation_rd.data_size = data_size;
1735 &parent_zone->key,
1736 parent_delegation_label,
1737 1,
1738 &delegation_rd,
1740 mzctx);
1741 GNUNET_free (data);
1742}

References data, GNUNET_GNSRECORD_Data::data, data_size, GNUNET_GNSRECORD_Data::data_size, delegation_store_cont(), Zone::domain, GNUNET_GNSRECORD_Data::expiration_time, GNUNET_GNSRECORD_Data::flags, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_key_get_public(), GNUNET_DNSPARSER_MAX_NAME_LENGTH, GNUNET_EC_NONE, GNUNET_ERROR_TYPE_ERROR, GNUNET_ErrorCode_get_hint(), GNUNET_free, GNUNET_GNSRECORD_data_from_identity(), GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, GNUNET_log, GNUNET_NAMESTORE_record_set_store(), GNUNET_new, GNUNET_OK, GNUNET_SCHEDULER_shutdown(), GNUNET_strdup, GNUNET_TIME_UNIT_WEEKS, Request::hostname, MissingZoneCreationCtx::id_op, Zone::key, Zone::next, ns, MissingZoneCreationCtx::ns_qe, pk, GNUNET_GNSRECORD_Data::record_type, MissingZoneCreationCtx::req, Request::zone, zone_head, and zone_tail.

Referenced by queue().

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

◆ queue()

static void queue ( const char *  hostname)
static

Add hostname to the list of requests to be made.

Parameters
hostnamename to resolve

Definition at line 1751 of file gnunet-zoneimport.c.

1752{
1753 struct Request *req;
1754 const char *dot;
1755 struct Zone *zone;
1756 size_t hlen;
1757 struct GNUNET_HashCode hc;
1758
1759 if (GNUNET_OK != GNUNET_DNSPARSER_check_name (hostname))
1760 {
1762 "Refusing invalid hostname `%s'\n",
1763 hostname);
1764 rejects++;
1765 return;
1766 }
1767 dot = strchr (hostname, (unsigned char) '.');
1768 if (NULL == dot)
1769 {
1771 "Refusing invalid hostname `%s' (lacks '.')\n",
1772 hostname);
1773 rejects++;
1774 return;
1775 }
1776 for (zone = zone_head; NULL != zone; zone = zone->next)
1777 if (0 == strcmp (zone->domain, dot + 1))
1778 break;
1779 hlen = strlen (hostname) + 1;
1780 req = GNUNET_malloc (sizeof(struct Request) + hlen);
1781 if (NULL == zone)
1782 {
1783 struct MissingZoneCreationCtx *mzctx;
1784
1785 for (mzctx = missing_zones_head;
1786 NULL != mzctx;
1787 mzctx = mzctx->next)
1788 {
1789 const char *tmp_dot;
1790 tmp_dot = strchr (mzctx->req->hostname, (unsigned char) '.');
1791 GNUNET_assert (NULL != tmp_dot);
1792 if (0 != strcmp (dot + 1, tmp_dot + 1))
1793 continue;
1794 break;
1795 }
1796 if (NULL == mzctx)
1797 {
1799 "Domain name `%s' not in ego list! Creating.\n",
1800 dot + 1);
1801 mzctx = GNUNET_new (struct MissingZoneCreationCtx);
1802 mzctx->id_op = GNUNET_IDENTITY_create (id,
1803 dot + 1,
1804 NULL,
1807 mzctx);
1808 mzctx->req = req;
1811 mzctx);
1812 }
1813 }
1814 else
1815 {
1816 req->zone = zone;
1817 }
1818
1819 req->hostname = (char *) &req[1];
1820 GNUNET_memcpy (req->hostname, hostname, hlen);
1822 UINT16_MAX);
1823 GNUNET_CRYPTO_hash (req->hostname, hlen, &hc);
1825 ns_pending,
1826 &hc,
1827 req,
1829 {
1831 "Duplicate hostname `%s' ignored\n",
1832 hostname);
1833 GNUNET_free (req);
1834 return;
1835 }
1836}

References Zone::domain, GNUNET_assert, GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CRYPTO_hash(), GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_DNSPARSER_check_name(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_IDENTITY_create(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_new, GNUNET_OK, GNUNET_PUBLIC_KEY_TYPE_EDDSA, Request::hostname, Request::id, MissingZoneCreationCtx::id_op, missing_zone_creation_cont(), missing_zones_head, missing_zones_tail, Zone::next, MissingZoneCreationCtx::next, ns_pending, rejects, MissingZoneCreationCtx::req, Request::zone, and zone_head.

Referenced by process_stdin().

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

◆ move_to_queue()

static int move_to_queue ( void *  cls,
const struct GNUNET_HashCode key,
void *  value 
)
static

We have completed the initial iteration over the namestore's database.

This function is called on each of the remaining records in move_to_queue to queue() them, as we will simply not find existing records for them any longer.

Parameters
clsNULL
keyunused
valuea struct Request
Returns
GNUNET_OK (continue to iterate)

Definition at line 1851 of file gnunet-zoneimport.c.

1852{
1853 struct Request *req = value;
1854
1855 (void) cls;
1856 (void) key;
1857 insert_sorted (req);
1858 return GNUNET_OK;
1859}

References GNUNET_OK, insert_sorted(), key, and value.

Referenced by iterate_zones().

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

◆ process_stdin()

static void process_stdin ( void *  cls)
static

Begin processing hostnames from stdin.

Parameters
clsNULL

Definition at line 1937 of file gnunet-zoneimport.c.

1938{
1939 static struct GNUNET_TIME_Absolute last;
1940 char hn[256];
1941 char *hn_utf8;
1942
1943 (void) cls;
1944 t = NULL;
1945 while (NULL != fgets (hn, sizeof(hn), stdin))
1946 {
1947 if (strlen (hn) > 0)
1948 hn[strlen (hn) - 1] = '\0'; /* eat newline */
1949 if (0 == stdin_lines_read)
1950 last = GNUNET_TIME_absolute_get ();
1952 if (0 == stdin_lines_read % 100000)
1953 {
1955
1957 last = GNUNET_TIME_absolute_get ();
1958 fprintf (stderr,
1959 "Read 100000 domain names in %s\n",
1961 GNUNET_STATISTICS_set (stats, "# domain names provided", stdin_lines_read,
1962 GNUNET_NO);
1963 }
1964 idna_to_unicode_8z8z (hn,
1965 &hn_utf8,
1966 IDNA_ALLOW_UNASSIGNED);
1967 queue (hn_utf8);
1968 GNUNET_free (hn_utf8);
1969 }
1970 fprintf (stderr,
1971 "Done reading %llu domain names\n",
1972 (unsigned long long) stdin_lines_read);
1973 GNUNET_STATISTICS_set (stats, "# domain names provided", stdin_lines_read,
1974 GNUNET_NO);
1975 // Only start iteration immediately if no zones are missing.
1976 if (NULL == missing_zones_head)
1977 {
1978 iterate_zones (NULL);
1979 }
1980}

References delta, GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_set(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, iterate_zones(), missing_zones_head, queue(), stats, stdin_lines_read, and t.

Referenced by identity_cb().

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

◆ identity_cb()

static void identity_cb ( void *  cls,
struct GNUNET_IDENTITY_Ego ego,
void **  ctx,
const char *  name 
)
static

Method called to inform about the egos of this peer.

When used with GNUNET_IDENTITY_connect, this function is initially called for all egos and then again whenever a ego's name changes or if it is deleted. At the end of the initial pass over all egos, the function is once called with 'NULL' for ego. That does NOT mean that the callback won't be invoked in the future or that there was an error.

When used with GNUNET_IDENTITY_create, this function is only called ONCE, and 'NULL' being passed in ego does indicate an error (for example because name is taken or no default value is known). If ego is non-NULL and if '*ctx' is set in those callbacks, the value WILL be passed to a subsequent call to the identity callback of GNUNET_IDENTITY_connect (if that one was not NULL).

When an identity is renamed, this function is called with the (known) ego but the NEW name.

When an identity is deleted, this function is called with the (known) ego and "NULL" for the name. In this case, the ego is henceforth invalid (and the ctx should also be cleaned up).

Parameters
clsclosure
egoego handle, NULL for end of list
ctxcontext for application to store data for this ego (during the lifetime of this process, initially NULL)
namename assigned by the user for this ego, NULL if the user just deleted the ego and it must thus no longer be used

Definition at line 2017 of file gnunet-zoneimport.c.

2021{
2022 (void) cls;
2023 (void) ctx;
2024 static int initial_iteration = GNUNET_YES;
2025
2026 if (GNUNET_NO == initial_iteration)
2027 return;
2028 if (NULL == ego)
2029 {
2030 /* end of iteration */
2031 if (NULL == zone_head)
2032 {
2033 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No zone found\n");
2035 return;
2036 }
2037 initial_iteration = GNUNET_NO;
2038 /* zone_head non-null, process hostnames from stdin */
2040 return;
2041 }
2042 if (NULL != name)
2043 {
2044 struct Zone *zone;
2045
2046 zone = GNUNET_new (struct Zone);
2048 zone->domain = GNUNET_strdup (name);
2050 }
2051}

References ctx, Zone::domain, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_ERROR, GNUNET_IDENTITY_ego_get_private_key(), GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_shutdown(), GNUNET_strdup, GNUNET_YES, Zone::key, name, process_stdin(), t, zone_head, and zone_tail.

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

Process requests from the queue, then if the queue is not empty, try again.

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

Definition at line 2064 of file gnunet-zoneimport.c.

2068{
2069 (void) cls;
2070 (void) args;
2071 (void) cfgfile;
2072 stats = GNUNET_STATISTICS_create ("zoneimport", cfg);
2075 if (NULL == ns_pending)
2076 {
2077 fprintf (stderr, "Failed to allocate memory for main hash map\n");
2078 return;
2079 }
2081 if (NULL == dns_ctx)
2082 {
2083 fprintf (stderr, "Failed to initialize GNUnet DNS STUB\n");
2084 return;
2085 }
2086 if (NULL == args[0])
2087 {
2088 fprintf (stderr,
2089 "You must provide a list of DNS resolvers on the command line\n");
2090 return;
2091 }
2092 for (unsigned int i = 0; NULL != args[i]; i++)
2093 {
2095 {
2096 fprintf (stderr, "Failed to use `%s' for DNS resolver\n", args[i]);
2097 return;
2098 }
2099 }
2100
2101
2104 if (NULL == ns)
2105 {
2107 return;
2108 }
2110}

References cfg, dns_ctx, do_shutdown, GNUNET_CONTAINER_heap_create(), GNUNET_CONTAINER_HEAP_ORDER_MIN, GNUNET_CONTAINER_multihashmap_create(), GNUNET_DNSSTUB_add_dns_ip(), GNUNET_DNSSTUB_start(), GNUNET_IDENTITY_connect(), GNUNET_NAMESTORE_connect(), GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), identity_cb(), map_size, ns, ns_pending, req_heap, and stats.

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 
)

Call with IP address of resolver to query.

Parameters
argcshould be 2
argv[1]should contain IP address
Returns
0 on success

Definition at line 2121 of file gnunet-zoneimport.c.

2122{
2125 "size",
2126 "MAPSIZE",
2127 gettext_noop (
2128 "size to use for the main hash map"),
2129 &map_size),
2131 'm',
2132 "minimum-expiration",
2133 "RELATIVETIME",
2134 gettext_noop ("minimum expiration time we assume for imported records"),
2137 int ret;
2138
2139 if (GNUNET_OK !=
2141 argc,
2142 argv,
2143 "gnunet-zoneimport",
2144 "import DNS zone into namestore",
2145 options,
2146 &run,
2147 NULL)))
2148 return 1;
2149 fprintf (stderr,
2150 "Rejected %u names, had %u cached, did %u lookups, stored %u record sets\n"
2151 "Found %u records, %u lookups failed, %u/%u pending on shutdown\n",
2152 rejects,
2153 cached,
2154 lookups,
2156 records,
2157 failures,
2158 pending,
2159 pending_rs);
2160 return 0;
2161}

References cached, failures, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_relative_time(), GNUNET_GETOPT_option_uint(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), lookups, map_size, minimum_expiration_time, options, pending, pending_rs, record_sets, records, rejects, ret, and run().

Here is the call graph for this function:

Variable Documentation

◆ minimum_expiration_time

struct GNUNET_TIME_Relative minimum_expiration_time
static

How long do DNS records have to last at least after being imported?

Definition at line 76 of file gnunet-zoneimport.c.

Referenced by check_for_glue(), main(), and process_record().

◆ missing_zones_head

struct MissingZoneCreationCtx* missing_zones_head
static

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

Referenced by delegation_store_cont(), do_shutdown(), process_stdin(), and queue().

◆ missing_zones_tail

struct MissingZoneCreationCtx* missing_zones_tail
static

Definition at line 244 of file gnunet-zoneimport.c.

Referenced by delegation_store_cont(), do_shutdown(), and queue().

◆ stdin_lines_read

uint64_t stdin_lines_read
static

Definition at line 247 of file gnunet-zoneimport.c.

Referenced by process_stdin(), and store_completed_cb().

◆ map_size

unsigned int map_size = 1024
static

Command-line argument specifying desired size of the hash map with all of our pending names.

Usually, we use an automatically growing map, but this is only OK up to about a million entries. Above that number, the user must explicitly specify the size at startup.

Definition at line 255 of file gnunet-zoneimport.c.

Referenced by main(), process_notify(), and run().

◆ id

struct GNUNET_IDENTITY_Handle* id
static

Handle to the identity service.

Definition at line 260 of file gnunet-zoneimport.c.

◆ ns

struct GNUNET_NAMESTORE_Handle* ns
static

Namestore handle.

Definition at line 265 of file gnunet-zoneimport.c.

Referenced by do_shutdown(), iterate_zones(), missing_zone_creation_cont(), process_result(), and run().

◆ stats

◆ dns_ctx

struct GNUNET_DNSSTUB_Context* dns_ctx
static

Context for DNS resolution.

Definition at line 275 of file gnunet-zoneimport.c.

Referenced by do_shutdown(), process_queue(), and run().

◆ pending

unsigned int pending
static

The number of DNS queries that are outstanding.

Definition at line 280 of file gnunet-zoneimport.c.

Referenced by main(), process_queue(), and process_result().

◆ pending_rs

unsigned int pending_rs
static

The number of NAMESTORE record store operations that are outstanding.

Definition at line 285 of file gnunet-zoneimport.c.

Referenced by main(), process_queue(), process_result(), and store_completed_cb().

◆ lookups

unsigned int lookups
static

Number of lookups we performed overall.

Definition at line 290 of file gnunet-zoneimport.c.

Referenced by main(), and process_queue().

◆ cached

unsigned int cached
static

Number of records we had cached.

Definition at line 295 of file gnunet-zoneimport.c.

Referenced by main(), and ns_lookup_result_cb().

◆ rejects

unsigned int rejects
static

How many hostnames did we reject (malformed).

Definition at line 300 of file gnunet-zoneimport.c.

Referenced by build_dns_query(), main(), and queue().

◆ failures

unsigned int failures
static

Number of lookups that failed.

Definition at line 305 of file gnunet-zoneimport.c.

Referenced by main(), and process_result().

◆ records

unsigned int records
static

Number of records we found.

Definition at line 310 of file gnunet-zoneimport.c.

Referenced by cache_answers(), GNUNET_GNSRECORD_JSON_from_gnsrecord(), main(), and process_record().

◆ record_sets

unsigned int record_sets
static

Number of record sets given to namestore.

Definition at line 315 of file gnunet-zoneimport.c.

Referenced by main(), and process_result().

◆ req_heap

struct GNUNET_CONTAINER_Heap* req_heap
static

Heap of all requests to perform, sorted by the time we should next do the request (i.e.

by expires).

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

Referenced by do_shutdown(), insert_sorted(), process_queue(), and run().

◆ req_head

struct Request* req_head
static

Active requests are kept in a DLL.

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

Referenced by do_shutdown(), process_queue(), and process_result().

◆ req_tail

struct Request* req_tail
static

Active requests are kept in a DLL.

Definition at line 331 of file gnunet-zoneimport.c.

Referenced by do_shutdown(), process_queue(), and process_result().

◆ t

◆ ns_pending

struct GNUNET_CONTAINER_MultiHashMap* ns_pending
static

Hash map of requests for which we may still get a response from the namestore.

Set to NULL once the initial namestore iteration is done.

Definition at line 343 of file gnunet-zoneimport.c.

Referenced by do_shutdown(), iterate_zones(), ns_lookup_result_cb(), queue(), and run().

◆ zone_it

struct GNUNET_NAMESTORE_ZoneIterator* zone_it
static

Current zone iteration handle.

Definition at line 348 of file gnunet-zoneimport.c.

Referenced by do_shutdown(), iterate_zones(), ns_lookup_error_cb(), and ns_lookup_result_cb().

◆ zone_head

struct Zone* zone_head
static

Head of list of zones we are managing.

Definition at line 353 of file gnunet-zoneimport.c.

Referenced by do_shutdown(), identity_cb(), iterate_zones(), missing_zone_creation_cont(), and queue().

◆ zone_tail

struct Zone* zone_tail
static

Tail of list of zones we are managing.

Definition at line 358 of file gnunet-zoneimport.c.

Referenced by do_shutdown(), identity_cb(), iterate_zones(), and missing_zone_creation_cont().

◆ ns_iterator_trigger_next

uint64_t ns_iterator_trigger_next
static

After how many more results must ns_lookup_result_cb() ask the namestore for more?

Definition at line 364 of file gnunet-zoneimport.c.

Referenced by iterate_zones(), ns_lookup_error_cb(), and ns_lookup_result_cb().

◆ total_dns_latency_cnt

uint64_t total_dns_latency_cnt
static

Number of DNS requests counted in latency total.

Definition at line 369 of file gnunet-zoneimport.c.

Referenced by process_result().

◆ total_dns_latency

struct GNUNET_TIME_Relative total_dns_latency
static

Sum of DNS latencies observed.

Definition at line 374 of file gnunet-zoneimport.c.

Referenced by process_result().

◆ total_reg_proc_dns

uint64_t total_reg_proc_dns
static

Number of records processed (DNS lookup, no NAMESTORE) in total.

Definition at line 379 of file gnunet-zoneimport.c.

Referenced by iterate_zones(), process_result(), and store_completed_cb().

◆ total_reg_proc_dns_ns

uint64_t total_reg_proc_dns_ns
static

Number of records processed (DNS lookup, with NAMESTORE) in total.

Definition at line 384 of file gnunet-zoneimport.c.

Referenced by iterate_zones(), and store_completed_cb().

◆ start_time_reg_proc

struct GNUNET_TIME_Absolute start_time_reg_proc
static

Start time of the regular processing.

Definition at line 389 of file gnunet-zoneimport.c.

Referenced by iterate_zones(), and store_completed_cb().

◆ sleep_time_reg_proc

struct GNUNET_TIME_Absolute sleep_time_reg_proc
static

Last time we worked before going idle.

Definition at line 394 of file gnunet-zoneimport.c.

Referenced by insert_sorted(), process_queue(), process_result(), and store_completed_cb().

◆ idle_time

struct GNUNET_TIME_Relative idle_time
static

Time we slept just waiting for work.

Definition at line 399 of file gnunet-zoneimport.c.

Referenced by process_queue(), and store_completed_cb().