GNUnet  0.19.3
gnunet-zonewalk.c File Reference
#include "platform.h"
#include <gnunet_util_lib.h>
Include dependency graph for gnunet-zonewalk.c:

Go to the source code of this file.

Data Structures

struct  Request
 Request we should make. More...
 

Macros

#define THRESH   20
 Maximum number of queries pending at the same time. More...
 
#define TIME_THRESH   10
 TIME_THRESH is in usecs. More...
 
#define MAX_RETRIES   5
 How often do we retry a query before giving up for good? More...
 

Functions

static void process_record (struct Request *req, struct GNUNET_DNSPARSER_Record *rec)
 We received rec for req. More...
 
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. More...
 
static int submit_req (struct Request *req)
 Submit a request to DNS unless we need to slow down because we are at the rate limit. More...
 
static void process_queue (void *cls)
 Process as many requests as possible from the queue. More...
 
static void do_shutdown (void *cls)
 Clean up and terminate the process. More...
 
static void run (void *cls)
 Process requests from the queue, then if the queue is not empty, try again. More...
 
static void queue (const char *hostname)
 Add hostname to the list of requests to be made. More...
 
int main (int argc, char **argv)
 Call with IP address of resolver to query. More...
 

Variables

static struct GNUNET_DNSSTUB_Contextctx
 Context for DNS resolution. More...
 
static unsigned int pending
 The number of queries that are outstanding. More...
 
static unsigned int lookups
 Number of lookups we performed overall. More...
 
static unsigned int failures
 Number of lookups that failed. More...
 
static unsigned int records
 Number of records we found. More...
 
static struct Requestreq_head
 Head of DLL of all requests to perform. More...
 
static struct Requestreq_tail
 Tail of DLL of all requests to perform. More...
 
static struct GNUNET_SCHEDULER_Taskt
 Main task. More...
 

Macro Definition Documentation

◆ THRESH

#define THRESH   20

Maximum number of queries pending at the same time.

Definition at line 124 of file gnunet-zonewalk.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 130 of file gnunet-zonewalk.c.

◆ MAX_RETRIES

#define MAX_RETRIES   5

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

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

Function Documentation

◆ process_record()

static void process_record ( struct Request req,
struct GNUNET_DNSPARSER_Record rec 
)
static

We received rec for req.

Remember the answer.

Parameters
reqrequest
recresponse

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

