aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gns_api.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-06-11 14:59:04 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-06-11 14:59:04 +0000
commit8338aebe1b4be9e8cb27be564851a14a9ebb6b14 (patch)
treed9b37c09a7bf1226d899671765548d5fe0bad145 /src/gns/gns_api.c
parentc4ea2585c71c4d619f3f24f32c277a5fa6b5772a (diff)
downloadgnunet-8338aebe1b4be9e8cb27be564851a14a9ebb6b14.tar.gz
gnunet-8338aebe1b4be9e8cb27be564851a14a9ebb6b14.zip
new API for shorten key
Diffstat (limited to 'src/gns/gns_api.c')
-rw-r--r--src/gns/gns_api.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index a92280f25..2cdb58a31 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -640,6 +640,7 @@ get_request_id (struct GNUNET_GNS_Handle *h)
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 zone the zone to start the resolution in
643 * @param shorten_zone the zone where to shorten names into
643 * @param type the record type to look up 644 * @param type the record type to look up
644 * @param proc processor to call on result 645 * @param proc processor to call on result
645 * @param proc_cls closure for processor 646 * @param proc_cls closure for processor
@@ -649,6 +650,7 @@ struct GNUNET_GNS_QueueEntry *
649GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle, 650GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
650 const char * name, 651 const char * name,
651 struct GNUNET_CRYPTO_ShortHashCode *zone, 652 struct GNUNET_CRYPTO_ShortHashCode *zone,
653 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
652 enum GNUNET_GNS_RecordType type, 654 enum GNUNET_GNS_RecordType type,
653 GNUNET_GNS_LookupResultProcessor proc, 655 GNUNET_GNS_LookupResultProcessor proc,
654 void *proc_cls) 656 void *proc_cls)
@@ -695,7 +697,20 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
695 lookup_msg->use_default_zone = htonl(1); 697 lookup_msg->use_default_zone = htonl(1);
696 memset(&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); 698 memset(&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
697 } 699 }
698 700
701 if (NULL != shorten_zone)
702 {
703 lookup_msg->use_shorten_zone = htonl(1);
704 memcpy(&lookup_msg->shorten_zone, shorten_zone,
705 sizeof(struct GNUNET_CRYPTO_ShortHashCode));
706 }
707 else
708 {
709 lookup_msg->use_shorten_zone = htonl(0);
710 memset(&lookup_msg->shorten_zone, 0,
711 sizeof(struct GNUNET_CRYPTO_ShortHashCode));
712 }
713
699 lookup_msg->type = htonl(type); 714 lookup_msg->type = htonl(type);
700 715
701 memcpy(&lookup_msg[1], name, strlen(name)); 716 memcpy(&lookup_msg[1], name, strlen(name));
@@ -724,7 +739,9 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
724 GNUNET_GNS_LookupResultProcessor proc, 739 GNUNET_GNS_LookupResultProcessor proc,
725 void *proc_cls) 740 void *proc_cls)
726{ 741{
727 return GNUNET_GNS_lookup_zone (handle, name, NULL, type, proc, proc_cls); 742 return GNUNET_GNS_lookup_zone (handle, name,
743 NULL, NULL,
744 type, proc, proc_cls);
728} 745}
729 746
730/** 747/**
@@ -733,6 +750,7 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
733 * @param handle handle to the GNS service 750 * @param handle handle to the GNS service
734 * @param name the name to look up 751 * @param name the name to look up
735 * @param zone the zone to start the resolution in 752 * @param zone the zone to start the resolution in
753 * @param shorten_zone the zone where to shorten names into
736 * @param proc function to call on result 754 * @param proc function to call on result
737 * @param proc_cls closure for processor 755 * @param proc_cls closure for processor
738 * @return handle to the operation 756 * @return handle to the operation
@@ -741,6 +759,7 @@ struct GNUNET_GNS_QueueEntry *
741GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle, 759GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
742 const char * name, 760 const char * name,
743 struct GNUNET_CRYPTO_ShortHashCode *zone, 761 struct GNUNET_CRYPTO_ShortHashCode *zone,
762 struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
744 GNUNET_GNS_ShortenResultProcessor proc, 763 GNUNET_GNS_ShortenResultProcessor proc,
745 void *proc_cls) 764 void *proc_cls)
746{ 765{
@@ -787,7 +806,20 @@ GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
787 shorten_msg->use_default_zone = htonl(1); 806 shorten_msg->use_default_zone = htonl(1);
788 memset(&shorten_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode)); 807 memset(&shorten_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
789 } 808 }
790 809
810 if (NULL != shorten_zone)
811 {
812 shorten_msg->use_shorten_zone = htonl(1);
813 memcpy(&shorten_msg->shorten_zone, shorten_zone,
814 sizeof(struct GNUNET_CRYPTO_ShortHashCode));
815 }
816 else
817 {
818 shorten_msg->use_shorten_zone = htonl(0);
819 memset(&shorten_msg->shorten_zone, 0,
820 sizeof(struct GNUNET_CRYPTO_ShortHashCode));
821 }
822
791 memcpy(&shorten_msg[1], name, strlen(name)); 823 memcpy(&shorten_msg[1], name, strlen(name));
792 824
793 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, 825 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail,
@@ -812,7 +844,7 @@ GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
812 GNUNET_GNS_ShortenResultProcessor proc, 844 GNUNET_GNS_ShortenResultProcessor proc,
813 void *proc_cls) 845 void *proc_cls)
814{ 846{
815 return GNUNET_GNS_shorten_zone (handle, name, NULL, proc, proc_cls); 847 return GNUNET_GNS_shorten_zone (handle, name, NULL, NULL, proc, proc_cls);
816} 848}
817/** 849/**
818 * Perform an authority lookup for a given name. 850 * Perform an authority lookup for a given name.