X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fdns%2Fdnsstub.c;h=c755aff16032b0d4e45b36bbafa4d86de7b294a5;hb=70466ec3c34f9a920e9e798e3169f886e9486a59;hp=154d59326638a33e18b2a42aa716328badadf14f;hpb=760d2d696450ef550abf99e16f4092b8050a9f4c;p=oweals%2Fgnunet.git diff --git a/src/dns/dnsstub.c b/src/dns/dnsstub.c index 154d59326..c755aff16 100644 --- a/src/dns/dnsstub.c +++ b/src/dns/dnsstub.c @@ -250,7 +250,8 @@ get_request_socket (struct GNUNET_DNSSTUB_Context *ctx, * Perform DNS resolution. * * @param ctx stub resolver to use - * @param af address family to use + * @param sa the socket address + * @param sa_len the socket length * @param request DNS request to transmit * @param request_len number of bytes in msg * @param rc function to call with result @@ -278,6 +279,10 @@ GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx, else ret = rs->dnsout6; GNUNET_assert (NULL != ret); + memcpy (&rs->addr, + sa, + sa_len); + rs->addrlen = sa_len; rs->rc = rc; rs->rc_cls = rc_cls; if (GNUNET_SYSERR == @@ -289,6 +294,10 @@ GNUNET_DNSSTUB_resolve (struct GNUNET_DNSSTUB_Context *ctx, GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to send DNS request to %s\n"), GNUNET_a2s (sa, sa_len)); + else + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + _("Sent DNS request to %s\n"), + GNUNET_a2s (sa, sa_len)); return rs; } @@ -408,7 +417,9 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs, /* port the code above? */ len = UINT16_MAX; #endif - + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Receiving %d byte DNS reply\n", + len); { unsigned char buf[len] GNUNET_ALIGN; @@ -436,11 +447,16 @@ do_dns_read (struct GNUNET_DNSSTUB_RequestSocket *rs, &addr, addrlen)) || (0 == GNUNET_TIME_absolute_get_remaining (rs->timeout).rel_value) ) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Request timeout or invalid sender address; ignoring reply\n"); return GNUNET_NO; - rs->rc (rs->rc_cls, - rs, - dns, - r); + } + if (NULL != rs->rc) + rs->rc (rs->rc_cls, + rs, + dns, + r); } return GNUNET_OK; } @@ -491,6 +507,17 @@ read_response (void *cls, } +/** + * Cancel DNS resolution. + * + * @param rs resolution to cancel + */ +void +GNUNET_DNSSTUB_resolve_cancel (struct GNUNET_DNSSTUB_RequestSocket *rs) +{ + rs->rc = NULL; +} + /** * Start a DNS stub resolver.