147 {
148  char buf[INET6_ADDRSTRLEN];
149 
150  records++;
151  switch (rec->type)
152  {
154  fprintf (stdout,
155  "%s A %s\n",
156  req->hostname,
157  inet_ntop (AF_INET,
158  rec->data.raw.data,
159  buf,
160  sizeof(buf)));
161  break;
162 
164  fprintf (stdout,
165  "%s AAAA %s\n",
166  req->hostname,
167  inet_ntop (AF_INET6,
168  rec->data.raw.data,
169  buf,
170  sizeof(buf)));
171  break;
172 
174  fprintf (stdout,
175  "%s NS %s\n",
176  req->hostname,
177  rec->data.hostname);
178  break;
179 
181  fprintf (stdout,
182  "%s CNAME %s\n",
183  req->hostname,
184  rec->data.hostname);
185  break;
186 
188  fprintf (stdout,
189  "%s MX %u %s\n",
190  req->hostname,
191  (unsigned int) rec->data.mx->preference,
192  rec->data.mx->mxhost);
193  break;
194 
196  fprintf (stdout,
197  "%s SOA %s %s %u %u %u %u %u\n",
198  req->hostname,
199  rec->data.soa->mname,
200  rec->data.soa->rname,
201  (unsigned int) rec->data.soa->serial,
202  (unsigned int) rec->data.soa->refresh,
203  (unsigned int) rec->data.soa->retry,
204  (unsigned int) rec->data.soa->expire,
205  (unsigned int) rec->data.soa->minimum_ttl);
206  break;
207 
209  fprintf (stdout,
210  "%s SRV %s %u %u %u\n",
211  req->hostname,
212  rec->data.srv->target,
213  rec->data.srv->priority,
214  rec->data.srv->weight,
215  rec->data.srv->port);
216  break;
217 
219  fprintf (stdout,
220  "%s PTR %s\n",
221  req->hostname,
222  rec->data.hostname);
223  break;
224 
226  fprintf (stdout,
227  "%s TXT %.*s\n",
228  req->hostname,
229  (int) rec->data.raw.data_len,
230  (char *) rec->data.raw.data);
231  break;
232 
234  fprintf (stdout,
235  "%s DNAME %s\n",
236  req->hostname,
237  rec->data.hostname);
238  break;
239 
240  /* obscure records */
252 
253  /* DNSSEC */
262 
263  /* DNSSEC payload */
269 
270  /* obsolete records */
274  {
275  char *base32;
276 
278  rec->data.raw.data_len);
279  fprintf (stdout,
280  "%s (%u) %s\n",
281  req->hostname,
282  rec->type,
283  base32);
284  GNUNET_free (base32);
285  }
286  break;
287 
288  default:
289  fprintf (stderr,
290  "Unsupported type %u\n",
291  (unsigned int) rec->type);
292  break;
293  }
294 }
static char buf[2048]
static unsigned int records
Number of records we found.
#define GNUNET_DNSPARSER_TYPE_RRSIG
#define GNUNET_DNSPARSER_TYPE_SIG
#define GNUNET_DNSPARSER_TYPE_TKEY
#define GNUNET_DNSPARSER_TYPE_URI
#define GNUNET_DNSPARSER_TYPE_OPENPGPKEY
#define GNUNET_DNSPARSER_TYPE_TA
#define GNUNET_DNSPARSER_TYPE_IPSECKEY
#define GNUNET_DNSPARSER_TYPE_TLSA
#define GNUNET_DNSPARSER_TYPE_DHCID
#define GNUNET_DNSPARSER_TYPE_NSEC3
#define GNUNET_DNSPARSER_TYPE_SRV
#define GNUNET_DNSPARSER_TYPE_SSHFP
#define GNUNET_DNSPARSER_TYPE_SOA
#define GNUNET_DNSPARSER_TYPE_CERT
#define GNUNET_DNSPARSER_TYPE_A
#define GNUNET_DNSPARSER_TYPE_NSEC3PARAM
#define GNUNET_DNSPARSER_TYPE_NSEC
#define GNUNET_DNSPARSER_TYPE_DS
#define GNUNET_DNSPARSER_TYPE_PTR
#define GNUNET_DNSPARSER_TYPE_HIP
#define GNUNET_DNSPARSER_TYPE_DNSKEY
#define GNUNET_DNSPARSER_TYPE_TSIG
#define GNUNET_DNSPARSER_TYPE_NS
#define GNUNET_DNSPARSER_TYPE_NAPTR
#define GNUNET_DNSPARSER_TYPE_CNAME
#define GNUNET_DNSPARSER_TYPE_DNAME
#define GNUNET_DNSPARSER_TYPE_LOC
#define GNUNET_DNSPARSER_TYPE_RP
#define GNUNET_DNSPARSER_TYPE_CDS
#define GNUNET_DNSPARSER_TYPE_APL
#define GNUNET_DNSPARSER_TYPE_AAAA
#define GNUNET_DNSPARSER_TYPE_AFSDB
#define GNUNET_DNSPARSER_TYPE_KEY
#define GNUNET_DNSPARSER_TYPE_KX
#define GNUNET_DNSPARSER_TYPE_MX
#define GNUNET_DNSPARSER_TYPE_TXT
#define GNUNET_DNSPARSER_TYPE_CDNSKEY
#define GNUNET_free(ptr)
Wrapper around free.
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:763
char * mxhost
Name of the mail server.
uint16_t preference
Preference for this entry (lower value is higher preference).
void * data
Binary record data.
size_t data_len
Number of bytes in data.
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.
uint16_t type
See GNUNET_DNSPARSER_TYPE_*.
union GNUNET_DNSPARSER_Record::@24 data
Payload of the record (which one of these is valid depends on the 'type').
struct GNUNET_DNSPARSER_RawRecord raw
Raw data for all other types.
uint32_t retry
Time interval that should elapse before a failed refresh should be retried.
char * mname
The domainname of the name server that was the original or primary source of data for this zone.
uint32_t refresh
Time interval before the zone should be refreshed.
uint32_t minimum_ttl
The bit minimum TTL field that should be exported with any RR from this zone.
char * rname
A domainname which specifies the mailbox of the person responsible for this zone.
uint32_t expire
Time value that specifies the upper limit on the time interval that can elapse before the zone is no ...
uint32_t serial
The version number of the original copy of the zone.
uint16_t port
TCP or UDP port of the service.
uint16_t weight
Relative weight for records with the same priority.
uint16_t priority
Preference for this entry (lower value is higher preference).
char * target
Hostname offering the service.
char * hostname
Hostname we are resolving.

