diff options
Diffstat (limited to 'src/dns/dnsstub.c')
-rw-r--r-- | src/dns/dnsstub.c | 40 |
1 files changed, 20 insertions, 20 deletions
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 | */ |
44 | struct GNUNET_DNSSTUB_RequestSocket | 44 | struct 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 | */ |
93 | struct GNUNET_DNSSTUB_Context | 93 | struct 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 | */ |
142 | static struct GNUNET_NETWORK_Handle * | 142 | static struct GNUNET_NETWORK_Handle * |
143 | open_socket (int af) | 143 | open_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 * | |||
530 | GNUNET_DNSSTUB_start (const char *dns_ip) | 530 | GNUNET_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); |