aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-24 16:20:35 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-24 16:20:35 +0000
commit1f53f3eac1fe5673c7933a25710e2f4fb73b8270 (patch)
tree46f7ce84916c2d7c5b8ba66a768dc0e770de10e7 /src
parent3c30d9be2e4c02b9d7a94191ad050fd83a011e09 (diff)
downloadgnunet-1f53f3eac1fe5673c7933a25710e2f4fb73b8270.tar.gz
gnunet-1f53f3eac1fe5673c7933a25710e2f4fb73b8270.zip
-cleanup
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns.c185
1 files changed, 101 insertions, 84 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index 563c9d851..d6989cb6a 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -57,7 +57,7 @@ struct GNUNET_GNS_QueryRecordList
57/** 57/**
58 * A result list for namestore queries 58 * A result list for namestore queries
59 */ 59 */
60struct GNUNET_GNS_PendingQuery 60struct GNUNET_GNS_ResolverHandle
61{ 61{
62 /* the answer packet */ 62 /* the answer packet */
63 struct GNUNET_DNSPARSER_Packet *answer; 63 struct GNUNET_DNSPARSER_Packet *answer;
@@ -69,13 +69,8 @@ struct GNUNET_GNS_PendingQuery
69 int num_records; 69 int num_records;
70 int num_authority_records; //FIXME are all of our replies auth? 70 int num_authority_records; //FIXME are all of our replies auth?
71 71
72 char *original_name;
73 char *name; 72 char *name;
74 73
75 uint16_t type;
76 /* the dns request id */
77 int id; // FIXME can handle->request_id also be used here?
78
79 /* the request handle to reply to */ 74 /* the request handle to reply to */
80 struct GNUNET_DNS_RequestHandle *request_handle; 75 struct GNUNET_DNS_RequestHandle *request_handle;
81 76
@@ -90,7 +85,9 @@ struct GNUNET_GNS_PendingQuery
90 */ 85 */
91 int authority_found; 86 int authority_found;
92 87
93 struct GNUNET_DNSPARSER_Packet *p; 88 struct GNUNET_DNSPARSER_Packet *packet;
89
90 struct GNUNET_DNSPARSER_Query *query;
94}; 91};
95 92
96 93
@@ -143,9 +140,9 @@ static int num_public_records = 3600;
143struct GNUNET_TIME_Relative dht_update_interval; 140struct GNUNET_TIME_Relative dht_update_interval;
144 141
145 142
146void reply_to_dns(struct GNUNET_GNS_PendingQuery *answer, uint32_t rd_count, 143void reply_to_dns(struct GNUNET_GNS_ResolverHandle *answer, uint32_t rd_count,
147 const struct GNUNET_NAMESTORE_RecordData *rd); 144 const struct GNUNET_NAMESTORE_RecordData *rd);
148void resolve_name(struct GNUNET_GNS_PendingQuery *query, 145void resolve_name(struct GNUNET_GNS_ResolverHandle *query,
149 GNUNET_HashCode *zone); 146 GNUNET_HashCode *zone);
150 147
151/** 148/**
@@ -209,7 +206,7 @@ process_authority_dht_result(void* cls,
209 enum GNUNET_BLOCK_Type type, 206 enum GNUNET_BLOCK_Type type,
210 size_t size, const void *data) 207 size_t size, const void *data)
211{ 208{
212 struct GNUNET_GNS_PendingQuery *query; 209 struct GNUNET_GNS_ResolverHandle *rh;
213 uint32_t num_records; 210 uint32_t num_records;
214 uint16_t namelen; 211 uint16_t namelen;
215 char* name = NULL; 212 char* name = NULL;
@@ -222,7 +219,7 @@ process_authority_dht_result(void* cls,
222 if (data == NULL) 219 if (data == NULL)
223 return; 220 return;
224 221
225 query = (struct GNUNET_GNS_PendingQuery *)cls; 222 rh = (struct GNUNET_GNS_ResolverHandle *)cls;
226 pos = (char*)data; 223 pos = (char*)data;
227 224
228 num_records = ntohl(*pos); 225 num_records = ntohl(*pos);
@@ -256,9 +253,9 @@ process_authority_dht_result(void* cls,
256 pos += sizeof(uint16_t); 253 pos += sizeof(uint16_t);
257 //FIXME class? 254 //FIXME class?
258 // 255 //
259 if (strcmp(name, query->name) && rd[i].record_type == query->type) 256 if (strcmp(name, rh->query->name) && rd[i].record_type == rh->query->type)
260 { 257 {
261 query->answered = 1; 258 rh->answered = 1;
262 } 259 }
263 260
264 } 261 }
@@ -290,11 +287,11 @@ process_authority_dht_result(void* cls,
290 &on_namestore_record_put_result, //cont 287 &on_namestore_record_put_result, //cont
291 NULL); //cls 288 NULL); //cls
292 289
293 if (query->answered) 290 if (rh->answered)
294 { 291 {
295 query->answered = 0; 292 rh->answered = 0;
296 memcpy(query->authority, &zone, sizeof(GNUNET_HashCode)); 293 memcpy(rh->authority, &zone, sizeof(GNUNET_HashCode));
297 resolve_name(query, query->authority); 294 resolve_name(rh, rh->authority);
298 } 295 }
299 /** 296 /**
300 * data is a serialized PKEY record (probably) 297 * data is a serialized PKEY record (probably)
@@ -316,7 +313,7 @@ process_authority_dht_result(void* cls,
316 * @param name the name of the PKEY record 313 * @param name the name of the PKEY record
317 */ 314 */
318void 315void
319resolve_authority_dht(struct GNUNET_GNS_PendingQuery *query, const char* name) 316resolve_authority_dht(struct GNUNET_GNS_ResolverHandle *rh, const char* name)
320{ 317{
321 enum GNUNET_GNS_RecordType rtype = GNUNET_GNS_RECORD_PKEY; 318 enum GNUNET_GNS_RecordType rtype = GNUNET_GNS_RECORD_PKEY;
322 struct GNUNET_TIME_Relative timeout; 319 struct GNUNET_TIME_Relative timeout;
@@ -324,7 +321,7 @@ resolve_authority_dht(struct GNUNET_GNS_PendingQuery *query, const char* name)
324 GNUNET_HashCode lookup_key; 321 GNUNET_HashCode lookup_key;
325 322
326 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash); 323 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash);
327 GNUNET_CRYPTO_hash_xor(&name_hash, query->authority, &lookup_key); 324 GNUNET_CRYPTO_hash_xor(&name_hash, rh->authority, &lookup_key);
328 325
329 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20); 326 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20);
330 327
@@ -337,7 +334,7 @@ resolve_authority_dht(struct GNUNET_GNS_PendingQuery *query, const char* name)
337 &rtype, //xquery FIXME this is bad 334 &rtype, //xquery FIXME this is bad
338 sizeof(GNUNET_GNS_RECORD_PKEY), 335 sizeof(GNUNET_GNS_RECORD_PKEY),
339 &process_authority_dht_result, 336 &process_authority_dht_result,
340 query); 337 rh);
341 338
342} 339}
343 340
@@ -367,7 +364,7 @@ process_name_dht_result(void* cls,
367 enum GNUNET_BLOCK_Type type, 364 enum GNUNET_BLOCK_Type type,
368 size_t size, const void *data) 365 size_t size, const void *data)
369{ 366{
370 struct GNUNET_GNS_PendingQuery *query; 367 struct GNUNET_GNS_ResolverHandle *rh;
371 uint32_t num_records; 368 uint32_t num_records;
372 uint16_t namelen; 369 uint16_t namelen;
373 char* name = NULL; 370 char* name = NULL;
@@ -380,7 +377,7 @@ process_name_dht_result(void* cls,
380 if (data == NULL) 377 if (data == NULL)
381 return; 378 return;
382 379
383 query = (struct GNUNET_GNS_PendingQuery *)cls; 380 rh = (struct GNUNET_GNS_ResolverHandle *)cls;
384 pos = (char*)data; 381 pos = (char*)data;
385 382
386 num_records = ntohl(*pos); 383 num_records = ntohl(*pos);
@@ -414,9 +411,9 @@ process_name_dht_result(void* cls,
414 pos += sizeof(uint16_t); 411 pos += sizeof(uint16_t);
415 //FIXME class? 412 //FIXME class?
416 // 413 //
417 if (strcmp(name, query->name) && rd[i].record_type == query->type) 414 if (strcmp(name, rh->query->name) && rd[i].record_type == rh->query->type)
418 { 415 {
419 query->answered = 1; 416 rh->answered = 1;
420 } 417 }
421 418
422 } 419 }
@@ -449,12 +446,12 @@ process_name_dht_result(void* cls,
449 &on_namestore_record_put_result, //cont 446 &on_namestore_record_put_result, //cont
450 NULL); //cls 447 NULL); //cls
451 448
452 if (query->answered) 449 if (rh->answered)
453 { 450 {
454 //FIXME: add records to query handle, but on stack! 451 //FIXME: add records to query handle, but on stack!
455 //do we need records in query handle? can't we just 452 //do we need records in query handle? can't we just
456 //pass them to reply_to_dns? 453 //pass them to reply_to_dns?
457 reply_to_dns(query, num_records, rd); 454 reply_to_dns(rh, num_records, rd);
458 } 455 }
459 456
460 /** 457 /**
@@ -472,14 +469,14 @@ process_name_dht_result(void* cls,
472 * @param name the name to query record 469 * @param name the name to query record
473 */ 470 */
474void 471void
475resolve_name_dht(struct GNUNET_GNS_PendingQuery *query, const char* name) 472resolve_name_dht(struct GNUNET_GNS_ResolverHandle *rh, const char* name)
476{ 473{
477 struct GNUNET_TIME_Relative timeout; 474 struct GNUNET_TIME_Relative timeout;
478 GNUNET_HashCode name_hash; 475 GNUNET_HashCode name_hash;
479 GNUNET_HashCode lookup_key; 476 GNUNET_HashCode lookup_key;
480 477
481 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash); 478 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash);
482 GNUNET_CRYPTO_hash_xor(&name_hash, query->authority, &lookup_key); 479 GNUNET_CRYPTO_hash_xor(&name_hash, rh->authority, &lookup_key);
483 480
484 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20); 481 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20);
485 482
@@ -489,16 +486,16 @@ resolve_name_dht(struct GNUNET_GNS_PendingQuery *query, const char* name)
489 &lookup_key, 486 &lookup_key,
490 5, //Replication level FIXME 487 5, //Replication level FIXME
491 GNUNET_DHT_RO_NONE, 488 GNUNET_DHT_RO_NONE,
492 &query->type, //xquery 489 &rh->query->type, //xquery
493 sizeof(query->type), 490 sizeof(rh->query->type),
494 &process_name_dht_result, 491 &process_name_dht_result,
495 query); 492 rh);
496 493
497} 494}
498 495
499//Prototype 496//Prototype
500void 497void
501resolve_name(struct GNUNET_GNS_PendingQuery *query, GNUNET_HashCode *zone); 498resolve_name(struct GNUNET_GNS_ResolverHandle *query, GNUNET_HashCode *zone);
502 499
503/** 500/**
504 * This is a callback function that should give us only PKEY 501 * This is a callback function that should give us only PKEY
@@ -524,10 +521,10 @@ process_authority_lookup(void* cls,
524 const struct GNUNET_NAMESTORE_RecordData *rd, 521 const struct GNUNET_NAMESTORE_RecordData *rd,
525 const struct GNUNET_CRYPTO_RsaSignature *signature) 522 const struct GNUNET_CRYPTO_RsaSignature *signature)
526{ 523{
527 struct GNUNET_GNS_PendingQuery *query; 524 struct GNUNET_GNS_ResolverHandle *query;
528 GNUNET_HashCode zone; 525 GNUNET_HashCode zone;
529 526
530 query = (struct GNUNET_GNS_PendingQuery *)cls; 527 query = (struct GNUNET_GNS_ResolverHandle *)cls;
531 GNUNET_CRYPTO_hash(key, GNUNET_CRYPTO_RSA_KEY_LENGTH, &zone); 528 GNUNET_CRYPTO_hash(key, GNUNET_CRYPTO_RSA_KEY_LENGTH, &zone);
532 529
533 /** 530 /**
@@ -576,7 +573,7 @@ process_authority_lookup(void* cls,
576 * @param answer the pending query used in the lookup 573 * @param answer the pending query used in the lookup
577 */ 574 */
578void 575void
579reply_to_dns(struct GNUNET_GNS_PendingQuery *answer, uint32_t rd_count, 576reply_to_dns(struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count,
580 const struct GNUNET_NAMESTORE_RecordData *rd) 577 const struct GNUNET_NAMESTORE_RecordData *rd)
581{ 578{
582 struct GNUNET_DNSPARSER_Flags dnsflags; 579 struct GNUNET_DNSPARSER_Flags dnsflags;
@@ -584,8 +581,8 @@ reply_to_dns(struct GNUNET_GNS_PendingQuery *answer, uint32_t rd_count,
584 size_t len; 581 size_t len;
585 int ret; 582 int ret;
586 char *buf; 583 char *buf;
587 struct GNUNET_DNSPARSER_Packet *packet = answer->p; 584 struct GNUNET_DNSPARSER_Packet *packet = rh->packet;
588 struct GNUNET_DNSPARSER_Record answer_records[answer->num_records]; 585 struct GNUNET_DNSPARSER_Record answer_records[rh->num_records];
589 packet->answers = answer_records; 586 packet->answers = answer_records;
590 587
591 len = sizeof(struct GNUNET_DNSPARSER_Record*); 588 len = sizeof(struct GNUNET_DNSPARSER_Record*);
@@ -593,11 +590,11 @@ reply_to_dns(struct GNUNET_GNS_PendingQuery *answer, uint32_t rd_count,
593 { 590 {
594 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 591 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
595 "Adding type %d to DNS response\n", rd[i].record_type); 592 "Adding type %d to DNS response\n", rd[i].record_type);
596 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Name: %s\n", answer->name); 593 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Name: %s\n", rh->name);
597 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "OName: %s\n", answer->original_name); 594 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "QName: %s\n", rh->query->name);
598 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Record %d/%d\n", i+1, rd_count); 595 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Record %d/%d\n", i+1, rd_count);
599 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Record len %d\n", rd[i].data_size); 596 GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Record len %d\n", rd[i].data_size);
600 answer_records[i].name = answer->original_name; //FIXME yes? 597 answer_records[i].name = rh->query->name;
601 answer_records[i].type = rd[i].record_type; 598 answer_records[i].type = rd[i].record_type;
602 answer_records[i].data.raw.data_len = rd[i].data_size; 599 answer_records[i].data.raw.data_len = rd[i].data_size;
603 answer_records[i].data.raw.data = (char*)rd[i].data; 600 answer_records[i].data.raw.data = (char*)rd[i].data;
@@ -643,7 +640,7 @@ reply_to_dns(struct GNUNET_GNS_PendingQuery *answer, uint32_t rd_count,
643 { 640 {
644 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 641 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
645 "Answering DNS request\n"); 642 "Answering DNS request\n");
646 GNUNET_DNS_request_answer(answer->request_handle, 643 GNUNET_DNS_request_answer(rh->request_handle,
647 len, 644 len,
648 buf); 645 buf);
649 //GNUNET_free(answer); 646 //GNUNET_free(answer);
@@ -655,6 +652,11 @@ reply_to_dns(struct GNUNET_GNS_PendingQuery *answer, uint32_t rd_count,
655 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 652 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
656 "Error building DNS response! (ret=%d)", ret); 653 "Error building DNS response! (ret=%d)", ret);
657 } 654 }
655
656 //FIXME into free_resolver(rh)
657 //GNUNET_DNSPARSER_free_packet(rh->packet);
658 //GNUNET_free(rh->name);
659 //GNUNET_free(rh);
658} 660}
659 661
660 662
@@ -680,13 +682,13 @@ process_authoritative_result(void* cls,
680 const struct GNUNET_NAMESTORE_RecordData *rd, 682 const struct GNUNET_NAMESTORE_RecordData *rd,
681 const struct GNUNET_CRYPTO_RsaSignature *signature) 683 const struct GNUNET_CRYPTO_RsaSignature *signature)
682{ 684{
683 struct GNUNET_GNS_PendingQuery *query; 685 struct GNUNET_GNS_ResolverHandle *query;
684 struct GNUNET_GNS_QueryRecordList *qrecord; 686 struct GNUNET_GNS_QueryRecordList *qrecord;
685 struct GNUNET_NAMESTORE_RecordData *record; 687 struct GNUNET_NAMESTORE_RecordData *record;
686 struct GNUNET_TIME_Relative remaining_time; 688 struct GNUNET_TIME_Relative remaining_time;
687 GNUNET_HashCode zone; 689 GNUNET_HashCode zone;
688 690
689 query = (struct GNUNET_GNS_PendingQuery *) cls; 691 query = (struct GNUNET_GNS_ResolverHandle *) cls;
690 GNUNET_CRYPTO_hash(key, GNUNET_CRYPTO_RSA_KEY_LENGTH, &zone); 692 GNUNET_CRYPTO_hash(key, GNUNET_CRYPTO_RSA_KEY_LENGTH, &zone);
691 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); 693 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration);
692 694
@@ -844,28 +846,28 @@ char* pop_tld(char* name)
844 * @param zone the zone we are currently resolving in 846 * @param zone the zone we are currently resolving in
845 */ 847 */
846void 848void
847resolve_name(struct GNUNET_GNS_PendingQuery *query, GNUNET_HashCode *zone) 849resolve_name(struct GNUNET_GNS_ResolverHandle *rh, GNUNET_HashCode *zone)
848{ 850{
849 if (is_canonical(query->name)) 851 if (is_canonical(rh->name))
850 { 852 {
851 //We only need to check this zone's ns 853 //We only need to check this zone's ns
852 GNUNET_NAMESTORE_lookup_record(namestore_handle, 854 GNUNET_NAMESTORE_lookup_record(namestore_handle,
853 zone, 855 zone,
854 query->name, 856 rh->name,
855 query->type, 857 rh->query->type,
856 &process_authoritative_result, 858 &process_authoritative_result,
857 query); 859 rh);
858 } 860 }
859 else 861 else
860 { 862 {
861 //We have to resolve the authoritative entity 863 //We have to resolve the authoritative entity
862 char *new_authority = pop_tld(query->name); 864 char *new_authority = pop_tld(rh->name);
863 GNUNET_NAMESTORE_lookup_record(namestore_handle, 865 GNUNET_NAMESTORE_lookup_record(namestore_handle,
864 zone, 866 zone,
865 new_authority, 867 new_authority,
866 GNUNET_GNS_RECORD_PKEY, 868 GNUNET_GNS_RECORD_PKEY,
867 &process_authority_lookup, 869 &process_authority_lookup,
868 query); 870 rh);
869 } 871 }
870} 872}
871 873
@@ -876,34 +878,37 @@ resolve_name(struct GNUNET_GNS_PendingQuery *query, GNUNET_HashCode *zone)
876 * Setup a new query and try to resolve 878 * Setup a new query and try to resolve
877 * 879 *
878 * @param rh the request handle of the DNS request from a client 880 * @param rh the request handle of the DNS request from a client
881 * @param p the DNS query packet we received
879 * @param name the name to look up 882 * @param name the name to look up
880 * @param id the id of the dns request (for the reply) 883 * @param id the id of the dns request (for the reply)
881 * @param type the record type to look for 884 * @param type the record type to look for
882 */ 885 */
883void 886void
884start_resolution(struct GNUNET_DNS_RequestHandle *rh, 887start_resolution(struct GNUNET_DNS_RequestHandle *request,
885 struct GNUNET_DNSPARSER_Packet *p, 888 struct GNUNET_DNSPARSER_Packet *p,
886 char* name, uint16_t id, uint16_t type) 889 struct GNUNET_DNSPARSER_Query *q)
887{ 890{
888 struct GNUNET_GNS_PendingQuery *query; 891 struct GNUNET_GNS_ResolverHandle *rh;
889 892
890 //FIXME remove .gnunet here from name 893 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting resolution for (%s)!\n",
891 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "This is .gnunet (%s)!\n", name); 894 q->name);
892 query = GNUNET_malloc(sizeof (struct GNUNET_GNS_PendingQuery)); 895
893 query->id = id; 896 rh = GNUNET_malloc(sizeof (struct GNUNET_GNS_ResolverHandle));
894 query->original_name = name; //Full name of original query 897 rh->packet = p;
895 query->p = p; 898 rh->query = q;
896 899
897 //FIXME do not forget to free!! 900 //FIXME do not forget to free!!
898 query->name = GNUNET_malloc(strlen(name)-strlen(gnunet_tld) + 1); 901 rh->name = GNUNET_malloc(strlen(q->name)
899 memset(query->name, 0, strlen(name)-strlen(gnunet_tld) + 1); 902 - strlen(gnunet_tld) + 1);
900 memcpy(query->name, name, strlen(name)-strlen(gnunet_tld)); 903 memset(rh->name, 0,
904 strlen(q->name)-strlen(gnunet_tld) + 1);
905 memcpy(rh->name, q->name,
906 strlen(q->name)-strlen(gnunet_tld));
901 907
902 query->type = type; 908 rh->request_handle = request;
903 query->request_handle = rh;
904 909
905 //Start resolution in our zone 910 //Start resolution in our zone
906 resolve_name(query, &zone_hash); 911 resolve_name(rh, &zone_hash);
907} 912}
908 913
909/** 914/**
@@ -922,7 +927,6 @@ handle_dns_request(void *cls,
922 const char *request) 927 const char *request)
923{ 928{
924 struct GNUNET_DNSPARSER_Packet *p; 929 struct GNUNET_DNSPARSER_Packet *p;
925 int i;
926 char *tldoffset; 930 char *tldoffset;
927 931
928 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Hijacked a DNS request...processing\n"); 932 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Hijacked a DNS request...processing\n");
@@ -948,27 +952,40 @@ handle_dns_request(void *cls,
948 * The way it is implemented here now is buggy and will lead to erratic 952 * The way it is implemented here now is buggy and will lead to erratic
949 * behaviour (if multiple queries are present). 953 * behaviour (if multiple queries are present).
950 */ 954 */
951 for (i=0;i<p->num_queries;i++) 955 if (p->num_queries == 0)
952 { 956 {
953 tldoffset = p->queries[i].name + strlen(p->queries[i].name); 957 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
958 "No Queries in DNS packet... forwarding\n");
959 GNUNET_DNS_request_forward (rh);
960 }
954 961
955 while ((*tldoffset) != '.') 962 if (p->num_queries > 1)
956 tldoffset--; 963 {
957 964 //Note: We could also look for .gnunet
958 if (0 == strcmp(tldoffset, gnunet_tld)) 965 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
959 { 966 ">1 queriy in DNS packet... odd. We only process #1\n");
960 start_resolution(rh, p, p->queries[i].name, p->id, p->queries[i].type);
961 }
962 else
963 {
964 /**
965 * This request does not concern us. Forward to real DNS.
966 */
967 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
968 "Request for %s is forwarded to DNS\n", p->queries[i].name);
969 GNUNET_DNS_request_forward (rh);
970 }
971 } 967 }
968
969
970 tldoffset = p->queries[0].name + strlen(p->queries[0].name);
971
972 while ((*tldoffset) != '.')
973 tldoffset--;
974
975 if (0 == strcmp(tldoffset, gnunet_tld))
976 {
977 start_resolution(rh, p, p->queries);
978 }
979 else
980 {
981 /**
982 * This request does not concern us. Forward to real DNS.
983 */
984 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
985 "Request for %s is forwarded to DNS\n", p->queries[0].name);
986 GNUNET_DNS_request_forward (rh);
987 }
988
972} 989}
973 990
974/** 991/**