diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-07 22:35:30 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-03-07 22:35:30 +0000 |
commit | 4509b5f0ab45bb094edfa977e113b24613421f43 (patch) | |
tree | a80d0b26bb8ff291011b9887957f440d7943eac6 /src/gns/gnunet-service-gns.c | |
parent | 948fa9a6942b2a4a10a8916f36bcd506cccb6aa2 (diff) | |
download | gnunet-4509b5f0ab45bb094edfa977e113b24613421f43.tar.gz gnunet-4509b5f0ab45bb094edfa977e113b24613421f43.zip |
-more generic record resolution, prepare for api lookup
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 142 |
1 files changed, 105 insertions, 37 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 5bd64c484..3cff47b3c 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -87,15 +87,7 @@ struct GNUNET_GNS_ResolverHandle | |||
87 | /* The name to resolve */ | 87 | /* The name to resolve */ |
88 | char *name; | 88 | char *name; |
89 | 89 | ||
90 | /* the request handle to reply to */ | ||
91 | struct GNUNET_DNS_RequestHandle *request_handle; | ||
92 | 90 | ||
93 | /* the dns parser packet received */ | ||
94 | struct GNUNET_DNSPARSER_Packet *packet; | ||
95 | |||
96 | /* the query parsed from the packet */ | ||
97 | |||
98 | struct GNUNET_DNSPARSER_Query *query; | ||
99 | 91 | ||
100 | /* has this query been answered? how many matches */ | 92 | /* has this query been answered? how many matches */ |
101 | int answered; | 93 | int answered; |
@@ -129,6 +121,25 @@ struct GNUNET_GNS_ResolverHandle | |||
129 | 121 | ||
130 | }; | 122 | }; |
131 | 123 | ||
124 | /** | ||
125 | * Handle to a record lookup | ||
126 | */ | ||
127 | struct RecordLookupHandle | ||
128 | { | ||
129 | /* the record type to look up */ | ||
130 | enum GNUNET_GNS_RecordType record_type; | ||
131 | |||
132 | /* the name to look up */ | ||
133 | char *name; | ||
134 | |||
135 | /* Method to call on resolution result */ | ||
136 | ResolutionResultProcessor proc; | ||
137 | |||
138 | /* closure to pass to proc */ | ||
139 | void* proc_cls; | ||
140 | |||
141 | }; | ||
142 | |||
132 | struct ClientShortenHandle | 143 | struct ClientShortenHandle |
133 | { | 144 | { |
134 | struct GNUNET_SERVER_Client *client; | 145 | struct GNUNET_SERVER_Client *client; |
@@ -138,6 +149,27 @@ struct ClientShortenHandle | |||
138 | uint32_t offset; | 149 | uint32_t offset; |
139 | }; | 150 | }; |
140 | 151 | ||
152 | struct ClientLookupHandle | ||
153 | { | ||
154 | struct GNUNET_SERVER_Client *client; | ||
155 | uint64_t unique_id; | ||
156 | GNUNET_HashCode key; | ||
157 | char* name; //Needed? | ||
158 | }; | ||
159 | |||
160 | struct InterceptLookupHandle | ||
161 | { | ||
162 | /* the request handle to reply to */ | ||
163 | struct GNUNET_DNS_RequestHandle *request_handle; | ||
164 | |||
165 | /* the dns parser packet received */ | ||
166 | struct GNUNET_DNSPARSER_Packet *packet; | ||
167 | |||
168 | /* the query parsed from the packet */ | ||
169 | |||
170 | struct GNUNET_DNSPARSER_Query *query; | ||
171 | }; | ||
172 | |||
141 | /** | 173 | /** |
142 | * Our handle to the DNS handler library | 174 | * Our handle to the DNS handler library |
143 | */ | 175 | */ |
@@ -208,7 +240,8 @@ reply_to_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count, | |||
208 | size_t len; | 240 | size_t len; |
209 | int ret; | 241 | int ret; |
210 | char *buf; | 242 | char *buf; |
211 | struct GNUNET_DNSPARSER_Packet *packet = rh->packet; | 243 | struct InterceptLookupHandle* ilh = (struct InterceptLookupHandle*)cls; |
244 | struct GNUNET_DNSPARSER_Packet *packet = ilh->packet; | ||
212 | struct GNUNET_DNSPARSER_Record answer_records[rh->answered]; | 245 | struct GNUNET_DNSPARSER_Record answer_records[rh->answered]; |
213 | struct GNUNET_DNSPARSER_Record additional_records[rd_count-(rh->answered)]; | 246 | struct GNUNET_DNSPARSER_Record additional_records[rd_count-(rh->answered)]; |
214 | packet->answers = answer_records; | 247 | packet->answers = answer_records; |
@@ -225,13 +258,13 @@ reply_to_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count, | |||
225 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 258 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
226 | "Adding type %d to DNS response\n", rd[i].record_type); | 259 | "Adding type %d to DNS response\n", rd[i].record_type); |
227 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Name: %s\n", rh->name); | 260 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Name: %s\n", rh->name); |
228 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "QName: %s\n", rh->query->name); | 261 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "QName: %s\n", ilh->query->name); |
229 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Record %d/%d\n", i+1, rd_count); | 262 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Record %d/%d\n", i+1, rd_count); |
230 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Record len %d\n", rd[i].data_size); | 263 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Record len %d\n", rd[i].data_size); |
231 | 264 | ||
232 | if (rd[i].record_type == rh->query->type) | 265 | if (rd[i].record_type == ilh->query->type) |
233 | { | 266 | { |
234 | answer_records[i].name = rh->query->name; | 267 | answer_records[i].name = ilh->query->name; |
235 | answer_records[i].type = rd[i].record_type; | 268 | answer_records[i].type = rd[i].record_type; |
236 | answer_records[i].data.raw.data_len = rd[i].data_size; | 269 | answer_records[i].data.raw.data_len = rd[i].data_size; |
237 | answer_records[i].data.raw.data = (char*)rd[i].data; | 270 | answer_records[i].data.raw.data = (char*)rd[i].data; |
@@ -240,7 +273,7 @@ reply_to_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count, | |||
240 | } | 273 | } |
241 | else | 274 | else |
242 | { | 275 | { |
243 | additional_records[i].name = rh->query->name; | 276 | additional_records[i].name = ilh->query->name; |
244 | additional_records[i].type = rd[i].record_type; | 277 | additional_records[i].type = rd[i].record_type; |
245 | additional_records[i].data.raw.data_len = rd[i].data_size; | 278 | additional_records[i].data.raw.data_len = rd[i].data_size; |
246 | additional_records[i].data.raw.data = (char*)rd[i].data; | 279 | additional_records[i].data.raw.data = (char*)rd[i].data; |
@@ -280,7 +313,7 @@ reply_to_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count, | |||
280 | { | 313 | { |
281 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 314 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
282 | "Answering DNS request\n"); | 315 | "Answering DNS request\n"); |
283 | GNUNET_DNS_request_answer(rh->request_handle, | 316 | GNUNET_DNS_request_answer(ilh->request_handle, |
284 | len, | 317 | len, |
285 | buf); | 318 | buf); |
286 | //GNUNET_free(answer); | 319 | //GNUNET_free(answer); |
@@ -292,8 +325,11 @@ reply_to_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count, | |||
292 | "Error building DNS response! (ret=%d)", ret); | 325 | "Error building DNS response! (ret=%d)", ret); |
293 | } | 326 | } |
294 | 327 | ||
328 | //FIXME free more! | ||
295 | GNUNET_free(rh->name); | 329 | GNUNET_free(rh->name); |
330 | GNUNET_free(rh->proc_cls); | ||
296 | GNUNET_free(rh); | 331 | GNUNET_free(rh); |
332 | GNUNET_free(ilh); | ||
297 | } | 333 | } |
298 | 334 | ||
299 | 335 | ||
@@ -355,8 +391,8 @@ dht_lookup_timeout(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
355 | struct GNUNET_GNS_ResolverHandle *rh = cls; | 391 | struct GNUNET_GNS_ResolverHandle *rh = cls; |
356 | 392 | ||
357 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 393 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
358 | "dht lookup for query %s (type=%d) timed out.\n", | 394 | "dht lookup for query %s timed out.\n", |
359 | rh->name, rh->query->type); | 395 | rh->name); |
360 | 396 | ||
361 | GNUNET_DHT_get_stop (rh->get_handle); | 397 | GNUNET_DHT_get_stop (rh->get_handle); |
362 | rh->proc(rh->proc_cls, rh, 0, NULL); | 398 | rh->proc(rh->proc_cls, rh, 0, NULL); |
@@ -391,6 +427,7 @@ process_record_dht_result(void* cls, | |||
391 | size_t size, const void *data) | 427 | size_t size, const void *data) |
392 | { | 428 | { |
393 | struct GNUNET_GNS_ResolverHandle *rh; | 429 | struct GNUNET_GNS_ResolverHandle *rh; |
430 | struct RecordLookupHandle *rlh; | ||
394 | struct GNSNameRecordBlock *nrb; | 431 | struct GNSNameRecordBlock *nrb; |
395 | uint32_t num_records; | 432 | uint32_t num_records; |
396 | char* name = NULL; | 433 | char* name = NULL; |
@@ -407,6 +444,7 @@ process_record_dht_result(void* cls, | |||
407 | //FIXME maybe check expiration here, check block type | 444 | //FIXME maybe check expiration here, check block type |
408 | 445 | ||
409 | rh = (struct GNUNET_GNS_ResolverHandle *)cls; | 446 | rh = (struct GNUNET_GNS_ResolverHandle *)cls; |
447 | rlh = (struct RecordLookupHandle *) rh->proc_cls; | ||
410 | nrb = (struct GNSNameRecordBlock*)data; | 448 | nrb = (struct GNSNameRecordBlock*)data; |
411 | 449 | ||
412 | /* stop lookup and timeout task */ | 450 | /* stop lookup and timeout task */ |
@@ -436,15 +474,15 @@ process_record_dht_result(void* cls, | |||
436 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 474 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
437 | "Got name: %s (wanted %s)\n", name, rh->name); | 475 | "Got name: %s (wanted %s)\n", name, rh->name); |
438 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 476 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
439 | "Got type: %d (wanted %d)\n", | 477 | "Got type: %d\n", |
440 | rd[i].record_type, rh->query->type); | 478 | rd[i].record_type); |
441 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 479 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
442 | "Got data length: %d\n", rd[i].data_size); | 480 | "Got data length: %d\n", rd[i].data_size); |
443 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 481 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
444 | "Got flag %d\n", rd[i].flags); | 482 | "Got flag %d\n", rd[i].flags); |
445 | 483 | ||
446 | if ((strcmp(name, rh->name) == 0) && | 484 | if ((strcmp(name, rh->name) == 0) && |
447 | (rd[i].record_type == rh->query->type)) | 485 | (rd[i].record_type == rlh->record_type)) |
448 | { | 486 | { |
449 | rh->answered++; | 487 | rh->answered++; |
450 | } | 488 | } |
@@ -493,6 +531,7 @@ resolve_record_from_dht(struct GNUNET_GNS_ResolverHandle *rh) | |||
493 | GNUNET_HashCode name_hash; | 531 | GNUNET_HashCode name_hash; |
494 | GNUNET_HashCode lookup_key; | 532 | GNUNET_HashCode lookup_key; |
495 | struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; | 533 | struct GNUNET_CRYPTO_HashAsciiEncoded lookup_key_string; |
534 | struct RecordLookupHandle *rlh = (struct RecordLookupHandle *)rh->proc_cls; | ||
496 | 535 | ||
497 | GNUNET_CRYPTO_hash(rh->name, strlen(rh->name), &name_hash); | 536 | GNUNET_CRYPTO_hash(rh->name, strlen(rh->name), &name_hash); |
498 | GNUNET_CRYPTO_hash_xor(&name_hash, &rh->authority, &lookup_key); | 537 | GNUNET_CRYPTO_hash_xor(&name_hash, &rh->authority, &lookup_key); |
@@ -505,7 +544,7 @@ resolve_record_from_dht(struct GNUNET_GNS_ResolverHandle *rh) | |||
505 | rh->dht_timeout_task = GNUNET_SCHEDULER_add_delayed(DHT_LOOKUP_TIMEOUT, | 544 | rh->dht_timeout_task = GNUNET_SCHEDULER_add_delayed(DHT_LOOKUP_TIMEOUT, |
506 | &dht_lookup_timeout, rh); | 545 | &dht_lookup_timeout, rh); |
507 | 546 | ||
508 | xquery = htonl(rh->query->type); | 547 | xquery = htonl(rlh->record_type); |
509 | rh->get_handle = GNUNET_DHT_get_start(dht_handle, | 548 | rh->get_handle = GNUNET_DHT_get_start(dht_handle, |
510 | DHT_OPERATION_TIMEOUT, | 549 | DHT_OPERATION_TIMEOUT, |
511 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD, | 550 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD, |
@@ -541,10 +580,12 @@ process_record_lookup_ns(void* cls, | |||
541 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 580 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
542 | { | 581 | { |
543 | struct GNUNET_GNS_ResolverHandle *rh; | 582 | struct GNUNET_GNS_ResolverHandle *rh; |
583 | struct RecordLookupHandle *rlh; | ||
544 | struct GNUNET_TIME_Relative remaining_time; | 584 | struct GNUNET_TIME_Relative remaining_time; |
545 | GNUNET_HashCode zone; | 585 | GNUNET_HashCode zone; |
546 | 586 | ||
547 | rh = (struct GNUNET_GNS_ResolverHandle *) cls; | 587 | rh = (struct GNUNET_GNS_ResolverHandle *) cls; |
588 | rlh = (struct RecordLookupHandle *)rh->proc_cls; | ||
548 | GNUNET_CRYPTO_hash(key, | 589 | GNUNET_CRYPTO_hash(key, |
549 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 590 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
550 | &zone); | 591 | &zone); |
@@ -591,7 +632,7 @@ process_record_lookup_ns(void* cls, | |||
591 | for (i=0; i<rd_count;i++) | 632 | for (i=0; i<rd_count;i++) |
592 | { | 633 | { |
593 | 634 | ||
594 | if (rd[i].record_type != rh->query->type) | 635 | if (rd[i].record_type != rlh->record_type) |
595 | continue; | 636 | continue; |
596 | 637 | ||
597 | if ((GNUNET_TIME_absolute_get_remaining (rd[i].expiration)).rel_value | 638 | if ((GNUNET_TIME_absolute_get_remaining (rd[i].expiration)).rel_value |
@@ -632,7 +673,7 @@ process_record_lookup_ns(void* cls, | |||
632 | static void | 673 | static void |
633 | resolve_record_from_ns(struct GNUNET_GNS_ResolverHandle *rh) | 674 | resolve_record_from_ns(struct GNUNET_GNS_ResolverHandle *rh) |
634 | { | 675 | { |
635 | 676 | struct RecordLookupHandle *rlh = (struct RecordLookupHandle *)rh->proc_cls; | |
636 | /** | 677 | /** |
637 | * Try to resolve this record in our namestore. | 678 | * Try to resolve this record in our namestore. |
638 | * The name to resolve is now in rh->authority_name | 679 | * The name to resolve is now in rh->authority_name |
@@ -642,7 +683,7 @@ resolve_record_from_ns(struct GNUNET_GNS_ResolverHandle *rh) | |||
642 | GNUNET_NAMESTORE_lookup_record(namestore_handle, | 683 | GNUNET_NAMESTORE_lookup_record(namestore_handle, |
643 | &rh->authority, | 684 | &rh->authority, |
644 | rh->name, | 685 | rh->name, |
645 | rh->query->type, | 686 | rlh->record_type, |
646 | &process_record_lookup_ns, | 687 | &process_record_lookup_ns, |
647 | rh); | 688 | rh); |
648 | 689 | ||
@@ -662,8 +703,8 @@ dht_authority_lookup_timeout(void *cls, | |||
662 | struct GNUNET_GNS_ResolverHandle *rh = cls; | 703 | struct GNUNET_GNS_ResolverHandle *rh = cls; |
663 | 704 | ||
664 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 705 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
665 | "dht lookup for query %s (type=%d) timed out.\n", | 706 | "dht lookup for query %s timed out.\n", |
666 | rh->name, rh->query->type); | 707 | rh->name); |
667 | 708 | ||
668 | GNUNET_DHT_get_stop (rh->get_handle); | 709 | GNUNET_DHT_get_stop (rh->get_handle); |
669 | if (strcmp(rh->name, "") == 0) | 710 | if (strcmp(rh->name, "") == 0) |
@@ -832,20 +873,24 @@ process_record_result_dht(void* cls, struct GNUNET_GNS_ResolverHandle *rh, | |||
832 | unsigned int rd_count, | 873 | unsigned int rd_count, |
833 | const struct GNUNET_NAMESTORE_RecordData *rd) | 874 | const struct GNUNET_NAMESTORE_RecordData *rd) |
834 | { | 875 | { |
876 | struct RecordLookupHandle* rlh; | ||
877 | rlh = (struct RecordLookupHandle*)cls; | ||
835 | if (rd_count == 0) | 878 | if (rd_count == 0) |
836 | { | 879 | { |
837 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 880 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
838 | "No records for %s found in DHT. Aborting\n", | 881 | "No records for %s found in DHT. Aborting\n", |
839 | rh->name); | 882 | rh->name); |
840 | /* give up, cannot resolve */ | 883 | /* give up, cannot resolve */ |
841 | reply_to_dns(NULL, rh, 0, NULL); | 884 | rlh->proc(rlh->proc_cls, rh, 0, NULL); |
885 | //reply_to_dns(NULL, rh, 0, NULL); | ||
842 | return; | 886 | return; |
843 | } | 887 | } |
844 | 888 | ||
845 | /* results found yay */ | 889 | /* results found yay */ |
846 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 890 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
847 | "Record resolved from namestore!"); | 891 | "Record resolved from namestore!"); |
848 | reply_to_dns(NULL, rh, rd_count, rd); | 892 | rlh->proc(rlh->proc_cls, rh, rd_count, rd); |
893 | //reply_to_dns(NULL, rh, rd_count, rd); | ||
849 | 894 | ||
850 | } | 895 | } |
851 | 896 | ||
@@ -863,6 +908,8 @@ process_record_result_ns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, | |||
863 | unsigned int rd_count, | 908 | unsigned int rd_count, |
864 | const struct GNUNET_NAMESTORE_RecordData *rd) | 909 | const struct GNUNET_NAMESTORE_RecordData *rd) |
865 | { | 910 | { |
911 | struct RecordLookupHandle* rlh; | ||
912 | rlh = (struct RecordLookupHandle*) cls; | ||
866 | if (rd_count == 0) | 913 | if (rd_count == 0) |
867 | { | 914 | { |
868 | /* ns entry expired. try dht */ | 915 | /* ns entry expired. try dht */ |
@@ -873,14 +920,16 @@ process_record_result_ns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, | |||
873 | return; | 920 | return; |
874 | } | 921 | } |
875 | /* give up, cannot resolve */ | 922 | /* give up, cannot resolve */ |
876 | reply_to_dns(NULL, rh, 0, NULL); | 923 | rlh->proc(rlh->proc_cls, rh, 0, NULL); |
924 | //reply_to_dns(NULL, rh, 0, NULL); | ||
877 | return; | 925 | return; |
878 | } | 926 | } |
879 | 927 | ||
880 | /* results found yay */ | 928 | /* results found yay */ |
881 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 929 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
882 | "Record resolved from namestore!"); | 930 | "Record resolved from namestore!"); |
883 | reply_to_dns(NULL, rh, rd_count, rd); | 931 | rlh->proc(rlh->proc_cls, rh, rd_count, rd); |
932 | //reply_to_dns(NULL, rh, rd_count, rd); | ||
884 | 933 | ||
885 | } | 934 | } |
886 | 935 | ||
@@ -955,6 +1004,9 @@ process_dht_delegation_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, | |||
955 | unsigned int rd_count, | 1004 | unsigned int rd_count, |
956 | const struct GNUNET_NAMESTORE_RecordData *rd) | 1005 | const struct GNUNET_NAMESTORE_RecordData *rd) |
957 | { | 1006 | { |
1007 | struct RecordLookupHandle* rlh; | ||
1008 | rlh = (struct RecordLookupHandle*) cls; | ||
1009 | |||
958 | if (strcmp(rh->name, "") == 0) | 1010 | if (strcmp(rh->name, "") == 0) |
959 | { | 1011 | { |
960 | /* We resolved full name for delegation. resolving record */ | 1012 | /* We resolved full name for delegation. resolving record */ |
@@ -980,7 +1032,8 @@ process_dht_delegation_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, | |||
980 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1032 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
981 | "Cannot fully resolve delegation for %s via DHT!\n", | 1033 | "Cannot fully resolve delegation for %s via DHT!\n", |
982 | rh->name); | 1034 | rh->name); |
983 | reply_to_dns(NULL, rh, 0, NULL); | 1035 | rlh->proc(rlh->proc_cls, rh, 0, NULL); |
1036 | //reply_to_dns(NULL, rh, 0, NULL); | ||
984 | } | 1037 | } |
985 | 1038 | ||
986 | 1039 | ||
@@ -1036,6 +1089,9 @@ process_ns_delegation_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, | |||
1036 | unsigned int rd_count, | 1089 | unsigned int rd_count, |
1037 | const struct GNUNET_NAMESTORE_RecordData *rd) | 1090 | const struct GNUNET_NAMESTORE_RecordData *rd) |
1038 | { | 1091 | { |
1092 | struct RecordLookupHandle* rlh; | ||
1093 | rlh = (struct RecordLookupHandle*) cls; | ||
1094 | |||
1039 | if (strcmp(rh->name, "") == 0) | 1095 | if (strcmp(rh->name, "") == 0) |
1040 | { | 1096 | { |
1041 | /* We resolved full name for delegation. resolving record */ | 1097 | /* We resolved full name for delegation. resolving record */ |
@@ -1065,7 +1121,8 @@ process_ns_delegation_dns(void* cls, struct GNUNET_GNS_ResolverHandle *rh, | |||
1065 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1121 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
1066 | "Cannot fully resolve delegation for %s!\n", | 1122 | "Cannot fully resolve delegation for %s!\n", |
1067 | rh->name); | 1123 | rh->name); |
1068 | reply_to_dns(NULL, rh, 0, NULL); | 1124 | rlh->proc(rlh->proc_cls, rh, 0, NULL); |
1125 | //reply_to_dns(NULL, rh, 0, NULL); | ||
1069 | } | 1126 | } |
1070 | return; | 1127 | return; |
1071 | } | 1128 | } |
@@ -1264,17 +1321,30 @@ start_resolution_from_dns(struct GNUNET_DNS_RequestHandle *request, | |||
1264 | struct GNUNET_DNSPARSER_Query *q) | 1321 | struct GNUNET_DNSPARSER_Query *q) |
1265 | { | 1322 | { |
1266 | struct GNUNET_GNS_ResolverHandle *rh; | 1323 | struct GNUNET_GNS_ResolverHandle *rh; |
1324 | struct RecordLookupHandle* rlh; | ||
1325 | struct InterceptLookupHandle* ilh; | ||
1267 | 1326 | ||
1268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1327 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1269 | "Starting resolution for %s (type=%d)!\n", | 1328 | "Starting resolution for %s (type=%d)!\n", |
1270 | q->name, q->type); | 1329 | q->name, q->type); |
1271 | 1330 | ||
1272 | rh = GNUNET_malloc(sizeof (struct GNUNET_GNS_ResolverHandle)); | 1331 | rh = GNUNET_malloc(sizeof (struct GNUNET_GNS_ResolverHandle)); |
1273 | rh->packet = p; | 1332 | rlh = GNUNET_malloc(sizeof(struct RecordLookupHandle)); |
1274 | rh->query = q; | 1333 | ilh = GNUNET_malloc(sizeof(struct InterceptLookupHandle)); |
1275 | rh->authority = zone_hash; | 1334 | ilh->packet = p; |
1335 | ilh->query = q; | ||
1336 | ilh->request_handle = request; | ||
1276 | 1337 | ||
1338 | rh->authority = zone_hash; | ||
1339 | |||
1340 | rlh->record_type = q->type; | ||
1341 | rlh->name = q->name; | ||
1342 | rlh->proc = &reply_to_dns; | ||
1343 | rlh->proc_cls = ilh; | ||
1344 | |||
1345 | rh->proc_cls = rlh; | ||
1277 | 1346 | ||
1347 | rh->authority = zone_hash; | ||
1278 | rh->name = GNUNET_malloc(strlen(q->name) | 1348 | rh->name = GNUNET_malloc(strlen(q->name) |
1279 | - strlen(gnunet_tld) + 1); | 1349 | - strlen(gnunet_tld) + 1); |
1280 | memset(rh->name, 0, | 1350 | memset(rh->name, 0, |
@@ -1283,9 +1353,7 @@ start_resolution_from_dns(struct GNUNET_DNS_RequestHandle *request, | |||
1283 | strlen(q->name)-strlen(gnunet_tld)); | 1353 | strlen(q->name)-strlen(gnunet_tld)); |
1284 | 1354 | ||
1285 | rh->authority_name = GNUNET_malloc(sizeof(char)*MAX_DNS_LABEL_LENGTH); | 1355 | rh->authority_name = GNUNET_malloc(sizeof(char)*MAX_DNS_LABEL_LENGTH); |
1286 | 1356 | ||
1287 | rh->request_handle = request; | ||
1288 | |||
1289 | rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain)); | 1357 | rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain)); |
1290 | rh->authority_chain_tail = rh->authority_chain_head; | 1358 | rh->authority_chain_tail = rh->authority_chain_head; |
1291 | rh->authority_chain_head->zone = zone_hash; | 1359 | rh->authority_chain_head->zone = zone_hash; |