aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-06 17:40:06 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-06 17:40:06 +0000
commit647b05ca4f4b069210709b65d943d18f570fe548 (patch)
treeb641c19a199a73903488fa7d5fcc02afe0f3e258 /src
parent16dd62ee0d62d6b9b319a159f48d0e6ec7601c1c (diff)
downloadgnunet-647b05ca4f4b069210709b65d943d18f570fe548.tar.gz
gnunet-647b05ca4f4b069210709b65d943d18f570fe548.zip
-fixes, shortening start
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns.c246
-rw-r--r--src/gns/test_gns_dht_delegated_lookup.c7
-rw-r--r--src/gns/test_gns_simple_delegated_lookup.c7
3 files changed, 214 insertions, 46 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 46c496661..c444964f3 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -39,7 +39,7 @@
39#include "block_gns.h" 39#include "block_gns.h"
40#include "gns.h" 40#include "gns.h"
41 41
42#define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 42#define DHT_OPERATION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
43#define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT 43#define DHT_LOOKUP_TIMEOUT DHT_OPERATION_TIMEOUT
44#define DHT_GNS_REPLICATION_LEVEL 5 44#define DHT_GNS_REPLICATION_LEVEL 5
45#define MAX_DNS_LABEL_LENGTH 63 45#define MAX_DNS_LABEL_LENGTH 63
@@ -50,6 +50,23 @@
50#define GNUNET_MESSAGE_TYPE_GNS_SHORTEN 25 50#define GNUNET_MESSAGE_TYPE_GNS_SHORTEN 25
51#define GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT 26 51#define GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT 26
52 52
53
54struct AuthorityChain
55{
56 struct AuthorityChain *prev;
57
58 struct AuthorityChain *next;
59
60 GNUNET_HashCode zone;
61};
62
63struct GNUNET_GNS_ResolverHandle;
64
65typedef void (*ResolutionResultProcessor) (void *cls,
66 struct GNUNET_GNS_ResolverHandle *rh,
67 uint32_t rd_count,
68 const struct GNUNET_NAMESTORE_RecordData *rd);
69
53/** 70/**
54 * Handle to a currenty pending resolution 71 * Handle to a currenty pending resolution
55 */ 72 */
@@ -89,6 +106,13 @@ struct GNUNET_GNS_ResolverHandle
89 /* timeout task for dht lookups */ 106 /* timeout task for dht lookups */
90 GNUNET_SCHEDULER_TaskIdentifier dht_timeout_task; 107 GNUNET_SCHEDULER_TaskIdentifier dht_timeout_task;
91 108
109 ResolutionResultProcessor proc;
110
111 void* proc_cls;
112
113 struct AuthorityChain *authority_chain_head;
114 struct AuthorityChain *authority_chain_tail;
115
92}; 116};
93 117
94struct ClientShortenHandle 118struct ClientShortenHandle
@@ -96,6 +120,8 @@ struct ClientShortenHandle
96 struct GNUNET_SERVER_Client *client; 120 struct GNUNET_SERVER_Client *client;
97 uint64_t unique_id; 121 uint64_t unique_id;
98 GNUNET_HashCode key; 122 GNUNET_HashCode key;
123 char* name;
124 uint32_t offset;
99}; 125};
100 126
101/** 127/**
@@ -161,7 +187,7 @@ static void resolve_name(struct GNUNET_GNS_ResolverHandle *rh);
161 * @param rd the record data 187 * @param rd the record data
162 */ 188 */
163static void 189static void
164reply_to_dns(struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count, 190reply_to_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count,
165 const struct GNUNET_NAMESTORE_RecordData *rd) 191 const struct GNUNET_NAMESTORE_RecordData *rd)
166{ 192{
167 int i; 193 int i;
@@ -319,7 +345,7 @@ dht_lookup_timeout(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
319 rh->name, rh->query->type); 345 rh->name, rh->query->type);
320 346
321 GNUNET_DHT_get_stop (rh->get_handle); 347 GNUNET_DHT_get_stop (rh->get_handle);
322 reply_to_dns(rh, 0, NULL); 348 rh->proc(rh->proc_cls, rh, 0, NULL);
323} 349}
324 350
325 351
@@ -431,9 +457,9 @@ process_record_dht_result(void* cls,
431 NULL); //cls 457 NULL); //cls
432 458
433 if (rh->answered) 459 if (rh->answered)
434 reply_to_dns(rh, num_records, rd); 460 rh->proc(rh->proc_cls, rh, num_records, rd);
435 else 461 else
436 reply_to_dns(rh, 0, NULL); 462 rh->proc(rh->proc_cls, rh, 0, NULL);
437 } 463 }
438 464
439} 465}
@@ -523,7 +549,7 @@ process_record_lookup(void* cls,
523 * Not our root and no record found. Try dht if expired 549 * Not our root and no record found. Try dht if expired
524 */ 550 */
525 if ((0 != GNUNET_CRYPTO_hash_cmp(&rh->authority, &zone_hash)) && 551 if ((0 != GNUNET_CRYPTO_hash_cmp(&rh->authority, &zone_hash)) &&
526 (remaining_time.rel_value != 0)) 552 ((name == NULL) || (remaining_time.rel_value != 0)))
527 { 553 {
528 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 554 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
529 "Record %s unknown in namestore, trying dht\n", 555 "Record %s unknown in namestore, trying dht\n",
@@ -536,7 +562,7 @@ process_record_lookup(void* cls,
536 * Our zone and no result? Cannot resolve TT 562 * Our zone and no result? Cannot resolve TT
537 */ 563 */
538 GNUNET_assert(rh->answered == 0); 564 GNUNET_assert(rh->answered == 0);
539 reply_to_dns(rh, 0, NULL); 565 rh->proc(rh->proc_cls, rh, 0, NULL);
540 return; 566 return;
541 567
542 } 568 }
@@ -570,14 +596,14 @@ process_record_lookup(void* cls,
570 { 596 {
571 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 597 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
572 "No answers found. This is odd!\n"); 598 "No answers found. This is odd!\n");
573 reply_to_dns(rh, 0, NULL); 599 rh->proc(rh->proc_cls, rh, 0, NULL);
574 return; 600 return;
575 } 601 }
576 602
577 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found %d answer(s) to query!\n", 603 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found %d answer(s) to query!\n",
578 rh->answered); 604 rh->answered);
579 605
580 reply_to_dns(rh, rd_count, rd); 606 rh->proc(rh->proc_cls, rh, rd_count, rd);
581 } 607 }
582} 608}
583 609
@@ -623,7 +649,8 @@ dht_authority_lookup_timeout(void *cls,
623 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 649 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
624 "dht lookup for query %s (type=%d) timed out.\n", 650 "dht lookup for query %s (type=%d) timed out.\n",
625 rh->name, rh->query->type); 651 rh->name, rh->query->type);
626 652
653 GNUNET_DHT_get_stop (rh->get_handle);
627 if (strcmp(rh->name, "") == 0) 654 if (strcmp(rh->name, "") == 0)
628 { 655 {
629 /* 656 /*
@@ -634,8 +661,7 @@ dht_authority_lookup_timeout(void *cls,
634 } 661 }
635 else 662 else
636 { 663 {
637 GNUNET_DHT_get_stop (rh->get_handle); 664 rh->proc(rh->proc_cls, rh, 0, NULL);
638 reply_to_dns(rh, 0, NULL);
639 } 665 }
640} 666}
641 667
@@ -725,10 +751,13 @@ process_authority_dht_result(void* cls,
725 { 751 {
726 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Authority found in DHT\n"); 752 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Authority found in DHT\n");
727 rh->answered = 1; 753 rh->answered = 1;
728 GNUNET_CRYPTO_hash( 754 memcpy(&rh->authority, rd[i].data, sizeof(GNUNET_HashCode));
729 (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *)rd[i].data, 755 struct AuthorityChain *auth =
730 rd[i].data_size, 756 GNUNET_malloc(sizeof(struct AuthorityChain));
731 &rh->authority); 757 auth->zone = rh->authority;
758 GNUNET_CONTAINER_DLL_insert (rh->authority_chain_head,
759 rh->authority_chain_tail,
760 auth);
732 } 761 }
733 762
734 } 763 }
@@ -772,7 +801,7 @@ process_authority_dht_result(void* cls,
772 return; 801 return;
773 } 802 }
774 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "No authority in records\n"); 803 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "No authority in records\n");
775 reply_to_dns(rh, 0, NULL); 804 rh->proc(rh->proc_cls, rh, 0, NULL);
776} 805}
777 806
778/** 807/**
@@ -807,7 +836,7 @@ resolve_authority_dht(struct GNUNET_GNS_ResolverHandle *rh)
807 DHT_GNS_REPLICATION_LEVEL, 836 DHT_GNS_REPLICATION_LEVEL,
808 GNUNET_DHT_RO_NONE, 837 GNUNET_DHT_RO_NONE,
809 NULL, 838 NULL,
810 0,//sizeof(xquery), 839 sizeof(xquery),
811 &process_authority_dht_result, 840 &process_authority_dht_result,
812 rh); 841 rh);
813 842
@@ -877,10 +906,10 @@ process_authority_lookup(void* cls,
877 else 906 else
878 { 907 {
879 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 908 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
880 "Authority %s unknown in namestore, cannot resolve\n", 909 "Authority %s for %s unknown in namestore, cannot resolve\n",
881 rh->authority_name); 910 rh->authority_name, rh->name);
882 } 911 }
883 reply_to_dns(rh, 0, NULL); 912 rh->proc(rh->proc_cls, rh, 0, NULL);
884 return; 913 return;
885 } 914 }
886 915
@@ -891,11 +920,22 @@ process_authority_lookup(void* cls,
891 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "AAAA %d\n", remaining_time.rel_value); 920 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "AAAA %d\n", remaining_time.rel_value);
892 if ((0 != GNUNET_CRYPTO_hash_cmp(&rh->authority, &zone_hash))) 921 if ((0 != GNUNET_CRYPTO_hash_cmp(&rh->authority, &zone_hash)))
893 { 922 {
894 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 923 if (strcmp(rh->name, "") == 0)
895 "Authority %s unknown in namestore, trying dht\n", 924 {
896 rh->authority_name); 925 /**
897 resolve_authority_dht(rh); 926 * Promote this authority back to a name
898 return; 927 */
928 strcpy(rh->name, rh->authority_name);
929 resolve_record(rh);
930 }
931 else
932 {
933 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
934 "Authority %s for %s unknown in namestore, trying dht\n",
935 rh->authority_name, rh->name);
936 resolve_authority_dht(rh);
937 }
938 return;
899 } 939 }
900 940
901 /** 941 /**
@@ -903,7 +943,7 @@ process_authority_lookup(void* cls,
903 */ 943 */
904 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Authority %s unknown\n", 944 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Authority %s unknown\n",
905 rh->authority_name); 945 rh->authority_name);
906 reply_to_dns(rh, 0, NULL); 946 rh->proc(rh->proc_cls, rh, 0, NULL);
907 return; 947 return;
908 } 948 }
909 949
@@ -938,9 +978,13 @@ process_authority_lookup(void* cls,
938 * Resolve rest of query with new authority 978 * Resolve rest of query with new authority
939 */ 979 */
940 GNUNET_assert(rd[i].record_type == GNUNET_GNS_RECORD_PKEY); 980 GNUNET_assert(rd[i].record_type == GNUNET_GNS_RECORD_PKEY);
941 GNUNET_CRYPTO_hash(rd[i].data, 981 memcpy(&rh->authority, rd[i].data, sizeof(GNUNET_HashCode));
942 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 982 struct AuthorityChain *auth = GNUNET_malloc(sizeof(struct AuthorityChain));
943 &rh->authority); 983 auth->zone = rh->authority;
984 GNUNET_CONTAINER_DLL_insert (rh->authority_chain_head,
985 rh->authority_chain_tail,
986 auth);
987
944 if (strcmp(rh->name, "") == 0) 988 if (strcmp(rh->name, "") == 0)
945 resolve_record(rh); 989 resolve_record(rh);
946 else 990 else
@@ -953,7 +997,7 @@ process_authority_lookup(void* cls,
953 */ 997 */
954 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 998 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
955 "Authority lookup successful but no PKEY... never get here\n"); 999 "Authority lookup successful but no PKEY... never get here\n");
956 reply_to_dns(rh, 0, NULL); 1000 rh->proc(rh->proc_cls, rh, 0, NULL);
957} 1001}
958 1002
959 1003
@@ -1049,9 +1093,9 @@ resolve_name(struct GNUNET_GNS_ResolverHandle *rh)
1049 * @param q the DNS query we received parsed from p 1093 * @param q the DNS query we received parsed from p
1050 */ 1094 */
1051static void 1095static void
1052start_resolution(struct GNUNET_DNS_RequestHandle *request, 1096start_resolution_from_dns(struct GNUNET_DNS_RequestHandle *request,
1053 struct GNUNET_DNSPARSER_Packet *p, 1097 struct GNUNET_DNSPARSER_Packet *p,
1054 struct GNUNET_DNSPARSER_Query *q) 1098 struct GNUNET_DNSPARSER_Query *q)
1055{ 1099{
1056 struct GNUNET_GNS_ResolverHandle *rh; 1100 struct GNUNET_GNS_ResolverHandle *rh;
1057 1101
@@ -1063,6 +1107,7 @@ start_resolution(struct GNUNET_DNS_RequestHandle *request,
1063 rh->packet = p; 1107 rh->packet = p;
1064 rh->query = q; 1108 rh->query = q;
1065 rh->authority = zone_hash; 1109 rh->authority = zone_hash;
1110 rh->proc = &reply_to_dns;
1066 1111
1067 rh->name = GNUNET_malloc(strlen(q->name) 1112 rh->name = GNUNET_malloc(strlen(q->name)
1068 - strlen(gnunet_tld) + 1); 1113 - strlen(gnunet_tld) + 1);
@@ -1075,6 +1120,10 @@ start_resolution(struct GNUNET_DNS_RequestHandle *request,
1075 1120
1076 rh->request_handle = request; 1121 rh->request_handle = request;
1077 1122
1123 rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain));
1124 rh->authority_chain_tail = rh->authority_chain_head;
1125 rh->authority_chain_head->zone = zone_hash;
1126
1078 /* Start resolution in our zone */ 1127 /* Start resolution in our zone */
1079 resolve_name(rh); 1128 resolve_name(rh);
1080} 1129}
@@ -1145,7 +1194,7 @@ handle_dns_request(void *cls,
1145 1194
1146 if (0 == strcmp(tldoffset, gnunet_tld)) 1195 if (0 == strcmp(tldoffset, gnunet_tld))
1147 { 1196 {
1148 start_resolution(rh, p, p->queries); 1197 start_resolution_from_dns(rh, p, p->queries);
1149 } 1198 }
1150 else 1199 else
1151 { 1200 {
@@ -1324,6 +1373,82 @@ update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1324 NULL); 1373 NULL);
1325} 1374}
1326 1375
1376//Prototype
1377static void send_shorten_response(const char* name,
1378 struct ClientShortenHandle *csh);
1379
1380void
1381handle_local_zone_to_name(void *cls,
1382 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
1383 struct GNUNET_TIME_Absolute expire,
1384 const char *name,
1385 unsigned int rd_len,
1386 const struct GNUNET_NAMESTORE_RecordData *rd,
1387 const struct GNUNET_CRYPTO_RsaSignature *signature)
1388{
1389 struct GNUNET_GNS_ResolverHandle *rh =
1390 (struct GNUNET_GNS_ResolverHandle *)cls;
1391 struct ClientShortenHandle* csh = (struct ClientShortenHandle*) rh->proc_cls;
1392 /* we found a match in our own zone */
1393 if (rd_len != 0)
1394 {
1395 send_shorten_response(name, csh);
1396 //FIXME free, add .gnunet
1397 }
1398 else
1399 {
1400
1401 }
1402}
1403
1404void
1405handle_shorten_result(void* cls,
1406 struct GNUNET_GNS_ResolverHandle *rh,
1407 uint32_t rd_count,
1408 const struct GNUNET_NAMESTORE_RecordData *rd)
1409{
1410 struct ClientShortenHandle* csh = (struct ClientShortenHandle*) cls;
1411 struct AuthorityChain *auth_chain;
1412
1413 /**
1414 * Couldn't completely resolve
1415 * Search authority chain
1416 */
1417
1418 if (rd_count == 0)
1419 {
1420 /* Nothing we can do. That name is unknown */
1421 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
1422 "PKEY for %s unknown!\n", csh->name);
1423 if (GNUNET_CRYPTO_hash_cmp(&rh->authority_chain_head->zone,
1424 &zone_hash) == 0)
1425 {
1426 /* either we can shorten completely or we don't know this name */
1427 if (rh->authority_chain_head->next == NULL)
1428 send_shorten_response('\0', csh);
1429 else
1430 send_shorten_response(rh->name, csh); //FIXME +.gnunet!
1431 //FIXME free
1432 return;
1433 }
1434 csh->offset++;
1435 auth_chain = rh->authority_chain_head;
1436 /* backtrack authorities for pseu */
1437 GNUNET_NAMESTORE_zone_to_name (namestore_handle,
1438 &zone_hash, //ours
1439 &auth_chain->zone,
1440 &handle_local_zone_to_name,
1441 rh);
1442 }
1443 else /* we can use the result directly */
1444 {
1445 /* First check local namestore for name */
1446 /* Then try dht/namestore for PSEU */
1447 }
1448
1449
1450}
1451
1327typedef void (*ShortenResponseProc) (void* cls, const char* name); 1452typedef void (*ShortenResponseProc) (void* cls, const char* name);
1328 1453
1329/** 1454/**
@@ -1334,24 +1459,57 @@ typedef void (*ShortenResponseProc) (void* cls, const char* name);
1334 * @praram cls the closure to the processor 1459 * @praram cls the closure to the processor
1335 */ 1460 */
1336static void 1461static void
1337shorten_name(char* name, ShortenResponseProc proc, void* cls) 1462shorten_name(char* name, struct ClientShortenHandle* csh)
1338{ 1463{
1339 char* result = name; 1464
1340 proc(cls, result); 1465 struct GNUNET_GNS_ResolverHandle *rh;
1466
1467 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1468 "Starting resolution for %s (type=%d)!\n",
1469 name, GNUNET_GNS_RECORD_PKEY);
1470
1471 rh = GNUNET_malloc(sizeof (struct GNUNET_GNS_ResolverHandle));
1472 rh->authority = zone_hash;
1473
1474 rh->name = GNUNET_malloc(strlen(name)
1475 - strlen(gnunet_tld) + 1);
1476 memset(rh->name, 0,
1477 strlen(name)-strlen(gnunet_tld) + 1);
1478 memcpy(rh->name, name,
1479 strlen(name)-strlen(gnunet_tld));
1480
1481 csh->name = GNUNET_malloc(strlen(name)
1482 - strlen(gnunet_tld) + 1);
1483 memset(rh->name, 0,
1484 strlen(name)-strlen(gnunet_tld) + 1);
1485 memcpy(rh->name, name,
1486 strlen(name)-strlen(gnunet_tld));
1487
1488 rh->authority_name = GNUNET_malloc(sizeof(char)*MAX_DNS_LABEL_LENGTH);
1489
1490 rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain));
1491 rh->authority_chain_tail = rh->authority_chain_head;
1492 rh->authority_chain_head->zone = zone_hash;
1493 rh->proc = handle_shorten_result;
1494 rh->proc_cls = (void*)csh;
1495
1496 /* Start resolution in our zone */
1497 resolve_name(rh);
1498
1341} 1499}
1342 1500
1343/** 1501/**
1344 * Send shorten response back to client 1502 * Send shorten response back to client
1503 * FIXME this is without .gnunet!
1345 * 1504 *
1346 * @param cls the client handle in closure 1505 * @param cls the client handle in closure
1347 * @param name the shortened name result or NULL if cannot be shortened 1506 * @param name the shortened name result or NULL if cannot be shortened
1348 */ 1507 */
1349static void 1508static void
1350send_shorten_response(void* cls, const char* name) 1509send_shorten_response(const char* name, struct ClientShortenHandle *csh)
1351{ 1510{
1352 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", 1511 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n",
1353 "SHORTEN_RESULT"); 1512 "SHORTEN_RESULT");
1354 struct ClientShortenHandle *csh = (struct ClientShortenHandle *)cls;
1355 struct GNUNET_GNS_ClientShortenResultMessage *rmsg; 1513 struct GNUNET_GNS_ClientShortenResultMessage *rmsg;
1356 1514
1357 if (name == NULL) 1515 if (name == NULL)
@@ -1365,6 +1523,9 @@ send_shorten_response(void* cls, const char* name)
1365 rmsg->unique_id = csh->unique_id; 1523 rmsg->unique_id = csh->unique_id;
1366 rmsg->key = csh->key; 1524 rmsg->key = csh->key;
1367 rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT); 1525 rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT);
1526 rmsg->header.size =
1527 htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage *) +
1528 strlen(name));
1368 1529
1369 strcpy((char*)&rmsg[1], name); 1530 strcpy((char*)&rmsg[1], name);
1370 1531
@@ -1419,8 +1580,11 @@ static void handle_shorten(void *cls,
1419 csh->unique_id = sh_msg->unique_id; 1580 csh->unique_id = sh_msg->unique_id;
1420 csh->key = sh_msg->key; 1581 csh->key = sh_msg->key;
1421 1582
1583 //Offset in original name
1584 csh->offset = 0;
1585
1422 1586
1423 shorten_name((char*)&sh_msg[1], &send_shorten_response, csh); 1587 shorten_name((char*)&sh_msg[1], csh);
1424 1588
1425} 1589}
1426 1590
diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c
index 816196048..83fdf1873 100644
--- a/src/gns/test_gns_dht_delegated_lookup.c
+++ b/src/gns/test_gns_dht_delegated_lookup.c
@@ -255,7 +255,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
255 255
256 256
257 char* alice_keyfile; 257 char* alice_keyfile;
258 258 GNUNET_HashCode bob_hash;
259 259
260 260
261 GNUNET_SCHEDULER_cancel (die_task); 261 GNUNET_SCHEDULER_cancel (die_task);
@@ -292,11 +292,12 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
292 292
293 GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); 293 GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey);
294 GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); 294 GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey);
295 GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
295 296
296 struct GNUNET_NAMESTORE_RecordData rd; 297 struct GNUNET_NAMESTORE_RecordData rd;
297 rd.expiration = GNUNET_TIME_absolute_get_forever (); 298 rd.expiration = GNUNET_TIME_absolute_get_forever ();
298 rd.data_size = sizeof(bob_pkey); 299 rd.data_size = sizeof(GNUNET_HashCode);
299 rd.data = &bob_pkey; 300 rd.data = &bob_hash;
300 rd.record_type = GNUNET_GNS_RECORD_PKEY; 301 rd.record_type = GNUNET_GNS_RECORD_PKEY;
301 302
302 GNUNET_NAMESTORE_record_create (namestore_handle, 303 GNUNET_NAMESTORE_record_create (namestore_handle,
diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c
index e4383fe4c..059d08c06 100644
--- a/src/gns/test_gns_simple_delegated_lookup.c
+++ b/src/gns/test_gns_simple_delegated_lookup.c
@@ -182,6 +182,7 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
182 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey; 182 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded bob_pkey;
183 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; 183 struct GNUNET_CRYPTO_RsaPrivateKey *alice_key;
184 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key; 184 struct GNUNET_CRYPTO_RsaPrivateKey *bob_key;
185 GNUNET_HashCode bob_hash;
185 struct GNUNET_CRYPTO_RsaSignature *sig; 186 struct GNUNET_CRYPTO_RsaSignature *sig;
186 char* alice_keyfile; 187 char* alice_keyfile;
187 188
@@ -216,9 +217,11 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id,
216 struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr)); 217 struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
217 rd.expiration = GNUNET_TIME_absolute_get_forever (); 218 rd.expiration = GNUNET_TIME_absolute_get_forever ();
218 GNUNET_assert(1 == inet_pton (AF_INET, ip, web)); 219 GNUNET_assert(1 == inet_pton (AF_INET, ip, web));
220
221 GNUNET_CRYPTO_hash(&bob_pkey, sizeof(bob_pkey), &bob_hash);
219 222
220 rd.data_size = sizeof(bob_pkey); 223 rd.data_size = sizeof(GNUNET_HashCode);
221 rd.data = &bob_pkey; 224 rd.data = &bob_hash;
222 rd.record_type = GNUNET_GNS_RECORD_PKEY; 225 rd.record_type = GNUNET_GNS_RECORD_PKEY;
223 226
224 GNUNET_NAMESTORE_record_create (namestore_handle, 227 GNUNET_NAMESTORE_record_create (namestore_handle,