struct GNUNET_CRYPTO_EcdsaPublicKey zone;
/**
- * Only check cached results
+ * Local options for where to look for results
+ * (an `enum GNUNET_GNS_LocalOptions` in NBO).
*/
- int16_t only_cached GNUNET_PACKED;
+ int16_t options GNUNET_PACKED;
/**
* Is a shorten key attached?
* @param name the name to look up
* @param zone the zone to start the resolution in
* @param type the record type to look up
- * @param only_cached #GNUNET_YES to only check locally (not in the DHT)
+ * @param options local options for the lookup
* @param shorten_zone_key the private key of the shorten zone (can be NULL)
* @param proc processor to call on result
* @param proc_cls closure for @a proc
const char *name,
const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
uint32_t type,
- int only_cached,
+ enum GNUNET_GNS_LocalOptions options,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key,
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls)
lookup_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP);
lookup_msg->header.size = htons (msize);
lookup_msg->id = htonl (lr->r_id);
- lookup_msg->only_cached = htons (only_cached);
+ lookup_msg->options = htons ((uint16_t) options);
lookup_msg->zone = *zone;
lookup_msg->type = htonl (type);
if (NULL != shorten_zone_key)
static char *public_key;
/**
- * Set to #GNUNET_YES if we must not use the DHT (only local lookup).
+ * Set to GNUNET_GNS_LO_LOCAL_MASTER if we are looking up in the master zone.
*/
-static int only_cached;
+static enum GNUNET_GNS_LocalOptions local_options;
/**
* raw output
lookup_name,
pkey,
rtype,
- only_cached,
+ local_options,
shorten_key,
&process_lookup_result,
lookup_name);
return;
}
GNUNET_IDENTITY_ego_get_public_key (ego, &pkey);
+ /* main name is our own master zone, do no look for that in the DHT */
+ local_options = GNUNET_GNS_LO_LOCAL_MASTER;
+
/* if the name is of the form 'label.gnu', never go to the DHT */
dot = NULL;
if (NULL != lookup_name)
dot = strchr (lookup_name, '.');
if ( (NULL != dot) &&
(0 == strcasecmp (dot, ".gnu")) )
- only_cached = GNUNET_YES;
+ local_options = GNUNET_GNS_LO_NO_DHT;
lookup_with_public_key (&pkey);
}
ntohl (sh_msg->type),
name,
key,
- ntohs (sh_msg->only_cached),
+ (enum GNUNET_GNS_LocalOptions) ntohs (sh_msg->options),
&send_lookup_response, clh);
GNUNET_STATISTICS_update (statistics,
"Lookup attempts",
/**
* Use only cache
*/
- int only_cached;
+ enum GNUNET_GNS_LocalOptions options;
/**
* Desired type for the resolution.
g2dc->rh->proc = &handle_gns2dns_result;
g2dc->rh->proc_cls = rh;
g2dc->rh->record_type = GNUNET_GNSRECORD_TYPE_ANY;
- g2dc->rh->only_cached = GNUNET_NO;
+ g2dc->rh->options = GNUNET_GNS_LO_DEFAULT;
g2dc->rh->loop_limiter = rh->loop_limiter + 1;
rh->g2dc = g2dc;
start_resolver_lookup (g2dc->rh);
GNUNET_assert (NULL != rh->namecache_qe);
rh->namecache_qe = NULL;
- if ( (GNUNET_NO == rh->only_cached) &&
+ if ( ( (GNUNET_GNS_LO_DEFAULT == rh->options) ||
+ ( (GNUNET_GNS_LO_LOCAL_MASTER == rh->options) &&
+ (ac != rh->ac_head) ) ) &&
( (NULL == block) ||
(0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh (block->expiration_time)).rel_value_us) ) )
{
* @param record_type the record type to look up
* @param name the name to look up
* @param shorten_key a private key for use with PSEU import (can be NULL)
- * @param only_cached #GNUNET_NO to only check locally not DHT for performance
+ * @param options local options to control local lookup
* @param proc the processor to call on result
* @param proc_cls the closure to pass to @a proc
* @return handle to cancel operation
uint32_t record_type,
const char *name,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key,
- int only_cached,
+ enum GNUNET_GNS_LocalOptions options,
GNS_ResultProcessor proc, void *proc_cls)
{
struct GNS_ResolverHandle *rh;
rh->authority_zone = *zone;
rh->proc = proc;
rh->proc_cls = proc_cls;
- rh->only_cached = only_cached;
+ rh->options = options;
rh->record_type = record_type;
rh->name = GNUNET_strdup (name);
rh->name_resolution_pos = strlen (name);
#define GNS_RESOLVER_H
#include "gns.h"
#include "gnunet_dht_service.h"
+#include "gnunet_gns_service.h"
#include "gnunet_namecache_service.h"
/**
* @param record_type the record type to look up
* @param name the name to look up
* @param shorten_key optional private key for authority caching, can be NULL
- * @param only_cached GNUNET_NO to only check locally not DHT for performance
+ * @param options options set to control local lookup
* @param proc the processor to call
* @param proc_cls the closure to pass to @a proc
* @return handle to cancel operation
uint32_t record_type,
const char *name,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key,
- int only_cached,
+ enum GNUNET_GNS_LocalOptions options,
GNS_ResultProcessor proc,
void *proc_cls);
/*
This file is part of GNUnet
- (C) 2012-2013 Christian Grothoff (and other contributing authors)
+ (C) 2012-2014 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
const struct GNUNET_GNSRECORD_Data *rd);
+/**
+ * Options for the GNS lookup.
+ */
+enum GNUNET_GNS_LocalOptions
+{
+ /**
+ * Defaults, look in cache, then in DHT.
+ */
+ GNUNET_GNS_LO_DEFAULT = 0,
+
+ /**
+ * Never look in the DHT, keep request to local cache.
+ */
+ GNUNET_GNS_LO_NO_DHT = 1,
+
+ /**
+ * For the rightmost label, only look in the cache (it
+ * is our master zone), for the others, the DHT is OK.
+ */
+ GNUNET_GNS_LO_LOCAL_MASTER = 2
+
+};
+
+
/**
* Perform an asynchronous lookup operation on the GNS.
*
* @param name the name to look up
* @param zone zone to look in
* @param type the GNS record type to look for
- * @param only_cached #GNUNET_YES to only check locally (not in the DHT)
+ * @param options local options for the lookup
* @param shorten_zone_key the private key of the shorten zone (can be NULL);
* specify to enable automatic shortening (given a PSEU
* record, if a given pseudonym is not yet used in the
const char *name,
const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
uint32_t type,
- int only_cached,
+ enum GNUNET_GNS_LocalOptions options,
const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key,
GNUNET_GNS_LookupResultProcessor proc,
void *proc_cls);