aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gns_api.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-05-09 09:50:13 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-05-09 09:50:13 +0000
commita9e83be91832bfa07b33c8d865cab9f00df05b78 (patch)
treeb9811079267b710fa71cc8819f4d8b589a4c9928 /src/gns/gns_api.c
parentde21b0b29055c33ed2ee1ce36abecacf77836808 (diff)
downloadgnunet-a9e83be91832bfa07b33c8d865cab9f00df05b78.tar.gz
gnunet-a9e83be91832bfa07b33c8d865cab9f00df05b78.zip
-new per zone api
Diffstat (limited to 'src/gns/gns_api.c')
-rw-r--r--src/gns/gns_api.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index 1a06f34e0..a92280f25 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -639,14 +639,16 @@ get_request_id (struct GNUNET_GNS_Handle *h)
639 * 639 *
640 * @param handle handle to the GNS service 640 * @param handle handle to the GNS service
641 * @param name the name to look up 641 * @param name the name to look up
642 * @param zone the zone to start the resolution in
642 * @param type the record type to look up 643 * @param type the record type to look up
643 * @param proc processor to call on result 644 * @param proc processor to call on result
644 * @param proc_cls closure for processor 645 * @param proc_cls closure for processor
645 * @return handle to the get 646 * @return handle to the get
646 */ 647 */
647struct GNUNET_GNS_QueueEntry * 648struct GNUNET_GNS_QueueEntry *
648GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle, 649GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
649 const char * name, 650 const char * name,
651 struct GNUNET_CRYPTO_ShortHashCode *zone,
650 enum GNUNET_GNS_RecordType type, 652 enum GNUNET_GNS_RecordType type,
651 GNUNET_GNS_LookupResultProcessor proc, 653 GNUNET_GNS_LookupResultProcessor proc,
652 void *proc_cls) 654 void *proc_cls)
@@ -682,6 +684,18 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
682 lookup_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP); 684 lookup_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP);
683 lookup_msg->header.size = htons (msize); 685 lookup_msg->header.size = htons (msize);
684 lookup_msg->id = htonl(qe->r_id); 686 lookup_msg->id = htonl(qe->r_id);
687
688 if (NULL != zone)
689 {
690 lookup_msg->use_default_zone = htonl(0);
691 memcpy(&lookup_msg->zone, zone, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
692 }
693 else
694 {
695 lookup_msg->use_default_zone = htonl(1);
696 memset(&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
697 }
698
685 lookup_msg->type = htonl(type); 699 lookup_msg->type = htonl(type);
686 700
687 memcpy(&lookup_msg[1], name, strlen(name)); 701 memcpy(&lookup_msg[1], name, strlen(name));
@@ -693,19 +707,40 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
693 return qe; 707 return qe;
694} 708}
695 709
710/**
711 * Perform an asynchronous Lookup operation on the GNS.
712 *
713 * @param handle handle to the GNS service
714 * @param name the name to look up
715 * @param type the record type to look up
716 * @param proc processor to call on result
717 * @param proc_cls closure for processor
718 * @return handle to the get
719 */
720struct GNUNET_GNS_QueueEntry *
721GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
722 const char * name,
723 enum GNUNET_GNS_RecordType type,
724 GNUNET_GNS_LookupResultProcessor proc,
725 void *proc_cls)
726{
727 return GNUNET_GNS_lookup_zone (handle, name, NULL, type, proc, proc_cls);
728}
696 729
697/** 730/**
698 * Perform a name shortening operation on the GNS. 731 * Perform a name shortening operation on the GNS.
699 * 732 *
700 * @param handle handle to the GNS service 733 * @param handle handle to the GNS service
701 * @param name the name to look up 734 * @param name the name to look up
735 * @param zone the zone to start the resolution in
702 * @param proc function to call on result 736 * @param proc function to call on result
703 * @param proc_cls closure for processor 737 * @param proc_cls closure for processor
704 * @return handle to the operation 738 * @return handle to the operation
705 */ 739 */
706struct GNUNET_GNS_QueueEntry * 740struct GNUNET_GNS_QueueEntry *
707GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle, 741GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
708 const char * name, 742 const char * name,
743 struct GNUNET_CRYPTO_ShortHashCode *zone,
709 GNUNET_GNS_ShortenResultProcessor proc, 744 GNUNET_GNS_ShortenResultProcessor proc,
710 void *proc_cls) 745 void *proc_cls)
711{ 746{
@@ -740,6 +775,18 @@ GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
740 shorten_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_SHORTEN); 775 shorten_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_SHORTEN);
741 shorten_msg->header.size = htons (msize); 776 shorten_msg->header.size = htons (msize);
742 shorten_msg->id = htonl(qe->r_id); 777 shorten_msg->id = htonl(qe->r_id);
778
779 if (NULL != zone)
780 {
781 shorten_msg->use_default_zone = htonl(0);
782 memcpy(&shorten_msg->zone, zone,
783 sizeof(struct GNUNET_CRYPTO_ShortHashCode));
784 }
785 else
786 {
787 shorten_msg->use_default_zone = htonl(1);
788 memset(&shorten_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
789 }
743 790
744 memcpy(&shorten_msg[1], name, strlen(name)); 791 memcpy(&shorten_msg[1], name, strlen(name));
745 792
@@ -750,7 +797,23 @@ GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
750 return qe; 797 return qe;
751} 798}
752 799
753 800/**
801 * Perform a name shortening operation on the GNS.
802 *
803 * @param handle handle to the GNS service
804 * @param name the name to look up
805 * @param proc function to call on result
806 * @param proc_cls closure for processor
807 * @return handle to the operation
808 */
809struct GNUNET_GNS_QueueEntry *
810GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
811 const char * name,
812 GNUNET_GNS_ShortenResultProcessor proc,
813 void *proc_cls)
814{
815 return GNUNET_GNS_shorten_zone (handle, name, NULL, proc, proc_cls);
816}
754/** 817/**
755 * Perform an authority lookup for a given name. 818 * Perform an authority lookup for a given name.
756 * 819 *