References buf, GNUNET_DNSPARSER_RawRecord::data, GNUNET_DNSPARSER_Record::data, GNUNET_DNSPARSER_RawRecord::data_len, GNUNET_DNSPARSER_SoaRecord::expire, GNUNET_DNSPARSER_TYPE_A, GNUNET_DNSPARSER_TYPE_AAAA, GNUNET_DNSPARSER_TYPE_AFSDB, GNUNET_DNSPARSER_TYPE_APL, GNUNET_DNSPARSER_TYPE_CDNSKEY, GNUNET_DNSPARSER_TYPE_CDS, GNUNET_DNSPARSER_TYPE_CERT, GNUNET_DNSPARSER_TYPE_CNAME, GNUNET_DNSPARSER_TYPE_DHCID, GNUNET_DNSPARSER_TYPE_DNAME, GNUNET_DNSPARSER_TYPE_DNSKEY, GNUNET_DNSPARSER_TYPE_DS, GNUNET_DNSPARSER_TYPE_HIP, GNUNET_DNSPARSER_TYPE_IPSECKEY, GNUNET_DNSPARSER_TYPE_KEY, GNUNET_DNSPARSER_TYPE_KX, GNUNET_DNSPARSER_TYPE_LOC, GNUNET_DNSPARSER_TYPE_MX, GNUNET_DNSPARSER_TYPE_NAPTR, GNUNET_DNSPARSER_TYPE_NS, GNUNET_DNSPARSER_TYPE_NSEC, GNUNET_DNSPARSER_TYPE_NSEC3, GNUNET_DNSPARSER_TYPE_NSEC3PARAM, GNUNET_DNSPARSER_TYPE_OPENPGPKEY, GNUNET_DNSPARSER_TYPE_PTR, GNUNET_DNSPARSER_TYPE_RP, GNUNET_DNSPARSER_TYPE_RRSIG, GNUNET_DNSPARSER_TYPE_SIG, GNUNET_DNSPARSER_TYPE_SOA, GNUNET_DNSPARSER_TYPE_SRV, GNUNET_DNSPARSER_TYPE_SSHFP, GNUNET_DNSPARSER_TYPE_TA, GNUNET_DNSPARSER_TYPE_TKEY, GNUNET_DNSPARSER_TYPE_TLSA, GNUNET_DNSPARSER_TYPE_TSIG, GNUNET_DNSPARSER_TYPE_TXT, GNUNET_DNSPARSER_TYPE_URI, GNUNET_free, GNUNET_STRINGS_data_to_string_alloc(), Request::hostname, GNUNET_DNSPARSER_Record::hostname, GNUNET_DNSPARSER_SoaRecord::minimum_ttl, GNUNET_DNSPARSER_SoaRecord::mname, GNUNET_DNSPARSER_Record::mx, GNUNET_DNSPARSER_MxRecord::mxhost, GNUNET_DNSPARSER_SrvRecord::port, GNUNET_DNSPARSER_MxRecord::preference, GNUNET_DNSPARSER_SrvRecord::priority, GNUNET_DNSPARSER_Record::raw, records, GNUNET_DNSPARSER_SoaRecord::refresh, GNUNET_DNSPARSER_SoaRecord::retry, GNUNET_DNSPARSER_SoaRecord::rname, GNUNET_DNSPARSER_SoaRecord::serial, GNUNET_DNSPARSER_Record::soa, GNUNET_DNSPARSER_Record::srv, GNUNET_DNSPARSER_SrvRecord::target, GNUNET_DNSPARSER_Record::type, and GNUNET_DNSPARSER_SrvRecord::weight.

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 305 of file gnunet-zonewalk.c.

