int fresh;
};
+/* handle to a resolution process */
struct GNUNET_GNS_ResolverHandle;
+/**
+ * processor for a resultion result
+ *
+ * @param cls the closure
+ * @param rh the resolution handle
+ * @param rd_count number of results
+ * @pram rd resukt data
+ */
typedef void (*ResolutionResultProcessor) (void *cls,
struct GNUNET_GNS_ResolverHandle *rh,
uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd);
+/**
+ * Resoltion status indicator
+ * EXISTS: the name to lookup exists
+ * EXPIRED: the name in the record expired
+ */
enum ResolutionStatus
{
EXISTS = 1,
/* The name to resolve */
char *name;
-
-
/* has this query been answered? how many matches */
int answered;
/* closure passed to proc */
void* proc_cls;
+ /* DLL to store the authority chain */
struct AuthorityChain *authority_chain_head;
- struct AuthorityChain *authority_chain_tail;
+ /* DLL to store the authority chain */
+ struct AuthorityChain *authority_chain_tail;
+
+ /* status of the resolution result */
enum ResolutionStatus status;
};
struct GNUNET_DNSPARSER_Query *query;
};
+
/**
* Our handle to the DNS handler library
*/
* Useful for zone update for DHT put
*/
static int num_public_records = 3600;
-struct GNUNET_TIME_Relative dht_update_interval;
+
+/* dht update interval FIXME define? */
+static struct GNUNET_TIME_Relative dht_update_interval;
+
+/* zone update task */
GNUNET_SCHEDULER_TaskIdentifier zone_update_taskid = GNUNET_SCHEDULER_NO_TASK;
/**
* Helper function to free resolver handle
+ *
+ * @rh the handle to free
*/
static void
free_resolver_handle(struct GNUNET_GNS_ResolverHandle* rh)
/**
- * Reply to client with the result from our lookup.
+ * Reply to dns request with the result from our lookup.
*
+ * @param cls the closure to the request (an InterceptLookupHandle)
* @param rh the request handle of the lookup
* @param rd_count the number of records to return
* @param rd the record data
GNUNET_DHT_disconnect(dht_handle);
}
+
/**
* Callback when record data is put into namestore
*
"Error putting records into namestore: %s\n", emsg);
}
+
/**
* Handle timeout for DHT requests
*
}
-
/**
* Function called when we get a result from the dht
- * for our query
+ * for our record query
*
* @param cls the request handle
* @param exp lifetime
* rh->authority's zone
*
* @param rh the pending gns query context
- * @param name the name to query record
*/
static void
-resolve_record_from_dht(struct GNUNET_GNS_ResolverHandle *rh)
+resolve_record_dht(struct GNUNET_GNS_ResolverHandle *rh)
{
uint32_t xquery;
GNUNET_HashCode name_hash;
*/
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Namestore lookup for %s terminated without results\n", name);
-
-
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Record %s unknown in namestore\n",
}
}
+
/**
* The final phase of resolution.
- * This is a name that is canonical and we do not have a delegation.
+ * rh->name is a name that is canonical and we do not have a delegation.
+ * Query namestore for this record
*
* @param rh the pending lookup
*/
static void
-resolve_record_from_ns(struct GNUNET_GNS_ResolverHandle *rh)
+resolve_record_ns(struct GNUNET_GNS_ResolverHandle *rh)
{
struct RecordLookupHandle *rlh = (struct RecordLookupHandle *)rh->proc_cls;
+
/**
* Try to resolve this record in our namestore.
* The name to resolve is now in rh->authority_name
rlh->record_type,
&process_record_lookup_ns,
rh);
-
}
rh->proc(rh->proc_cls, rh, 0, NULL);
}
-// Prototype
-static void resolve_delegation_from_dht(struct GNUNET_GNS_ResolverHandle *rh);
+/* Prototype */
+static void resolve_delegation_dht(struct GNUNET_GNS_ResolverHandle *rh);
/**
* Function called when we get a result from the dht
- * for our query. Recursively tries to resolve PKEYs
+ * for our query. Recursively tries to resolve authorities
* for name in DHT.
*
* @param cls the request handle
* @param data the record data
*/
static void
-process_authority_dht_result(void* cls,
+process_delegation_result_dht(void* cls,
struct GNUNET_TIME_Absolute exp,
const GNUNET_HashCode * key,
const struct GNUNET_PeerIdentity *get_path,
if (rh->answered)
{
rh->answered = 0;
- /* delegate */
+ /**
+ * delegate
+ * FIXME in this case. should we ask namestore again?
+ */
if (strcmp(rh->name, "") == 0)
rh->proc(rh->proc_cls, rh, 0, NULL);
else
- resolve_delegation_from_dht(rh);
+ resolve_delegation_dht(rh);
return;
}
* should never get here unless false dht key/put
* block plugin should handle this
**/
-
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DHT authority lookup error!\n");
GNUNET_break(0);
}
rh->name);
/* give up, cannot resolve */
rlh->proc(rlh->proc_cls, rh, 0, NULL);
- //reply_to_dns(NULL, rh, 0, NULL);
return;
}
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Record resolved from namestore!");
rlh->proc(rlh->proc_cls, rh, rd_count, rd);
- //reply_to_dns(NULL, rh, rd_count, rd);
}
if (rh->status & (EXPIRED | !EXISTS))
{
rh->proc = &process_record_result_dht;
- resolve_record_from_dht(rh);
+ resolve_record_dht(rh);
return;
}
/* give up, cannot resolve */
rlh->proc(rlh->proc_cls, rh, 0, NULL);
- //reply_to_dns(NULL, rh, 0, NULL);
return;
}
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Record resolved from namestore!");
rlh->proc(rlh->proc_cls, rh, rd_count, rd);
- //reply_to_dns(NULL, rh, rd_count, rd);
}
* @param rd record data (always NULL)
*/
static void
-process_dht_delegation_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh,
+process_delegation_dht(void* cls, struct GNUNET_GNS_ResolverHandle *rh,
unsigned int rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Resolved full name for delegation via DHT. resolving record '' in ns\n");
rh->proc = &process_record_result_ns;
- resolve_record_from_ns(rh);
+ resolve_record_ns(rh);
return;
}
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Resolving canonical record %s in ns\n", rh->name);
rh->proc = &process_record_result_ns;
- resolve_record_from_ns(rh);
+ resolve_record_ns(rh);
return;
}
/* give up, cannot resolve */
"Cannot fully resolve delegation for %s via DHT!\n",
rh->name);
rlh->proc(rlh->proc_cls, rh, 0, NULL);
- //reply_to_dns(NULL, rh, 0, NULL);
}
* @param name the name of the PKEY record
*/
static void
-resolve_delegation_from_dht(struct GNUNET_GNS_ResolverHandle *rh)
+resolve_delegation_dht(struct GNUNET_GNS_ResolverHandle *rh)
{
uint32_t xquery;
GNUNET_HashCode name_hash;
GNUNET_DHT_RO_NONE,
&xquery,
sizeof(xquery),
- &process_authority_dht_result,
+ &process_delegation_result_dht,
rh);
}
* @param rd record data (always NULL)
*/
static void
-process_ns_delegation_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh,
+process_delegation_ns(void* cls, struct GNUNET_GNS_ResolverHandle *rh,
unsigned int rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Resolved full name for delegation. resolving record ''\n");
rh->proc = &process_record_result_ns;
- resolve_record_from_ns(rh);
+ resolve_record_ns(rh);
return;
}
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Resolving canonical record %s\n", rh->name);
rh->proc = &process_record_result_ns;
- resolve_record_from_ns(rh);
+ resolve_record_ns(rh);
}
else
{
"Cannot fully resolve delegation for %s!\n",
rh->name);
rlh->proc(rlh->proc_cls, rh, 0, NULL);
- //reply_to_dns(NULL, rh, 0, NULL);
}
return;
}
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"Trying to resolve delegation for %s via DHT\n",
rh->name);
- rh->proc = &process_dht_delegation_dns;
- resolve_delegation_from_dht(rh);
+ rh->proc = &process_delegation_dht;
+ resolve_delegation_dht(rh);
}
//Prototype
-static void resolve_delegation_from_ns(struct GNUNET_GNS_ResolverHandle *rh);
+static void resolve_delegation_ns(struct GNUNET_GNS_ResolverHandle *rh);
/**
* This is a callback function that should give us only PKEY
* @param signature the signature of the authority for the record data
*/
static void
-process_authority_lookup_ns(void* cls,
+process_delegation_result_ns(void* cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
struct GNUNET_TIME_Absolute expiration,
const char *name,
if (strcmp(rh->name, "") == 0)
rh->proc(rh->proc_cls, rh, 0, NULL);
else
- resolve_delegation_from_ns(rh);
+ resolve_delegation_ns(rh);
return;
}
/**
- * Resolve the delegation chain for the request
+ * Resolve the delegation chain for the request in our namestore
*
* @param rh the resolver handle
*/
static void
-resolve_delegation_from_ns(struct GNUNET_GNS_ResolverHandle *rh)
+resolve_delegation_ns(struct GNUNET_GNS_ResolverHandle *rh)
{
pop_tld(rh->name, rh->authority_name);
&rh->authority,
rh->authority_name,
GNUNET_GNS_RECORD_PKEY,
- &process_authority_lookup_ns,
+ &process_delegation_result_ns,
rh);
}
* @param q the DNS query we received parsed from p
*/
static void
-start_resolution_from_dns(struct GNUNET_DNS_RequestHandle *request,
+start_resolution_for_dns(struct GNUNET_DNS_RequestHandle *request,
struct GNUNET_DNSPARSER_Packet *p,
struct GNUNET_DNSPARSER_Query *q)
{
rh->proc_cls = rlh;
- rh->authority = zone_hash;
rh->name = GNUNET_malloc(strlen(q->name)
- strlen(gnunet_tld) + 1);
memset(rh->name, 0,
rh->authority_chain_head->zone = zone_hash;
/* Start resolution in our zone */
- rh->proc = &process_ns_delegation_dns;
- resolve_delegation_from_ns(rh);
+ rh->proc = &process_delegation_ns;
+ resolve_delegation_ns(rh);
}
if ((i==strlen(gnunet_tld)-1) && (0 == strcmp(tldoffset-i, gnunet_tld)))
{
- start_resolution_from_dns(rh, p, p->queries);
+ start_resolution_for_dns(rh, p, p->queries);
}
else
{
* rh->authority's zone
*
* @param rh the pending gns query
- * @param name the name of the PKEY record
*/
static void
-resolve_pseu_from_dht(struct GNUNET_GNS_ResolverHandle *rh)
+resolve_pseu_dht(struct GNUNET_GNS_ResolverHandle *rh)
{
uint32_t xquery;
GNUNET_HashCode name_hash;
GNUNET_DHT_RO_NONE,
&xquery,
sizeof(xquery),
- &process_authority_dht_result,
+ &process_delegation_result_dht,
rh);
}
*/
rh->authority = rh->authority_chain_head->zone;
rh->proc = &handle_shorten_pseu_dht_result;
- resolve_pseu_from_dht(rh);
+ resolve_pseu_dht(rh);
}
* Shorten a given name
*
* @param name the name to shorten
- * @param proc the processor to call when finished
- * @praram cls the closure to the processor
+ * @param csh the shorten handle of the request
*/
static void
shorten_name(char* name, struct ClientShortenHandle* csh)
rh->proc_cls = (void*)csh;
/* Start delegation resolution in our namestore */
- resolve_delegation_from_ns(rh);
+ resolve_delegation_ns(rh);
}
/**
* Send shorten response back to client
- * FIXME this is without .gnunet!
*
- * @param cls the client handle in closure
* @param name the shortened name result or NULL if cannot be shortened
+ * @param csh the handle to the shorten request
*/
static void
send_shorten_response(const char* name, struct ClientShortenHandle *csh)
rh->authority_chain_head->zone = zone_hash;
/* Start resolution in our zone */
- rh->proc = &process_ns_delegation_dns; //FIXME rename
- resolve_delegation_from_ns(rh);
+ rh->proc = &process_delegation_ns;
+ resolve_delegation_ns(rh);
}