diff options
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 0cf0fca56..8fcd75e7c 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -98,7 +98,7 @@ struct ClientLookupHandle | |||
98 | struct GNS_ResolverHandle *lookup; | 98 | struct GNS_ResolverHandle *lookup; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * request id | 101 | * request id |
102 | */ | 102 | */ |
103 | uint32_t request_id; | 103 | uint32_t request_id; |
104 | 104 | ||
@@ -199,7 +199,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
199 | 199 | ||
200 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 200 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
201 | "Shutting down!\n"); | 201 | "Shutting down!\n"); |
202 | GNUNET_SERVER_notification_context_destroy (nc); | 202 | GNUNET_SERVER_notification_context_destroy (nc); |
203 | while (NULL != (clh = clh_head)) | 203 | while (NULL != (clh = clh_head)) |
204 | { | 204 | { |
205 | GNUNET_SERVER_client_set_user_context (clh->client, NULL); | 205 | GNUNET_SERVER_client_set_user_context (clh->client, NULL); |
@@ -266,7 +266,7 @@ publish_zone_dht_next (void *cls, | |||
266 | * @param tc task context | 266 | * @param tc task context |
267 | */ | 267 | */ |
268 | static void | 268 | static void |
269 | publish_zone_dht_start (void *cls, | 269 | publish_zone_dht_start (void *cls, |
270 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 270 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
271 | 271 | ||
272 | 272 | ||
@@ -280,10 +280,10 @@ static void | |||
280 | dht_put_continuation (void *cls, | 280 | dht_put_continuation (void *cls, |
281 | int success) | 281 | int success) |
282 | { | 282 | { |
283 | struct GNUNET_TIME_Relative next_put_interval; | 283 | struct GNUNET_TIME_Relative next_put_interval; |
284 | 284 | ||
285 | active_put = NULL; | 285 | active_put = NULL; |
286 | num_public_records++; | 286 | num_public_records++; |
287 | if ( (num_public_records > last_num_public_records) && | 287 | if ( (num_public_records > last_num_public_records) && |
288 | (GNUNET_NO == first_zone_iteration) ) | 288 | (GNUNET_NO == first_zone_iteration) ) |
289 | { | 289 | { |
@@ -300,7 +300,7 @@ dht_put_continuation (void *cls, | |||
300 | GNUNET_STATISTICS_set (statistics, | 300 | GNUNET_STATISTICS_set (statistics, |
301 | "Current zone iteration interval (ms)", | 301 | "Current zone iteration interval (ms)", |
302 | next_put_interval.rel_value_us / 1000LL, | 302 | next_put_interval.rel_value_us / 1000LL, |
303 | GNUNET_NO); | 303 | GNUNET_NO); |
304 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval, | 304 | zone_publish_task = GNUNET_SCHEDULER_add_delayed (next_put_interval, |
305 | &publish_zone_dht_next, | 305 | &publish_zone_dht_next, |
306 | NULL); | 306 | NULL); |
@@ -322,10 +322,10 @@ put_gns_record (void *cls, | |||
322 | const char *name, | 322 | const char *name, |
323 | unsigned int rd_count, | 323 | unsigned int rd_count, |
324 | const struct GNUNET_NAMESTORE_RecordData *rd) | 324 | const struct GNUNET_NAMESTORE_RecordData *rd) |
325 | { | 325 | { |
326 | struct GNUNET_NAMESTORE_Block *block; | 326 | struct GNUNET_NAMESTORE_Block *block; |
327 | struct GNUNET_HashCode query; | 327 | struct GNUNET_HashCode query; |
328 | struct GNUNET_TIME_Absolute expire; | 328 | struct GNUNET_TIME_Absolute expire; |
329 | struct GNUNET_TIME_Absolute now; | 329 | struct GNUNET_TIME_Absolute now; |
330 | size_t block_size; | 330 | size_t block_size; |
331 | struct GNUNET_NAMESTORE_RecordData rd_public[rd_count]; | 331 | struct GNUNET_NAMESTORE_RecordData rd_public[rd_count]; |
@@ -365,8 +365,8 @@ put_gns_record (void *cls, | |||
365 | put_interval.rel_value_us / 1000LL, | 365 | put_interval.rel_value_us / 1000LL, |
366 | GNUNET_NO); | 366 | GNUNET_NO); |
367 | GNUNET_STATISTICS_update (statistics, | 367 | GNUNET_STATISTICS_update (statistics, |
368 | "Number of zone iterations", | 368 | "Number of zone iterations", |
369 | 1, | 369 | 1, |
370 | GNUNET_NO); | 370 | GNUNET_NO); |
371 | GNUNET_STATISTICS_set (statistics, | 371 | GNUNET_STATISTICS_set (statistics, |
372 | "Number of public records in DHT", | 372 | "Number of public records in DHT", |
@@ -377,7 +377,7 @@ put_gns_record (void *cls, | |||
377 | &publish_zone_dht_start, | 377 | &publish_zone_dht_start, |
378 | NULL); | 378 | NULL); |
379 | else | 379 | else |
380 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, | 380 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, |
381 | NULL); | 381 | NULL); |
382 | return; | 382 | return; |
383 | } | 383 | } |
@@ -413,8 +413,8 @@ put_gns_record (void *cls, | |||
413 | name, | 413 | name, |
414 | rd_public, | 414 | rd_public, |
415 | rd_public_count); | 415 | rd_public_count); |
416 | block_size = ntohl (block->purpose.size) | 416 | block_size = ntohl (block->purpose.size) |
417 | + sizeof (struct GNUNET_CRYPTO_EccSignature) | 417 | + sizeof (struct GNUNET_CRYPTO_EccSignature) |
418 | + sizeof (struct GNUNET_CRYPTO_EccPublicSignKey); | 418 | + sizeof (struct GNUNET_CRYPTO_EccPublicSignKey); |
419 | GNUNET_NAMESTORE_query_from_private_key (key, | 419 | GNUNET_NAMESTORE_query_from_private_key (key, |
420 | name, | 420 | name, |
@@ -429,7 +429,7 @@ put_gns_record (void *cls, | |||
429 | expire, | 429 | expire, |
430 | DHT_OPERATION_TIMEOUT, | 430 | DHT_OPERATION_TIMEOUT, |
431 | &dht_put_continuation, | 431 | &dht_put_continuation, |
432 | NULL); | 432 | NULL); |
433 | if (NULL == active_put) | 433 | if (NULL == active_put) |
434 | { | 434 | { |
435 | GNUNET_break (0); | 435 | GNUNET_break (0); |
@@ -446,13 +446,13 @@ put_gns_record (void *cls, | |||
446 | * @param tc task context | 446 | * @param tc task context |
447 | */ | 447 | */ |
448 | static void | 448 | static void |
449 | publish_zone_dht_start (void *cls, | 449 | publish_zone_dht_start (void *cls, |
450 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 450 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
451 | { | 451 | { |
452 | zone_publish_task = GNUNET_SCHEDULER_NO_TASK; | 452 | zone_publish_task = GNUNET_SCHEDULER_NO_TASK; |
453 | 453 | ||
454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 454 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
455 | "Scheduling DHT zone update!\n"); | 455 | "Scheduling DHT zone update!\n"); |
456 | /* start counting again */ | 456 | /* start counting again */ |
457 | num_public_records = 0; | 457 | num_public_records = 0; |
458 | namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, | 458 | namestore_iter = GNUNET_NAMESTORE_zone_iteration_start (namestore_handle, |
@@ -480,21 +480,21 @@ send_lookup_response (void* cls, | |||
480 | struct ClientLookupHandle *clh = cls; | 480 | struct ClientLookupHandle *clh = cls; |
481 | struct GNUNET_GNS_ClientLookupResultMessage *rmsg; | 481 | struct GNUNET_GNS_ClientLookupResultMessage *rmsg; |
482 | size_t len; | 482 | size_t len; |
483 | 483 | ||
484 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 484 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
485 | "Sending `%s' message with %d results\n", | 485 | "Sending `%s' message with %d results\n", |
486 | "LOOKUP_RESULT", | 486 | "LOOKUP_RESULT", |
487 | rd_count); | 487 | rd_count); |
488 | 488 | ||
489 | len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); | 489 | len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); |
490 | rmsg = GNUNET_malloc (len + sizeof (struct GNUNET_GNS_ClientLookupResultMessage)); | 490 | rmsg = GNUNET_malloc (len + sizeof (struct GNUNET_GNS_ClientLookupResultMessage)); |
491 | rmsg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT); | 491 | rmsg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT); |
492 | rmsg->header.size = htons (len + sizeof(struct GNUNET_GNS_ClientLookupResultMessage)); | 492 | rmsg->header.size = htons (len + sizeof(struct GNUNET_GNS_ClientLookupResultMessage)); |
493 | rmsg->id = clh->request_id; | 493 | rmsg->id = clh->request_id; |
494 | rmsg->rd_count = htonl (rd_count); | 494 | rmsg->rd_count = htonl (rd_count); |
495 | GNUNET_NAMESTORE_records_serialize (rd_count, rd, len, | 495 | GNUNET_NAMESTORE_records_serialize (rd_count, rd, len, |
496 | (char*) &rmsg[1]); | 496 | (char*) &rmsg[1]); |
497 | GNUNET_SERVER_notification_context_unicast (nc, | 497 | GNUNET_SERVER_notification_context_unicast (nc, |
498 | clh->client, | 498 | clh->client, |
499 | &rmsg->header, | 499 | &rmsg->header, |
500 | GNUNET_NO); | 500 | GNUNET_NO); |
@@ -503,11 +503,11 @@ send_lookup_response (void* cls, | |||
503 | GNUNET_SERVER_client_set_user_context (clh->client, NULL); | 503 | GNUNET_SERVER_client_set_user_context (clh->client, NULL); |
504 | GNUNET_free (clh); | 504 | GNUNET_free (clh); |
505 | GNUNET_STATISTICS_update (statistics, | 505 | GNUNET_STATISTICS_update (statistics, |
506 | "Completed lookups", 1, | 506 | "Completed lookups", 1, |
507 | GNUNET_NO); | 507 | GNUNET_NO); |
508 | GNUNET_STATISTICS_update (statistics, | 508 | GNUNET_STATISTICS_update (statistics, |
509 | "Records resolved", | 509 | "Records resolved", |
510 | rd_count, | 510 | rd_count, |
511 | GNUNET_NO); | 511 | GNUNET_NO); |
512 | } | 512 | } |
513 | 513 | ||
@@ -531,9 +531,9 @@ handle_lookup (void *cls, | |||
531 | const struct GNUNET_CRYPTO_EccPrivateKey *key; | 531 | const struct GNUNET_CRYPTO_EccPrivateKey *key; |
532 | uint16_t msg_size; | 532 | uint16_t msg_size; |
533 | const struct GNUNET_GNS_ClientLookupMessage *sh_msg; | 533 | const struct GNUNET_GNS_ClientLookupMessage *sh_msg; |
534 | 534 | ||
535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 535 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
536 | "Received `%s' message\n", | 536 | "Received `%s' message\n", |
537 | "LOOKUP"); | 537 | "LOOKUP"); |
538 | msg_size = ntohs (message->size); | 538 | msg_size = ntohs (message->size); |
539 | if (msg_size < sizeof (struct GNUNET_GNS_ClientLookupMessage)) | 539 | if (msg_size < sizeof (struct GNUNET_GNS_ClientLookupMessage)) |
@@ -557,8 +557,8 @@ handle_lookup (void *cls, | |||
557 | return; | 557 | return; |
558 | } | 558 | } |
559 | GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr); | 559 | GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr); |
560 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 560 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
561 | 561 | ||
562 | clh = GNUNET_new (struct ClientLookupHandle); | 562 | clh = GNUNET_new (struct ClientLookupHandle); |
563 | GNUNET_SERVER_client_set_user_context (client, clh); | 563 | GNUNET_SERVER_client_set_user_context (client, clh); |
564 | GNUNET_CONTAINER_DLL_insert (clh_head, clh_tail, clh); | 564 | GNUNET_CONTAINER_DLL_insert (clh_head, clh_tail, clh); |
@@ -571,7 +571,7 @@ handle_lookup (void *cls, | |||
571 | "LOOKUP: Query for A record but AF_INET not supported!"); | 571 | "LOOKUP: Query for A record but AF_INET not supported!"); |
572 | send_lookup_response (clh, 0, NULL); | 572 | send_lookup_response (clh, 0, NULL); |
573 | return; | 573 | return; |
574 | } | 574 | } |
575 | if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) && | 575 | if ( (GNUNET_DNSPARSER_TYPE_AAAA == ntohl (sh_msg->type)) && |
576 | (GNUNET_OK != v6_enabled) ) | 576 | (GNUNET_OK != v6_enabled) ) |
577 | { | 577 | { |
@@ -580,14 +580,14 @@ handle_lookup (void *cls, | |||
580 | send_lookup_response (clh, 0, NULL); | 580 | send_lookup_response (clh, 0, NULL); |
581 | return; | 581 | return; |
582 | } | 582 | } |
583 | clh->lookup = GNS_resolver_lookup (&sh_msg->zone, | 583 | clh->lookup = GNS_resolver_lookup (&sh_msg->zone, |
584 | ntohl (sh_msg->type), | 584 | ntohl (sh_msg->type), |
585 | name, | 585 | name, |
586 | key, | 586 | key, |
587 | ntohl (sh_msg->only_cached), | 587 | ntohl (sh_msg->only_cached), |
588 | &send_lookup_response, clh); | 588 | &send_lookup_response, clh); |
589 | GNUNET_STATISTICS_update (statistics, | 589 | GNUNET_STATISTICS_update (statistics, |
590 | "Lookup attempts", | 590 | "Lookup attempts", |
591 | 1, GNUNET_NO); | 591 | 1, GNUNET_NO); |
592 | } | 592 | } |
593 | 593 | ||
@@ -645,7 +645,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
645 | GNUNET_SCHEDULER_shutdown (); | 645 | GNUNET_SCHEDULER_shutdown (); |
646 | return; | 646 | return; |
647 | } | 647 | } |
648 | 648 | ||
649 | put_interval = INITIAL_PUT_INTERVAL; | 649 | put_interval = INITIAL_PUT_INTERVAL; |
650 | zone_publish_time_window = DEFAULT_ZONE_PUBLISH_TIME_WINDOW; | 650 | zone_publish_time_window = DEFAULT_ZONE_PUBLISH_TIME_WINDOW; |
651 | 651 | ||
@@ -677,7 +677,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
677 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 677 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
678 | return; | 678 | return; |
679 | } | 679 | } |
680 | 680 | ||
681 | if (GNUNET_OK == | 681 | if (GNUNET_OK == |
682 | GNUNET_CONFIGURATION_get_value_string (c, "gns", "DNS_ROOT", | 682 | GNUNET_CONFIGURATION_get_value_string (c, "gns", "DNS_ROOT", |
683 | &dns_root_name)) | 683 | &dns_root_name)) |
@@ -688,7 +688,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
688 | &dns_root)) | 688 | &dns_root)) |
689 | { | 689 | { |
690 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 690 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
691 | "gns", "DNS_ROOT", | 691 | "gns", "DNS_ROOT", |
692 | _("valid public key required")); | 692 | _("valid public key required")); |
693 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 693 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
694 | GNUNET_free (dns_root_name); | 694 | GNUNET_free (dns_root_name); |
@@ -697,7 +697,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
697 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 697 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
698 | "DNS hijacking with root `%s' enabled. Connecting to DNS service.\n", | 698 | "DNS hijacking with root `%s' enabled. Connecting to DNS service.\n", |
699 | dns_root_name); | 699 | dns_root_name); |
700 | GNUNET_free (dns_root_name); | 700 | GNUNET_free (dns_root_name); |
701 | if (GNUNET_SYSERR == | 701 | if (GNUNET_SYSERR == |
702 | GNS_interceptor_init (&dns_root, c)) | 702 | GNS_interceptor_init (&dns_root, c)) |
703 | { | 703 | { |
@@ -705,21 +705,21 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
705 | return; | 705 | return; |
706 | } | 706 | } |
707 | } | 707 | } |
708 | GNS_resolver_init (namestore_handle, dht_handle, | 708 | GNS_resolver_init (namestore_handle, dht_handle, |
709 | c, | 709 | c, |
710 | max_parallel_bg_queries); | 710 | max_parallel_bg_queries); |
711 | GNS_shorten_init (namestore_handle, dht_handle); | 711 | GNS_shorten_init (namestore_handle, dht_handle); |
712 | GNUNET_SERVER_disconnect_notify (server, | 712 | GNUNET_SERVER_disconnect_notify (server, |
713 | ¬ify_client_disconnect, | 713 | ¬ify_client_disconnect, |
714 | NULL); | 714 | NULL); |
715 | /* Schedule periodic put for our records. */ | 715 | /* Schedule periodic put for our records. */ |
716 | first_zone_iteration = GNUNET_YES; | 716 | first_zone_iteration = GNUNET_YES; |
717 | GNUNET_SERVER_add_handlers (server, handlers); | 717 | GNUNET_SERVER_add_handlers (server, handlers); |
718 | statistics = GNUNET_STATISTICS_create ("gns", c); | 718 | statistics = GNUNET_STATISTICS_create ("gns", c); |
719 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 719 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
720 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, | 720 | zone_publish_task = GNUNET_SCHEDULER_add_now (&publish_zone_dht_start, |
721 | NULL); | 721 | NULL); |
722 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 722 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
723 | &shutdown_task, NULL); | 723 | &shutdown_task, NULL); |
724 | } | 724 | } |
725 | 725 | ||