aboutsummaryrefslogtreecommitdiff
path: root/src/dns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-06 20:55:28 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-06 20:55:28 +0000
commit61c39c60565b386e0e12ea669556b030e8cd7180 (patch)
tree59109aeab8297bdc996faca8c4e38ec7426c36cf /src/dns
parent780eb09dd8040ecf8649d40ddf8314464e0fc48e (diff)
downloadgnunet-61c39c60565b386e0e12ea669556b030e8cd7180.tar.gz
gnunet-61c39c60565b386e0e12ea669556b030e8cd7180.zip
-remove trailing whitespace
Diffstat (limited to 'src/dns')
-rw-r--r--src/dns/dns.h4
-rw-r--r--src/dns/dns_api.c34
-rw-r--r--src/dns/dnsparser.c86
-rw-r--r--src/dns/dnsstub.c40
-rw-r--r--src/dns/gnunet-dns-monitor.c12
-rw-r--r--src/dns/gnunet-dns-redirector.c14
-rw-r--r--src/dns/gnunet-helper-dns.c82
-rw-r--r--src/dns/gnunet-service-dns.c64
-rw-r--r--src/dns/plugin_block_dns.c10
9 files changed, 173 insertions, 173 deletions
diff --git a/src/dns/dns.h b/src/dns/dns.h
index 7ee49a9c8..4c41335a3 100644
--- a/src/dns/dns.h
+++ b/src/dns/dns.h
@@ -60,7 +60,7 @@ struct GNUNET_DNS_Request
60 * Always zero. 60 * Always zero.
61 */ 61 */
62 uint32_t reserved GNUNET_PACKED; 62 uint32_t reserved GNUNET_PACKED;
63 63
64 /** 64 /**
65 * Unique request ID. 65 * Unique request ID.
66 */ 66 */
@@ -85,7 +85,7 @@ struct GNUNET_DNS_Response
85 * Zero to drop, 1 for no change (no payload), 2 for update (message has payload). 85 * Zero to drop, 1 for no change (no payload), 2 for update (message has payload).
86 */ 86 */
87 uint32_t drop_flag GNUNET_PACKED; 87 uint32_t drop_flag GNUNET_PACKED;
88 88
89 /** 89 /**
90 * Unique request ID. 90 * Unique request ID.
91 */ 91 */
diff --git a/src/dns/dns_api.c b/src/dns/dns_api.c
index f48457a01..9a8e1ca2d 100644
--- a/src/dns/dns_api.c
+++ b/src/dns/dns_api.c
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file dns/dns_api.c 22 * @file dns/dns_api.c
23 * @brief API to access the DNS service. 23 * @brief API to access the DNS service.
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
@@ -100,7 +100,7 @@ struct GNUNET_DNS_Handle
100 * Function to call to get replies. 100 * Function to call to get replies.
101 */ 101 */
102 GNUNET_DNS_RequestHandler rh; 102 GNUNET_DNS_RequestHandler rh;
103 103
104 /** 104 /**
105 * Closure for 'rh'. 105 * Closure for 'rh'.
106 */ 106 */
@@ -125,7 +125,7 @@ struct GNUNET_DNS_Handle
125 * Re-connect counter, to make sure we did not reconnect in the meantime. 125 * Re-connect counter, to make sure we did not reconnect in the meantime.
126 */ 126 */
127 uint32_t generation; 127 uint32_t generation;
128 128
129 /** 129 /**
130 * Flags for events we care about. 130 * Flags for events we care about.
131 */ 131 */
@@ -253,7 +253,7 @@ request_handler (void *cls,
253 req = (const struct GNUNET_DNS_Request *) msg; 253 req = (const struct GNUNET_DNS_Request *) msg;
254 GNUNET_break (ntohl (req->reserved) == 0); 254 GNUNET_break (ntohl (req->reserved) == 0);
255 payload_length = ntohs (req->header.size) - sizeof (struct GNUNET_DNS_Request); 255 payload_length = ntohs (req->header.size) - sizeof (struct GNUNET_DNS_Request);
256 GNUNET_CLIENT_receive (dh->dns_connection, 256 GNUNET_CLIENT_receive (dh->dns_connection,
257 &request_handler, dh, 257 &request_handler, dh,
258 GNUNET_TIME_UNIT_FOREVER_REL); 258 GNUNET_TIME_UNIT_FOREVER_REL);
259 259
@@ -261,7 +261,7 @@ request_handler (void *cls,
261 rh = GNUNET_malloc (sizeof (struct GNUNET_DNS_RequestHandle)); 261 rh = GNUNET_malloc (sizeof (struct GNUNET_DNS_RequestHandle));
262 rh->dh =dh; 262 rh->dh =dh;
263 rh->request_id = req->request_id; 263 rh->request_id = req->request_id;
264 rh->generation = dh->generation; 264 rh->generation = dh->generation;
265 dh->pending_requests++; 265 dh->pending_requests++;
266 dh->rh (dh->rh_cls, 266 dh->rh (dh->rh_cls,
267 rh, 267 rh,
@@ -285,7 +285,7 @@ send_response (void *cls, size_t size, void *buf)
285 struct GNUNET_DNS_Handle *dh = cls; 285 struct GNUNET_DNS_Handle *dh = cls;
286 struct ReplyQueueEntry *qe; 286 struct ReplyQueueEntry *qe;
287 size_t len; 287 size_t len;
288 288
289 dh->dns_transmit_handle = NULL; 289 dh->dns_transmit_handle = NULL;
290 if (NULL == buf) 290 if (NULL == buf)
291 { 291 {
@@ -300,12 +300,12 @@ send_response (void *cls, size_t size, void *buf)
300 return 0; 300 return 0;
301 len = ntohs (qe->msg->size); 301 len = ntohs (qe->msg->size);
302 if (len > size) 302 if (len > size)
303 { 303 {
304 dh->dns_transmit_handle = 304 dh->dns_transmit_handle =
305 GNUNET_CLIENT_notify_transmit_ready (dh->dns_connection, 305 GNUNET_CLIENT_notify_transmit_ready (dh->dns_connection,
306 len, 306 len,
307 GNUNET_TIME_UNIT_FOREVER_REL, 307 GNUNET_TIME_UNIT_FOREVER_REL,
308 GNUNET_NO, 308 GNUNET_NO,
309 &send_response, dh); 309 &send_response, dh);
310 return 0; 310 return 0;
311 } 311 }
@@ -317,7 +317,7 @@ send_response (void *cls, size_t size, void *buf)
317 if (GNUNET_NO == dh->in_receive) 317 if (GNUNET_NO == dh->in_receive)
318 { 318 {
319 dh->in_receive = GNUNET_YES; 319 dh->in_receive = GNUNET_YES;
320 GNUNET_CLIENT_receive (dh->dns_connection, 320 GNUNET_CLIENT_receive (dh->dns_connection,
321 &request_handler, dh, 321 &request_handler, dh,
322 GNUNET_TIME_UNIT_FOREVER_REL); 322 GNUNET_TIME_UNIT_FOREVER_REL);
323 } 323 }
@@ -327,11 +327,11 @@ send_response (void *cls, size_t size, void *buf)
327 GNUNET_CLIENT_notify_transmit_ready (dh->dns_connection, 327 GNUNET_CLIENT_notify_transmit_ready (dh->dns_connection,
328 ntohs (qe->msg->size), 328 ntohs (qe->msg->size),
329 GNUNET_TIME_UNIT_FOREVER_REL, 329 GNUNET_TIME_UNIT_FOREVER_REL,
330 GNUNET_NO, 330 GNUNET_NO,
331 &send_response, dh); 331 &send_response, dh);
332 } 332 }
333 return len; 333 return len;
334} 334}
335 335
336 336
337/** 337/**
@@ -344,7 +344,7 @@ static void
344queue_reply (struct GNUNET_DNS_Handle *dh, 344queue_reply (struct GNUNET_DNS_Handle *dh,
345 struct ReplyQueueEntry *qe) 345 struct ReplyQueueEntry *qe)
346{ 346{
347 if (NULL == dh->dns_connection) 347 if (NULL == dh->dns_connection)
348 { 348 {
349 GNUNET_free (qe); 349 GNUNET_free (qe);
350 return; 350 return;
@@ -354,12 +354,12 @@ queue_reply (struct GNUNET_DNS_Handle *dh,
354 qe); 354 qe);
355 if (NULL != dh->dns_transmit_handle) 355 if (NULL != dh->dns_transmit_handle)
356 return; 356 return;
357 /* trigger sending */ 357 /* trigger sending */
358 dh->dns_transmit_handle = 358 dh->dns_transmit_handle =
359 GNUNET_CLIENT_notify_transmit_ready (dh->dns_connection, 359 GNUNET_CLIENT_notify_transmit_ready (dh->dns_connection,
360 ntohs (dh->rq_head->msg->size), 360 ntohs (dh->rq_head->msg->size),
361 GNUNET_TIME_UNIT_FOREVER_REL, 361 GNUNET_TIME_UNIT_FOREVER_REL,
362 GNUNET_NO, 362 GNUNET_NO,
363 &send_response, dh); 363 &send_response, dh);
364} 364}
365 365
@@ -440,7 +440,7 @@ GNUNET_DNS_request_drop (struct GNUNET_DNS_RequestHandle *rh)
440 * @param reply reply data 440 * @param reply reply data
441 */ 441 */
442void 442void
443GNUNET_DNS_request_answer (struct GNUNET_DNS_RequestHandle *rh, 443GNUNET_DNS_request_answer (struct GNUNET_DNS_RequestHandle *rh,
444 uint16_t reply_length, 444 uint16_t reply_length,
445 const char *reply) 445 const char *reply)
446{ 446{
@@ -480,7 +480,7 @@ GNUNET_DNS_request_answer (struct GNUNET_DNS_RequestHandle *rh,
480 * @param flags when to call rh 480 * @param flags when to call rh
481 * @param rh function to call with DNS requests 481 * @param rh function to call with DNS requests
482 * @param rh_cls closure to pass to rh 482 * @param rh_cls closure to pass to rh
483 * @return DNS handle 483 * @return DNS handle
484 */ 484 */
485struct GNUNET_DNS_Handle * 485struct GNUNET_DNS_Handle *
486GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 486GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
@@ -489,7 +489,7 @@ GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
489 void *rh_cls) 489 void *rh_cls)
490{ 490{
491 struct GNUNET_DNS_Handle *dh; 491 struct GNUNET_DNS_Handle *dh;
492 492
493 dh = GNUNET_malloc (sizeof (struct GNUNET_DNS_Handle)); 493 dh = GNUNET_malloc (sizeof (struct GNUNET_DNS_Handle));
494 dh->cfg = cfg; 494 dh->cfg = cfg;
495 dh->flags = flags; 495 dh->flags = flags;
diff --git a/src/dns/dnsparser.c b/src/dns/dnsparser.c
index 369f90215..d10da1ca9 100644
--- a/src/dns/dnsparser.c
+++ b/src/dns/dnsparser.c
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file dns/dnsparser.c 22 * @file dns/dnsparser.c
23 * @brief helper library to parse DNS packets. 23 * @brief helper library to parse DNS packets.
24 * @author Philipp Toelke 24 * @author Philipp Toelke
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
@@ -47,10 +47,10 @@ GNUNET_DNSPARSER_check_label (const char *label)
47{ 47{
48 char *output; 48 char *output;
49 size_t slen; 49 size_t slen;
50 50
51 if (NULL != strchr (label, '.')) 51 if (NULL != strchr (label, '.'))
52 return GNUNET_SYSERR; /* not a label! Did you mean GNUNET_DNSPARSER_check_name? */ 52 return GNUNET_SYSERR; /* not a label! Did you mean GNUNET_DNSPARSER_check_name? */
53 if (IDNA_SUCCESS != 53 if (IDNA_SUCCESS !=
54 idna_to_ascii_8z (label, &output, IDNA_ALLOW_UNASSIGNED)) 54 idna_to_ascii_8z (label, &output, IDNA_ALLOW_UNASSIGNED))
55 return GNUNET_SYSERR; 55 return GNUNET_SYSERR;
56 slen = strlen (output); 56 slen = strlen (output);
@@ -78,7 +78,7 @@ GNUNET_DNSPARSER_check_name (const char *name)
78 char *output; 78 char *output;
79 size_t slen; 79 size_t slen;
80 char *tok; 80 char *tok;
81 81
82 ldup = GNUNET_strdup (name); 82 ldup = GNUNET_strdup (name);
83 for (tok = strtok (ldup, "."); NULL != tok; tok = strtok (NULL, ".")) 83 for (tok = strtok (ldup, "."); NULL != tok; tok = strtok (NULL, "."))
84 if (GNUNET_OK != 84 if (GNUNET_OK !=
@@ -88,7 +88,7 @@ GNUNET_DNSPARSER_check_name (const char *name)
88 return GNUNET_SYSERR; 88 return GNUNET_SYSERR;
89 } 89 }
90 GNUNET_free (ldup); 90 GNUNET_free (ldup);
91 if (IDNA_SUCCESS != 91 if (IDNA_SUCCESS !=
92 idna_to_ascii_8z (name, &output, IDNA_ALLOW_UNASSIGNED)) 92 idna_to_ascii_8z (name, &output, IDNA_ALLOW_UNASSIGNED))
93 return GNUNET_SYSERR; 93 return GNUNET_SYSERR;
94 slen = strlen (output); 94 slen = strlen (output);
@@ -113,7 +113,7 @@ GNUNET_DNSPARSER_free_soa (struct GNUNET_DNSPARSER_SoaRecord *soa)
113 return; 113 return;
114 GNUNET_free_non_null (soa->mname); 114 GNUNET_free_non_null (soa->mname);
115 GNUNET_free_non_null (soa->rname); 115 GNUNET_free_non_null (soa->rname);
116 GNUNET_free (soa); 116 GNUNET_free (soa);
117} 117}
118 118
119 119
@@ -131,7 +131,7 @@ GNUNET_DNSPARSER_free_srv (struct GNUNET_DNSPARSER_SrvRecord *srv)
131 GNUNET_free_non_null (srv->domain_name); 131 GNUNET_free_non_null (srv->domain_name);
132 GNUNET_free_non_null (srv->proto); 132 GNUNET_free_non_null (srv->proto);
133 GNUNET_free_non_null (srv->service); 133 GNUNET_free_non_null (srv->service);
134 GNUNET_free (srv); 134 GNUNET_free (srv);
135} 135}
136 136
137 137
@@ -146,13 +146,13 @@ GNUNET_DNSPARSER_free_mx (struct GNUNET_DNSPARSER_MxRecord *mx)
146 if (NULL == mx) 146 if (NULL == mx)
147 return; 147 return;
148 GNUNET_free_non_null (mx->mxhost); 148 GNUNET_free_non_null (mx->mxhost);
149 GNUNET_free (mx); 149 GNUNET_free (mx);
150} 150}
151 151
152 152
153/** 153/**
154 * Free the given DNS record. 154 * Free the given DNS record.
155 * 155 *
156 * @param r record to free 156 * @param r record to free
157 */ 157 */
158void 158void
@@ -206,7 +206,7 @@ parse_name (const char *udp_payload,
206 size_t xoff; 206 size_t xoff;
207 char *utf8; 207 char *utf8;
208 Idna_rc rc; 208 Idna_rc rc;
209 209
210 ret = GNUNET_strdup (""); 210 ret = GNUNET_strdup ("");
211 while (1) 211 while (1)
212 { 212 {
@@ -301,7 +301,7 @@ parse_name (const char *udp_payload,
301 *off += 2; 301 *off += 2;
302 /* pointers always terminate names */ 302 /* pointers always terminate names */
303 break; 303 break;
304 } 304 }
305 else 305 else
306 { 306 {
307 /* neither pointer nor inline string, not supported... */ 307 /* neither pointer nor inline string, not supported... */
@@ -312,7 +312,7 @@ parse_name (const char *udp_payload,
312 if (0 < strlen(ret)) 312 if (0 < strlen(ret))
313 ret[strlen(ret)-1] = '\0'; /* eat tailing '.' */ 313 ret[strlen(ret)-1] = '\0'; /* eat tailing '.' */
314 return ret; 314 return ret;
315 error: 315 error:
316 GNUNET_break_op (0); 316 GNUNET_break_op (0);
317 GNUNET_free (ret); 317 GNUNET_free (ret);
318 return NULL; 318 return NULL;
@@ -356,7 +356,7 @@ GNUNET_DNSPARSER_parse_query (const char *udp_payload,
356 char *name; 356 char *name;
357 struct GNUNET_TUN_DnsQueryLine ql; 357 struct GNUNET_TUN_DnsQueryLine ql;
358 358
359 name = GNUNET_DNSPARSER_parse_name (udp_payload, 359 name = GNUNET_DNSPARSER_parse_name (udp_payload,
360 udp_payload_length, 360 udp_payload_length,
361 off); 361 off);
362 if (NULL == name) 362 if (NULL == name)
@@ -414,7 +414,7 @@ GNUNET_DNSPARSER_parse_soa (const char *udp_payload,
414 return NULL; 414 return NULL;
415 } 415 }
416 memcpy (&soa_bin, 416 memcpy (&soa_bin,
417 &udp_payload[*off], 417 &udp_payload[*off],
418 sizeof (struct GNUNET_TUN_DnsSoaRecord)); 418 sizeof (struct GNUNET_TUN_DnsSoaRecord));
419 soa->serial = ntohl (soa_bin.serial); 419 soa->serial = ntohl (soa_bin.serial);
420 soa->refresh = ntohl (soa_bin.refresh); 420 soa->refresh = ntohl (soa_bin.refresh);
@@ -450,7 +450,7 @@ GNUNET_DNSPARSER_parse_mx (const char *udp_payload,
450 GNUNET_break_op (0); 450 GNUNET_break_op (0);
451 return NULL; 451 return NULL;
452 } 452 }
453 memcpy (&mxpref, &udp_payload[*off], sizeof (uint16_t)); 453 memcpy (&mxpref, &udp_payload[*off], sizeof (uint16_t));
454 (*off) += sizeof (uint16_t); 454 (*off) += sizeof (uint16_t);
455 mx = GNUNET_new (struct GNUNET_DNSPARSER_MxRecord); 455 mx = GNUNET_new (struct GNUNET_DNSPARSER_MxRecord);
456 mx->preference = ntohs (mxpref); 456 mx->preference = ntohs (mxpref);
@@ -498,8 +498,8 @@ GNUNET_DNSPARSER_parse_srv (const char *r_name,
498 if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > udp_payload_length) 498 if (*off + sizeof (struct GNUNET_TUN_DnsSrvRecord) > udp_payload_length)
499 return NULL; 499 return NULL;
500 memcpy (&srv_bin, 500 memcpy (&srv_bin,
501 &udp_payload[*off], 501 &udp_payload[*off],
502 sizeof (struct GNUNET_TUN_DnsSrvRecord)); 502 sizeof (struct GNUNET_TUN_DnsSrvRecord));
503 (*off) += sizeof (struct GNUNET_TUN_DnsSrvRecord); 503 (*off) += sizeof (struct GNUNET_TUN_DnsSrvRecord);
504 srv = GNUNET_new (struct GNUNET_DNSPARSER_SrvRecord); 504 srv = GNUNET_new (struct GNUNET_DNSPARSER_SrvRecord);
505 srv->priority = ntohs (srv_bin.prio); 505 srv->priority = ntohs (srv_bin.prio);
@@ -565,7 +565,7 @@ GNUNET_DNSPARSER_parse_record (const char *udp_payload,
565 size_t old_off; 565 size_t old_off;
566 uint16_t data_len; 566 uint16_t data_len;
567 567
568 name = GNUNET_DNSPARSER_parse_name (udp_payload, 568 name = GNUNET_DNSPARSER_parse_name (udp_payload,
569 udp_payload_length, 569 udp_payload_length,
570 off); 570 off);
571 if (NULL == name) 571 if (NULL == name)
@@ -599,7 +599,7 @@ GNUNET_DNSPARSER_parse_record (const char *udp_payload,
599 case GNUNET_DNSPARSER_TYPE_PTR: 599 case GNUNET_DNSPARSER_TYPE_PTR:
600 r->data.hostname = GNUNET_DNSPARSER_parse_name (udp_payload, 600 r->data.hostname = GNUNET_DNSPARSER_parse_name (udp_payload,
601 udp_payload_length, 601 udp_payload_length,
602 off); 602 off);
603 if ( (NULL == r->data.hostname) || 603 if ( (NULL == r->data.hostname) ||
604 (old_off + data_len != *off) ) 604 (old_off + data_len != *off) )
605 return GNUNET_SYSERR; 605 return GNUNET_SYSERR;
@@ -645,7 +645,7 @@ GNUNET_DNSPARSER_parse_record (const char *udp_payload,
645 break; 645 break;
646 } 646 }
647 (*off) += data_len; 647 (*off) += data_len;
648 return GNUNET_OK; 648 return GNUNET_OK;
649} 649}
650 650
651 651
@@ -654,7 +654,7 @@ GNUNET_DNSPARSER_parse_record (const char *udp_payload,
654 * processing and manipulation. 654 * processing and manipulation.
655 * 655 *
656 * @param udp_payload wire-format of the DNS packet 656 * @param udp_payload wire-format of the DNS packet
657 * @param udp_payload_length number of bytes in @a udp_payload 657 * @param udp_payload_length number of bytes in @a udp_payload
658 * @return NULL on error, otherwise the parsed packet 658 * @return NULL on error, otherwise the parsed packet
659 */ 659 */
660struct GNUNET_DNSPARSER_Packet * 660struct GNUNET_DNSPARSER_Packet *
@@ -664,7 +664,7 @@ GNUNET_DNSPARSER_parse (const char *udp_payload,
664 struct GNUNET_DNSPARSER_Packet *p; 664 struct GNUNET_DNSPARSER_Packet *p;
665 const struct GNUNET_TUN_DnsHeader *dns; 665 const struct GNUNET_TUN_DnsHeader *dns;
666 size_t off; 666 size_t off;
667 unsigned int n; 667 unsigned int n;
668 unsigned int i; 668 unsigned int i;
669 669
670 if (udp_payload_length < sizeof (struct GNUNET_TUN_DnsHeader)) 670 if (udp_payload_length < sizeof (struct GNUNET_TUN_DnsHeader))
@@ -711,7 +711,7 @@ GNUNET_DNSPARSER_parse (const char *udp_payload,
711 udp_payload_length, 711 udp_payload_length,
712 &off, 712 &off,
713 &p->authority_records[i])) 713 &p->authority_records[i]))
714 goto error; 714 goto error;
715 } 715 }
716 n = ntohs (dns->additional_rcount); 716 n = ntohs (dns->additional_rcount);
717 if (n > 0) 717 if (n > 0)
@@ -724,7 +724,7 @@ GNUNET_DNSPARSER_parse (const char *udp_payload,
724 udp_payload_length, 724 udp_payload_length,
725 &off, 725 &off,
726 &p->additional_records[i])) 726 &p->additional_records[i]))
727 goto error; 727 goto error;
728 } 728 }
729 return p; 729 return p;
730 error: 730 error:
@@ -793,7 +793,7 @@ GNUNET_DNSPARSER_builder_add_name (char *dst,
793 if (NULL == name) 793 if (NULL == name)
794 return GNUNET_SYSERR; 794 return GNUNET_SYSERR;
795 795
796 if (IDNA_SUCCESS != 796 if (IDNA_SUCCESS !=
797 (rc = idna_to_ascii_8z (name, &idna_start, IDNA_ALLOW_UNASSIGNED))) 797 (rc = idna_to_ascii_8z (name, &idna_start, IDNA_ALLOW_UNASSIGNED)))
798 { 798 {
799 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 799 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -815,7 +815,7 @@ GNUNET_DNSPARSER_builder_add_name (char *dst,
815 else 815 else
816 len = dot - idna_name; 816 len = dot - idna_name;
817 if ( (len >= 64) || (0 == len) ) 817 if ( (len >= 64) || (0 == len) )
818 goto fail; /* segment too long or empty */ 818 goto fail; /* segment too long or empty */
819 dst[pos++] = (char) (uint8_t) len; 819 dst[pos++] = (char) (uint8_t) len;
820 memcpy (&dst[pos], idna_name, len); 820 memcpy (&dst[pos], idna_name, len);
821 pos += len; 821 pos += len;
@@ -836,7 +836,7 @@ GNUNET_DNSPARSER_builder_add_name (char *dst,
836#else 836#else
837 free (idna_start); 837 free (idna_start);
838#endif 838#endif
839 return GNUNET_NO; 839 return GNUNET_NO;
840} 840}
841 841
842 842
@@ -1004,7 +1004,7 @@ add_record (char *dst,
1004 size_t pos; 1004 size_t pos;
1005 struct GNUNET_TUN_DnsRecordLine rl; 1005 struct GNUNET_TUN_DnsRecordLine rl;
1006 char *name; 1006 char *name;
1007 1007
1008 start = *off; 1008 start = *off;
1009 /* for SRV records, we can create the name from the details 1009 /* for SRV records, we can create the name from the details
1010 of the record if needed */ 1010 of the record if needed */
@@ -1025,9 +1025,9 @@ add_record (char *dst,
1025 1025
1026 pos = *off + sizeof (struct GNUNET_TUN_DnsRecordLine); 1026 pos = *off + sizeof (struct GNUNET_TUN_DnsRecordLine);
1027 switch (record->type) 1027 switch (record->type)
1028 { 1028 {
1029 case GNUNET_DNSPARSER_TYPE_MX: 1029 case GNUNET_DNSPARSER_TYPE_MX:
1030 ret = GNUNET_DNSPARSER_builder_add_mx (dst, dst_len, &pos, record->data.mx); 1030 ret = GNUNET_DNSPARSER_builder_add_mx (dst, dst_len, &pos, record->data.mx);
1031 break; 1031 break;
1032 case GNUNET_DNSPARSER_TYPE_SOA: 1032 case GNUNET_DNSPARSER_TYPE_SOA:
1033 ret = GNUNET_DNSPARSER_builder_add_soa (dst, dst_len, &pos, record->data.soa); 1033 ret = GNUNET_DNSPARSER_builder_add_soa (dst, dst_len, &pos, record->data.soa);
@@ -1069,14 +1069,14 @@ add_record (char *dst,
1069 rl.data_len = htons ((uint16_t) (pos - (*off + sizeof (struct GNUNET_TUN_DnsRecordLine)))); 1069 rl.data_len = htons ((uint16_t) (pos - (*off + sizeof (struct GNUNET_TUN_DnsRecordLine))));
1070 memcpy (&dst[*off], &rl, sizeof (struct GNUNET_TUN_DnsRecordLine)); 1070 memcpy (&dst[*off], &rl, sizeof (struct GNUNET_TUN_DnsRecordLine));
1071 *off = pos; 1071 *off = pos;
1072 return GNUNET_OK; 1072 return GNUNET_OK;
1073} 1073}
1074 1074
1075 1075
1076/** 1076/**
1077 * Given a DNS packet @a p, generate the corresponding UDP payload. 1077 * Given a DNS packet @a p, generate the corresponding UDP payload.
1078 * Note that we do not attempt to pack the strings with pointers 1078 * Note that we do not attempt to pack the strings with pointers
1079 * as this would complicate the code and this is about being 1079 * as this would complicate the code and this is about being
1080 * simple and secure, not fast, fancy and broken like bind. 1080 * simple and secure, not fast, fancy and broken like bind.
1081 * 1081 *
1082 * @param p packet to pack 1082 * @param p packet to pack
@@ -1092,14 +1092,14 @@ GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p,
1092 uint16_t max, 1092 uint16_t max,
1093 char **buf, 1093 char **buf,
1094 size_t *buf_length) 1094 size_t *buf_length)
1095{ 1095{
1096 struct GNUNET_TUN_DnsHeader dns; 1096 struct GNUNET_TUN_DnsHeader dns;
1097 size_t off; 1097 size_t off;
1098 char tmp[max]; 1098 char tmp[max];
1099 unsigned int i; 1099 unsigned int i;
1100 int ret; 1100 int ret;
1101 int trc; 1101 int trc;
1102 1102
1103 if ( (p->num_queries > UINT16_MAX) || 1103 if ( (p->num_queries > UINT16_MAX) ||
1104 (p->num_answers > UINT16_MAX) || 1104 (p->num_answers > UINT16_MAX) ||
1105 (p->num_authority_records > UINT16_MAX) || 1105 (p->num_authority_records > UINT16_MAX) ||
@@ -1116,55 +1116,55 @@ GNUNET_DNSPARSER_pack (const struct GNUNET_DNSPARSER_Packet *p,
1116 trc = GNUNET_NO; 1116 trc = GNUNET_NO;
1117 for (i=0;i<p->num_queries;i++) 1117 for (i=0;i<p->num_queries;i++)
1118 { 1118 {
1119 ret = GNUNET_DNSPARSER_builder_add_query (tmp, sizeof (tmp), &off, &p->queries[i]); 1119 ret = GNUNET_DNSPARSER_builder_add_query (tmp, sizeof (tmp), &off, &p->queries[i]);
1120 if (GNUNET_SYSERR == ret) 1120 if (GNUNET_SYSERR == ret)
1121 return GNUNET_SYSERR; 1121 return GNUNET_SYSERR;
1122 if (GNUNET_NO == ret) 1122 if (GNUNET_NO == ret)
1123 { 1123 {
1124 dns.query_count = htons ((uint16_t) (i-1)); 1124 dns.query_count = htons ((uint16_t) (i-1));
1125 trc = GNUNET_YES; 1125 trc = GNUNET_YES;
1126 break; 1126 break;
1127 } 1127 }
1128 } 1128 }
1129 for (i=0;i<p->num_answers;i++) 1129 for (i=0;i<p->num_answers;i++)
1130 { 1130 {
1131 ret = add_record (tmp, sizeof (tmp), &off, &p->answers[i]); 1131 ret = add_record (tmp, sizeof (tmp), &off, &p->answers[i]);
1132 if (GNUNET_SYSERR == ret) 1132 if (GNUNET_SYSERR == ret)
1133 return GNUNET_SYSERR; 1133 return GNUNET_SYSERR;
1134 if (GNUNET_NO == ret) 1134 if (GNUNET_NO == ret)
1135 { 1135 {
1136 dns.answer_rcount = htons ((uint16_t) (i-1)); 1136 dns.answer_rcount = htons ((uint16_t) (i-1));
1137 trc = GNUNET_YES; 1137 trc = GNUNET_YES;
1138 break; 1138 break;
1139 } 1139 }
1140 } 1140 }
1141 for (i=0;i<p->num_authority_records;i++) 1141 for (i=0;i<p->num_authority_records;i++)
1142 { 1142 {
1143 ret = add_record (tmp, sizeof (tmp), &off, &p->authority_records[i]); 1143 ret = add_record (tmp, sizeof (tmp), &off, &p->authority_records[i]);
1144 if (GNUNET_SYSERR == ret) 1144 if (GNUNET_SYSERR == ret)
1145 return GNUNET_SYSERR; 1145 return GNUNET_SYSERR;
1146 if (GNUNET_NO == ret) 1146 if (GNUNET_NO == ret)
1147 { 1147 {
1148 dns.authority_rcount = htons ((uint16_t) (i-1)); 1148 dns.authority_rcount = htons ((uint16_t) (i-1));
1149 trc = GNUNET_YES; 1149 trc = GNUNET_YES;
1150 break; 1150 break;
1151 } 1151 }
1152 } 1152 }
1153 for (i=0;i<p->num_additional_records;i++) 1153 for (i=0;i<p->num_additional_records;i++)
1154 { 1154 {
1155 ret = add_record (tmp, sizeof (tmp), &off, &p->additional_records[i]); 1155 ret = add_record (tmp, sizeof (tmp), &off, &p->additional_records[i]);
1156 if (GNUNET_SYSERR == ret) 1156 if (GNUNET_SYSERR == ret)
1157 return GNUNET_SYSERR; 1157 return GNUNET_SYSERR;
1158 if (GNUNET_NO == ret) 1158 if (GNUNET_NO == ret)
1159 { 1159 {
1160 dns.additional_rcount = htons (i-1); 1160 dns.additional_rcount = htons (i-1);
1161 trc = GNUNET_YES; 1161 trc = GNUNET_YES;
1162 break; 1162 break;
1163 } 1163 }
1164 } 1164 }
1165 1165
1166 if (GNUNET_YES == trc) 1166 if (GNUNET_YES == trc)
1167 dns.flags.message_truncated = 1; 1167 dns.flags.message_truncated = 1;
1168 memcpy (tmp, &dns, sizeof (struct GNUNET_TUN_DnsHeader)); 1168 memcpy (tmp, &dns, sizeof (struct GNUNET_TUN_DnsHeader));
1169 1169
1170 *buf = GNUNET_malloc (off); 1170 *buf = GNUNET_malloc (off);
diff --git a/src/dns/dnsstub.c b/src/dns/dnsstub.c
index 0e130a77f..bd85bf896 100644
--- a/src/dns/dnsstub.c
+++ b/src/dns/dnsstub.c
@@ -43,7 +43,7 @@
43 */ 43 */
44struct GNUNET_DNSSTUB_RequestSocket 44struct GNUNET_DNSSTUB_RequestSocket
45{ 45{
46 46
47 /** 47 /**
48 * UDP socket we use for this request for IPv4 48 * UDP socket we use for this request for IPv4
49 */ 49 */
@@ -89,12 +89,12 @@ struct GNUNET_DNSSTUB_RequestSocket
89 89
90/** 90/**
91 * Handle to the stub resolver. 91 * Handle to the stub resolver.
92 */ 92 */
93struct GNUNET_DNSSTUB_Context 93struct GNUNET_DNSSTUB_Context
94{ 94{
95 95
96 /** 96 /**
97 * Array of all open sockets for DNS requests. 97 * Array of all open sockets for DNS requests.
98 */ 98 */
99 struct GNUNET_DNSSTUB_RequestSocket sockets[DNS_SOCKET_MAX]; 99 struct GNUNET_DNSSTUB_RequestSocket sockets[DNS_SOCKET_MAX];
100 100
@@ -138,7 +138,7 @@ cleanup_rs (struct GNUNET_DNSSTUB_RequestSocket *rs)
138 * 138 *
139 * @param af AF_INET or AF_INET6 139 * @param af AF_INET or AF_INET6
140 * @return GNUNET_OK on success 140 * @return GNUNET_OK on success
141 */ 141 */
142static struct GNUNET_NETWORK_Handle * 142static struct GNUNET_NETWORK_Handle *
143open_socket (int af) 143open_socket (int af)
144{ 144{
@@ -168,11 +168,11 @@ open_socket (int af)
168 } 168 }
169 sa->sa_family = af; 169 sa->sa_family = af;
170 if (GNUNET_OK != GNUNET_NETWORK_socket_bind (ret, 170 if (GNUNET_OK != GNUNET_NETWORK_socket_bind (ret,
171 sa, 171 sa,
172 alen, 172 alen,
173 0)) 173 0))
174 { 174 {
175 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 175 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
176 _("Could not bind to any port: %s\n"), 176 _("Could not bind to any port: %s\n"),
177 STRERROR (errno)); 177 STRERROR (errno));
178 GNUNET_NETWORK_socket_close (ret); 178 GNUNET_NETWORK_socket_close (ret);
@@ -195,7 +195,7 @@ read_response (void *cls,
195 195
196/** 196/**
197 * Get a socket of the specified address family to send out a 197 * Get a socket of the specified address family to send out a
198 * UDP DNS request to the Internet. 198 * UDP DNS request to the Internet.
199 * 199 *
200 * @param ctx the DNSSTUB context 200 * @param ctx the DNSSTUB context
201 * @param af desired address family 201 * @param af desired address family
@@ -208,7 +208,7 @@ get_request_socket (struct GNUNET_DNSSTUB_Context *ctx,
208 struct GNUNET_DNSSTUB_RequestSocket *rs; 208 struct GNUNET_DNSSTUB_RequestSocket *rs;
209 struct GNUNET_NETWORK_FDSet *rset; 209 struct GNUNET_NETWORK_FDSet *rset;
210 210
211 rs = &ctx->sockets[GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 211 rs = &ctx->sockets[GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
212 DNS_SOCKET_MAX)]; 212 DNS_SOCKET_MAX)];
213 rs->timeout = GNUNET_TIME_relative_to_absolute (REQUEST_TIMEOUT); 213 rs->timeout = GNUNET_TIME_relative_to_absolute (REQUEST_TIMEOUT);
214 switch (af) 214 switch (af)
@@ -223,7 +223,7 @@ get_request_socket (struct GNUNET_DNSSTUB_Context *ctx,
223 break; 223 break;
224 default: 224 default:
225 return NULL; 225 return NULL;
226 } 226 }
227 if (GNUNET_SCHEDULER_NO_TASK != rs->read_task) 227 if (GNUNET_SCHEDULER_NO_TASK != rs->read_task)
228 { 228 {
229 GNUNET_SCHEDULER_cancel (rs->read_task); 229 GNUNET_SCHEDULER_cancel (rs->read_task);
@@ -286,7 +286,7 @@ GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx,
286 rs->addrlen = sa_len; 286 rs->addrlen = sa_len;
287 rs->rc = rc; 287 rs->rc = rc;
288 rs->rc_cls = rc_cls; 288 rs->rc_cls = rc_cls;
289 if (GNUNET_SYSERR == 289 if (GNUNET_SYSERR ==
290 GNUNET_NETWORK_socket_sendto (ret, 290 GNUNET_NETWORK_socket_sendto (ret,
291 request, 291 request,
292 request_len, 292 request_len,
@@ -351,7 +351,7 @@ GNUNET_DNSSTUB_resolve2 (struct GNUNET_DNSSTUB_Context *ctx,
351#endif 351#endif
352 sa = (struct sockaddr *) &v6; 352 sa = (struct sockaddr *) &v6;
353 af = AF_INET6; 353 af = AF_INET6;
354 } 354 }
355 else 355 else
356 { 356 {
357 GNUNET_break (0); 357 GNUNET_break (0);
@@ -384,7 +384,7 @@ GNUNET_DNSSTUB_resolve2 (struct GNUNET_DNSSTUB_Context *ctx,
384 _("Failed to send DNS request to %s\n"), 384 _("Failed to send DNS request to %s\n"),
385 GNUNET_a2s (sa, salen)); 385 GNUNET_a2s (sa, salen));
386 rs->timeout = GNUNET_TIME_relative_to_absolute (REQUEST_TIMEOUT); 386 rs->timeout = GNUNET_TIME_relative_to_absolute (REQUEST_TIMEOUT);
387 387
388 return rs; 388 return rs;
389 389
390} 390}
@@ -420,13 +420,13 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
420#endif 420#endif
421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
422 "Receiving %d byte DNS reply\n", 422 "Receiving %d byte DNS reply\n",
423 len); 423 len);
424 { 424 {
425 unsigned char buf[len] GNUNET_ALIGN; 425 unsigned char buf[len] GNUNET_ALIGN;
426 426
427 addrlen = sizeof (addr); 427 addrlen = sizeof (addr);
428 memset (&addr, 0, sizeof (addr)); 428 memset (&addr, 0, sizeof (addr));
429 r = GNUNET_NETWORK_socket_recvfrom (dnsout, 429 r = GNUNET_NETWORK_socket_recvfrom (dnsout,
430 buf, sizeof (buf), 430 buf, sizeof (buf),
431 (struct sockaddr*) &addr, &addrlen); 431 (struct sockaddr*) &addr, &addrlen);
432 if (-1 == r) 432 if (-1 == r)
@@ -437,7 +437,7 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
437 } 437 }
438 if (sizeof (struct GNUNET_TUN_DnsHeader) > r) 438 if (sizeof (struct GNUNET_TUN_DnsHeader) > r)
439 { 439 {
440 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 440 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
441 _("Received DNS response that is too small (%u bytes)"), 441 _("Received DNS response that is too small (%u bytes)"),
442 r); 442 r);
443 return GNUNET_NO; 443 return GNUNET_NO;
@@ -446,11 +446,11 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
446 if ( (addrlen != rs->addrlen) || 446 if ( (addrlen != rs->addrlen) ||
447 (0 != memcmp (&rs->addr, 447 (0 != memcmp (&rs->addr,
448 &addr, 448 &addr,
449 addrlen)) || 449 addrlen)) ||
450 (0 == GNUNET_TIME_absolute_get_remaining (rs->timeout).rel_value_us) ) 450 (0 == GNUNET_TIME_absolute_get_remaining (rs->timeout).rel_value_us) )
451 { 451 {
452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
453 "Request timeout or invalid sender address; ignoring reply\n"); 453 "Request timeout or invalid sender address; ignoring reply\n");
454 return GNUNET_NO; 454 return GNUNET_NO;
455 } 455 }
456 if (NULL != rs->rc) 456 if (NULL != rs->rc)
@@ -458,7 +458,7 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs,
458 rs, 458 rs,
459 dns, 459 dns,
460 r); 460 r);
461 } 461 }
462 return GNUNET_OK; 462 return GNUNET_OK;
463} 463}
464 464
@@ -530,7 +530,7 @@ struct GNUNET_DNSSTUB_Context *
530GNUNET_DNSSTUB_start (const char *dns_ip) 530GNUNET_DNSSTUB_start (const char *dns_ip)
531{ 531{
532 struct GNUNET_DNSSTUB_Context *ctx; 532 struct GNUNET_DNSSTUB_Context *ctx;
533 533
534 ctx = GNUNET_malloc (sizeof (struct GNUNET_DNSSTUB_Context)); 534 ctx = GNUNET_malloc (sizeof (struct GNUNET_DNSSTUB_Context));
535 if (NULL != dns_ip) 535 if (NULL != dns_ip)
536 ctx->dns_exit = GNUNET_strdup (dns_ip); 536 ctx->dns_exit = GNUNET_strdup (dns_ip);
diff --git a/src/dns/gnunet-dns-monitor.c b/src/dns/gnunet-dns-monitor.c
index 4c92009eb..48dd7a12d 100644
--- a/src/dns/gnunet-dns-monitor.c
+++ b/src/dns/gnunet-dns-monitor.c
@@ -130,7 +130,7 @@ display_record (const struct GNUNET_DNSPARSER_Record *record)
130 const char *format; 130 const char *format;
131 char buf[INET6_ADDRSTRLEN]; 131 char buf[INET6_ADDRSTRLEN];
132 char *tmp; 132 char *tmp;
133 133
134 tmp = NULL; 134 tmp = NULL;
135 switch (record->type) 135 switch (record->type)
136 { 136 {
@@ -164,7 +164,7 @@ display_record (const struct GNUNET_DNSPARSER_Record *record)
164 (unsigned int) record->data.soa->refresh, 164 (unsigned int) record->data.soa->refresh,
165 (unsigned int) record->data.soa->retry, 165 (unsigned int) record->data.soa->retry,
166 (unsigned int) record->data.soa->expire, 166 (unsigned int) record->data.soa->expire,
167 (unsigned int) record->data.soa->minimum_ttl); 167 (unsigned int) record->data.soa->minimum_ttl);
168 format = tmp; 168 format = tmp;
169 } 169 }
170 break; 170 break;
@@ -242,7 +242,7 @@ display_record (const struct GNUNET_DNSPARSER_Record *record)
242 * @param request_length number of bytes in request 242 * @param request_length number of bytes in request
243 * @param request udp payload of the DNS request 243 * @param request udp payload of the DNS request
244 */ 244 */
245static void 245static void
246display_request (void *cls, 246display_request (void *cls,
247 struct GNUNET_DNS_RequestHandle *rh, 247 struct GNUNET_DNS_RequestHandle *rh,
248 size_t request_length, 248 size_t request_length,
@@ -284,13 +284,13 @@ display_request (void *cls,
284 p->flags.authenticated_data ? "AD " : "", 284 p->flags.authenticated_data ? "AD " : "",
285 p->flags.recursion_available ? "RA " : "", 285 p->flags.recursion_available ? "RA " : "",
286 return_codes[p->flags.return_code & 15], 286 return_codes[p->flags.return_code & 15],
287 op_codes[p->flags.opcode & 15]); 287 op_codes[p->flags.opcode & 15]);
288 if (p->num_queries > 0) 288 if (p->num_queries > 0)
289 fprintf (stdout, 289 fprintf (stdout,
290 "\tQueries:\n"); 290 "\tQueries:\n");
291 for (i=0;i<p->num_queries;i++) 291 for (i=0;i<p->num_queries;i++)
292 display_query (&p->queries[i]); 292 display_query (&p->queries[i]);
293 293
294 if (p->num_answers > 0) 294 if (p->num_answers > 0)
295 fprintf (stdout, 295 fprintf (stdout,
296 "\tAnswers:\n"); 296 "\tAnswers:\n");
@@ -338,7 +338,7 @@ run (void *cls, char *const *args, const char *cfgfile,
338 if (outbound_only) 338 if (outbound_only)
339 flags |= GNUNET_DNS_FLAG_RESPONSE_MONITOR; 339 flags |= GNUNET_DNS_FLAG_RESPONSE_MONITOR;
340 handle = 340 handle =
341 GNUNET_DNS_connect (cfg, 341 GNUNET_DNS_connect (cfg,
342 flags, 342 flags,
343 &display_request, 343 &display_request,
344 NULL); 344 NULL);
diff --git a/src/dns/gnunet-dns-redirector.c b/src/dns/gnunet-dns-redirector.c
index 3df2ac21a..4d1a452a5 100644
--- a/src/dns/gnunet-dns-redirector.c
+++ b/src/dns/gnunet-dns-redirector.c
@@ -67,13 +67,13 @@ modify_record (const struct GNUNET_DNSPARSER_Record *record)
67 67
68 switch (record->type) 68 switch (record->type)
69 { 69 {
70 case GNUNET_DNSPARSER_TYPE_A: 70 case GNUNET_DNSPARSER_TYPE_A:
71 if (record->data.raw.data_len != sizeof (struct in_addr)) 71 if (record->data.raw.data_len != sizeof (struct in_addr))
72 return; 72 return;
73 if (NULL != n4) 73 if (NULL != n4)
74 { 74 {
75 if (verbosity > 1) 75 if (verbosity > 1)
76 fprintf (stderr, 76 fprintf (stderr,
77 "Changing A record from `%s' to `%s'\n", 77 "Changing A record from `%s' to `%s'\n",
78 inet_ntop (AF_INET, record->data.raw.data, buf, sizeof (buf)), 78 inet_ntop (AF_INET, record->data.raw.data, buf, sizeof (buf)),
79 n4); 79 n4);
@@ -86,7 +86,7 @@ modify_record (const struct GNUNET_DNSPARSER_Record *record)
86 if (NULL != n6) 86 if (NULL != n6)
87 { 87 {
88 if (verbosity > 1) 88 if (verbosity > 1)
89 fprintf (stderr, 89 fprintf (stderr,
90 "Changing AAAA record from `%s' to `%s'\n", 90 "Changing AAAA record from `%s' to `%s'\n",
91 inet_ntop (AF_INET6, record->data.raw.data, buf, sizeof (buf)), 91 inet_ntop (AF_INET6, record->data.raw.data, buf, sizeof (buf)),
92 n6); 92 n6);
@@ -129,7 +129,7 @@ modify_record (const struct GNUNET_DNSPARSER_Record *record)
129 * @param request_length number of bytes in request 129 * @param request_length number of bytes in request
130 * @param request udp payload of the DNS request 130 * @param request udp payload of the DNS request
131 */ 131 */
132static void 132static void
133modify_request (void *cls, 133modify_request (void *cls,
134 struct GNUNET_DNS_RequestHandle *rh, 134 struct GNUNET_DNS_RequestHandle *rh,
135 size_t request_length, 135 size_t request_length,
@@ -156,7 +156,7 @@ modify_request (void *cls,
156 if (GNUNET_OK != ret) 156 if (GNUNET_OK != ret)
157 { 157 {
158 if (GNUNET_NO == ret) 158 if (GNUNET_NO == ret)
159 fprintf (stderr, 159 fprintf (stderr,
160 "Modified DNS response did not fit, keeping old response\n"); 160 "Modified DNS response did not fit, keeping old response\n");
161 else 161 else
162 GNUNET_break (0); /* our modifications should have been sane! */ 162 GNUNET_break (0); /* our modifications should have been sane! */
@@ -169,7 +169,7 @@ modify_request (void *cls,
169 "Injecting modified DNS response\n"); 169 "Injecting modified DNS response\n");
170 GNUNET_DNS_request_answer (rh, len, buf); 170 GNUNET_DNS_request_answer (rh, len, buf);
171 } 171 }
172 GNUNET_free_non_null (buf); 172 GNUNET_free_non_null (buf);
173} 173}
174 174
175 175
@@ -219,7 +219,7 @@ run (void *cls, char *const *args, const char *cfgfile,
219 } 219 }
220 220
221 handle = 221 handle =
222 GNUNET_DNS_connect (cfg, 222 GNUNET_DNS_connect (cfg,
223 GNUNET_DNS_FLAG_POST_RESOLUTION, 223 GNUNET_DNS_FLAG_POST_RESOLUTION,
224 &modify_request, 224 &modify_request,
225 NULL); 225 NULL);
diff --git a/src/dns/gnunet-helper-dns.c b/src/dns/gnunet-helper-dns.c
index bc83da027..8ff6413f8 100644
--- a/src/dns/gnunet-helper-dns.c
+++ b/src/dns/gnunet-helper-dns.c
@@ -23,7 +23,7 @@
23 * @brief helper to install firewall rules to hijack all DNS traffic 23 * @brief helper to install firewall rules to hijack all DNS traffic
24 * and send it to our virtual interface (except for DNS traffic 24 * and send it to our virtual interface (except for DNS traffic
25 * that originates on the specified port). We then 25 * that originates on the specified port). We then
26 * allow interacting with our virtual interface via stdin/stdout. 26 * allow interacting with our virtual interface via stdin/stdout.
27 * @author Philipp Tölke 27 * @author Philipp Tölke
28 * @author Christian Grothoff 28 * @author Christian Grothoff
29 * 29 *
@@ -55,13 +55,13 @@
55 * Naturally, neither of these problems can be helped as this is the 55 * Naturally, neither of these problems can be helped as this is the
56 * fundamental purpose of the binary. Certifying that this code is 56 * fundamental purpose of the binary. Certifying that this code is
57 * "safe" thus only means that it doesn't allow anything else (such 57 * "safe" thus only means that it doesn't allow anything else (such
58 * as local priv. escalation, etc.). 58 * as local priv. escalation, etc.).
59 * 59 *
60 * The following list of people have reviewed this code and considered 60 * The following list of people have reviewed this code and considered
61 * it safe (within specifications) since the last modification (if you 61 * it safe (within specifications) since the last modification (if you
62 * reviewed it, please have your name added to the list): 62 * reviewed it, please have your name added to the list):
63 * 63 *
64 * - Christian Grothoff 64 * - Christian Grothoff
65 */ 65 */
66#include "platform.h" 66#include "platform.h"
67 67
@@ -174,7 +174,7 @@ open_dev_null (int target_fd,
174 if (fd == target_fd) 174 if (fd == target_fd)
175 return; 175 return;
176 if (-1 == dup2 (fd, target_fd)) 176 if (-1 == dup2 (fd, target_fd))
177 { 177 {
178 (void) close (fd); 178 (void) close (fd);
179 abort (); 179 abort ();
180 } 180 }
@@ -184,13 +184,13 @@ open_dev_null (int target_fd,
184 184
185/** 185/**
186 * Run the given command and wait for it to complete. 186 * Run the given command and wait for it to complete.
187 * 187 *
188 * @param file name of the binary to run 188 * @param file name of the binary to run
189 * @param cmd command line arguments (as given to 'execv') 189 * @param cmd command line arguments (as given to 'execv')
190 * @return 0 on success, 1 on any error 190 * @return 0 on success, 1 on any error
191 */ 191 */
192static int 192static int
193fork_and_exec (const char *file, 193fork_and_exec (const char *file,
194 char *const cmd[]) 194 char *const cmd[])
195{ 195{
196 int status; 196 int status;
@@ -200,8 +200,8 @@ fork_and_exec (const char *file,
200 pid = fork (); 200 pid = fork ();
201 if (-1 == pid) 201 if (-1 == pid)
202 { 202 {
203 fprintf (stderr, 203 fprintf (stderr,
204 "fork failed: %s\n", 204 "fork failed: %s\n",
205 strerror (errno)); 205 strerror (errno));
206 return 1; 206 return 1;
207 } 207 }
@@ -210,25 +210,25 @@ fork_and_exec (const char *file,
210 /* we are the child process */ 210 /* we are the child process */
211 /* close stdin/stdout to not cause interference 211 /* close stdin/stdout to not cause interference
212 with the helper's main protocol! */ 212 with the helper's main protocol! */
213 (void) close (0); 213 (void) close (0);
214 open_dev_null (0, O_RDONLY); 214 open_dev_null (0, O_RDONLY);
215 (void) close (1); 215 (void) close (1);
216 open_dev_null (1, O_WRONLY); 216 open_dev_null (1, O_WRONLY);
217 (void) execv (file, cmd); 217 (void) execv (file, cmd);
218 /* can only get here on error */ 218 /* can only get here on error */
219 fprintf (stderr, 219 fprintf (stderr,
220 "exec `%s' failed: %s\n", 220 "exec `%s' failed: %s\n",
221 file, 221 file,
222 strerror (errno)); 222 strerror (errno));
223 _exit (1); 223 _exit (1);
224 } 224 }
225 /* keep running waitpid as long as the only error we get is 'EINTR' */ 225 /* keep running waitpid as long as the only error we get is 'EINTR' */
226 while ( (-1 == (ret = waitpid (pid, &status, 0))) && 226 while ( (-1 == (ret = waitpid (pid, &status, 0))) &&
227 (errno == EINTR) ); 227 (errno == EINTR) );
228 if (-1 == ret) 228 if (-1 == ret)
229 { 229 {
230 fprintf (stderr, 230 fprintf (stderr,
231 "waitpid failed: %s\n", 231 "waitpid failed: %s\n",
232 strerror (errno)); 232 strerror (errno));
233 return 1; 233 return 1;
234 } 234 }
@@ -312,8 +312,8 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len)
312 sa6.sin6_family = AF_INET6; 312 sa6.sin6_family = AF_INET6;
313 if (1 != inet_pton (AF_INET6, address, sa6.sin6_addr.s6_addr)) 313 if (1 != inet_pton (AF_INET6, address, sa6.sin6_addr.s6_addr))
314 { 314 {
315 fprintf (stderr, 315 fprintf (stderr,
316 "Failed to parse IPv6 address `%s': %s\n", 316 "Failed to parse IPv6 address `%s': %s\n",
317 address, 317 address,
318 strerror (errno)); 318 strerror (errno));
319 exit (1); 319 exit (1);
@@ -321,11 +321,11 @@ set_address6 (const char *dev, const char *address, unsigned long prefix_len)
321 321
322 if (-1 == (fd = socket (PF_INET6, SOCK_DGRAM, 0))) 322 if (-1 == (fd = socket (PF_INET6, SOCK_DGRAM, 0)))
323 { 323 {
324 fprintf (stderr, 324 fprintf (stderr,
325 "Error creating IPv6 socket: %s (ignored)\n", 325 "Error creating IPv6 socket: %s (ignored)\n",
326 strerror (errno)); 326 strerror (errno));
327 /* ignore error, maybe only IPv4 works on this system! */ 327 /* ignore error, maybe only IPv4 works on this system! */
328 return; 328 return;
329 } 329 }
330 330
331 memset (&ifr, 0, sizeof (struct ifreq)); 331 memset (&ifr, 0, sizeof (struct ifreq));
@@ -410,8 +410,8 @@ set_address4 (const char *dev, const char *address, const char *mask)
410 */ 410 */
411 if (1 != inet_pton (AF_INET, address, &addr->sin_addr.s_addr)) 411 if (1 != inet_pton (AF_INET, address, &addr->sin_addr.s_addr))
412 { 412 {
413 fprintf (stderr, 413 fprintf (stderr,
414 "Failed to parse IPv4 address `%s': %s\n", 414 "Failed to parse IPv4 address `%s': %s\n",
415 address, 415 address,
416 strerror (errno)); 416 strerror (errno));
417 exit (1); 417 exit (1);
@@ -420,7 +420,7 @@ set_address4 (const char *dev, const char *address, const char *mask)
420 if (-1 == (fd = socket (PF_INET, SOCK_DGRAM, 0))) 420 if (-1 == (fd = socket (PF_INET, SOCK_DGRAM, 0)))
421 { 421 {
422 fprintf (stderr, 422 fprintf (stderr,
423 "Error creating IPv4 socket: %s\n", 423 "Error creating IPv4 socket: %s\n",
424 strerror (errno)); 424 strerror (errno));
425 exit (1); 425 exit (1);
426 } 426 }
@@ -619,7 +619,7 @@ run (int fd_tun)
619 return; 619 return;
620 } 620 }
621 buftun_size -= written; 621 buftun_size -= written;
622 buftun_read += written; 622 buftun_read += written;
623 } 623 }
624 624
625 if (FD_ISSET (0, &fds_r)) 625 if (FD_ISSET (0, &fds_r))
@@ -749,7 +749,7 @@ main (int argc, char *const*argv)
749 return 254; 749 return 254;
750 } 750 }
751#else 751#else
752 if (0 != seteuid (0)) 752 if (0 != seteuid (0))
753 { 753 {
754 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno)); 754 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno));
755 return 254; 755 return 254;
@@ -763,7 +763,7 @@ main (int argc, char *const*argv)
763 sbin_iptables = "/usr/sbin/iptables"; 763 sbin_iptables = "/usr/sbin/iptables";
764 else 764 else
765 { 765 {
766 fprintf (stderr, 766 fprintf (stderr,
767 "Fatal: executable iptables not found in approved directories: %s\n", 767 "Fatal: executable iptables not found in approved directories: %s\n",
768 strerror (errno)); 768 strerror (errno));
769 return 3; 769 return 3;
@@ -805,7 +805,7 @@ main (int argc, char *const*argv)
805 /* setup pipe to shutdown nicely on SIGINT */ 805 /* setup pipe to shutdown nicely on SIGINT */
806 if (0 != pipe (cpipe)) 806 if (0 != pipe (cpipe))
807 { 807 {
808 fprintf (stderr, 808 fprintf (stderr,
809 "Fatal: could not setup control pipe: %s\n", 809 "Fatal: could not setup control pipe: %s\n",
810 strerror (errno)); 810 strerror (errno));
811 return 6; 811 return 6;
@@ -839,14 +839,14 @@ main (int argc, char *const*argv)
839 } 839 }
840 if ( (SIG_ERR == signal (SIGTERM, &signal_handler)) || 840 if ( (SIG_ERR == signal (SIGTERM, &signal_handler)) ||
841 (SIG_ERR == signal (SIGINT, &signal_handler)) || 841 (SIG_ERR == signal (SIGINT, &signal_handler)) ||
842 (SIG_ERR == signal (SIGHUP, &signal_handler)) ) 842 (SIG_ERR == signal (SIGHUP, &signal_handler)) )
843 { 843 {
844 fprintf (stderr, 844 fprintf (stderr,
845 "Fatal: could not initialize signal handler: %s\n", 845 "Fatal: could not initialize signal handler: %s\n",
846 strerror (errno)); 846 strerror (errno));
847 (void) close (cpipe[0]); 847 (void) close (cpipe[0]);
848 (void) close (cpipe[1]); 848 (void) close (cpipe[1]);
849 return 7; 849 return 7;
850 } 850 }
851 851
852 852
@@ -868,8 +868,8 @@ main (int argc, char *const*argv)
868 return 5; 868 return 5;
869 } 869 }
870 } 870 }
871 871
872 872
873 /* now open virtual interface (first part that requires root) */ 873 /* now open virtual interface (first part that requires root) */
874 if (-1 == (fd_tun = init_tun (dev))) 874 if (-1 == (fd_tun = init_tun (dev)))
875 { 875 {
@@ -907,14 +907,14 @@ main (int argc, char *const*argv)
907 set_address4 (dev, address, mask); 907 set_address4 (dev, address, mask);
908 } 908 }
909 909
910 910
911 /* update routing tables -- next part why we need SUID! */ 911 /* update routing tables -- next part why we need SUID! */
912 /* Forward everything from our EGID (which should only be held 912 /* Forward everything from our EGID (which should only be held
913 by the 'gnunet-service-dns') and with destination 913 by the 'gnunet-service-dns') and with destination
914 to port 53 on UDP, without hijacking */ 914 to port 53 on UDP, without hijacking */
915 r = 8; /* failed to fully setup routing table */ 915 r = 8; /* failed to fully setup routing table */
916 { 916 {
917 char *const mangle_args[] = 917 char *const mangle_args[] =
918 { 918 {
919 "iptables", "-m", "owner", "-t", "mangle", "-I", "OUTPUT", "1", "-p", 919 "iptables", "-m", "owner", "-t", "mangle", "-I", "OUTPUT", "1", "-p",
920 "udp", "--gid-owner", mygid, "--dport", DNS_PORT, "-j", 920 "udp", "--gid-owner", mygid, "--dport", DNS_PORT, "-j",
@@ -922,7 +922,7 @@ main (int argc, char *const*argv)
922 }; 922 };
923 if (0 != fork_and_exec (sbin_iptables, mangle_args)) 923 if (0 != fork_and_exec (sbin_iptables, mangle_args))
924 goto cleanup_rest; 924 goto cleanup_rest;
925 } 925 }
926 /* Mark all of the other DNS traffic using our mark DNS_MARK */ 926 /* Mark all of the other DNS traffic using our mark DNS_MARK */
927 { 927 {
928 char *const mark_args[] = 928 char *const mark_args[] =
@@ -965,7 +965,7 @@ main (int argc, char *const*argv)
965 } 965 }
966#else 966#else
967 /* Note: no 'setuid' here as we must keep our saved UID as root */ 967 /* Note: no 'setuid' here as we must keep our saved UID as root */
968 if (0 != seteuid (uid)) 968 if (0 != seteuid (uid))
969 { 969 {
970 fprintf (stderr, "Failed to seteuid: %s\n", strerror (errno)); 970 fprintf (stderr, "Failed to seteuid: %s\n", strerror (errno));
971 r = 24; 971 r = 24;
@@ -977,7 +977,7 @@ main (int argc, char *const*argv)
977 977
978 /* now forward until we hit a problem */ 978 /* now forward until we hit a problem */
979 run (fd_tun); 979 run (fd_tun);
980 980
981 /* now need to regain privs so we can remove the firewall rules we added! */ 981 /* now need to regain privs so we can remove the firewall rules we added! */
982#ifdef HAVE_SETRESUID 982#ifdef HAVE_SETRESUID
983 if (0 != setresuid (uid, 0, 0)) 983 if (0 != setresuid (uid, 0, 0))
@@ -987,19 +987,19 @@ main (int argc, char *const*argv)
987 goto cleanup_route_4; 987 goto cleanup_route_4;
988 } 988 }
989#else 989#else
990 if (0 != seteuid (0)) 990 if (0 != seteuid (0))
991 { 991 {
992 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno)); 992 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno));
993 r = 40; 993 r = 40;
994 goto cleanup_route_4; 994 goto cleanup_route_4;
995 } 995 }
996#endif 996#endif
997 997
998 /* update routing tables again -- this is why we could not fully drop privs */ 998 /* update routing tables again -- this is why we could not fully drop privs */
999 /* now undo updating of routing tables; normal exit or clean-up-on-error case */ 999 /* now undo updating of routing tables; normal exit or clean-up-on-error case */
1000 cleanup_route_4: 1000 cleanup_route_4:
1001 { 1001 {
1002 char *const route_clean_args[] = 1002 char *const route_clean_args[] =
1003 { 1003 {
1004 "ip", "route", "del", "default", "dev", dev, 1004 "ip", "route", "del", "default", "dev", dev,
1005 "table", DNS_TABLE, NULL 1005 "table", DNS_TABLE, NULL
diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c
index ac410d3ed..53c19d01c 100644
--- a/src/dns/gnunet-service-dns.c
+++ b/src/dns/gnunet-service-dns.c
@@ -34,7 +34,7 @@
34 * each request will be given one of 128 random source ports, and the 34 * each request will be given one of 128 random source ports, and the
35 * 128 random source ports will also change "often" (less often if the 35 * 128 random source ports will also change "often" (less often if the
36 * system is very busy, each time if we are mostly idle). At the same 36 * system is very busy, each time if we are mostly idle). At the same
37 * time, the system will never use more than 256 UDP sockets. 37 * time, the system will never use more than 256 UDP sockets.
38 */ 38 */
39#include "platform.h" 39#include "platform.h"
40#include "gnunet_util_lib.h" 40#include "gnunet_util_lib.h"
@@ -88,7 +88,7 @@ enum RequestPhase
88 * Global Internet query is now pending. 88 * Global Internet query is now pending.
89 */ 89 */
90 RP_INTERNET_DNS, 90 RP_INTERNET_DNS,
91 91
92 /** 92 /**
93 * Client (or global DNS request) has resulted in a response. 93 * Client (or global DNS request) has resulted in a response.
94 * Forward to all POST-RESOLUTION clients. If client list is empty, 94 * Forward to all POST-RESOLUTION clients. If client list is empty,
@@ -111,22 +111,22 @@ enum RequestPhase
111 111
112/** 112/**
113 * Entry we keep for each client. 113 * Entry we keep for each client.
114 */ 114 */
115struct ClientRecord 115struct ClientRecord
116{ 116{
117 /** 117 /**
118 * Kept in doubly-linked list. 118 * Kept in doubly-linked list.
119 */ 119 */
120 struct ClientRecord *next; 120 struct ClientRecord *next;
121 121
122 /** 122 /**
123 * Kept in doubly-linked list. 123 * Kept in doubly-linked list.
124 */ 124 */
125 struct ClientRecord *prev; 125 struct ClientRecord *prev;
126 126
127 /** 127 /**
128 * Handle to the client. 128 * Handle to the client.
129 */ 129 */
130 struct GNUNET_SERVER_Client *client; 130 struct GNUNET_SERVER_Client *client;
131 131
132 /** 132 /**
@@ -139,7 +139,7 @@ struct ClientRecord
139 139
140/** 140/**
141 * Entry we keep for each active request. 141 * Entry we keep for each active request.
142 */ 142 */
143struct RequestRecord 143struct RequestRecord
144{ 144{
145 145
@@ -180,7 +180,7 @@ struct RequestRecord
180 180
181 /** 181 /**
182 * Number of bytes in payload. 182 * Number of bytes in payload.
183 */ 183 */
184 size_t payload_length; 184 size_t payload_length;
185 185
186 /** 186 /**
@@ -317,7 +317,7 @@ request_done (struct RequestRecord *rr)
317 317
318 GNUNET_array_grow (rr->client_wait_list, 318 GNUNET_array_grow (rr->client_wait_list,
319 rr->client_wait_list_length, 319 rr->client_wait_list_length,
320 0); 320 0);
321 if (RP_RESPONSE_MONITOR != rr->phase) 321 if (RP_RESPONSE_MONITOR != rr->phase)
322 { 322 {
323 /* no response, drop */ 323 /* no response, drop */
@@ -330,7 +330,7 @@ request_done (struct RequestRecord *rr)
330 330
331 LOG (GNUNET_ERROR_TYPE_DEBUG, 331 LOG (GNUNET_ERROR_TYPE_DEBUG,
332 "Transmitting response for request %llu\n", 332 "Transmitting response for request %llu\n",
333 (unsigned long long) rr->request_id); 333 (unsigned long long) rr->request_id);
334 /* send response via hijacker */ 334 /* send response via hijacker */
335 reply_len = sizeof (struct GNUNET_MessageHeader); 335 reply_len = sizeof (struct GNUNET_MessageHeader);
336 reply_len += sizeof (struct GNUNET_TUN_Layer2PacketHeader); 336 reply_len += sizeof (struct GNUNET_TUN_Layer2PacketHeader);
@@ -345,7 +345,7 @@ request_done (struct RequestRecord *rr)
345 default: 345 default:
346 GNUNET_break (0); 346 GNUNET_break (0);
347 cleanup_rr (rr); 347 cleanup_rr (rr);
348 return; 348 return;
349 } 349 }
350 reply_len += sizeof (struct GNUNET_TUN_UdpHeader); 350 reply_len += sizeof (struct GNUNET_TUN_UdpHeader);
351 reply_len += rr->payload_length; 351 reply_len += rr->payload_length;
@@ -354,7 +354,7 @@ request_done (struct RequestRecord *rr)
354 /* response too big, drop */ 354 /* response too big, drop */
355 GNUNET_break (0); /* how can this be? */ 355 GNUNET_break (0); /* how can this be? */
356 cleanup_rr(rr); 356 cleanup_rr(rr);
357 return; 357 return;
358 } 358 }
359 { 359 {
360 char buf[reply_len] GNUNET_ALIGN; 360 char buf[reply_len] GNUNET_ALIGN;
@@ -374,7 +374,7 @@ request_done (struct RequestRecord *rr)
374 374
375 tun.flags = htons (0); 375 tun.flags = htons (0);
376 if (rr->src_addr.ss_family == AF_INET) 376 if (rr->src_addr.ss_family == AF_INET)
377 tun.proto = htons (ETH_P_IPV4); 377 tun.proto = htons (ETH_P_IPV4);
378 else 378 else
379 tun.proto = htons (ETH_P_IPV6); 379 tun.proto = htons (ETH_P_IPV6);
380 memcpy (&buf[off], &tun, sizeof (struct GNUNET_TUN_Layer2PacketHeader)); 380 memcpy (&buf[off], &tun, sizeof (struct GNUNET_TUN_Layer2PacketHeader));
@@ -483,14 +483,14 @@ send_request_to_client (struct RequestRecord *rr,
483 } 483 }
484 LOG (GNUNET_ERROR_TYPE_DEBUG, 484 LOG (GNUNET_ERROR_TYPE_DEBUG,
485 "Sending information about request %llu to local client\n", 485 "Sending information about request %llu to local client\n",
486 (unsigned long long) rr->request_id); 486 (unsigned long long) rr->request_id);
487 req = (struct GNUNET_DNS_Request*) buf; 487 req = (struct GNUNET_DNS_Request*) buf;
488 req->header.type = htons (GNUNET_MESSAGE_TYPE_DNS_CLIENT_REQUEST); 488 req->header.type = htons (GNUNET_MESSAGE_TYPE_DNS_CLIENT_REQUEST);
489 req->header.size = htons (sizeof (buf)); 489 req->header.size = htons (sizeof (buf));
490 req->reserved = htonl (0); 490 req->reserved = htonl (0);
491 req->request_id = rr->request_id; 491 req->request_id = rr->request_id;
492 memcpy (&req[1], rr->payload, rr->payload_length); 492 memcpy (&req[1], rr->payload, rr->payload_length);
493 GNUNET_SERVER_notification_context_unicast (nc, 493 GNUNET_SERVER_notification_context_unicast (nc,
494 client, 494 client,
495 &req->header, 495 &req->header,
496 GNUNET_NO); 496 GNUNET_NO);
@@ -541,8 +541,8 @@ next_phase (struct RequestRecord *rr)
541 nz = (int) j; 541 nz = (int) j;
542 break; 542 break;
543 } 543 }
544 } 544 }
545 if (-1 != nz) 545 if (-1 != nz)
546 { 546 {
547 send_request_to_client (rr, rr->client_wait_list[nz]->client); 547 send_request_to_client (rr, rr->client_wait_list[nz]->client);
548 return; 548 return;
@@ -551,7 +551,7 @@ next_phase (struct RequestRecord *rr)
551 LOG (GNUNET_ERROR_TYPE_DEBUG, 551 LOG (GNUNET_ERROR_TYPE_DEBUG,
552 "Request %llu now in phase %d\n", 552 "Request %llu now in phase %d\n",
553 rr->request_id, 553 rr->request_id,
554 rr->phase); 554 rr->phase);
555 switch (rr->phase) 555 switch (rr->phase)
556 { 556 {
557 case RP_INIT: 557 case RP_INIT:
@@ -647,7 +647,7 @@ next_phase (struct RequestRecord *rr)
647 * 647 *
648 * @param cls unused 648 * @param cls unused
649 * @param client handle of client that disconnected 649 * @param client handle of client that disconnected
650 */ 650 */
651static void 651static void
652client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) 652client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
653{ 653{
@@ -674,7 +674,7 @@ client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
674 if (rr->client_wait_list[j] == cr) 674 if (rr->client_wait_list[j] == cr)
675 { 675 {
676 rr->client_wait_list[j] = NULL; 676 rr->client_wait_list[j] = NULL;
677 next_phase (rr); 677 next_phase (rr);
678 } 678 }
679 } 679 }
680 } 680 }
@@ -714,8 +714,8 @@ process_dns_result (void *cls,
714 gettext_noop ("# External DNS response discarded (no matching request)"), 714 gettext_noop ("# External DNS response discarded (no matching request)"),
715 1, GNUNET_NO); 715 1, GNUNET_NO);
716 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 716 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
717 "Received DNS reply that does not match any pending request. Dropping.\n"); 717 "Received DNS reply that does not match any pending request. Dropping.\n");
718 return; 718 return;
719 } 719 }
720 LOG (GNUNET_ERROR_TYPE_DEBUG, 720 LOG (GNUNET_ERROR_TYPE_DEBUG,
721 "Got a response from the stub resolver for DNS request %llu intercepted locally!\n", 721 "Got a response from the stub resolver for DNS request %llu intercepted locally!\n",
@@ -736,7 +736,7 @@ process_dns_result (void *cls,
736 * @param message the init message (unused) 736 * @param message the init message (unused)
737 */ 737 */
738static void 738static void
739handle_client_init (void *cls GNUNET_UNUSED, 739handle_client_init (void *cls GNUNET_UNUSED,
740 struct GNUNET_SERVER_Client *client, 740 struct GNUNET_SERVER_Client *client,
741 const struct GNUNET_MessageHeader *message) 741 const struct GNUNET_MessageHeader *message)
742{ 742{
@@ -745,7 +745,7 @@ handle_client_init (void *cls GNUNET_UNUSED,
745 745
746 cr = GNUNET_malloc (sizeof (struct ClientRecord)); 746 cr = GNUNET_malloc (sizeof (struct ClientRecord));
747 cr->client = client; 747 cr->client = client;
748 cr->flags = (enum GNUNET_DNS_Flags) ntohl (reg->flags); 748 cr->flags = (enum GNUNET_DNS_Flags) ntohl (reg->flags);
749 GNUNET_SERVER_client_keep (client); 749 GNUNET_SERVER_client_keep (client);
750 GNUNET_CONTAINER_DLL_insert (clients_head, 750 GNUNET_CONTAINER_DLL_insert (clients_head,
751 clients_tail, 751 clients_tail,
@@ -763,7 +763,7 @@ handle_client_init (void *cls GNUNET_UNUSED,
763 * @param message the response 763 * @param message the response
764 */ 764 */
765static void 765static void
766handle_client_response (void *cls GNUNET_UNUSED, 766handle_client_response (void *cls GNUNET_UNUSED,
767 struct GNUNET_SERVER_Client *client, 767 struct GNUNET_SERVER_Client *client,
768 const struct GNUNET_MessageHeader *message) 768 const struct GNUNET_MessageHeader *message)
769{ 769{
@@ -816,7 +816,7 @@ handle_client_response (void *cls GNUNET_UNUSED,
816 { 816 {
817 GNUNET_break (0); 817 GNUNET_break (0);
818 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 818 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
819 next_phase (rr); 819 next_phase (rr);
820 return; 820 return;
821 } 821 }
822 GNUNET_free_non_null (rr->payload); 822 GNUNET_free_non_null (rr->payload);
@@ -844,9 +844,9 @@ handle_client_response (void *cls GNUNET_UNUSED,
844 } 844 }
845 break; 845 break;
846 } 846 }
847 next_phase (rr); 847 next_phase (rr);
848 GNUNET_SERVER_receive_done (client, GNUNET_OK); 848 GNUNET_SERVER_receive_done (client, GNUNET_OK);
849 return; 849 return;
850 } 850 }
851 /* odd, client was not on our list for the request, that ought 851 /* odd, client was not on our list for the request, that ought
852 to be an error */ 852 to be an error */
@@ -936,7 +936,7 @@ process_helper_messages (void *cls GNUNET_UNUSED, void *client,
936 } 936 }
937 if ( (msize <= sizeof (struct GNUNET_TUN_UdpHeader) + sizeof (struct GNUNET_TUN_DnsHeader)) || 937 if ( (msize <= sizeof (struct GNUNET_TUN_UdpHeader) + sizeof (struct GNUNET_TUN_DnsHeader)) ||
938 (DNS_PORT != ntohs (udp->destination_port)) ) 938 (DNS_PORT != ntohs (udp->destination_port)) )
939 { 939 {
940 /* non-DNS packet received on TUN, ignore */ 940 /* non-DNS packet received on TUN, ignore */
941 GNUNET_STATISTICS_update (stats, 941 GNUNET_STATISTICS_update (stats,
942 gettext_noop ("# Non-DNS UDP packet received via TUN interface"), 942 gettext_noop ("# Non-DNS UDP packet received via TUN interface"),
@@ -1025,7 +1025,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1025{ 1025{
1026 static const struct GNUNET_SERVER_MessageHandler handlers[] = { 1026 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
1027 /* callback, cls, type, size */ 1027 /* callback, cls, type, size */
1028 {&handle_client_init, NULL, GNUNET_MESSAGE_TYPE_DNS_CLIENT_INIT, 1028 {&handle_client_init, NULL, GNUNET_MESSAGE_TYPE_DNS_CLIENT_INIT,
1029 sizeof (struct GNUNET_DNS_Register)}, 1029 sizeof (struct GNUNET_DNS_Register)},
1030 {&handle_client_response, NULL, GNUNET_MESSAGE_TYPE_DNS_CLIENT_RESPONSE, 0}, 1030 {&handle_client_response, NULL, GNUNET_MESSAGE_TYPE_DNS_CLIENT_RESPONSE, 0},
1031 {NULL, NULL, 0, 0} 1031 {NULL, NULL, 0, 0}
@@ -1059,7 +1059,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1059 cls); 1059 cls);
1060 dns_exit = NULL; 1060 dns_exit = NULL;
1061 if ( ( (GNUNET_OK != 1061 if ( ( (GNUNET_OK !=
1062 GNUNET_CONFIGURATION_get_value_string (cfg, "dns", 1062 GNUNET_CONFIGURATION_get_value_string (cfg, "dns",
1063 "DNS_EXIT", 1063 "DNS_EXIT",
1064 &dns_exit)) || 1064 &dns_exit)) ||
1065 ( (1 != inet_pton (AF_INET, dns_exit, &dns_exit4)) && 1065 ( (1 != inet_pton (AF_INET, dns_exit, &dns_exit4)) &&
@@ -1157,7 +1157,7 @@ main (int argc, char *const *argv)
1157 strerror (errno)); 1157 strerror (errno));
1158 } 1158 }
1159 else if (sgid != rgid) 1159 else if (sgid != rgid)
1160 { 1160 {
1161 if (-1 == setregid (sgid, sgid)) 1161 if (-1 == setregid (sgid, sgid))
1162 fprintf (stderr, "setregid failed: %s\n", strerror (errno)); 1162 fprintf (stderr, "setregid failed: %s\n", strerror (errno));
1163 } 1163 }
diff --git a/src/dns/plugin_block_dns.c b/src/dns/plugin_block_dns.c
index de9185a5a..a8846944e 100644
--- a/src/dns/plugin_block_dns.c
+++ b/src/dns/plugin_block_dns.c
@@ -85,14 +85,14 @@ block_plugin_dns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
85 GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh 85 GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh
86 (ad->expiration_time)).rel_value_us) 86 (ad->expiration_time)).rel_value_us)
87 { 87 {
88 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 88 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
89 "DNS advertisement has expired\n"); 89 "DNS advertisement has expired\n");
90 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 90 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
91 } 91 }
92 if (GNUNET_OK != 92 if (GNUNET_OK !=
93 GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD, 93 GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_DNS_RECORD,
94 &ad->purpose, 94 &ad->purpose,
95 &ad->signature, 95 &ad->signature,
96 &ad->peer.public_key)) 96 &ad->peer.public_key))
97 { 97 {
98 GNUNET_break_op (0); 98 GNUNET_break_op (0);
@@ -117,9 +117,9 @@ block_plugin_dns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
117 * (or if extracting a key from a block of this type does not work) 117 * (or if extracting a key from a block of this type does not work)
118 */ 118 */
119static int 119static int
120block_plugin_dns_get_key (void *cls, 120block_plugin_dns_get_key (void *cls,
121 enum GNUNET_BLOCK_Type type, 121 enum GNUNET_BLOCK_Type type,
122 const void *block, 122 const void *block,
123 size_t block_size, 123 size_t block_size,
124 struct GNUNET_HashCode *key) 124 struct GNUNET_HashCode *key)
125{ 125{