aboutsummaryrefslogtreecommitdiff
path: root/src/util/resolver_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-10-18 14:55:17 +0200
committerChristian Grothoff <christian@grothoff.org>2018-10-18 14:55:17 +0200
commitc7c6446e3ea37531b67252a452937f3578570a57 (patch)
tree25c3e77499bc2bc14bd408ae1414badced015265 /src/util/resolver_api.c
parent418bf5953acdba2e325528d739fb115b51b7141f (diff)
downloadgnunet-c7c6446e3ea37531b67252a452937f3578570a57.tar.gz
gnunet-c7c6446e3ea37531b67252a452937f3578570a57.zip
use unique 32-bit IDs for DNS requests to avoid random confusions, handle additional and authoritative records as well
Diffstat (limited to 'src/util/resolver_api.c')
-rw-r--r--src/util/resolver_api.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index 8a054327b..871eeb4bf 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -68,10 +68,10 @@ static struct GNUNET_RESOLVER_RequestHandle *req_head;
68 */ 68 */
69static struct GNUNET_RESOLVER_RequestHandle *req_tail; 69static struct GNUNET_RESOLVER_RequestHandle *req_tail;
70 70
71///** 71/**
72// * ID of the last request we sent to the service 72 * ID of the last request we sent to the service
73// */ 73 */
74//static uint16_t last_request_id; 74static uint32_t last_request_id;
75 75
76/** 76/**
77 * How long should we wait to reconnect? 77 * How long should we wait to reconnect?
@@ -445,7 +445,7 @@ process_requests ()
445 GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST); 445 GNUNET_MESSAGE_TYPE_RESOLVER_REQUEST);
446 msg->direction = htonl (rh->direction); 446 msg->direction = htonl (rh->direction);
447 msg->af = htonl (rh->af); 447 msg->af = htonl (rh->af);
448 msg->id = htons (rh->id); 448 msg->client_id = rh->id;
449 GNUNET_memcpy (&msg[1], 449 GNUNET_memcpy (&msg[1],
450 &rh[1], 450 &rh[1],
451 rh->data_len); 451 rh->data_len);
@@ -491,11 +491,11 @@ handle_response (void *cls,
491 struct GNUNET_RESOLVER_RequestHandle *rh = req_head; 491 struct GNUNET_RESOLVER_RequestHandle *rh = req_head;
492 uint16_t size; 492 uint16_t size;
493 char *nret; 493 char *nret;
494 uint16_t request_id = msg->id; 494 uint32_t client_request_id = msg->client_id;
495 495
496 for (; rh != NULL; rh = rh->next) 496 for (; rh != NULL; rh = rh->next)
497 { 497 {
498 if (rh->id == request_id) 498 if (rh->id == client_request_id)
499 break; 499 break;
500 } 500 }
501 501
@@ -911,14 +911,6 @@ handle_lookup_timeout (void *cls)
911} 911}
912 912
913 913
914static uint16_t
915get_request_id ()
916{
917 return (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
918 UINT16_MAX);
919}
920
921
922/** 914/**
923 * Convert a string to one or more IP addresses. 915 * Convert a string to one or more IP addresses.
924 * 916 *
@@ -953,8 +945,7 @@ GNUNET_RESOLVER_ip_get (const char *hostname,
953 hostname); 945 hostname);
954 rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + slen); 946 rh = GNUNET_malloc (sizeof (struct GNUNET_RESOLVER_RequestHandle) + slen);
955 rh->af = af; 947 rh->af = af;
956 //rh->id = ++last_request_id; 948 rh->id = ++last_request_id;
957 rh->id = get_request_id ();
958 rh->addr_callback = callback; 949 rh->addr_callback = callback;
959 rh->cls = callback_cls; 950 rh->cls = callback_cls;
960 GNUNET_memcpy (&rh[1], 951 GNUNET_memcpy (&rh[1],
@@ -1101,8 +1092,7 @@ GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
1101 rh->name_callback = callback; 1092 rh->name_callback = callback;
1102 rh->cls = cls; 1093 rh->cls = cls;
1103 rh->af = sa->sa_family; 1094 rh->af = sa->sa_family;
1104 //rh->id = ++last_request_id; 1095 rh->id = ++last_request_id;
1105 rh->id = get_request_id ();
1106 rh->timeout = GNUNET_TIME_relative_to_absolute (timeout); 1096 rh->timeout = GNUNET_TIME_relative_to_absolute (timeout);
1107 GNUNET_memcpy (&rh[1], 1097 GNUNET_memcpy (&rh[1],
1108 ip, 1098 ip,