/*
This file is part of GNUnet.
- (C) 2011-2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2011-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
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., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
/**
* Default timeout for DNS lookups.
*/
-#define DNS_LOOKUP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define DNS_LOOKUP_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
/**
* Default timeout for VPN redirections.
/**
* Expiration time for the DNS record, 0 if we didn't
- * get anything useful (i.e. 'gethostbyname' was used).
+ * get anything useful (i.e. 'gethostbyname()' was used).
*/
uint64_t expiration_time;
/**
* ID of a task associated with the resolution process.
*/
- GNUNET_SCHEDULER_TaskIdentifier task_id;
+ struct GNUNET_SCHEDULER_Task * task_id;
/**
* The name to resolve
* Task scheduled to asynchronously fail a resolution.
*
* @param cls the 'struct GNS_ResolverHandle' of the resolution to fail
- * @param tc task context
*/
static void
-fail_resolution (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+fail_resolution (void *cls)
{
struct GNS_ResolverHandle *rh = cls;
- rh->task_id = GNUNET_SCHEDULER_NO_TASK;
+ rh->task_id = NULL;
rh->proc (rh->proc_cls, 0, NULL);
GNS_resolver_lookup_cancel (rh);
}
res->data_size = data_size;
res->record_type = record_type;
res->data = &res[1];
- memcpy (&res[1], data, data_size);
+ GNUNET_memcpy (&res[1], data, data_size);
GNUNET_CONTAINER_DLL_insert (rh->dns_result_head,
rh->dns_result_tail,
res);
const struct sockaddr_in *sa4;
const struct sockaddr_in6 *sa6;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received %u bytes of DNS IP data\n",
- addrlen);
if (NULL == addr)
{
rh->std_resolve = NULL;
transmit_lookup_dns_result (rh);
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received %u bytes of DNS IP data\n",
+ addrlen);
switch (addr->sa_family)
{
case AF_INET:
* @param tc task context
*/
static void
-recursive_resolution (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
+recursive_resolution (void *cls);
/**
rh->dns_request = NULL;
GNUNET_SCHEDULER_cancel (rh->task_id);
- rh->task_id = GNUNET_SCHEDULER_NO_TASK;
+ rh->task_id = NULL;
p = GNUNET_DNSPARSER_parse ((const char *) dns,
dns_len);
if (NULL == p)
else if (i < p->num_answers + p->num_authority_records)
rec = &p->authority_records[i - p->num_answers];
else
- rec = &p->authority_records[i - p->num_answers - p->num_authority_records];
+ rec = &p->additional_records[i - p->num_answers - p->num_authority_records];
/* As we copied the full DNS name to 'rh->ac_tail->label', this
should be the correct check to see if this record is actually
a record for our label... */
#if HAVE_SOCKADDR_IN_SIN_LEN
v4.sin_len = (u_char) sa_len;
#endif
- memcpy (&v4.sin_addr,
+ GNUNET_memcpy (&v4.sin_addr,
rd[j].data,
sizeof (struct in_addr));
sa = (struct sockaddr *) &v4;
#if HAVE_SOCKADDR_IN_SIN_LEN
v6.sin6_len = (u_char) sa_len;
#endif
- memcpy (&v6.sin6_addr,
+ GNUNET_memcpy (&v6.sin6_addr,
rd[j].data,
sizeof (struct in6_addr));
sa = (struct sockaddr *) &v6;
/* expand authority chain */
ac = GNUNET_new (struct AuthorityChain);
ac->rh = rh;
+ GNUNET_assert (strlen (rh->g2dc->ns) <= GNUNET_DNSPARSER_MAX_NAME_LENGTH);
strcpy (ac->authority_info.dns_authority.name,
rh->g2dc->ns);
- memcpy (&ac->authority_info.dns_authority.dns_ip,
+ GNUNET_memcpy (&ac->authority_info.dns_authority.dns_ip,
sa,
sa_len);
/* for DNS recursion, the label is the full DNS name,
GNUNET_break_op (0);
break;
}
- memcpy (&pub, rd[i].data, rd[i].data_size);
+ GNUNET_memcpy (&pub, rd[i].data, rd[i].data_size);
rd_off++;
if (GNUNET_GNSRECORD_TYPE_PKEY != rh->record_type)
{
case GNUNET_GNSRECORD_TYPE_GNS2DNS:
{
/* delegation to DNS */
+ if (GNUNET_GNSRECORD_TYPE_GNS2DNS == rh->record_type)
+ {
+ rd_off++;
+ break; /* do not follow to DNS, we wanted the GNS2DNS record! */
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Found GNS2DNS record, delegating to DNS!\n");
goto do_recurse;
ac->gns_authority = GNUNET_YES;
ac->suggested_shortening_label = NULL;
ac->shortening_started = GNUNET_NO;
- memcpy (&ac->authority_info.gns_authority,
+ GNUNET_memcpy (&ac->authority_info.gns_authority,
rd[i].data,
sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey));
ac->label = resolver_lookup_get_next_label (rh);
resolver to use */
g2dc = GNUNET_new (struct Gns2DnsContext);
g2dc->ns = ns;
+
g2dc->rh = GNUNET_new (struct GNS_ResolverHandle);
g2dc->rh->authority_zone = rh->ac_tail->authority_info.gns_authority;
ip = translate_dot_plus (rh, ip);
* Task scheduled to continue with the resolution process.
*
* @param cls the `struct GNS_ResolverHandle` of the resolution
- * @param tc task context
*/
static void
-recursive_resolution (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+recursive_resolution (void *cls)
{
struct GNS_ResolverHandle *rh = cls;
- rh->task_id = GNUNET_SCHEDULER_NO_TASK;
+ rh->task_id = NULL;
if (MAX_RECURSION < rh->loop_limiter++)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
GNUNET_free (rh->g2dc);
rh->g2dc = NULL;
}
- if (GNUNET_SCHEDULER_NO_TASK != rh->task_id)
+ if (NULL != rh->task_id)
{
GNUNET_SCHEDULER_cancel (rh->task_id);
- rh->task_id = GNUNET_SCHEDULER_NO_TASK;
+ rh->task_id = NULL;
}
if (NULL != rh->get_handle)
{
dht_lookup_heap =
GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
max_allowed_background_queries = max_bg_queries;
- if (GNUNET_SYSERR == (use_cache = GNUNET_CONFIGURATION_get_value_yesno (c,
- "gns",
- "USE_CACHE")))
+ if (GNUNET_SYSERR == (use_cache =
+ GNUNET_CONFIGURATION_get_value_yesno (c,
+ "gns",
+ "USE_CACHE")))
use_cache = GNUNET_YES;
if (GNUNET_NO == use_cache)
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Namecache disabled\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Namecache disabled\n");
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (c,