X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fgns%2Fgnunet-dns2gns.c;h=e6e53d40524b4ce8810336af39e238ba421164d3;hb=e54f88a363b8560f83b13875c6e450b5393b0a7b;hp=3d16cd773b49406d5e2f12702c0e3b47e9d14160;hpb=37f62bb432a79506cffaa1663e5e1bd6b6c96bea;p=oweals%2Fgnunet.git
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 3d16cd773..e6e53d405 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -2,20 +2,18 @@
This file is part of GNUnet.
Copyright (C) 2012-2013 GNUnet e.V.
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
*/
/**
* @file gnunet-dns2gns.c
@@ -85,6 +83,11 @@ struct Request
* Number of bytes in @e udp_msg.
*/
size_t udp_msg_size;
+
+ /**
+ * ID of the original request.
+ */
+ uint16_t original_request_id;
};
@@ -242,19 +245,28 @@ do_timeout (void *cls)
* Iterator called on obtained result for a DNS lookup
*
* @param cls closure
- * @param rs the request socket
* @param dns the DNS udp payload
* @param r size of the DNS payload
*/
static void
dns_result_processor (void *cls,
- struct GNUNET_DNSSTUB_RequestSocket *rs,
const struct GNUNET_TUN_DnsHeader *dns,
size_t r)
{
struct Request *request = cls;
- (void) rs;
+ if (NULL == dns)
+ {
+ /* DNSSTUB gave up, so we trigger timeout early */
+ GNUNET_SCHEDULER_cancel (request->timeout_task);
+ do_timeout (request);
+ return;
+ }
+ if (request->original_request_id != dns->id)
+ {
+ /* for a another query, ignore */
+ return;
+ }
request->packet = GNUNET_DNSPARSER_parse ((char*)dns,
r);
send_response (request);
@@ -277,7 +289,6 @@ result_processor (void *cls,
{
struct Request *request = cls;
struct GNUNET_DNSPARSER_Packet *packet;
- uint32_t i;
struct GNUNET_DNSPARSER_Record rec;
request->lookup = NULL;
@@ -288,15 +299,16 @@ result_processor (void *cls,
"Using DNS resolver IP `%s' to resolve `%s'\n",
dns_ip,
request->packet->queries[0].name);
+ request->original_request_id = request->packet->id;
GNUNET_DNSPARSER_free_packet (request->packet);
request->packet = NULL;
- request->dns_lookup = GNUNET_DNSSTUB_resolve2 (dns_stub,
- request->udp_msg,
- request->udp_msg_size,
- &dns_result_processor,
- request);
+ request->dns_lookup = GNUNET_DNSSTUB_resolve (dns_stub,
+ request->udp_msg,
+ request->udp_msg_size,
+ &dns_result_processor,
+ request);
return;
- }
+ }
packet = request->packet;
packet->flags.query_or_response = 1;
packet->flags.return_code = GNUNET_TUN_DNS_RETURN_CODE_NO_ERROR;
@@ -307,7 +319,7 @@ result_processor (void *cls,
packet->flags.message_truncated = 0;
packet->flags.authoritative_answer = 0;
//packet->flags.opcode = GNUNET_TUN_DNS_OPCODE_STATUS; // ???
- for (i=0;i