308 {
309  struct Request *req = cls;
310  struct GNUNET_DNSPARSER_Packet *p;
311 
312  if (NULL == dns)
313  {
314  /* stub gave up */
315  pending--;
317  "Stub gave up on DNS reply for `%s'\n",
318  req->hostname);
320  req_tail,
321  req);
322  if (req->issue_num > MAX_RETRIES)
323  {
324  failures++;
325  GNUNET_free (req->hostname);
326  GNUNET_free (req->raw);
327  GNUNET_free (req);
328  return;
329  }
331  req_tail,
332  req);
333  req->rs = NULL;
334  return;
335  }
336  if (req->id != dns->id)
337  return;
338  pending--;
340  req->rs = NULL;
342  req_tail,
343  req);
344  p = GNUNET_DNSPARSER_parse ((const char *) dns,
345  dns_len);
346  if (NULL == p)
347  {
349  "Failed to parse DNS reply for `%s'\n",
350  req->hostname);
351  if (req->issue_num > MAX_RETRIES)
352  {
353  failures++;
354  GNUNET_free (req->hostname);
355  GNUNET_free (req->raw);
356  GNUNET_free (req);
357  return;
358  }
360  req_tail,
361  req);
362  return;
363  }
364  for (unsigned int i = 0; i < p->num_answers; i++)
365  {
366  struct GNUNET_DNSPARSER_Record *rs = &p->answers[i];
367 
368  process_record (req,
369  rs);
370  }
371  for (unsigned int i = 0; i < p->num_authority_records; i++)
372  {
373  struct GNUNET_DNSPARSER_Record *rs = &p->authority_records[i];
374 
375  process_record (req,
376  rs);
377  }
378  for (unsigned int i = 0; i < p->num_additional_records; i++)
379  {
380  struct GNUNET_DNSPARSER_Record *rs = &p->additional_records[i];
381 
382  process_record (req,
383  rs);
384  }
386  GNUNET_free (req->hostname);
387  GNUNET_free (req->raw);
388  GNUNET_free (req);
389 }
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:38
static unsigned int pending
The number of queries that are outstanding.
static struct Request * req_tail
Tail of DLL of all requests to perform.
static struct Request * req_head
Head of DLL of all requests to perform.
#define MAX_RETRIES
How often do we retry a query before giving up for good?
static unsigned int failures
Number of lookups that failed.
static void process_record(struct Request *req, struct GNUNET_DNSPARSER_Record *rec)
We received rec for req.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
Definition: dnsparser.c:854
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:656
void GNUNET_DNSSTUB_resolve_cancel(struct GNUNET_DNSSTUB_RequestSocket *rs)
Cancel DNS resolution.
Definition: dnsstub.c:562
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_ERROR
Easy-to-process, parsed version of a DNS packet.
A DNS response record.
uint16_t id
Unique identifier for the request/response.
Request we should make.
void * raw
Raw DNS query.
struct GNUNET_DNSSTUB_RequestSocket * rs
Socket used to make the request, NULL if not active.
int issue_num
How often did we issue this query?
uint16_t id
random 16-bit DNS query identifier.

References failures, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_DNSPARSER_free_packet(), GNUNET_DNSPARSER_parse(), GNUNET_DNSSTUB_resolve_cancel(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, Request::hostname, Request::id, GNUNET_TUN_DnsHeader::id, Request::issue_num, MAX_RETRIES, p, pending, process_record(), Request::raw, req_head, req_tail, and Request::rs.

Referenced by submit_req().

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

◆ submit_req()

static int submit_req ( struct Request req)
static

Submit a request to DNS unless we need to slow down because we are at the rate limit.

Parameters
reqrequest to submit
Returns
GNUNET_OK if request was submitted GNUNET_NO if request was already submitted GNUNET_SYSERR if we are at the rate limit

Definition at line 402 of file gnunet-zonewalk.c.

403 {
404  static struct timeval last_request;
405  struct timeval now;
406 
407  if (NULL != req->rs)
408  return GNUNET_NO; /* already submitted */
409  gettimeofday (&now,
410  NULL);
411  if ((((now.tv_sec - last_request.tv_sec) == 0) &&
412  ((now.tv_usec - last_request.tv_usec) < TIME_THRESH)) ||
413  (pending >= THRESH))
414  return GNUNET_SYSERR;
415  GNUNET_assert (NULL == req->rs);
416  req->rs = GNUNET_DNSSTUB_resolve (ctx,
417  req->raw,
418  req->raw_len,
420  req);
421  GNUNET_assert (NULL != req->rs);
422  req->issue_num++;
423  last_request = now;
424  lookups++;
425  pending++;
426  req->time = time (NULL);
427  return GNUNET_OK;
428 }
#define THRESH
Maximum number of queries pending at the same time.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static unsigned int lookups
Number of lookups we performed overall.
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.
#define TIME_THRESH
TIME_THRESH is in usecs.
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
@ GNUNET_OK
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
time_t time
When did we last issue this request?
size_t raw_len
Number of bytes in raw.

References ctx, GNUNET_assert, GNUNET_DNSSTUB_resolve(), GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, Request::issue_num, lookups, pending, process_result(), Request::raw, Request::raw_len, Request::rs, THRESH, Request::time, and TIME_THRESH.

Referenced by process_queue().

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 437 of file gnunet-zonewalk.c.

438 {
439  (void) cls;
440  t = NULL;
441  for (struct Request *req = req_head;
442  NULL != req;
443  req = req->next)
444  {
445  if (GNUNET_SYSERR == submit_req (req))
446  break;
447  }
448  if (NULL != req_head)
450  &process_queue,
451  NULL);
452  else
454 }
static void process_queue(void *cls)
Process as many requests as possible from the queue.
static struct GNUNET_SCHEDULER_Task * t
Main task.
static int submit_req(struct Request *req)
Submit a request to DNS unless we need to slow down because we are at the rate limit.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:562
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:1272
#define GNUNET_TIME_UNIT_MILLISECONDS
One millisecond.
struct Request * next
Requests are kept in a DLL.

References GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_TIME_UNIT_MILLISECONDS, Request::next, req_head, submit_req(), and t.

Referenced by run().

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 463 of file gnunet-zonewalk.c.

464 {
465  (void) cls;
466  if (NULL != t)
467  {
469  t = NULL;
470  }
472  ctx = NULL;
473 }
void GNUNET_DNSSTUB_stop(struct GNUNET_DNSSTUB_Context *ctx)
Cleanup DNSSTUB resolver.
Definition: dnsstub.c:705
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:975

References ctx, GNUNET_DNSSTUB_stop(), GNUNET_SCHEDULER_cancel(), and t.

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

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

Parameters
clsNULL

Definition at line 483 of file gnunet-zonewalk.c.

484 {
485  (void) cls;
486 
488  NULL);
490  NULL);
491 }
static void do_shutdown(void *cls)
Clean up and terminate the process.
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:1299
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:1334

References do_shutdown(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_shutdown(), process_queue(), and t.

Referenced by main().

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 500 of file gnunet-zonewalk.c.

501 {
502  struct GNUNET_DNSPARSER_Packet p;
503  struct GNUNET_DNSPARSER_Query q;
504  struct Request *req;
505  char *raw;
506  size_t raw_size;
507  int ret;
508 
509  if (GNUNET_OK !=
511  {
513  "Refusing invalid hostname `%s'\n",
514  hostname);
515  return;
516  }
517  q.name = (char *) hostname;
519  q.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET;
520 
521  memset (&p,
522  0,
523  sizeof(p));
524  p.num_queries = 1;
525  p.queries = &q;
527  UINT16_MAX);
529  UINT16_MAX,
530  &raw,
531  &raw_size);
532  if (GNUNET_OK != ret)
533  {
534  if (GNUNET_NO == ret)
535  GNUNET_free (raw);
537  "Failed to pack query for hostname `%s'\n",
538  hostname);
539  return;
540  }
541 
542  req = GNUNET_new (struct Request);
543  req->hostname = strdup (hostname);
544  req->raw = raw;
545  req->raw_len = raw_size;
546  req->id = p.id;
548  req_tail,
549  req);
550 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static int raw
raw output
Definition: gnunet-gns.c:78
static struct GNUNET_REVOCATION_Query * q
Handle for revocation query.
static char * hostname
Our hostname; we give this to all the peers we start.
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.
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
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:1259
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#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...

References GNUNET_CONTAINER_DLL_insert_tail, GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_DNSPARSER_check_name(), GNUNET_DNSPARSER_pack(), GNUNET_DNSPARSER_TYPE_NS, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_NO, GNUNET_OK, GNUNET_TUN_DNS_CLASS_INTERNET, Request::hostname, hostname, Request::id, p, q, Request::raw, raw, Request::raw_len, req_head, req_tail, and ret.

