aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/gnunet-namestore-fcfsd.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-14 22:44:18 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-14 22:44:18 +0000
commit17d1146c625092753e1b29b7ce6f0dfb603fbd09 (patch)
treea747d21a24654dceebe2b31b9960bfcc1333d222 /src/namestore/gnunet-namestore-fcfsd.c
parent670ef7244591123c4d6432b8a76fe8b4a9e39ee4 (diff)
downloadgnunet-17d1146c625092753e1b29b7ce6f0dfb603fbd09.tar.gz
gnunet-17d1146c625092753e1b29b7ce6f0dfb603fbd09.zip
-addressing #2995
Diffstat (limited to 'src/namestore/gnunet-namestore-fcfsd.c')
-rw-r--r--src/namestore/gnunet-namestore-fcfsd.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c
index d949806db..9fc75ee5e 100644
--- a/src/namestore/gnunet-namestore-fcfsd.c
+++ b/src/namestore/gnunet-namestore-fcfsd.c
@@ -525,22 +525,17 @@ zone_to_name_cb (void *cls,
525 * proceed to check if the requested key already exists. 525 * proceed to check if the requested key already exists.
526 * 526 *
527 * @param cls closure 527 * @param cls closure
528 * @param zone_key private key of the zone
529 * @param name name that is being mapped (at most 255 characters long)
530 * @param rd_count number of entries in 'rd' array 528 * @param rd_count number of entries in 'rd' array
531 * @param rd array of records with data to store 529 * @param rd array of records with data to store
532 */ 530 */
533static void 531static void
534lookup_result_processor (void *cls, 532lookup_result_processor (void *cls,
535 const struct GNUNET_CRYPTO_EccPrivateKey *zone_key,
536 const char *name,
537 unsigned int rd_count, 533 unsigned int rd_count,
538 const struct GNUNET_NAMESTORE_RecordData *rd) 534 const struct GNUNET_NAMESTORE_RecordData *rd)
539{ 535{
540 struct Request *request = cls; 536 struct Request *request = cls;
541 struct GNUNET_CRYPTO_EccPublicKey pub; 537 struct GNUNET_CRYPTO_EccPublicKey pub;
542 538
543 request->qe = NULL;
544 if (0 != rd_count) 539 if (0 != rd_count)
545 { 540 {
546 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 541 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -570,6 +565,43 @@ lookup_result_processor (void *cls,
570 565
571 566
572/** 567/**
568 * We got a block back from the namestore. Decrypt it
569 * and continue to process the result.
570 *
571 * @param cls the 'struct Request' we are processing
572 * @param block block returned form namestore, NULL on error
573 */
574static void
575lookup_block_processor (void *cls,
576 const struct GNUNET_NAMESTORE_Block *block)
577{
578 struct Request *request = cls;
579 struct GNUNET_CRYPTO_EccPublicKey pub;
580
581 request->qe = NULL;
582 if (NULL == block)
583 {
584 lookup_result_processor (request, 0, NULL);
585 return;
586 }
587 GNUNET_CRYPTO_ecc_key_get_public (fcfs_zone_pkey,
588 &pub);
589 if (GNUNET_OK !=
590 GNUNET_NAMESTORE_block_decrypt (block,
591 &pub,
592 request->domain_name,
593 &lookup_result_processor,
594 request))
595 {
596 GNUNET_break (0);
597 request->phase = RP_FAIL;
598 run_httpd_now ();
599 return;
600 }
601}
602
603
604/**
573 * Main MHD callback for handling requests. 605 * Main MHD callback for handling requests.
574 * 606 *
575 * @param cls unused 607 * @param cls unused
@@ -606,6 +638,7 @@ create_response (void *cls,
606 struct Request *request; 638 struct Request *request;
607 int ret; 639 int ret;
608 struct GNUNET_CRYPTO_EccPublicKey pub; 640 struct GNUNET_CRYPTO_EccPublicKey pub;
641 struct GNUNET_HashCode query;
609 642
610 if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) || 643 if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) ||
611 (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) ) 644 (0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) )
@@ -684,11 +717,13 @@ create_response (void *cls,
684 request->phase = RP_LOOKUP; 717 request->phase = RP_LOOKUP;
685 GNUNET_CRYPTO_ecc_key_get_public (fcfs_zone_pkey, 718 GNUNET_CRYPTO_ecc_key_get_public (fcfs_zone_pkey,
686 &pub); 719 &pub);
687 request->qe = GNUNET_NAMESTORE_lookup (ns, 720 GNUNET_NAMESTORE_query_from_public_key (&pub,
688 &pub, 721 request->domain_name,
689 request->domain_name, 722 &query);
690 &lookup_result_processor, 723 request->qe = GNUNET_NAMESTORE_lookup_block (ns,
691 request); 724 &query,
725 &lookup_block_processor,
726 request);
692 break; 727 break;
693 case RP_LOOKUP: 728 case RP_LOOKUP:
694 break; 729 break;