#include "gnunet_dnsstub_lib.h"
#include "gnunet_dht_service.h"
#include "gnunet_gnsrecord_lib.h"
+#include "gnunet_namecache_service.h"
#include "gnunet_namestore_service.h"
#include "gnunet_dns_service.h"
#include "gnunet_resolver_service.h"
struct GNUNET_RESOLVER_RequestHandle *std_resolve;
/**
- * Pending Namestore lookup task
+ * Pending Namecache lookup task
*/
- struct GNUNET_NAMESTORE_QueueEntry *namestore_qe;
+ struct GNUNET_NAMECACHE_QueueEntry *namecache_qe;
/**
* Heap node associated with this lookup. Used to limit number of
/**
* Pending Namestore caching task.
*/
- struct GNUNET_NAMESTORE_QueueEntry *namestore_qe_cache;
+ struct GNUNET_NAMECACHE_QueueEntry *namecache_qe_cache;
};
*/
static struct GNUNET_NAMESTORE_Handle *namestore_handle;
+/**
+ * Our handle to the namecache service
+ */
+static struct GNUNET_NAMECACHE_Handle *namecache_handle;
+
/**
* Our handle to the vpn service
*/
"%.*s.%s",
(int) (s_len - 2),
name,
- GNUNET_NAMESTORE_pkey_to_zkey (&rh->ac_tail->authority_info.gns_authority));
+ GNUNET_GNSRECORD_pkey_to_zkey (&rh->ac_tail->authority_info.gns_authority));
GNUNET_free (name);
return ret;
}
for (pos = rh->dns_result_head; NULL != pos; pos = pos->next)
n++;
{
- struct GNUNET_NAMESTORE_RecordData rd[n];
+ struct GNUNET_GNSRECORD_Data rd[n];
i = 0;
for (pos = rh->dns_result_head; NULL != pos; pos = pos->next)
rd[i].record_type = pos->record_type;
if (0 == pos->expiration_time)
{
- rd[i].flags = GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
+ rd[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
rd[i].expiration_time = 0;
}
else
{
- rd[i].flags = GNUNET_NAMESTORE_RF_NONE;
+ rd[i].flags = GNUNET_GNSRECORD_RF_NONE;
rd[i].expiration_time = pos->expiration_time;
}
i++;
/* convert from (parsed) DNS to (binary) GNS format! */
rd_count = p->num_answers + p->num_authority_records + p->num_additional_records;
{
- struct GNUNET_NAMESTORE_RecordData rd[rd_count];
+ struct GNUNET_GNSRECORD_Data rd[rd_count];
unsigned int skip;
char buf[UINT16_MAX];
size_t buf_off;
static void
handle_gns_resolution_result (void *cls,
unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd);
+ const struct GNUNET_GNSRECORD_Data *rd);
/**
{
struct VpnContext *vpn_ctx = cls;
struct GNS_ResolverHandle *rh = vpn_ctx->rh;
- struct GNUNET_NAMESTORE_RecordData rd[vpn_ctx->rd_count];
+ struct GNUNET_GNSRECORD_Data rd[vpn_ctx->rd_count];
unsigned int i;
vpn_ctx->vpn_request = NULL;
rh->vpn_ctx = NULL;
GNUNET_assert (GNUNET_OK ==
- GNUNET_NAMESTORE_records_deserialize (vpn_ctx->rd_data_size,
+ GNUNET_GNSRECORD_records_deserialize (vpn_ctx->rd_data_size,
vpn_ctx->rd_data,
vpn_ctx->rd_count,
rd));
static void
handle_gns_resolution_result (void *cls,
unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd)
+ const struct GNUNET_GNSRECORD_Data *rd)
{
struct GNS_ResolverHandle *rh = cls;
struct AuthorityChain *ac;
size_t scratch_off;
size_t scratch_start;
size_t off;
- struct GNUNET_NAMESTORE_RecordData rd_new[rd_count];
+ struct GNUNET_GNSRECORD_Data rd_new[rd_count];
unsigned int rd_off;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Resolution succeeded for `%s' in zone %s, got %u records\n",
rh->ac_tail->label,
- GNUNET_NAMESTORE_z2s (&rh->ac_tail->authority_info.gns_authority),
+ GNUNET_GNSRECORD_z2s (&rh->ac_tail->authority_info.gns_authority),
rd_count);
if (0 == rh->name_resolution_pos)
{
vpn_ctx = GNUNET_new (struct VpnContext);
rh->vpn_ctx = vpn_ctx;
vpn_ctx->rh = rh;
- vpn_ctx->rd_data_size = GNUNET_NAMESTORE_records_get_size (rd_count,
+ vpn_ctx->rd_data_size = GNUNET_GNSRECORD_records_get_size (rd_count,
rd);
vpn_ctx->rd_data = GNUNET_malloc (vpn_ctx->rd_data_size);
- (void) GNUNET_NAMESTORE_records_serialize (rd_count,
+ (void) GNUNET_GNSRECORD_records_serialize (rd_count,
rd,
vpn_ctx->rd_data_size,
vpn_ctx->rd_data);
* @param emsg error message
*/
static void
-namestore_cache_continuation (void *cls,
+namecache_cache_continuation (void *cls,
int32_t success,
const char *emsg)
{
struct CacheOps *co = cls;
- co->namestore_qe_cache = NULL;
+ co->namecache_qe_cache = NULL;
if (NULL != emsg)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Failed to cache GNS resolution: %s\n"),
{
struct GNS_ResolverHandle *rh = cls;
struct AuthorityChain *ac = rh->ac_tail;
- const struct GNUNET_NAMESTORE_Block *block;
+ const struct GNUNET_GNSRECORD_Block *block;
struct CacheOps *co;
GNUNET_DHT_get_stop (rh->get_handle);
rh->dht_heap_node = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Handling response from the DHT\n");
- if (size < sizeof (struct GNUNET_NAMESTORE_Block))
+ if (size < sizeof (struct GNUNET_GNSRECORD_Block))
{
/* how did this pass DHT block validation!? */
GNUNET_break (0);
return;
}
if (GNUNET_OK !=
- GNUNET_NAMESTORE_block_decrypt (block,
+ GNUNET_GNSRECORD_block_decrypt (block,
&ac->authority_info.gns_authority,
ac->label,
&handle_gns_resolution_result,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Caching response from the DHT in namestore\n");
co = GNUNET_new (struct CacheOps);
- co->namestore_qe_cache = GNUNET_NAMESTORE_block_cache (namestore_handle,
+ co->namecache_qe_cache = GNUNET_NAMECACHE_block_cache (namecache_handle,
block,
- &namestore_cache_continuation,
+ &namecache_cache_continuation,
co);
GNUNET_CONTAINER_DLL_insert (co_head,
co_tail,
*/
static void
handle_namestore_block_response (void *cls,
- const struct GNUNET_NAMESTORE_Block *block)
+ const struct GNUNET_GNSRECORD_Block *block)
{
struct GNS_ResolverHandle *rh = cls;
struct GNS_ResolverHandle *rx;
const struct GNUNET_CRYPTO_EcdsaPublicKey *auth = &ac->authority_info.gns_authority;
struct GNUNET_HashCode query;
- GNUNET_NAMESTORE_query_from_public_key (auth,
+ GNUNET_GNSRECORD_query_from_public_key (auth,
label,
&query);
- GNUNET_assert (NULL != rh->namestore_qe);
- rh->namestore_qe = NULL;
+ GNUNET_assert (NULL != rh->namecache_qe);
+ rh->namecache_qe = NULL;
if ( (GNUNET_NO == rh->only_cached) &&
( (NULL == block) ||
(0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (block->expiration_time)).rel_value_us) ) )
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting DHT lookup for `%s' in zone %s\n",
ac->label,
- GNUNET_NAMESTORE_z2s (&ac->authority_info.gns_authority));
+ GNUNET_GNSRECORD_z2s (&ac->authority_info.gns_authority));
GNUNET_assert (NULL == rh->get_handle);
rh->get_handle = GNUNET_DHT_get_start (dht_handle,
GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Resolution failed for `%s' in zone %s (DHT lookup not permitted by configuration)\n",
ac->label,
- GNUNET_NAMESTORE_z2s (&ac->authority_info.gns_authority));
+ GNUNET_GNSRECORD_z2s (&ac->authority_info.gns_authority));
rh->proc (rh->proc_cls, 0, NULL);
GNS_resolver_lookup_cancel (rh);
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Decrypting block from the namestore\n");
if (GNUNET_OK !=
- GNUNET_NAMESTORE_block_decrypt (block,
+ GNUNET_GNSRECORD_block_decrypt (block,
auth,
label,
&handle_gns_resolution_result,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting GNS resolution for `%s' in zone %s\n",
ac->label,
- GNUNET_NAMESTORE_z2s (&ac->authority_info.gns_authority));
- GNUNET_NAMESTORE_query_from_public_key (&ac->authority_info.gns_authority,
+ GNUNET_GNSRECORD_z2s (&ac->authority_info.gns_authority));
+ GNUNET_GNSRECORD_query_from_public_key (&ac->authority_info.gns_authority,
ac->label,
&query);
- rh->namestore_qe = GNUNET_NAMESTORE_lookup_block (namestore_handle,
+ rh->namecache_qe = GNUNET_NAMECACHE_lookup_block (namecache_handle,
&query,
&handle_namestore_block_response,
rh);
- GNUNET_assert (NULL != rh->namestore_qe);
+ GNUNET_assert (NULL != rh->namecache_qe);
}
GNUNET_DNSSTUB_resolve_cancel (rh->dns_request);
rh->dns_request = NULL;
}
- if (NULL != rh->namestore_qe)
+ if (NULL != rh->namecache_qe)
{
- GNUNET_NAMESTORE_cancel (rh->namestore_qe);
- rh->namestore_qe = NULL;
+ GNUNET_NAMECACHE_cancel (rh->namecache_qe);
+ rh->namecache_qe = NULL;
}
if (NULL != rh->std_resolve)
{
* Initialize the resolver
*
* @param nh the namestore handle
+ * @param nc the namecache handle
* @param dht the dht handle
* @param c configuration handle
* @param max_bg_queries maximum number of parallel background queries in dht
*/
void
GNS_resolver_init (struct GNUNET_NAMESTORE_Handle *nh,
+ struct GNUNET_NAMECACHE_Handle *nc,
struct GNUNET_DHT_Handle *dht,
const struct GNUNET_CONFIGURATION_Handle *c,
unsigned long long max_bg_queries)
char *dns_ip;
cfg = c;
+ namecache_handle = nc;
namestore_handle = nh;
dht_handle = dht;
dht_lookup_heap =
GNUNET_CONTAINER_DLL_remove (co_head,
co_tail,
co);
- GNUNET_NAMESTORE_cancel (co->namestore_qe_cache);
+ GNUNET_NAMECACHE_cancel (co->namecache_qe_cache);
GNUNET_free (co);
}
GNUNET_CONTAINER_heap_destroy (dht_lookup_heap);
GNUNET_VPN_disconnect (vpn_handle);
vpn_handle = NULL;
dht_handle = NULL;
+ namecache_handle = NULL;
namestore_handle = NULL;
}