Referenced by __attribute__(), adapt_parallelism(), adaptive_queue_set_max_active(), assign_timeslot(), boot_queue(), check_for_queue_with_higher_prio(), check_vl_transmission(), cleanup_tslots(), core_read_finished_cb(), decrypt_and_check_tc(), do_rekey(), fragment_message(), free_pending_acknowledgement(), free_queue(), get_audiobin(), get_queue_delete_it(), GNUNET_TESTBED_operation_queue_create_(), GNUNET_TESTBED_operation_queue_destroy_(), GNUNET_TESTBED_operation_queue_destroy_empty_(), GNUNET_TESTBED_operation_queue_insert2_(), GNUNET_TESTBED_operation_queue_insert_(), GNUNET_TESTBED_operation_queue_reset_max_active_(), handle_add_queue_message(), handle_del_queue_message(), handle_send_message_ack(), handshake_ack_monotime_cb(), handshake_ack_monotime_store_cb(), handshake_monotime_cb(), handshake_monotime_store_cb(), inject_rekey(), lookup_queue_it(), main(), mq_cancel(), mq_destroy(), mq_error(), mq_init(), mq_send(), pass_plaintext_to_core(), prepare_pending_acknowledgement(), process_rq_task(), proto_read_kx(), queue_destroy(), queue_finish(), queue_read(), queue_read_kx(), queue_send_msg(), queue_timeout(), queue_write(), rekey_monotime_cb(), rekey_monotime_store_cb(), reliability_box_message(), reschedule_queue_timeout(), schedule_transmit_on_queue(), select_best_pending_from_link(), select_read_cb(), select_write_cb(), send_challenge(), setup_in_cipher(), setup_out_cipher(), setup_queue(), start_initial_kx_out(), transmit_kx(), transmit_on_queue(), try_handle_plaintext(), and update_tslots().

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char **  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 561 of file gnunet-zonewalk.c.

