aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo/gnunet-service-peerinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peerinfo/gnunet-service-peerinfo.c')
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index cf28484eb..d62e81eae 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -81,7 +81,7 @@ struct TransmitContext
81 * Server transmit context 81 * Server transmit context
82 */ 82 */
83 struct GNUNET_SERVER_TransmitContext *tc; 83 struct GNUNET_SERVER_TransmitContext *tc;
84 84
85 /** 85 /**
86 * Include friend only HELLOs GNUNET_YES or _NO 86 * Include friend only HELLOs GNUNET_YES or _NO
87 */ 87 */
@@ -315,7 +315,7 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
315 * addresses. Removes the file if one the HELLO is mal-formed. If all 315 * addresses. Removes the file if one the HELLO is mal-formed. If all
316 * addresses are expired, the HELLO is also removed (but the HELLO 316 * addresses are expired, the HELLO is also removed (but the HELLO
317 * with the public key is still returned if it was found and valid). 317 * with the public key is still returned if it was found and valid).
318 * 318 *
319 * The file can contain multiple HELLO messages, but onlu a public and a friend only 319 * The file can contain multiple HELLO messages, but onlu a public and a friend only
320 * HELLO should be included 320 * HELLO should be included
321 * 321 *
@@ -351,7 +351,7 @@ read_host_file (const char *fn, int unlink_garbage, struct ReadHostFileContext *
351 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 351 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
352 _("Failed to parse HELLO in file `%s': %s\n"), 352 _("Failed to parse HELLO in file `%s': %s\n"),
353 fn, "Fail has invalid size"); 353 fn, "Fail has invalid size");
354 if ( (GNUNET_YES == unlink_garbage) && 354 if ( (GNUNET_YES == unlink_garbage) &&
355 (0 != UNLINK (fn)) && 355 (0 != UNLINK (fn)) &&
356 (ENOENT != errno) ) 356 (ENOENT != errno) )
357 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); 357 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
@@ -368,26 +368,26 @@ read_host_file (const char *fn, int unlink_garbage, struct ReadHostFileContext *
368 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 368 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
369 _("Failed to parse HELLO in file `%s': %s %u \n"), 369 _("Failed to parse HELLO in file `%s': %s %u \n"),
370 fn, "HELLO is invalid and has size of ", size_hello); 370 fn, "HELLO is invalid and has size of ", size_hello);
371 if ((GNUNET_YES == unlink_garbage) && 371 if ((GNUNET_YES == unlink_garbage) &&
372 (0 != UNLINK (fn)) && 372 (0 != UNLINK (fn)) &&
373 (ENOENT != errno) ) 373 (ENOENT != errno) )
374 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); 374 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
375 return; 375 return;
376 } 376 }
377 377
378 now = GNUNET_TIME_absolute_get (); 378 now = GNUNET_TIME_absolute_get ();
379 hello_clean = GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES, 379 hello_clean = GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES,
380 &discard_expired, &now); 380 &discard_expired, &now);
381 left = 0; 381 left = 0;
382 (void) GNUNET_HELLO_iterate_addresses (hello_clean, GNUNET_NO, 382 (void) GNUNET_HELLO_iterate_addresses (hello_clean, GNUNET_NO,
383 &count_addresses, &left); 383 &count_addresses, &left);
384 384
385 if (0 == left) 385 if (0 == left)
386 { 386 {
387 GNUNET_free (hello_clean); 387 GNUNET_free (hello_clean);
388 break; 388 break;
389 } 389 }
390 390
391 if (GNUNET_NO == GNUNET_HELLO_is_friend_only (hello_clean)) 391 if (GNUNET_NO == GNUNET_HELLO_is_friend_only (hello_clean))
392 { 392 {
393 if (NULL == r->hello) 393 if (NULL == r->hello)
@@ -497,7 +497,7 @@ struct DirScanContext
497 * GNUNET_YES if we should remove files that are broken, 497 * GNUNET_YES if we should remove files that are broken,
498 * GNUNET_NO if the directory we are iterating over should 498 * GNUNET_NO if the directory we are iterating over should
499 * be treated as read-only by us. 499 * be treated as read-only by us.
500 */ 500 */
501 int remove_files; 501 int remove_files;
502 502
503 /** 503 /**
@@ -565,7 +565,7 @@ hosts_directory_scan_callback (void *cls, const char *fullname)
565 } 565 }
566 id = id_public; 566 id = id_public;
567 } 567 }
568 568
569 if ( (NULL != r.hello) && (NULL != r.friend_only_hello) && 569 if ( (NULL != r.hello) && (NULL != r.friend_only_hello) &&
570 (0 != memcmp (&id_friend, &id_public, sizeof (id_friend))) ) 570 (0 != memcmp (&id_friend, &id_public, sizeof (id_friend))) )
571 { 571 {
@@ -575,7 +575,7 @@ hosts_directory_scan_callback (void *cls, const char *fullname)
575 remove_garbage (fullname); 575 remove_garbage (fullname);
576 return GNUNET_OK; 576 return GNUNET_OK;
577 } 577 }
578 if (GNUNET_OK == GNUNET_CRYPTO_ecc_public_sign_key_from_string (filename, 578 if (GNUNET_OK == GNUNET_CRYPTO_ecc_public_sign_key_from_string (filename,
579 strlen (filename), 579 strlen (filename),
580 &identity.public_key)) 580 &identity.public_key))
581 { 581 {
@@ -641,7 +641,7 @@ cron_scan_directory_data_hosts (void *cls,
641 if ((0 == dsc.matched) && (0 == (++retries & 31))) 641 if ((0 == dsc.matched) && (0 == (++retries & 31)))
642 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, 642 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
643 _("Still no peers found in `%s'!\n"), networkIdDirectory); 643 _("Still no peers found in `%s'!\n"), networkIdDirectory);
644 GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, 644 GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ,
645 GNUNET_SCHEDULER_PRIORITY_IDLE, 645 GNUNET_SCHEDULER_PRIORITY_IDLE,
646 &cron_scan_directory_data_hosts, 646 &cron_scan_directory_data_hosts,
647 NULL); 647 NULL);
@@ -655,14 +655,14 @@ update_friend_hello (const struct GNUNET_HELLO_Message *hello,
655 struct GNUNET_HELLO_Message * res; 655 struct GNUNET_HELLO_Message * res;
656 struct GNUNET_HELLO_Message * tmp; 656 struct GNUNET_HELLO_Message * tmp;
657 struct GNUNET_CRYPTO_EccPublicSignKey pk; 657 struct GNUNET_CRYPTO_EccPublicSignKey pk;
658 658
659 if (NULL != friend_hello) 659 if (NULL != friend_hello)
660 { 660 {
661 res = GNUNET_HELLO_merge (hello, friend_hello); 661 res = GNUNET_HELLO_merge (hello, friend_hello);
662 GNUNET_assert (GNUNET_YES == GNUNET_HELLO_is_friend_only (res)); 662 GNUNET_assert (GNUNET_YES == GNUNET_HELLO_is_friend_only (res));
663 return res; 663 return res;
664 } 664 }
665 665
666 if (GNUNET_OK != 666 if (GNUNET_OK !=
667 GNUNET_HELLO_get_key (hello, &pk)) 667 GNUNET_HELLO_get_key (hello, &pk))
668 { 668 {
@@ -779,7 +779,7 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
779 store_friend_hello = GNUNET_YES; 779 store_friend_hello = GNUNET_YES;
780 size += GNUNET_HELLO_size (host->friend_only_hello); 780 size += GNUNET_HELLO_size (host->friend_only_hello);
781 } 781 }
782 782
783 if ((GNUNET_NO == store_hello) && (GNUNET_NO == store_friend_hello)) 783 if ((GNUNET_NO == store_hello) && (GNUNET_NO == store_friend_hello))
784 { 784 {
785 /* no valid addresses, don't put HELLO on disk; in fact, 785 /* no valid addresses, don't put HELLO on disk; in fact,
@@ -790,7 +790,7 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
790 { 790 {
791 buffer = GNUNET_malloc (size); 791 buffer = GNUNET_malloc (size);
792 pos = 0; 792 pos = 0;
793 793
794 if (GNUNET_YES == store_hello) 794 if (GNUNET_YES == store_hello)
795 { 795 {
796 memcpy (buffer, host->hello, GNUNET_HELLO_size (host->hello)); 796 memcpy (buffer, host->hello, GNUNET_HELLO_size (host->hello));
@@ -802,7 +802,7 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
802 pos += GNUNET_HELLO_size (host->friend_only_hello); 802 pos += GNUNET_HELLO_size (host->friend_only_hello);
803 } 803 }
804 GNUNET_assert (pos == size); 804 GNUNET_assert (pos == size);
805 805
806 if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn, buffer, size, 806 if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn, buffer, size,
807 GNUNET_DISK_PERM_USER_READ | 807 GNUNET_DISK_PERM_USER_READ |
808 GNUNET_DISK_PERM_USER_WRITE | 808 GNUNET_DISK_PERM_USER_WRITE |
@@ -860,13 +860,13 @@ add_to_tc (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
860 GNUNET_assert (hs < GNUNET_SERVER_MAX_MESSAGE_SIZE - 860 GNUNET_assert (hs < GNUNET_SERVER_MAX_MESSAGE_SIZE -
861 sizeof (struct InfoMessage)); 861 sizeof (struct InfoMessage));
862 memcpy (&im[1], pos->friend_only_hello, hs); 862 memcpy (&im[1], pos->friend_only_hello, hs);
863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 863 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
864 "Sending friend-only HELLO with size %u for peer `%4s'\n", 864 "Sending friend-only HELLO with size %u for peer `%4s'\n",
865 hs, GNUNET_i2s (key)); 865 hs, GNUNET_i2s (key));
866 } 866 }
867 else 867 else
868 { 868 {
869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 869 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
870 "Adding no HELLO for peer `%s'\n", 870 "Adding no HELLO for peer `%s'\n",
871 GNUNET_i2s (key)); 871 GNUNET_i2s (key));
872 } 872 }
@@ -1086,14 +1086,14 @@ do_notify_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
1086 /* We have no public hello */ 1086 /* We have no public hello */
1087 return GNUNET_YES; 1087 return GNUNET_YES;
1088 } 1088 }
1089 1089
1090 if ( (NULL == he->friend_only_hello) && 1090 if ( (NULL == he->friend_only_hello) &&
1091 (GNUNET_YES == nc->include_friend_only) ) 1091 (GNUNET_YES == nc->include_friend_only) )
1092 { 1092 {
1093 /* We have no friend hello */ 1093 /* We have no friend hello */
1094 return GNUNET_YES; 1094 return GNUNET_YES;
1095 } 1095 }
1096 1096
1097 msg = make_info_message (he, nc->include_friend_only); 1097 msg = make_info_message (he, nc->include_friend_only);
1098 GNUNET_SERVER_notification_context_unicast (notify_list, 1098 GNUNET_SERVER_notification_context_unicast (notify_list,
1099 nc->client, 1099 nc->client,
@@ -1118,13 +1118,13 @@ handle_notify (void *cls, struct GNUNET_SERVER_Client *client,
1118 struct NotifyMessage *nm = (struct NotifyMessage *) message; 1118 struct NotifyMessage *nm = (struct NotifyMessage *) message;
1119 struct NotificationContext *nc; 1119 struct NotificationContext *nc;
1120 1120
1121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1122 "`%s' message received\n", 1122 "`%s' message received\n",
1123 "NOTIFY"); 1123 "NOTIFY");
1124 nc = GNUNET_malloc (sizeof (struct NotificationContext)); 1124 nc = GNUNET_malloc (sizeof (struct NotificationContext));
1125 nc->client = client; 1125 nc->client = client;
1126 nc->include_friend_only = ntohl (nm->include_friend_only); 1126 nc->include_friend_only = ntohl (nm->include_friend_only);
1127 1127
1128 GNUNET_CONTAINER_DLL_insert (nc_head, nc_tail, nc); 1128 GNUNET_CONTAINER_DLL_insert (nc_head, nc_tail, nc);
1129 GNUNET_SERVER_client_mark_monitor (client); 1129 GNUNET_SERVER_client_mark_monitor (client);
1130 GNUNET_SERVER_notification_context_add (notify_list, client); 1130 GNUNET_SERVER_notification_context_add (notify_list, client);
@@ -1139,7 +1139,7 @@ handle_notify (void *cls, struct GNUNET_SERVER_Client *client,
1139 * @param cls unused 1139 * @param cls unused
1140 * @param client server client 1140 * @param client server client
1141 */ 1141 */
1142static void 1142static void
1143disconnect_cb (void *cls,struct GNUNET_SERVER_Client *client) 1143disconnect_cb (void *cls,struct GNUNET_SERVER_Client *client)
1144{ 1144{
1145 struct NotificationContext *cur; 1145 struct NotificationContext *cur;
@@ -1251,7 +1251,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1251 GNUNET_SCHEDULER_shutdown (); 1251 GNUNET_SCHEDULER_shutdown ();
1252 return; 1252 return;
1253 } 1253 }
1254 1254
1255 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 1255 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
1256 &cron_scan_directory_data_hosts, NULL); 1256 &cron_scan_directory_data_hosts, NULL);
1257 1257