* @brief GNUnet GNS resolver logic
* @author Martin Schanzenbach
* @author Christian Grothoff
+ *
+ * TODO:
+ * - recurive GNS resulution
+ * - recursive DNS resolution
+ * - shortening triggers
+ * - revocation checks (privacy!?)
*/
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_dns_service.h"
#include "gnunet_resolver_service.h"
#include "gnunet_dnsparser_lib.h"
-#include "gns_protocol.h"
#include "gnunet_gns_service.h"
-#include "gns_common.h"
#include "gns.h"
#include "gnunet-service-gns_resolver.h"
#include "gnunet_vpn_service.h"
*/
char label[GNUNET_DNSPARSER_MAX_LABEL_LENGTH + 1];
+ /**
+ * Label we are currently trying out (during #perform_pseu_lookup).
+ */
+ char *current_label;
+
/**
* The zone for which we are trying to find the PSEU record.
*/
* even though they consist of multiple labels.
*
* Examples:
- * a.b.gads = not canonical
+ * a.b.gnu = not canonical
* a = canonical
* _foo._srv = canonical
* _f.bar = not canonical
gph->timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, gph);
+ GNUNET_free_non_null (gph->current_label);
GNUNET_free (gph);
}
* (or with rd_count=0 to indicate no matches).
*
* @param cls the pending query
- * @param key the key of the zone we did the lookup
- * @param name the name for which we need an authority
* @param rd_count the number of records with 'name'
* @param rd the record data
*/
static void
process_pseu_lookup_ns (void *cls,
- const struct GNUNET_CRYPTO_EccPrivateKey *key,
- const char *name,
+ unsigned int rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd);
+
+
+/**
+ * We obtained a result for our query to the shorten zone from
+ * the namestore. Try to decrypt.
+ *
+ * @param cls the handle to our shorten operation
+ * @param block resulting encrypted block
+ */
+static void
+process_pseu_block_ns (void *cls,
+ const struct GNUNET_NAMESTORE_Block *block)
+{
+ struct GetPseuAuthorityHandle *gph = cls;
+ struct GNUNET_CRYPTO_EccPublicKey pub;
+
+ gph->namestore_task = NULL;
+ if (NULL == block)
+ {
+ process_pseu_lookup_ns (gph, 0, NULL);
+ return;
+ }
+ GNUNET_CRYPTO_ecc_key_get_public (&gph->shorten_zone_key,
+ &pub);
+ if (GNUNET_OK !=
+ GNUNET_NAMESTORE_block_decrypt (block,
+ &pub,
+ gph->current_label,
+ &process_pseu_lookup_ns,
+ gph))
+ {
+ GNUNET_break (0);
+ free_get_pseu_authority_handle (gph);
+ return;
+ }
+}
+
+
+/**
+ * Lookup in the namestore for the shorten zone the given label.
+ *
+ * @param gph the handle to our shorten operation
+ * @param label the label to lookup
+ */
+static void
+perform_pseu_lookup (struct GetPseuAuthorityHandle *gph,
+ const char *label)
+{
+ struct GNUNET_CRYPTO_EccPublicKey pub;
+ struct GNUNET_HashCode query;
+
+ GNUNET_CRYPTO_ecc_key_get_public (&gph->shorten_zone_key,
+ &pub);
+ GNUNET_free_non_null (gph->current_label);
+ gph->current_label = GNUNET_strdup (label);
+ GNUNET_NAMESTORE_query_from_public_key (&pub,
+ label,
+ &query);
+ gph->namestore_task = GNUNET_NAMESTORE_lookup_block (namestore_handle,
+ &query,
+ &process_pseu_block_ns,
+ gph);
+}
+
+
+/**
+ * Namestore calls this function if we have record for this name.
+ * (or with rd_count=0 to indicate no matches).
+ *
+ * @param cls the pending query
+ * @param rd_count the number of records with 'name'
+ * @param rd the record data
+ */
+static void
+process_pseu_lookup_ns (void *cls,
unsigned int rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
{
struct GetPseuAuthorityHandle *gph = cls;
struct GNUNET_NAMESTORE_RecordData new_pkey;
- struct GNUNET_CRYPTO_EccPublicKey pub;
gph->namestore_task = NULL;
if (rd_count > 0)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Name `%s' already taken, cannot shorten.\n",
- name);
+ gph->current_label);
/* if this was not yet the original label, try one more
time, this time not using PSEU but the original label */
- if (0 == strcmp (name,
+ if (0 == strcmp (gph->current_label,
gph->label))
{
free_get_pseu_authority_handle (gph);
}
else
{
- GNUNET_CRYPTO_ecc_key_get_public (&gph->shorten_zone_key,
- &pub);
- gph->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle,
- &pub,
- gph->label,
- &process_pseu_lookup_ns,
- gph);
+ perform_pseu_lookup (gph, gph->label);
}
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Shortening `%s' to `%s'\n",
GNUNET_NAMESTORE_z2s (&gph->target_zone),
- name);
+ gph->current_label);
new_pkey.expiration_time = UINT64_MAX;
new_pkey.data_size = sizeof (struct GNUNET_CRYPTO_EccPublicKey);
new_pkey.data = &gph->target_zone;
gph->namestore_task
= GNUNET_NAMESTORE_records_store (namestore_handle,
&gph->shorten_zone_key,
- name,
+ gph->current_label,
1, &new_pkey,
&create_pkey_cont, gph);
}
process_pseu_result (struct GetPseuAuthorityHandle* gph,
const char *pseu)
{
- struct GNUNET_CRYPTO_EccPublicKey pub;
-
- GNUNET_CRYPTO_ecc_key_get_public (&gph->shorten_zone_key,
- &pub);
if (NULL == pseu)
{
/* no PSEU found, try original label */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No PSEU found, trying original label `%s' instead.\n",
gph->label);
- gph->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle,
- &pub,
- gph->label,
- &process_pseu_lookup_ns,
- gph);
+ perform_pseu_lookup (gph, gph->label);
return;
- }
-
+ }
/* check if 'pseu' is taken */
- gph->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle,
- &pub,
- pseu,
- &process_pseu_lookup_ns,
- gph);
+ perform_pseu_lookup (gph, pseu);
}
/* ************************** Resolution **************************** */
#if 0
-/**
- * Helper function to free resolver handle
- *
- * @param rh the handle to free
- */
-static void
-free_resolver_handle (struct ResolverHandle* rh)
-{
- struct AuthorityChain *ac;
- struct AuthorityChain *ac_next;
-
- if (NULL == rh)
- return;
-
- ac_next = rh->authority_chain_head;
- while (NULL != (ac = ac_next))
- {
- ac_next = ac->next;
- GNUNET_free (ac);
- }
-
- if (NULL != rh->get_handle)
- GNUNET_DHT_get_stop (rh->get_handle);
- if (NULL != rh->dns_raw_packet)
- GNUNET_free (rh->dns_raw_packet);
- if (NULL != rh->namestore_task)
- {
- GNUNET_NAMESTORE_cancel (rh->namestore_task);
- rh->namestore_task = NULL;
- }
- if (GNUNET_SCHEDULER_NO_TASK != rh->dns_read_task)
- GNUNET_SCHEDULER_cancel (rh->dns_read_task);
- if (GNUNET_SCHEDULER_NO_TASK != rh->timeout_task)
- GNUNET_SCHEDULER_cancel (rh->timeout_task);
- if (NULL != rh->dns_sock)
- GNUNET_NETWORK_socket_close (rh->dns_sock);
- if (NULL != rh->dns_resolver_handle)
- GNUNET_RESOLVER_request_cancel (rh->dns_resolver_handle);
- if (NULL != rh->rd.data)
- GNUNET_free ((void*)(rh->rd.data));
- if (NULL != rh->dht_heap_node)
- GNUNET_CONTAINER_heap_remove_node (rh->dht_heap_node);
- GNUNET_free (rh);
-}
-
-
-/**
- * Callback when record data is put into namestore
- *
- * @param cls the closure
- * @param success GNUNET_OK on success
- * @param emsg the error message. NULL if SUCCESS==GNUNET_OK
- */
-void
-on_namestore_record_put_result (void *cls,
- int32_t success,
- const char *emsg)
-{
- struct NamestoreBGTask *nbg = cls;
-
- GNUNET_CONTAINER_heap_remove_node (nbg->node);
- GNUNET_free (nbg);
-
- if (GNUNET_NO == success)
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "GNS_NS: records already in namestore\n");
- return;
- }
- else if (GNUNET_YES == success)
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "GNS_NS: records successfully put in namestore\n");
- return;
- }
-
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "GNS_NS: Error putting records into namestore: %s\n", emsg);
-}
-
-
-/**
- * Function called when we get a result from the dht
- * for our record query
- *
- * @param cls the request handle
- * @param exp lifetime
- * @param key the key the record was stored under
- * @param get_path get path
- * @param get_path_length get path length
- * @param put_path put path
- * @param put_path_length put path length
- * @param type the block type
- * @param size the size of the record
- * @param data the record data
- */
-static void
-process_record_result_dht (void* cls,
- struct GNUNET_TIME_Absolute exp,
- const struct GNUNET_HashCode * key,
- const struct GNUNET_PeerIdentity *get_path,
- unsigned int get_path_length,
- const struct GNUNET_PeerIdentity *put_path,
- unsigned int put_path_length,
- enum GNUNET_BLOCK_Type type,
- size_t size, const void *data)
-{
- struct ResolverHandle *rh = cls;
- struct RecordLookupHandle *rlh = rh->proc_cls;
- const struct GNSNameRecordBlock *nrb = data;
- uint32_t num_records;
- const char* name;
- const char* rd_data;
- uint32_t i;
- size_t rd_size;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: got dht result (size=%d)\n", rh->id, size);
- /* stop lookup and timeout task */
- GNUNET_DHT_get_stop (rh->get_handle);
- rh->get_handle = NULL;
- if (rh->dht_heap_node != NULL)
- {
- GNUNET_CONTAINER_heap_remove_node (rh->dht_heap_node);
- rh->dht_heap_node = NULL;
- }
- if (rh->timeout_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (rh->timeout_task);
- rh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
- }
- rh->get_handle = NULL;
- name = (const char*) &nrb[1];
- num_records = ntohl (nrb->rd_count);
- {
- struct GNUNET_NAMESTORE_RecordData rd[num_records];
- struct NamestoreBGTask *ns_heap_root;
- struct NamestoreBGTask *namestore_bg_task;
-
- rd_data = &name[strlen (name) + 1];
- rd_size = size - strlen (name) - 1 - sizeof (struct GNSNameRecordBlock);
- if (GNUNET_SYSERR ==
- GNUNET_NAMESTORE_records_deserialize (rd_size,
- rd_data,
- num_records,
- rd))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "GNS_PHASE_REC-%llu: Error deserializing data!\n", rh->id);
- rh->proc (rh->proc_cls, rh, 0, NULL);
- return;
- }
- for (i = 0; i < num_records; i++)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: Got name: %s (wanted %s)\n",
- rh->id, name, rh->name);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: Got type: %d (wanted %d)\n",
- rh->id, rd[i].record_type, rlh->record_type);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: Got data length: %d\n",
- rh->id, rd[i].data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: Got flag %d\n",
- rh->id, rd[i].flags);
-
- if ((strcmp (name, rh->name) == 0) &&
- (rd[i].record_type == rlh->record_type))
- rh->answered++;
-
- }
-
- /**
- * FIXME check pubkey against existing key in namestore?
- * https://gnunet.org/bugs/view.php?id=2179
- */
- if (max_allowed_ns_tasks <=
- GNUNET_CONTAINER_heap_get_size (ns_task_heap))
- {
- ns_heap_root = GNUNET_CONTAINER_heap_remove_root (ns_task_heap);
- GNUNET_NAMESTORE_cancel (ns_heap_root->qe);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: Replacing oldest background ns task\n",
- rh->id);
- }
-
- /* Save to namestore */
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: Caching record for %s\n",
- rh->id, name);
- namestore_bg_task = GNUNET_malloc (sizeof (struct NamestoreBGTask));
- namestore_bg_task->qe = GNUNET_NAMESTORE_record_put (namestore_handle,
- &nrb->public_key,
- name,
- exp,
- num_records,
- rd,
- &nrb->signature,
- &on_namestore_record_put_result, //cont
- namestore_bg_task);
-
- namestore_bg_task->node = GNUNET_CONTAINER_heap_insert (ns_task_heap,
- namestore_bg_task,
- GNUNET_TIME_absolute_get().abs_value_us);
- if (0 < rh->answered)
- rh->proc (rh->proc_cls, rh, num_records, rd);
- else
- rh->proc (rh->proc_cls, rh, 0, NULL);
- }
-}
-
-
-/**
- * Start DHT lookup for a (name -> query->record_type) record in
- * rh->authority's zone
- *
- * @param rh the pending gns query context
- */
-static void
-resolve_record_dht (struct ResolverHandle *rh)
-{
- struct RecordLookupHandle *rlh = rh->proc_cls;
- uint32_t xquery;
- struct GNUNET_HashCode lookup_key;
- struct ResolverHandle *rh_heap_root;
-
- GNUNET_GNS_get_key_for_record (rh->name, &rh->authority, &lookup_key);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: starting dht lookup for %s with key: %s\n",
- rh->id, rh->name, GNUNET_h2s (&lookup_key));
-
- rh->dht_heap_node = NULL;
-
- if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != rh->timeout.rel_value_us)
- {
- /**
- * Update timeout if necessary
- */
- if (GNUNET_SCHEDULER_NO_TASK == rh->timeout_task)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: Adjusting timeout to %s/2\n",
- rh->id,
- GNUNET_STRINGS_relative_time_to_string (rh->timeout, GNUNET_YES));
- /*
- * Set timeout for authority lookup phase to 1/2
- */
- rh->timeout_task = GNUNET_SCHEDULER_add_delayed (
- GNUNET_TIME_relative_divide (rh->timeout, 2),
- &handle_lookup_timeout,
- rh);
- }
- rh->timeout_cont = &dht_lookup_timeout;
- rh->timeout_cont_cls = rh;
- }
- else
- {
- if (max_allowed_background_queries <=
- GNUNET_CONTAINER_heap_get_size (dht_lookup_heap))
- {
- rh_heap_root = GNUNET_CONTAINER_heap_remove_root (dht_lookup_heap);
- GNUNET_DHT_get_stop (rh_heap_root->get_handle);
- rh_heap_root->get_handle = NULL;
- rh_heap_root->dht_heap_node = NULL;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_REC-%llu: Replacing oldest background query for %s\n",
- rh->id, rh_heap_root->name);
- rh_heap_root->proc (rh_heap_root->proc_cls,
- rh_heap_root,
- 0,
- NULL);
- }
- rh->dht_heap_node = GNUNET_CONTAINER_heap_insert (dht_lookup_heap,
- rh,
- GNUNET_TIME_absolute_get ().abs_value_us);
- }
-
- xquery = htonl (rlh->record_type);
-
- GNUNET_assert (rh->get_handle == NULL);
- rh->get_handle = GNUNET_DHT_get_start (dht_handle,
- GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
- &lookup_key,
- DHT_GNS_REPLICATION_LEVEL,
- GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
- &xquery,
- sizeof (xquery),
- &process_record_result_dht,
- rh);
-
-}
/**
}
-#ifndef WINDOWS
/**
* VPN redirect result callback
*
rh->id);
rh->proc (rh->proc_cls, rh, 0, NULL);
}
-#endif
/**
struct RecordLookupHandle *rlh = rh->proc_cls;
struct GNUNET_DNSPARSER_Query query;
struct GNUNET_DNSPARSER_Packet packet;
- struct GNUNET_DNSPARSER_Flags flags;
+ struct GNUNET_TUN_DnsFlags flags;
struct in_addr dnsip;
struct sockaddr_in addr;
struct sockaddr *sa;
}
query.name = rh->dns_name;
query.type = rlh->record_type;
- query.class = GNUNET_DNSPARSER_CLASS_INTERNET;
+ query.class = GNUNET_TUN_DNS_CLASS_INTERNET;
memset (&flags, 0, sizeof (flags));
flags.recursion_desired = 1;
flags.checking_disabled = 1;
{
struct RecordLookupHandle *rlh = rh->proc_cls;
struct GNUNET_HashCode serv_desc;
- struct vpn_data* vpn;
+ struct GNUNET_TUN_GnsVpnRecord* vpn;
int af;
/* We cancel here as to not include the ns lookup in the timeout */
rh->priv_key);
}
- vpn = (struct vpn_data*)rd->data;
+ vpn = (struct GNUNET_TUN_GnsVpnRecord*)rd->data;
GNUNET_CRYPTO_hash ((char*)&vpn[1],
strlen ((char*)&vpn[1]) + 1,
&serv_desc);
}
-/**
- * Handle timeout for DHT requests
- *
- * @param cls the request handle as closure
- * @param tc the task context
- */
-static void
-dht_authority_lookup_timeout (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
- struct ResolverHandle *rh = cls;
- struct RecordLookupHandle *rlh = rh->proc_cls;
- char new_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_DELEGATE_DHT-%llu: dht lookup for query %s (%s) timed out.\n",
- rh->id, rh->authority_name,
- GNUNET_STRINGS_relative_time_to_string (rh->timeout,
- GNUNET_YES));
-
- rh->status |= RSL_TIMED_OUT;
- rh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
- if (NULL != rh->get_handle)
- {
- GNUNET_DHT_get_stop (rh->get_handle);
- rh->get_handle = NULL;
- }
- if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_DELEGATE_DHT-%llu: Got shutdown\n",
- rh->id);
- rh->proc (rh->proc_cls, rh, 0, NULL);
- return;
- }
- if (0 == strcmp (rh->name, ""))
- {
- /*
- * promote authority back to name and try to resolve record
- */
- strcpy (rh->name, rh->authority_name);
- rh->proc (rh->proc_cls, rh, 0, NULL);
- return;
- }
-
- /**
- * Start resolution in bg
- */
- GNUNET_snprintf (new_name, GNUNET_DNSPARSER_MAX_NAME_LENGTH,
- "%s.%s.%s",
- rh->name, rh->authority_name, GNUNET_GNS_TLD);
- strcpy (rh->name, new_name);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_DELEGATE_DHT-%llu: Starting background query for %s type %d\n",
- rh->id, rh->name,
- rlh->record_type);
- gns_resolver_lookup_record (rh->authority,
- rh->private_local_zone,
- rlh->record_type,
- new_name,
- NULL,
- GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_NO,
- &background_lookup_result_processor,
- NULL);
- rh->proc (rh->proc_cls, rh, 0, NULL);
-}
-
-
/**
* This is a callback function that checks for key revocation
*
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_REV-%llu: Starting background lookup for %s type %d\n",
- rh->id, "+.gads", GNUNET_NAMESTORE_TYPE_REV);
+ rh->id, "+.gnu", GNUNET_NAMESTORE_TYPE_REV);
gns_resolver_lookup_record(rh->authority,
rh->private_local_zone,
}
-/**
- * Callback when record data is put into namestore
- *
- * @param cls the closure
- * @param success GNUNET_OK on success
- * @param emsg the error message. NULL if SUCCESS==GNUNET_OK
- */
-static void
-on_namestore_delegation_put_result(void *cls,
- int32_t success,
- const char *emsg)
-{
- struct NamestoreBGTask *nbg = cls;
-
- GNUNET_CONTAINER_heap_remove_node (nbg->node);
- GNUNET_free (nbg);
-
- if (GNUNET_NO == success)
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "GNS_NS: records already in namestore\n");
- return;
- }
- else if (GNUNET_YES == success)
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "GNS_NS: records successfully put in namestore\n");
- return;
- }
-
- GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
- "GNS_NS: Error putting records into namestore: %s\n", emsg);
-}
-
-
/**
* Function called when we get a result from the dht
* for our query. Recursively tries to resolve authorities
char new_mx_data[MAX_MX_LENGTH];
char new_soa_data[MAX_SOA_LENGTH];
char new_srv_data[MAX_SRV_LENGTH];
- struct srv_data *old_srv;
- struct srv_data *new_srv;
- struct soa_data *old_soa;
- struct soa_data *new_soa;
+ struct GNUNET_TUN_DnsSrvRecord *old_srv;
+ struct GNUNET_TUN_DnsSrvRecord *new_srv;
+ struct GNUNET_TUN_DnsSoaRecord *old_soa;
+ struct GNUNET_TUN_DnsSoaRecord *new_soa;
struct GNUNET_NAMESTORE_RecordData p_rd[rd_count];
char* repl_string;
char* pos;
/*
* Prio, weight and port
*/
- new_srv = (struct srv_data*)new_srv_data;
- old_srv = (struct srv_data*)rd[i].data;
+ new_srv = (struct GNUNET_TUN_DnsSrvRecord*)new_srv_data;
+ old_srv = (struct GNUNET_TUN_DnsSrvRecord*)rd[i].data;
new_srv->prio = old_srv->prio;
new_srv->weight = old_srv->weight;
new_srv->port = old_srv->port;
expand_plus((char*)&new_srv[1], (char*)&old_srv[1],
repl_string);
p_rd[i].data = new_srv_data;
- p_rd[i].data_size = sizeof (struct srv_data) + strlen ((char*)&new_srv[1]) + 1;
+ p_rd[i].data_size = sizeof (struct GNUNET_TUN_DnsSrvRecord) + strlen ((char*)&new_srv[1]) + 1;
}
else if (GNUNET_DNSPARSER_TYPE_SOA == rd[i].record_type)
{
/* expand mname and rname */
- old_soa = (struct soa_data*)rd[i].data;
- new_soa = (struct soa_data*)new_soa_data;
- memcpy (new_soa, old_soa, sizeof (struct soa_data));
+ old_soa = (struct GNUNET_TUN_DnsSoaRecord*)rd[i].data;
+ new_soa = (struct GNUNET_TUN_DnsSoaRecord*)new_soa_data;
+ memcpy (new_soa, old_soa, sizeof (struct GNUNET_TUN_DnsSoaRecord));
// FIXME: how do we know that 'new_soa[1]' has enough space for the new name?
expand_plus((char*)&new_soa[1], (char*)&old_soa[1], repl_string);
offset = strlen ((char*)&new_soa[1]) + 1;
expand_plus((char*)&new_soa[1] + offset,
(char*)&old_soa[1] + strlen ((char*)&old_soa[1]) + 1,
repl_string);
- p_rd[i].data_size = sizeof (struct soa_data)
+ p_rd[i].data_size = sizeof (struct GNUNET_TUN_DnsSoaRecord)
+ offset
+ strlen ((char*)&new_soa[1] + offset);
p_rd[i].data = new_soa_data;
}
-/**
- * Resolve the delegation chain for the request in our namestore
- * (as in, find the respective authority for the leftmost label).
- *
- * @param rh the resolver handle
- */
-static void
-resolve_delegation_ns (struct ResolverHandle *rh)
-{
- pop_tld (rh->name, rh->authority_name);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_DELEGATE_NS-%llu: Finding authority for `%s' by looking up `%s' in GADS zone `%s'\n",
- rh->id,
- rh->name,
- rh->authority_name,
- GNUNET_short_h2s (&rh->authority));
- rh->namestore_task = GNUNET_NAMESTORE_lookup (namestore_handle,
- &rh->authority,
- rh->authority_name,
- &process_delegation_result_ns,
- rh);
-}
-
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
query = GNUNET_new (struct GNUNET_DNSPARSER_Query);
query->name = GNUNET_strdup (ac->label);
query->type = rh->record_type;
- query->class = GNUNET_DNSPARSER_CLASS_INTERNET;
+ query->class = GNUNET_TUN_DNS_CLASS_INTERNET;
p = GNUNET_new (struct GNUNET_DNSPARSER_Packet);
p->queries = query;
p->num_queries = 1;
p->id = (uint16_t) GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
UINT16_MAX);
- p->flags.opcode = GNUNET_DNSPARSER_OPCODE_QUERY;
+ p->flags.opcode = GNUNET_TUN_DNS_OPCODE_QUERY;
p->flags.recursion_desired = 1;
if (GNUNET_OK !=
GNUNET_DNSPARSER_pack (p, 1024, &dns_request, &dns_request_length))
if ( ( (GNUNET_YES == is_canonical (name)) &&
(0 != strcmp (GNUNET_GNS_TLD, name)) ) ||
- ( (GNUNET_YES != is_gads_tld (name)) &&
+ ( (GNUNET_YES != is_gnu_tld (name)) &&
(GNUNET_YES != is_zkey_tld (name)) ) )
{
/* use standard DNS lookup */
* Initialize the resolver
*
* @param nh the namestore handle
- * @param dh the dht handle
+ * @param dht the dht handle
* @param c configuration handle
* @param max_bg_queries maximum number of parallel background queries in dht
- * @param ignore_pending ignore records that still require user confirmation
- * on lookup
*/
void
GNS_resolver_init (struct GNUNET_NAMESTORE_Handle *nh,
- struct GNUNET_DHT_Handle *dh,
+ struct GNUNET_DHT_Handle *dht,
const struct GNUNET_CONFIGURATION_Handle *c,
unsigned long long max_bg_queries)
{
cfg = c;
namestore_handle = nh;
- dht_handle = dh;
+ dht_handle = dht;
dht_lookup_heap =
GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
max_allowed_background_queries = max_bg_queries;