563 {
564  char hn[256];
565 
566  if (2 != argc)
567  {
568  fprintf (stderr,
569  "Missing required configuration argument\n");
570  return -1;
571  }
572  ctx = GNUNET_DNSSTUB_start (256);
573  if (NULL == ctx)
574  {
575  fprintf (stderr,
576  "Failed to initialize GNUnet DNS STUB\n");
577  return 1;
578  }
579  if (GNUNET_OK !=
581  argv[1]))
582  {
583  fprintf (stderr,
584  "Failed to use `%s' for DNS resolver\n",
585  argv[1]);
586  return 1;
587  }
588 
589  while (NULL !=
590  fgets (hn,
591  sizeof(hn),
592  stdin))
593  {
594  if (strlen (hn) > 0)
595  hn[strlen (hn) - 1] = '\0'; /* eat newline */
596  queue (hn);
597  }
599  NULL);
600  fprintf (stderr,
601  "Did %u lookups, found %u records, %u lookups failed, %u pending on shutdown\n",
602  lookups,
603  records,
604  failures,
605  pending);
606  return 0;
607 }
static void queue(const char *hostname)
Add hostname to the list of requests to be made.
static void run(void *cls)
Process requests from the queue, then if the queue is not empty, try again.
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
struct GNUNET_DNSSTUB_Context * GNUNET_DNSSTUB_start(unsigned int num_sockets)
Start a DNS stub resolver.
Definition: dnsstub.c:586
void GNUNET_SCHEDULER_run(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Initialize and run scheduler.
Definition: scheduler.c:720

References ctx, failures, GNUNET_DNSSTUB_add_dns_ip(), GNUNET_DNSSTUB_start(), GNUNET_OK, GNUNET_SCHEDULER_run(), Request::hn, lookups, pending, queue(), records, and run().

Here is the call graph for this function:

Variable Documentation

◆ ctx

struct GNUNET_DNSSTUB_Context* ctx
static

Context for DNS resolution.

Definition at line 84 of file gnunet-zonewalk.c.

Referenced by add_address_to_hello(), add_address_to_uri(), add_plugin(), automaton_merge_states(), block_plugin_template_check_block(), block_plugin_test_check_block(), cadet_connect_adapter(), cadet_connect_cb(), cadet_test_run(), callback_update_ego(), cancel_get(), check_connection_quality(), check_edge(), checkvec(), construct_dfa_states(), core_env_sent_cb(), cr_cont(), create_peer_ctx(), curl_download_cb(), debugctx(), delayed_put(), derive_aes_key(), derive_auth_key(), derive_iv(), derive_pong_iv(), dfa_add_multi_strides_helper(), dfa_merge_nondistinguishable_states(), dfa_minimize(), dfa_state_create(), dht_connect_cb(), dht_connected(), dht_get_string_accept_handler(), dht_get_string_handler(), dht_test_run(), do_dns_read(), do_notify(), do_shutdown(), event_do_poll(), find_best_address_it(), find_plugin(), finish_handling_raw_message(), forward_reply(), GCT_iterate_channels(), GDS_u_connect(), GDS_u_disconnect(), get_iter(), get_longest_prefix(), get_peer_ctx(), get_request_socket(), GNUNET_BLOCK_check_block(), GNUNET_BLOCK_context_create(), GNUNET_BLOCK_context_destroy(), GNUNET_CADET_TEST_cleanup(), GNUNET_CADET_TEST_ruN(), GNUNET_CRYPTO_ecdsa_private_key_derive(), GNUNET_CRYPTO_ecdsa_public_key_derive(), GNUNET_CRYPTO_eddsa_private_key_derive(), GNUNET_CRYPTO_eddsa_public_key_derive(), GNUNET_CRYPTO_kdf_mod_mpi(), GNUNET_CURL_enable_async_scope_header(), GNUNET_CURL_fini(), GNUNET_CURL_get_select_info(), GNUNET_CURL_gnunet_rc_create(), GNUNET_CURL_gnunet_rc_create_with_parser(), GNUNET_CURL_init(), GNUNET_CURL_job_add(), GNUNET_CURL_job_add2(), GNUNET_CURL_job_add_raw(), GNUNET_CURL_job_add_with_ct_json(), GNUNET_CURL_job_cancel(), GNUNET_CURL_perform(), GNUNET_CURL_perform2(), GNUNET_CURL_set_tlscert(), GNUNET_CURL_set_userpass(), GNUNET_DHT_TEST_cleanup(), GNUNET_DHT_TEST_run(), GNUNET_DNSSTUB_add_dns_ip(), GNUNET_DNSSTUB_add_dns_sa(), GNUNET_DNSSTUB_resolve(), GNUNET_DNSSTUB_set_retry(), GNUNET_DNSSTUB_start(), GNUNET_DNSSTUB_stop(), GNUNET_HELLO_compose_uri(), GNUNET_HELLO_parse_uri(), GNUNET_OP_add(), GNUNET_OP_get(), GNUNET_OP_result(), GNUNET_PLUGIN_load_all_in_context(), GNUNET_SET_element_hash(), GNUNET_SETI_element_hash(), GNUNET_SETU_element_hash(), GNUNET_SIGNAL_handler_uninstall(), GNUNET_SIGNAL_raise(), id_connect_cb(), identity_cb(), inspect_attrs(), iterate_channels_cb(), LEGACY_SERVICE_get_listen_sockets(), LEGACY_SERVICE_get_server(), libgnunet_plugin_block_consensus_done(), libgnunet_plugin_block_consensus_init(), main(), make_file(), new_regex_ctx(), nfa_add_alternation(), nfa_add_concatenation(), nfa_add_label(), nfa_add_plus_op(), nfa_add_question_op(), nfa_add_star_op(), nfa_state_create(), op_get_element(), op_get_element_iterator(), op_result(), output_vectors(), pabc_create_presentation(), PABC_load_public_parameters(), regex_add(), regex_add_multiple(), REGEX_BLOCK_check(), regex_combine(), regex_ctx_destroy(), regex_edge_iterator(), regex_find_path(), REGEX_INTERNAL_construct_dfa(), REGEX_INTERNAL_construct_nfa(), REGEX_INTERNAL_context_init(), REGEX_INTERNAL_dfa_add_multi_strides(), REGEX_INTERNAL_search(), regex_next_edge(), regex_result_iterator(), regex_split(), REGEX_TEST_automaton_save_graph(), REGEX_TEST_automaton_save_graph_step(), REGEX_TEST_combine(), service_started(), setup_job(), setup_job_headers(), start_profiling(), state_add_transition(), submit_req(), t_ax_decrypt_and_validate(), t_ax_encrypt(), t_ax_hmac_hash(), t_hmac(), t_hmac_derive_key(), tcp_send(), tmain(), transmit_query(), try_send_tcp(), u_address_add(), and u_address_del().

◆ pending

unsigned int pending
static

The number of queries that are outstanding.

Definition at line 89 of file gnunet-zonewalk.c.

Referenced by end(), GNUNET_NETWORK_socket_recvfrom_amount(), main(), process_result(), and submit_req().

◆ lookups

unsigned int lookups
static

Number of lookups we performed overall.

Definition at line 94 of file gnunet-zonewalk.c.

Referenced by main(), and submit_req().

◆ failures

unsigned int failures
static

Number of lookups that failed.

Definition at line 99 of file gnunet-zonewalk.c.

Referenced by main(), and process_result().

◆ records

unsigned int records
static

Number of records we found.

Definition at line 104 of file gnunet-zonewalk.c.

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

◆ req_head

struct Request* req_head
static

Head of DLL of all requests to perform.

Definition at line 109 of file gnunet-zonewalk.c.

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

◆ req_tail

struct Request* req_tail
static

Tail of DLL of all requests to perform.

Definition at line 114 of file gnunet-zonewalk.c.

Referenced by process_result(), and queue().

◆ t

struct GNUNET_SCHEDULER_Task* t
static

Main task.

Definition at line 119 of file gnunet-zonewalk.c.

Referenced by add_address_to_uri(), add_without_sets(), automaton_create_proofs(), automaton_destroy_state(), automaton_merge_states(), automaton_state_traverse(), check_dht_p2p_hello(), compute_scalar_product(), connection_ready_cb(), consider_path_cb(), construct_task_graph(), destroy_t_connection(), destroy_task(), destroy_tunnel(), destroy_tunnels_now(), dfa_add_multi_strides_helper(), dfa_compress_paths(), dfa_compress_paths_helper(), dfa_move(), dfa_remove_dead_states(), do_send(), do_shutdown(), driver_add_multiple(), dump_backtrace(), extract_abs_time(), extract_abs_time_nbo(), find_peer_context(), GCCH_channel_incoming_new(), GCP_drop_tunnel(), GCT_2s(), GCT_add_channel(), GCT_add_inbound_connection(), GCT_change_estate(), GCT_connection_lost(), GCT_consider_path(), GCT_count_any_connections(), GCT_count_channels(), GCT_create_tunnel(), GCT_debug(), GCT_destroy_tunnel_now(), GCT_get_destination(), GCT_get_estate(), GCT_handle_encrypted(), GCT_handle_kx(), GCT_iterate_channels(), GCT_iterate_connections(), GCT_remove_channel(), GCT_send(), GCT_send_cancel(), GCT_send_channel_destroy(), GDS_u_connect(), GDS_u_disconnect(), GDS_u_receive(), get_all_tunnels_iterator(), GNUNET_CRYPTO_hash_xorcmp(), GNUNET_DISK_directory_create(), GNUNET_DISK_file_get_identifiers(), GNUNET_DISK_mkdtemp(), GNUNET_FS_meta_data_add_publication_date(), GNUNET_log_setup(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_add_with_reason_and_priority(), GNUNET_SERVICE_client_drop(), GNUNET_STRINGS_absolute_time_to_string(), GNUNET_TIME_absolute2s(), GNUNET_TIME_absolute_approx_eq(), GNUNET_TIME_get_current_year(), GNUNET_TIME_time_to_year(), GNUNET_TRANSPORT_TESTING_done(), GNUNET_TRANSPORT_TESTING_get_test_plugin_name(), handle_connection_create(), handle_decrypted(), handle_dht_p2p_get(), handle_dht_p2p_hello(), handle_dht_p2p_put(), handle_encrypted(), handle_p2p_estimate(), handle_ping(), handle_plaintext_channel_destroy(), handle_plaintext_channel_open(), handle_plaintext_channel_open_ack(), handle_plaintext_data(), handle_plaintext_data_ack(), handle_plaintext_keepalive(), handle_pong(), helper_read(), helper_write(), init_backtrace(), init_fd_info(), iterate_initial_edge(), lookup_channel(), maintain_connections_cb(), mark_connection_unready(), mktemp_name(), offer_hello(), parse_definitions(), parse_pattern(), process_queue(), progress_cb(), put_task(), REGEX_INTERNAL_dfa_add_multi_strides(), restore_fair(), retry_kx(), rsa_gcd_validate(), run(), scc_tarjan_strongconnect(), send_create(), send_done_cb(), send_kx(), send_kx_auth(), shutdown_if_no_lifeness(), state_add_transition(), state_get_edges(), trigger_transmissions(), try_send_normal_payload(), update_tslots(), and vec_for().