[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28636 - in gnunet/src: gns include namestore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28636 - in gnunet/src: gns include namestore |
Date: |
Thu, 15 Aug 2013 00:44:18 +0200 |
Author: grothoff
Date: 2013-08-15 00:44:18 +0200 (Thu, 15 Aug 2013)
New Revision: 28636
Modified:
gnunet/src/gns/gnunet-service-gns_resolver.c
gnunet/src/include/gnunet_namestore_service.h
gnunet/src/namestore/gnunet-namestore-fcfsd.c
gnunet/src/namestore/gnunet-service-namestore.c
gnunet/src/namestore/namestore_api.c
Log:
-addressing #2995
Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c 2013-08-14 22:18:34 UTC
(rev 28635)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c 2013-08-14 22:44:18 UTC
(rev 28636)
@@ -371,6 +371,11 @@
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.
*/
struct GNUNET_CRYPTO_EccPublicKey target_zone;
@@ -542,6 +547,7 @@
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);
}
@@ -570,44 +576,110 @@
* (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;
}
@@ -615,7 +687,7 @@
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;
@@ -626,7 +698,7 @@
gph->namestore_task
= GNUNET_NAMESTORE_records_store (namestore_handle,
&gph->shorten_zone_key,
- name,
+ gph->current_label,
1, &new_pkey,
&create_pkey_cont, gph);
}
@@ -642,30 +714,17 @@
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);
}
Modified: gnunet/src/include/gnunet_namestore_service.h
===================================================================
--- gnunet/src/include/gnunet_namestore_service.h 2013-08-14 22:18:34 UTC
(rev 28635)
+++ gnunet/src/include/gnunet_namestore_service.h 2013-08-14 22:44:18 UTC
(rev 28636)
@@ -382,22 +382,6 @@
/**
- * Perform a lookup and decrypt the resulting block.
- *
- * @param h namestore to perform lookup in
- * @param value_zone zone to look up record in
- * @param label label to look for
- * @param proc function to call with the result
- * @param proc_cls closure for @a proc
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_lookup (struct GNUNET_NAMESTORE_Handle *h,
- const struct GNUNET_CRYPTO_EccPublicKey *value_zone,
- const char *label,
- GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls);
-
-
-/**
* Cancel a namestore operation. The final callback from the
* operation must not have been done yet. Must be called on any
* namestore operation that has not yet completed prior to calling
Modified: gnunet/src/namestore/gnunet-namestore-fcfsd.c
===================================================================
--- gnunet/src/namestore/gnunet-namestore-fcfsd.c 2013-08-14 22:18:34 UTC
(rev 28635)
+++ gnunet/src/namestore/gnunet-namestore-fcfsd.c 2013-08-14 22:44:18 UTC
(rev 28636)
@@ -525,22 +525,17 @@
* proceed to check if the requested key already exists.
*
* @param cls closure
- * @param zone_key private key of the zone
- * @param name name that is being mapped (at most 255 characters long)
* @param rd_count number of entries in 'rd' array
* @param rd array of records with data to store
*/
static void
lookup_result_processor (void *cls,
- const struct GNUNET_CRYPTO_EccPrivateKey *zone_key,
- const char *name,
unsigned int rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
{
struct Request *request = cls;
struct GNUNET_CRYPTO_EccPublicKey pub;
- request->qe = NULL;
if (0 != rd_count)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -570,6 +565,43 @@
/**
+ * We got a block back from the namestore. Decrypt it
+ * and continue to process the result.
+ *
+ * @param cls the 'struct Request' we are processing
+ * @param block block returned form namestore, NULL on error
+ */
+static void
+lookup_block_processor (void *cls,
+ const struct GNUNET_NAMESTORE_Block *block)
+{
+ struct Request *request = cls;
+ struct GNUNET_CRYPTO_EccPublicKey pub;
+
+ request->qe = NULL;
+ if (NULL == block)
+ {
+ lookup_result_processor (request, 0, NULL);
+ return;
+ }
+ GNUNET_CRYPTO_ecc_key_get_public (fcfs_zone_pkey,
+ &pub);
+ if (GNUNET_OK !=
+ GNUNET_NAMESTORE_block_decrypt (block,
+ &pub,
+ request->domain_name,
+ &lookup_result_processor,
+ request))
+ {
+ GNUNET_break (0);
+ request->phase = RP_FAIL;
+ run_httpd_now ();
+ return;
+ }
+}
+
+
+/**
* Main MHD callback for handling requests.
*
* @param cls unused
@@ -606,6 +638,7 @@
struct Request *request;
int ret;
struct GNUNET_CRYPTO_EccPublicKey pub;
+ struct GNUNET_HashCode query;
if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) ||
(0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) )
@@ -684,11 +717,13 @@
request->phase = RP_LOOKUP;
GNUNET_CRYPTO_ecc_key_get_public (fcfs_zone_pkey,
&pub);
- request->qe = GNUNET_NAMESTORE_lookup (ns,
- &pub,
- request->domain_name,
- &lookup_result_processor,
- request);
+ GNUNET_NAMESTORE_query_from_public_key (&pub,
+ request->domain_name,
+ &query);
+ request->qe = GNUNET_NAMESTORE_lookup_block (ns,
+ &query,
+ &lookup_block_processor,
+ request);
break;
case RP_LOOKUP:
break;
Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c 2013-08-14 22:18:34 UTC
(rev 28635)
+++ gnunet/src/namestore/gnunet-service-namestore.c 2013-08-14 22:44:18 UTC
(rev 28636)
@@ -334,10 +334,10 @@
/**
- * Context for name lookups passed from 'handle_lookup_name' to
- * 'handle_lookup_name_it' as closure
+ * Context for name lookups passed from #handle_lookup_block to
+ * #handle_lookup_block_it as closure
*/
-struct LookupNameContext
+struct LookupBlockContext
{
/**
* The client to send the response to
@@ -362,7 +362,7 @@
handle_lookup_block_it (void *cls,
const struct GNUNET_NAMESTORE_Block *block)
{
- struct LookupNameContext *lnc = cls;
+ struct LookupBlockContext *lnc = cls;
struct LookupBlockResponseMessage *r;
size_t esize;
@@ -379,7 +379,7 @@
memcpy (&r[1], &block[1], esize);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending `%s' message\n",
- "NAMESTORE_LOOKUP_NAME_RESPONSE");
+ "NAMESTORE_LOOKUP_BLOCK_RESPONSE");
GNUNET_SERVER_notification_context_unicast (snc,
lnc->nc->client,
&r->gns_header.header,
@@ -401,14 +401,14 @@
const struct GNUNET_MessageHeader *message)
{
const struct LookupBlockMessage *ln_msg;
- struct LookupNameContext lnc;
+ struct LookupBlockContext lnc;
struct NamestoreClient *nc;
struct LookupBlockResponseMessage zir_end;
int ret;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' message\n",
- "NAMESTORE_LOOKUP_NAME");
+ "NAMESTORE_LOOKUP_BLOCK");
nc = client_lookup(client);
ln_msg = (const struct LookupBlockMessage *) message;
lnc.request_id = ntohl (ln_msg->gns_header.r_id);
Modified: gnunet/src/namestore/namestore_api.c
===================================================================
--- gnunet/src/namestore/namestore_api.c 2013-08-14 22:18:34 UTC (rev
28635)
+++ gnunet/src/namestore/namestore_api.c 2013-08-14 22:44:18 UTC (rev
28636)
@@ -1097,7 +1097,6 @@
const struct GNUNET_HashCode *derived_hash,
GNUNET_NAMESTORE_BlockProcessor proc, void
*proc_cls)
{
-
struct GNUNET_NAMESTORE_QueueEntry *qe;
struct PendingMessage *pe;
struct LookupBlockMessage *msg;
@@ -1132,26 +1131,6 @@
/**
- * Perform a lookup and decrypt the resulting block.
- *
- * @param h namestore to perform lookup in
- * @param value_zone zone to look up record in
- * @param label label to look for
- * @param proc function to call with the result
- * @param proc_cls closure for @a proc
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_lookup (struct GNUNET_NAMESTORE_Handle *h,
- const struct GNUNET_CRYPTO_EccPublicKey *value_zone,
- const char *label,
- GNUNET_NAMESTORE_RecordMonitor proc, void *proc_cls)
-{
- GNUNET_break (0); // FIXME: not implemented
- return NULL;
-}
-
-
-/**
* Look for an existing PKEY delegation record for a given public key.
* Returns at most one result to the processor.
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28636 - in gnunet/src: gns include namestore,
gnunet <=