diff options
Diffstat (limited to 'src/peerinfo')
-rw-r--r-- | src/peerinfo/gnunet-service-peerinfo.c | 620 | ||||
-rw-r--r-- | src/peerinfo/perf_peerinfo_api.c | 2 |
2 files changed, 252 insertions, 370 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 61fdd0f24..a884c5b76 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c | |||
@@ -38,12 +38,14 @@ | |||
38 | /** | 38 | /** |
39 | * How often do we scan the HOST_DIR for new entries? | 39 | * How often do we scan the HOST_DIR for new entries? |
40 | */ | 40 | */ |
41 | #define DATA_HOST_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) | 41 | #define DATA_HOST_FREQ \ |
42 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) | ||
42 | 43 | ||
43 | /** | 44 | /** |
44 | * How often do we discard old entries in data/hosts/? | 45 | * How often do we discard old entries in data/hosts/? |
45 | */ | 46 | */ |
46 | #define DATA_HOST_CLEAN_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60) | 47 | #define DATA_HOST_CLEAN_FREQ \ |
48 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60) | ||
47 | 49 | ||
48 | 50 | ||
49 | /** | 51 | /** |
@@ -66,7 +68,6 @@ struct HostEntry | |||
66 | * Friend only hello for the peer (can be NULL) | 68 | * Friend only hello for the peer (can be NULL) |
67 | */ | 69 | */ |
68 | struct GNUNET_HELLO_Message *friend_only_hello; | 70 | struct GNUNET_HELLO_Message *friend_only_hello; |
69 | |||
70 | }; | 71 | }; |
71 | 72 | ||
72 | 73 | ||
@@ -134,8 +135,7 @@ static struct GNUNET_SCHEDULER_Task *cron_scan; | |||
134 | * @return generated notification message | 135 | * @return generated notification message |
135 | */ | 136 | */ |
136 | static struct InfoMessage * | 137 | static struct InfoMessage * |
137 | make_info_message (const struct HostEntry *he, | 138 | make_info_message (const struct HostEntry *he, int include_friend_only) |
138 | int include_friend_only) | ||
139 | { | 139 | { |
140 | struct InfoMessage *im; | 140 | struct InfoMessage *im; |
141 | struct GNUNET_HELLO_Message *src; | 141 | struct GNUNET_HELLO_Message *src; |
@@ -150,9 +150,7 @@ make_info_message (const struct HostEntry *he, | |||
150 | im->header.size = htons (hs + sizeof (struct InfoMessage)); | 150 | im->header.size = htons (hs + sizeof (struct InfoMessage)); |
151 | im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO); | 151 | im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO); |
152 | im->peer = he->identity; | 152 | im->peer = he->identity; |
153 | GNUNET_memcpy (&im[1], | 153 | GNUNET_memcpy (&im[1], src, hs); |
154 | src, | ||
155 | hs); | ||
156 | return im; | 154 | return im; |
157 | } | 155 | } |
158 | 156 | ||
@@ -175,7 +173,7 @@ discard_expired (void *cls, | |||
175 | if (now->abs_value_us > expiration.abs_value_us) | 173 | if (now->abs_value_us > expiration.abs_value_us) |
176 | { | 174 | { |
177 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 175 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
178 | _("Removing expired address of transport `%s'\n"), | 176 | _ ("Removing expired address of transport `%s'\n"), |
179 | address->transport_name); | 177 | address->transport_name); |
180 | return GNUNET_NO; | 178 | return GNUNET_NO; |
181 | } | 179 | } |
@@ -241,16 +239,14 @@ notify_all (struct HostEntry *entry) | |||
241 | struct InfoMessage *msg_friend; | 239 | struct InfoMessage *msg_friend; |
242 | 240 | ||
243 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 241 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
244 | "Notifying all clients about peer `%s'\n", | 242 | "Notifying all clients about peer `%s'\n", |
245 | GNUNET_i2s(&entry->identity)); | 243 | GNUNET_i2s (&entry->identity)); |
246 | msg_pub = make_info_message (entry, | 244 | msg_pub = make_info_message (entry, GNUNET_NO); |
247 | GNUNET_NO); | ||
248 | GNUNET_notification_context_broadcast (notify_list, | 245 | GNUNET_notification_context_broadcast (notify_list, |
249 | &msg_pub->header, | 246 | &msg_pub->header, |
250 | GNUNET_NO); | 247 | GNUNET_NO); |
251 | GNUNET_free (msg_pub); | 248 | GNUNET_free (msg_pub); |
252 | msg_friend = make_info_message (entry, | 249 | msg_friend = make_info_message (entry, GNUNET_YES); |
253 | GNUNET_YES); | ||
254 | GNUNET_notification_context_broadcast (notify_friend_only_list, | 250 | GNUNET_notification_context_broadcast (notify_friend_only_list, |
255 | &msg_friend->header, | 251 | &msg_friend->header, |
256 | GNUNET_NO); | 252 | GNUNET_NO); |
@@ -299,26 +295,21 @@ read_host_file (const char *fn, | |||
299 | 295 | ||
300 | if (GNUNET_YES != GNUNET_DISK_file_test (fn)) | 296 | if (GNUNET_YES != GNUNET_DISK_file_test (fn)) |
301 | return; | 297 | return; |
302 | size_total = GNUNET_DISK_fn_read (fn, | 298 | size_total = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer)); |
303 | buffer, | ||
304 | sizeof (buffer)); | ||
305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
306 | "Read %d bytes from `%s'\n", | 300 | "Read %d bytes from `%s'\n", |
307 | (int) size_total, | 301 | (int) size_total, |
308 | fn); | 302 | fn); |
309 | if ( (size_total < 0) || | 303 | if ((size_total < 0) || |
310 | (((size_t) size_total) < sizeof (struct GNUNET_MessageHeader)) ) | 304 | (((size_t) size_total) < sizeof (struct GNUNET_MessageHeader))) |
311 | { | 305 | { |
312 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 306 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
313 | _("Failed to parse HELLO in file `%s': %s\n"), | 307 | _ ("Failed to parse HELLO in file `%s': %s\n"), |
314 | fn, | 308 | fn, |
315 | "File has invalid size"); | 309 | "File has invalid size"); |
316 | if ( (GNUNET_YES == unlink_garbage) && | 310 | if ((GNUNET_YES == unlink_garbage) && (0 != unlink (fn)) && |
317 | (0 != UNLINK (fn)) && | 311 | (ENOENT != errno)) |
318 | (ENOENT != errno) ) | 312 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); |
319 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
320 | "unlink", | ||
321 | fn); | ||
322 | return; | 313 | return; |
323 | } | 314 | } |
324 | 315 | ||
@@ -327,29 +318,22 @@ read_host_file (const char *fn, | |||
327 | { | 318 | { |
328 | hello = (const struct GNUNET_HELLO_Message *) &buffer[read_pos]; | 319 | hello = (const struct GNUNET_HELLO_Message *) &buffer[read_pos]; |
329 | size_hello = GNUNET_HELLO_size (hello); | 320 | size_hello = GNUNET_HELLO_size (hello); |
330 | if ( (0 == size_hello) || | 321 | if ((0 == size_hello) || (((size_t) size_total) - read_pos < size_hello)) |
331 | (((size_t) size_total) - read_pos < size_hello) ) | ||
332 | { | 322 | { |
333 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 323 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
334 | _("Failed to parse HELLO in file `%s'\n"), | 324 | _ ("Failed to parse HELLO in file `%s'\n"), |
335 | fn); | 325 | fn); |
336 | if (0 == read_pos) | 326 | if (0 == read_pos) |
337 | { | 327 | { |
338 | if ((GNUNET_YES == unlink_garbage) && | 328 | if ((GNUNET_YES == unlink_garbage) && (0 != unlink (fn)) && |
339 | (0 != UNLINK (fn)) && | 329 | (ENOENT != errno)) |
340 | (ENOENT != errno) ) | 330 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); |
341 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
342 | "unlink", | ||
343 | fn); | ||
344 | } | 331 | } |
345 | else | 332 | else |
346 | { | 333 | { |
347 | if ( (GNUNET_YES == unlink_garbage) && | 334 | if ((GNUNET_YES == unlink_garbage) && (0 != truncate (fn, read_pos)) && |
348 | (0 != TRUNCATE (fn, read_pos)) && | 335 | (ENOENT != errno)) |
349 | (ENOENT != errno) ) | 336 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "truncate", fn); |
350 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
351 | "truncate", | ||
352 | fn); | ||
353 | } | 337 | } |
354 | return; | 338 | return; |
355 | } | 339 | } |
@@ -357,25 +341,22 @@ read_host_file (const char *fn, | |||
357 | now = GNUNET_TIME_absolute_get (); | 341 | now = GNUNET_TIME_absolute_get (); |
358 | hello_clean = GNUNET_HELLO_iterate_addresses (hello, | 342 | hello_clean = GNUNET_HELLO_iterate_addresses (hello, |
359 | GNUNET_YES, | 343 | GNUNET_YES, |
360 | &discard_expired, | 344 | &discard_expired, |
361 | &now); | 345 | &now); |
362 | if (NULL == hello_clean) | 346 | if (NULL == hello_clean) |
363 | { | 347 | { |
364 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 348 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
365 | _("Failed to parse HELLO in file `%s'\n"), | 349 | _ ("Failed to parse HELLO in file `%s'\n"), |
366 | fn); | 350 | fn); |
367 | if ((GNUNET_YES == unlink_garbage) && | 351 | if ((GNUNET_YES == unlink_garbage) && (0 != unlink (fn)) && |
368 | (0 != UNLINK (fn)) && | 352 | (ENOENT != errno)) |
369 | (ENOENT != errno) ) | 353 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); |
370 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
371 | "unlink", | ||
372 | fn); | ||
373 | return; | 354 | return; |
374 | } | 355 | } |
375 | left = 0; | 356 | left = 0; |
376 | (void) GNUNET_HELLO_iterate_addresses (hello_clean, | 357 | (void) GNUNET_HELLO_iterate_addresses (hello_clean, |
377 | GNUNET_NO, | 358 | GNUNET_NO, |
378 | &count_addresses, | 359 | &count_addresses, |
379 | &left); | 360 | &left); |
380 | 361 | ||
381 | if (0 == left) | 362 | if (0 == left) |
@@ -387,23 +368,23 @@ read_host_file (const char *fn, | |||
387 | if (GNUNET_NO == GNUNET_HELLO_is_friend_only (hello_clean)) | 368 | if (GNUNET_NO == GNUNET_HELLO_is_friend_only (hello_clean)) |
388 | { | 369 | { |
389 | if (NULL == r->hello) | 370 | if (NULL == r->hello) |
390 | r->hello = hello_clean; | 371 | r->hello = hello_clean; |
391 | else | 372 | else |
392 | { | 373 | { |
393 | GNUNET_break (0); | 374 | GNUNET_break (0); |
394 | GNUNET_free (r->hello); | 375 | GNUNET_free (r->hello); |
395 | r->hello = hello_clean; | 376 | r->hello = hello_clean; |
396 | } | 377 | } |
397 | } | 378 | } |
398 | else | 379 | else |
399 | { | 380 | { |
400 | if (NULL == r->friend_only_hello) | 381 | if (NULL == r->friend_only_hello) |
401 | r->friend_only_hello = hello_clean; | 382 | r->friend_only_hello = hello_clean; |
402 | else | 383 | else |
403 | { | 384 | { |
404 | GNUNET_break (0); | 385 | GNUNET_break (0); |
405 | GNUNET_free (r->friend_only_hello); | 386 | GNUNET_free (r->friend_only_hello); |
406 | r->friend_only_hello = hello_clean; | 387 | r->friend_only_hello = hello_clean; |
407 | } | 388 | } |
408 | } | 389 | } |
409 | read_pos += size_hello; | 390 | read_pos += size_hello; |
@@ -412,16 +393,14 @@ read_host_file (const char *fn, | |||
412 | if (0 == left) | 393 | if (0 == left) |
413 | { | 394 | { |
414 | /* no addresses left, remove from disk */ | 395 | /* no addresses left, remove from disk */ |
415 | if ( (GNUNET_YES == unlink_garbage) && | 396 | if ((GNUNET_YES == unlink_garbage) && (0 != unlink (fn))) |
416 | (0 != UNLINK (fn)) ) | 397 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn); |
417 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | ||
418 | "unlink", | ||
419 | fn); | ||
420 | } | 398 | } |
421 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 399 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
422 | "Found `%s' and `%s' HELLO message in file\n", | 400 | "Found `%s' and `%s' HELLO message in file\n", |
423 | (NULL != r->hello) ? "public" : "NON-public", | 401 | (NULL != r->hello) ? "public" : "NON-public", |
424 | (NULL != r->friend_only_hello) ? "friend only" : "NO friend only"); | 402 | (NULL != r->friend_only_hello) ? "friend only" |
403 | : "NO friend only"); | ||
425 | } | 404 | } |
426 | 405 | ||
427 | 406 | ||
@@ -438,8 +417,7 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) | |||
438 | struct ReadHostFileContext r; | 417 | struct ReadHostFileContext r; |
439 | char *fn; | 418 | char *fn; |
440 | 419 | ||
441 | entry = GNUNET_CONTAINER_multipeermap_get (hostmap, | 420 | entry = GNUNET_CONTAINER_multipeermap_get (hostmap, identity); |
442 | identity); | ||
443 | if (NULL == entry) | 421 | if (NULL == entry) |
444 | { | 422 | { |
445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 423 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -448,27 +426,24 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) | |||
448 | GNUNET_STATISTICS_update (stats, | 426 | GNUNET_STATISTICS_update (stats, |
449 | gettext_noop ("# peers known"), | 427 | gettext_noop ("# peers known"), |
450 | 1, | 428 | 1, |
451 | GNUNET_NO); | 429 | GNUNET_NO); |
452 | entry = GNUNET_new (struct HostEntry); | 430 | entry = GNUNET_new (struct HostEntry); |
453 | entry->identity = *identity; | 431 | entry->identity = *identity; |
454 | GNUNET_assert (GNUNET_OK == | 432 | GNUNET_assert (GNUNET_OK == |
455 | GNUNET_CONTAINER_multipeermap_put (hostmap, | 433 | GNUNET_CONTAINER_multipeermap_put ( |
456 | &entry->identity, | 434 | hostmap, |
457 | entry, | 435 | &entry->identity, |
458 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 436 | entry, |
437 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
459 | notify_all (entry); | 438 | notify_all (entry); |
460 | fn = get_host_filename (identity); | 439 | fn = get_host_filename (identity); |
461 | if (NULL != fn) | 440 | if (NULL != fn) |
462 | { | 441 | { |
463 | read_host_file (fn, | 442 | read_host_file (fn, GNUNET_YES, &r); |
464 | GNUNET_YES, | ||
465 | &r); | ||
466 | if (NULL != r.hello) | 443 | if (NULL != r.hello) |
467 | update_hello (identity, | 444 | update_hello (identity, r.hello); |
468 | r.hello); | ||
469 | if (NULL != r.friend_only_hello) | 445 | if (NULL != r.friend_only_hello) |
470 | update_hello (identity, | 446 | update_hello (identity, r.friend_only_hello); |
471 | r.friend_only_hello); | ||
472 | GNUNET_free_non_null (r.hello); | 447 | GNUNET_free_non_null (r.hello); |
473 | GNUNET_free_non_null (r.friend_only_hello); | 448 | GNUNET_free_non_null (r.friend_only_hello); |
474 | GNUNET_free (fn); | 449 | GNUNET_free (fn); |
@@ -487,11 +462,13 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) | |||
487 | static void | 462 | static void |
488 | remove_garbage (const char *fullname) | 463 | remove_garbage (const char *fullname) |
489 | { | 464 | { |
490 | if (0 == UNLINK (fullname)) | 465 | if (0 == unlink (fullname)) |
491 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 466 | GNUNET_log ( |
492 | _("File `%s' in directory `%s' does not match naming convention. Removed.\n"), | 467 | GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
493 | fullname, | 468 | _ ( |
494 | networkIdDirectory); | 469 | "File `%s' in directory `%s' does not match naming convention. Removed.\n"), |
470 | fullname, | ||
471 | networkIdDirectory); | ||
495 | else | 472 | else |
496 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 473 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
497 | "unlink", | 474 | "unlink", |
@@ -529,8 +506,7 @@ struct DirScanContext | |||
529 | * @return #GNUNET_OK (continue iteration) | 506 | * @return #GNUNET_OK (continue iteration) |
530 | */ | 507 | */ |
531 | static int | 508 | static int |
532 | hosts_directory_scan_callback (void *cls, | 509 | hosts_directory_scan_callback (void *cls, const char *fullname) |
533 | const char *fullname) | ||
534 | { | 510 | { |
535 | struct DirScanContext *dsc = cls; | 511 | struct DirScanContext *dsc = cls; |
536 | struct GNUNET_PeerIdentity identity; | 512 | struct GNUNET_PeerIdentity identity; |
@@ -541,51 +517,40 @@ hosts_directory_scan_callback (void *cls, | |||
541 | struct GNUNET_PeerIdentity id; | 517 | struct GNUNET_PeerIdentity id; |
542 | 518 | ||
543 | if (GNUNET_YES != GNUNET_DISK_file_test (fullname)) | 519 | if (GNUNET_YES != GNUNET_DISK_file_test (fullname)) |
544 | return GNUNET_OK; /* ignore non-files */ | 520 | return GNUNET_OK; /* ignore non-files */ |
545 | 521 | ||
546 | filename = strrchr (fullname, | 522 | filename = strrchr (fullname, DIR_SEPARATOR); |
547 | DIR_SEPARATOR); | 523 | if ((NULL == filename) || (1 > strlen (filename))) |
548 | if ( (NULL == filename) || | ||
549 | (1 > strlen (filename)) ) | ||
550 | filename = fullname; | 524 | filename = fullname; |
551 | else | 525 | else |
552 | filename ++; | 526 | filename++; |
553 | 527 | ||
554 | read_host_file (fullname, | 528 | read_host_file (fullname, dsc->remove_files, &r); |
555 | dsc->remove_files, | 529 | if ((NULL == r.hello) && (NULL == r.friend_only_hello)) |
556 | &r); | ||
557 | if ( (NULL == r.hello) && | ||
558 | (NULL == r.friend_only_hello)) | ||
559 | return GNUNET_OK; | 530 | return GNUNET_OK; |
560 | if (NULL != r.friend_only_hello) | 531 | if (NULL != r.friend_only_hello) |
561 | { | 532 | { |
562 | if (GNUNET_OK != | 533 | if (GNUNET_OK != GNUNET_HELLO_get_id (r.friend_only_hello, &id_friend)) |
563 | GNUNET_HELLO_get_id (r.friend_only_hello, | ||
564 | &id_friend)) | ||
565 | { | 534 | { |
566 | if (GNUNET_YES == dsc->remove_files) | 535 | if (GNUNET_YES == dsc->remove_files) |
567 | remove_garbage (fullname); | 536 | remove_garbage (fullname); |
568 | return GNUNET_OK; | 537 | return GNUNET_OK; |
569 | } | 538 | } |
570 | id = id_friend; | 539 | id = id_friend; |
571 | } | 540 | } |
572 | if (NULL != r.hello) | 541 | if (NULL != r.hello) |
573 | { | 542 | { |
574 | if (GNUNET_OK != | 543 | if (GNUNET_OK != GNUNET_HELLO_get_id (r.hello, &id_public)) |
575 | GNUNET_HELLO_get_id (r.hello, | ||
576 | &id_public)) | ||
577 | { | 544 | { |
578 | if (GNUNET_YES == dsc->remove_files) | 545 | if (GNUNET_YES == dsc->remove_files) |
579 | remove_garbage (fullname); | 546 | remove_garbage (fullname); |
580 | return GNUNET_OK; | 547 | return GNUNET_OK; |
581 | } | 548 | } |
582 | id = id_public; | 549 | id = id_public; |
583 | } | 550 | } |
584 | 551 | ||
585 | if ( (NULL != r.hello) && | 552 | if ((NULL != r.hello) && (NULL != r.friend_only_hello) && |
586 | (NULL != r.friend_only_hello) && | 553 | (0 != GNUNET_memcmp (&id_friend, &id_public))) |
587 | (0 != GNUNET_memcmp (&id_friend, | ||
588 | &id_public)) ) | ||
589 | { | 554 | { |
590 | /* HELLOs are not for the same peer */ | 555 | /* HELLOs are not for the same peer */ |
591 | GNUNET_break (0); | 556 | GNUNET_break (0); |
@@ -603,7 +568,7 @@ hosts_directory_scan_callback (void *cls, | |||
603 | /* HELLOs are not for the same peer */ | 568 | /* HELLOs are not for the same peer */ |
604 | GNUNET_break (0); | 569 | GNUNET_break (0); |
605 | if (GNUNET_YES == dsc->remove_files) | 570 | if (GNUNET_YES == dsc->remove_files) |
606 | remove_garbage (fullname); | 571 | remove_garbage (fullname); |
607 | return GNUNET_OK; | 572 | return GNUNET_OK; |
608 | } | 573 | } |
609 | } | 574 | } |
@@ -614,7 +579,7 @@ hosts_directory_scan_callback (void *cls, | |||
614 | { | 579 | { |
615 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 580 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
616 | "Updating peer `%s' public HELLO \n", | 581 | "Updating peer `%s' public HELLO \n", |
617 | GNUNET_i2s (&id)); | 582 | GNUNET_i2s (&id)); |
618 | update_hello (&id, r.hello); | 583 | update_hello (&id, r.hello); |
619 | GNUNET_free (r.hello); | 584 | GNUNET_free (r.hello); |
620 | } | 585 | } |
@@ -622,7 +587,7 @@ hosts_directory_scan_callback (void *cls, | |||
622 | { | 587 | { |
623 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 588 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
624 | "Updating peer `%s' friend only HELLO \n", | 589 | "Updating peer `%s' friend only HELLO \n", |
625 | GNUNET_i2s (&id)); | 590 | GNUNET_i2s (&id)); |
626 | update_hello (&id, r.friend_only_hello); | 591 | update_hello (&id, r.friend_only_hello); |
627 | GNUNET_free (r.friend_only_hello); | 592 | GNUNET_free (r.friend_only_hello); |
628 | } | 593 | } |
@@ -644,31 +609,32 @@ cron_scan_directory_data_hosts (void *cls) | |||
644 | 609 | ||
645 | (void) cls; | 610 | (void) cls; |
646 | cron_scan = NULL; | 611 | cron_scan = NULL; |
647 | if (GNUNET_SYSERR == | 612 | if (GNUNET_SYSERR == GNUNET_DISK_directory_create (networkIdDirectory)) |
648 | GNUNET_DISK_directory_create (networkIdDirectory)) | ||
649 | { | 613 | { |
650 | cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, | 614 | cron_scan = |
651 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 615 | GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, |
652 | &cron_scan_directory_data_hosts, NULL); | 616 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
617 | &cron_scan_directory_data_hosts, | ||
618 | NULL); | ||
653 | return; | 619 | return; |
654 | } | 620 | } |
655 | dsc.matched = 0; | 621 | dsc.matched = 0; |
656 | dsc.remove_files = GNUNET_YES; | 622 | dsc.remove_files = GNUNET_YES; |
657 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, | 623 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, |
658 | _("Scanning directory `%s'\n"), | 624 | _ ("Scanning directory `%s'\n"), |
659 | networkIdDirectory); | 625 | networkIdDirectory); |
660 | GNUNET_DISK_directory_scan (networkIdDirectory, | 626 | GNUNET_DISK_directory_scan (networkIdDirectory, |
661 | &hosts_directory_scan_callback, | 627 | &hosts_directory_scan_callback, |
662 | &dsc); | 628 | &dsc); |
663 | if ( (0 == dsc.matched) && | 629 | if ((0 == dsc.matched) && (0 == (++retries & 31))) |
664 | (0 == (++retries & 31)) ) | ||
665 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 630 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
666 | _("Still no peers found in `%s'!\n"), | 631 | _ ("Still no peers found in `%s'!\n"), |
667 | networkIdDirectory); | 632 | networkIdDirectory); |
668 | cron_scan = GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, | 633 | cron_scan = |
669 | GNUNET_SCHEDULER_PRIORITY_IDLE, | 634 | GNUNET_SCHEDULER_add_delayed_with_priority (DATA_HOST_FREQ, |
670 | &cron_scan_directory_data_hosts, | 635 | GNUNET_SCHEDULER_PRIORITY_IDLE, |
671 | NULL); | 636 | &cron_scan_directory_data_hosts, |
637 | NULL); | ||
672 | } | 638 | } |
673 | 639 | ||
674 | 640 | ||
@@ -681,31 +647,25 @@ cron_scan_directory_data_hosts (void *cls) | |||
681 | */ | 647 | */ |
682 | static struct GNUNET_HELLO_Message * | 648 | static struct GNUNET_HELLO_Message * |
683 | update_friend_hello (const struct GNUNET_HELLO_Message *hello, | 649 | update_friend_hello (const struct GNUNET_HELLO_Message *hello, |
684 | const struct GNUNET_HELLO_Message *friend_hello) | 650 | const struct GNUNET_HELLO_Message *friend_hello) |
685 | { | 651 | { |
686 | struct GNUNET_HELLO_Message * res; | 652 | struct GNUNET_HELLO_Message *res; |
687 | struct GNUNET_HELLO_Message * tmp; | 653 | struct GNUNET_HELLO_Message *tmp; |
688 | struct GNUNET_PeerIdentity pid; | 654 | struct GNUNET_PeerIdentity pid; |
689 | 655 | ||
690 | if (NULL != friend_hello) | 656 | if (NULL != friend_hello) |
691 | { | 657 | { |
692 | res = GNUNET_HELLO_merge (hello, | 658 | res = GNUNET_HELLO_merge (hello, friend_hello); |
693 | friend_hello); | 659 | GNUNET_assert (GNUNET_YES == GNUNET_HELLO_is_friend_only (res)); |
694 | GNUNET_assert (GNUNET_YES == | ||
695 | GNUNET_HELLO_is_friend_only (res)); | ||
696 | return res; | 660 | return res; |
697 | } | 661 | } |
698 | 662 | ||
699 | if (GNUNET_OK != | 663 | if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) |
700 | GNUNET_HELLO_get_id (hello, &pid)) | ||
701 | { | 664 | { |
702 | GNUNET_break (0); | 665 | GNUNET_break (0); |
703 | return NULL; | 666 | return NULL; |
704 | } | 667 | } |
705 | tmp = GNUNET_HELLO_create (&pid.public_key, | 668 | tmp = GNUNET_HELLO_create (&pid.public_key, NULL, NULL, GNUNET_YES); |
706 | NULL, | ||
707 | NULL, | ||
708 | GNUNET_YES); | ||
709 | res = GNUNET_HELLO_merge (hello, tmp); | 669 | res = GNUNET_HELLO_merge (hello, tmp); |
710 | GNUNET_free (tmp); | 670 | GNUNET_free (tmp); |
711 | GNUNET_assert (GNUNET_YES == GNUNET_HELLO_is_friend_only (res)); | 671 | GNUNET_assert (GNUNET_YES == GNUNET_HELLO_is_friend_only (res)); |
@@ -762,11 +722,8 @@ update_hello (const struct GNUNET_PeerIdentity *peer, | |||
762 | } | 722 | } |
763 | else | 723 | else |
764 | { | 724 | { |
765 | mrg = GNUNET_HELLO_merge ((*dest), | 725 | mrg = GNUNET_HELLO_merge ((*dest), hello); |
766 | hello); | 726 | delta = GNUNET_HELLO_equals (mrg, (*dest), GNUNET_TIME_absolute_get ()); |
767 | delta = GNUNET_HELLO_equals (mrg, | ||
768 | (*dest), | ||
769 | GNUNET_TIME_absolute_get ()); | ||
770 | if (delta.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) | 727 | if (delta.abs_value_us == GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) |
771 | { | 728 | { |
772 | /* no differences, just ignore the update */ | 729 | /* no differences, just ignore the update */ |
@@ -781,35 +738,30 @@ update_hello (const struct GNUNET_PeerIdentity *peer, | |||
781 | (*dest) = mrg; | 738 | (*dest) = mrg; |
782 | } | 739 | } |
783 | 740 | ||
784 | if ( (NULL != (host->hello)) && | 741 | if ((NULL != (host->hello)) && (GNUNET_NO == friend_hello_type)) |
785 | (GNUNET_NO == friend_hello_type) ) | ||
786 | { | 742 | { |
787 | /* Update friend only hello */ | 743 | /* Update friend only hello */ |
788 | mrg = update_friend_hello (host->hello, | 744 | mrg = update_friend_hello (host->hello, host->friend_only_hello); |
789 | host->friend_only_hello); | ||
790 | if (NULL != host->friend_only_hello) | 745 | if (NULL != host->friend_only_hello) |
791 | GNUNET_free (host->friend_only_hello); | 746 | GNUNET_free (host->friend_only_hello); |
792 | host->friend_only_hello = mrg; | 747 | host->friend_only_hello = mrg; |
793 | } | 748 | } |
794 | 749 | ||
795 | if (NULL != host->hello) | 750 | if (NULL != host->hello) |
796 | GNUNET_assert ((GNUNET_NO == | 751 | GNUNET_assert ((GNUNET_NO == GNUNET_HELLO_is_friend_only (host->hello))); |
797 | GNUNET_HELLO_is_friend_only (host->hello))); | ||
798 | if (NULL != host->friend_only_hello) | 752 | if (NULL != host->friend_only_hello) |
799 | GNUNET_assert ((GNUNET_YES == | 753 | GNUNET_assert ( |
800 | GNUNET_HELLO_is_friend_only (host->friend_only_hello))); | 754 | (GNUNET_YES == GNUNET_HELLO_is_friend_only (host->friend_only_hello))); |
801 | 755 | ||
802 | fn = get_host_filename (peer); | 756 | fn = get_host_filename (peer); |
803 | if ( (NULL != fn) && | 757 | if ((NULL != fn) && (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn))) |
804 | (GNUNET_OK == | ||
805 | GNUNET_DISK_directory_create_for_file (fn)) ) | ||
806 | { | 758 | { |
807 | store_hello = GNUNET_NO; | 759 | store_hello = GNUNET_NO; |
808 | size = 0; | 760 | size = 0; |
809 | cnt = 0; | 761 | cnt = 0; |
810 | if (NULL != host->hello) | 762 | if (NULL != host->hello) |
811 | (void) GNUNET_HELLO_iterate_addresses (host->hello, | 763 | (void) GNUNET_HELLO_iterate_addresses (host->hello, |
812 | GNUNET_NO, | 764 | GNUNET_NO, |
813 | &count_addresses, | 765 | &count_addresses, |
814 | &cnt); | 766 | &cnt); |
815 | if (cnt > 0) | 767 | if (cnt > 0) |
@@ -821,7 +773,7 @@ update_hello (const struct GNUNET_PeerIdentity *peer, | |||
821 | if (NULL != host->friend_only_hello) | 773 | if (NULL != host->friend_only_hello) |
822 | (void) GNUNET_HELLO_iterate_addresses (host->friend_only_hello, | 774 | (void) GNUNET_HELLO_iterate_addresses (host->friend_only_hello, |
823 | GNUNET_NO, | 775 | GNUNET_NO, |
824 | &count_addresses, | 776 | &count_addresses, |
825 | &cnt); | 777 | &cnt); |
826 | store_friend_hello = GNUNET_NO; | 778 | store_friend_hello = GNUNET_NO; |
827 | if (0 < cnt) | 779 | if (0 < cnt) |
@@ -830,12 +782,11 @@ update_hello (const struct GNUNET_PeerIdentity *peer, | |||
830 | size += GNUNET_HELLO_size (host->friend_only_hello); | 782 | size += GNUNET_HELLO_size (host->friend_only_hello); |
831 | } | 783 | } |
832 | 784 | ||
833 | if ( (GNUNET_NO == store_hello) && | 785 | if ((GNUNET_NO == store_hello) && (GNUNET_NO == store_friend_hello)) |
834 | (GNUNET_NO == store_friend_hello) ) | ||
835 | { | 786 | { |
836 | /* no valid addresses, don't put HELLO on disk; in fact, | 787 | /* no valid addresses, don't put HELLO on disk; in fact, |
837 | if one exists on disk, remove it */ | 788 | if one exists on disk, remove it */ |
838 | (void) UNLINK (fn); | 789 | (void) unlink (fn); |
839 | } | 790 | } |
840 | else | 791 | else |
841 | { | 792 | { |
@@ -844,32 +795,32 @@ update_hello (const struct GNUNET_PeerIdentity *peer, | |||
844 | 795 | ||
845 | if (GNUNET_YES == store_hello) | 796 | if (GNUNET_YES == store_hello) |
846 | { | 797 | { |
847 | GNUNET_memcpy (buffer, | 798 | GNUNET_memcpy (buffer, host->hello, GNUNET_HELLO_size (host->hello)); |
848 | host->hello, | 799 | pos += GNUNET_HELLO_size (host->hello); |
849 | GNUNET_HELLO_size (host->hello)); | ||
850 | pos += GNUNET_HELLO_size (host->hello); | ||
851 | } | 800 | } |
852 | if (GNUNET_YES == store_friend_hello) | 801 | if (GNUNET_YES == store_friend_hello) |
853 | { | 802 | { |
854 | GNUNET_memcpy (&buffer[pos], | 803 | GNUNET_memcpy (&buffer[pos], |
855 | host->friend_only_hello, | 804 | host->friend_only_hello, |
856 | GNUNET_HELLO_size (host->friend_only_hello)); | 805 | GNUNET_HELLO_size (host->friend_only_hello)); |
857 | pos += GNUNET_HELLO_size (host->friend_only_hello); | 806 | pos += GNUNET_HELLO_size (host->friend_only_hello); |
858 | } | 807 | } |
859 | GNUNET_assert (pos == size); | 808 | GNUNET_assert (pos == size); |
860 | 809 | ||
861 | if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn, buffer, size, | 810 | if (GNUNET_SYSERR == GNUNET_DISK_fn_write (fn, |
862 | GNUNET_DISK_PERM_USER_READ | | 811 | buffer, |
863 | GNUNET_DISK_PERM_USER_WRITE | | 812 | size, |
864 | GNUNET_DISK_PERM_GROUP_READ | | 813 | GNUNET_DISK_PERM_USER_READ | |
865 | GNUNET_DISK_PERM_OTHER_READ)) | 814 | GNUNET_DISK_PERM_USER_WRITE | |
866 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn); | 815 | GNUNET_DISK_PERM_GROUP_READ | |
816 | GNUNET_DISK_PERM_OTHER_READ)) | ||
817 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn); | ||
867 | else | 818 | else |
868 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
869 | "Stored %s %s HELLO in %s with total size %u\n", | 820 | "Stored %s %s HELLO in %s with total size %u\n", |
870 | (GNUNET_YES == store_friend_hello) ? "friend-only": "", | 821 | (GNUNET_YES == store_friend_hello) ? "friend-only" : "", |
871 | (GNUNET_YES == store_hello) ? "public": "", | 822 | (GNUNET_YES == store_hello) ? "public" : "", |
872 | fn, | 823 | fn, |
873 | size); | 824 | size); |
874 | GNUNET_free (buffer); | 825 | GNUNET_free (buffer); |
875 | } | 826 | } |
@@ -905,9 +856,7 @@ struct TransmitContext | |||
905 | * @return #GNUNET_YES (continue to iterate) | 856 | * @return #GNUNET_YES (continue to iterate) |
906 | */ | 857 | */ |
907 | static int | 858 | static int |
908 | add_to_tc (void *cls, | 859 | add_to_tc (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
909 | const struct GNUNET_PeerIdentity *key, | ||
910 | void *value) | ||
911 | { | 860 | { |
912 | struct TransmitContext *tc = cls; | 861 | struct TransmitContext *tc = cls; |
913 | struct HostEntry *pos = value; | 862 | struct HostEntry *pos = value; |
@@ -917,53 +866,39 @@ add_to_tc (void *cls, | |||
917 | 866 | ||
918 | hs = 0; | 867 | hs = 0; |
919 | 868 | ||
920 | if ( (NULL != pos->hello) && | 869 | if ((NULL != pos->hello) && (GNUNET_NO == tc->friend_only)) |
921 | (GNUNET_NO == tc->friend_only) ) | ||
922 | { | 870 | { |
923 | /* Copy public HELLO */ | 871 | /* Copy public HELLO */ |
924 | hs = GNUNET_HELLO_size (pos->hello); | 872 | hs = GNUNET_HELLO_size (pos->hello); |
925 | GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE - | 873 | GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE - sizeof (struct InfoMessage)); |
926 | sizeof (struct InfoMessage)); | 874 | env = GNUNET_MQ_msg_extra (im, hs, GNUNET_MESSAGE_TYPE_PEERINFO_INFO); |
927 | env = GNUNET_MQ_msg_extra (im, | 875 | GNUNET_memcpy (&im[1], pos->hello, hs); |
928 | hs, | ||
929 | GNUNET_MESSAGE_TYPE_PEERINFO_INFO); | ||
930 | GNUNET_memcpy (&im[1], | ||
931 | pos->hello, | ||
932 | hs); | ||
933 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 876 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
934 | "Sending public HELLO with size %u for peer `%s'\n", | 877 | "Sending public HELLO with size %u for peer `%s'\n", |
935 | hs, | 878 | hs, |
936 | GNUNET_i2s (key)); | 879 | GNUNET_i2s (key)); |
937 | } | 880 | } |
938 | else if ( (NULL != pos->friend_only_hello) && | 881 | else if ((NULL != pos->friend_only_hello) && (GNUNET_YES == tc->friend_only)) |
939 | (GNUNET_YES == tc->friend_only) ) | ||
940 | { | 882 | { |
941 | /* Copy friend only HELLO */ | 883 | /* Copy friend only HELLO */ |
942 | hs = GNUNET_HELLO_size (pos->friend_only_hello); | 884 | hs = GNUNET_HELLO_size (pos->friend_only_hello); |
943 | GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE - | 885 | GNUNET_assert (hs < GNUNET_MAX_MESSAGE_SIZE - sizeof (struct InfoMessage)); |
944 | sizeof (struct InfoMessage)); | 886 | env = GNUNET_MQ_msg_extra (im, hs, GNUNET_MESSAGE_TYPE_PEERINFO_INFO); |
945 | env = GNUNET_MQ_msg_extra (im, | 887 | GNUNET_memcpy (&im[1], pos->friend_only_hello, hs); |
946 | hs, | ||
947 | GNUNET_MESSAGE_TYPE_PEERINFO_INFO); | ||
948 | GNUNET_memcpy (&im[1], | ||
949 | pos->friend_only_hello, | ||
950 | hs); | ||
951 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 888 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
952 | "Sending friend-only HELLO with size %u for peer `%s'\n", | 889 | "Sending friend-only HELLO with size %u for peer `%s'\n", |
953 | hs, | 890 | hs, |
954 | GNUNET_i2s (key)); | 891 | GNUNET_i2s (key)); |
955 | } | 892 | } |
956 | else | 893 | else |
957 | { | 894 | { |
958 | env = GNUNET_MQ_msg (im, | 895 | env = GNUNET_MQ_msg (im, GNUNET_MESSAGE_TYPE_PEERINFO_INFO); |
959 | GNUNET_MESSAGE_TYPE_PEERINFO_INFO); | ||
960 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 896 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
961 | "Adding no HELLO for peer `%s'\n", | 897 | "Adding no HELLO for peer `%s'\n", |
962 | GNUNET_i2s (key)); | 898 | GNUNET_i2s (key)); |
963 | } | 899 | } |
964 | im->peer = pos->identity; | 900 | im->peer = pos->identity; |
965 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (tc->client), | 901 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (tc->client), env); |
966 | env); | ||
967 | return GNUNET_YES; | 902 | return GNUNET_YES; |
968 | } | 903 | } |
969 | 904 | ||
@@ -976,8 +911,7 @@ add_to_tc (void *cls, | |||
976 | * @return #GNUNET_OK (continue iteration) | 911 | * @return #GNUNET_OK (continue iteration) |
977 | */ | 912 | */ |
978 | static int | 913 | static int |
979 | discard_hosts_helper (void *cls, | 914 | discard_hosts_helper (void *cls, const char *fn) |
980 | const char *fn) | ||
981 | { | 915 | { |
982 | struct GNUNET_TIME_Absolute *now = cls; | 916 | struct GNUNET_TIME_Absolute *now = cls; |
983 | char buffer[GNUNET_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN; | 917 | char buffer[GNUNET_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN; |
@@ -991,31 +925,25 @@ discard_hosts_helper (void *cls, | |||
991 | unsigned int cnt; | 925 | unsigned int cnt; |
992 | char *writebuffer; | 926 | char *writebuffer; |
993 | uint64_t fsize; | 927 | uint64_t fsize; |
994 | 928 | ||
995 | if (GNUNET_OK != | 929 | if (GNUNET_OK != GNUNET_DISK_file_size (fn, &fsize, GNUNET_YES, GNUNET_YES)) |
996 | GNUNET_DISK_file_size (fn, | ||
997 | &fsize, | ||
998 | GNUNET_YES, | ||
999 | GNUNET_YES)) | ||
1000 | { | 930 | { |
1001 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | | 931 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | |
1002 | GNUNET_ERROR_TYPE_BULK, | 932 | GNUNET_ERROR_TYPE_BULK, |
1003 | "fstat", | 933 | "fstat", |
1004 | fn); | 934 | fn); |
1005 | return GNUNET_OK; | 935 | return GNUNET_OK; |
1006 | } | 936 | } |
1007 | read_size = GNUNET_DISK_fn_read (fn, | 937 | read_size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer)); |
1008 | buffer, | ||
1009 | sizeof (buffer)); | ||
1010 | 938 | ||
1011 | if ( (read_size < (int) sizeof (struct GNUNET_MessageHeader)) || | 939 | if ((read_size < (int) sizeof (struct GNUNET_MessageHeader)) || |
1012 | (fsize > GNUNET_MAX_MESSAGE_SIZE) ) | 940 | (fsize > GNUNET_MAX_MESSAGE_SIZE)) |
1013 | { | 941 | { |
1014 | if (0 != UNLINK (fn)) | 942 | if (0 != unlink (fn)) |
1015 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | | 943 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | |
1016 | GNUNET_ERROR_TYPE_BULK, | 944 | GNUNET_ERROR_TYPE_BULK, |
1017 | "unlink", | 945 | "unlink", |
1018 | fn); | 946 | fn); |
1019 | return GNUNET_OK; | 947 | return GNUNET_OK; |
1020 | } | 948 | } |
1021 | 949 | ||
@@ -1030,31 +958,27 @@ discard_hosts_helper (void *cls, | |||
1030 | if (0 == cur_hello_size) | 958 | if (0 == cur_hello_size) |
1031 | { | 959 | { |
1032 | /* Invalid data, discard */ | 960 | /* Invalid data, discard */ |
1033 | if (0 != UNLINK (fn)) | 961 | if (0 != unlink (fn)) |
1034 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | | 962 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | |
1035 | GNUNET_ERROR_TYPE_BULK, | 963 | GNUNET_ERROR_TYPE_BULK, |
1036 | "unlink", | 964 | "unlink", |
1037 | fn); | 965 | fn); |
1038 | GNUNET_free (writebuffer); | 966 | GNUNET_free (writebuffer); |
1039 | return GNUNET_OK; | 967 | return GNUNET_OK; |
1040 | } | 968 | } |
1041 | new_hello = GNUNET_HELLO_iterate_addresses (hello, | 969 | new_hello = |
1042 | GNUNET_YES, | 970 | GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES, &discard_expired, now); |
1043 | &discard_expired, | ||
1044 | now); | ||
1045 | cnt = 0; | 971 | cnt = 0; |
1046 | if (NULL != new_hello) | 972 | if (NULL != new_hello) |
1047 | (void) GNUNET_HELLO_iterate_addresses (hello, | 973 | (void) GNUNET_HELLO_iterate_addresses (hello, |
1048 | GNUNET_NO, | 974 | GNUNET_NO, |
1049 | &count_addresses, | 975 | &count_addresses, |
1050 | &cnt); | 976 | &cnt); |
1051 | if ( (NULL != new_hello) && (0 < cnt) ) | 977 | if ((NULL != new_hello) && (0 < cnt)) |
1052 | { | 978 | { |
1053 | /* Store new HELLO to write it when done */ | 979 | /* Store new HELLO to write it when done */ |
1054 | new_hello_size = GNUNET_HELLO_size (new_hello); | 980 | new_hello_size = GNUNET_HELLO_size (new_hello); |
1055 | GNUNET_memcpy (&writebuffer[write_pos], | 981 | GNUNET_memcpy (&writebuffer[write_pos], new_hello, new_hello_size); |
1056 | new_hello, | ||
1057 | new_hello_size); | ||
1058 | write_pos += new_hello_size; | 982 | write_pos += new_hello_size; |
1059 | } | 983 | } |
1060 | read_pos += cur_hello_size; | 984 | read_pos += cur_hello_size; |
@@ -1067,14 +991,15 @@ discard_hosts_helper (void *cls, | |||
1067 | writebuffer, | 991 | writebuffer, |
1068 | write_pos, | 992 | write_pos, |
1069 | GNUNET_DISK_PERM_USER_READ | | 993 | GNUNET_DISK_PERM_USER_READ | |
1070 | GNUNET_DISK_PERM_USER_WRITE | | 994 | GNUNET_DISK_PERM_USER_WRITE | |
1071 | GNUNET_DISK_PERM_GROUP_READ | | 995 | GNUNET_DISK_PERM_GROUP_READ | |
1072 | GNUNET_DISK_PERM_OTHER_READ); | 996 | GNUNET_DISK_PERM_OTHER_READ); |
1073 | } | 997 | } |
1074 | else if (0 != UNLINK (fn)) | 998 | else if (0 != unlink (fn)) |
1075 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | | 999 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING | |
1076 | GNUNET_ERROR_TYPE_BULK, | 1000 | GNUNET_ERROR_TYPE_BULK, |
1077 | "unlink", fn); | 1001 | "unlink", |
1002 | fn); | ||
1078 | 1003 | ||
1079 | GNUNET_free (writebuffer); | 1004 | GNUNET_free (writebuffer); |
1080 | return GNUNET_OK; | 1005 | return GNUNET_OK; |
@@ -1096,14 +1021,12 @@ cron_clean_data_hosts (void *cls) | |||
1096 | cron_clean = NULL; | 1021 | cron_clean = NULL; |
1097 | now = GNUNET_TIME_absolute_get (); | 1022 | now = GNUNET_TIME_absolute_get (); |
1098 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, | 1023 | GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK, |
1099 | _("Cleaning up directory `%s'\n"), | 1024 | _ ("Cleaning up directory `%s'\n"), |
1100 | networkIdDirectory); | 1025 | networkIdDirectory); |
1101 | GNUNET_DISK_directory_scan (networkIdDirectory, | 1026 | GNUNET_DISK_directory_scan (networkIdDirectory, &discard_hosts_helper, &now); |
1102 | &discard_hosts_helper, | ||
1103 | &now); | ||
1104 | cron_clean = GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, | 1027 | cron_clean = GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, |
1105 | &cron_clean_data_hosts, | 1028 | &cron_clean_data_hosts, |
1106 | NULL); | 1029 | NULL); |
1107 | } | 1030 | } |
1108 | 1031 | ||
1109 | 1032 | ||
@@ -1115,15 +1038,12 @@ cron_clean_data_hosts (void *cls) | |||
1115 | * @return #GNUNET_OK if @a hello is well-formed | 1038 | * @return #GNUNET_OK if @a hello is well-formed |
1116 | */ | 1039 | */ |
1117 | static int | 1040 | static int |
1118 | check_hello (void *cls, | 1041 | check_hello (void *cls, const struct GNUNET_HELLO_Message *hello) |
1119 | const struct GNUNET_HELLO_Message *hello) | ||
1120 | { | 1042 | { |
1121 | struct GNUNET_PeerIdentity pid; | 1043 | struct GNUNET_PeerIdentity pid; |
1122 | 1044 | ||
1123 | (void) cls; | 1045 | (void) cls; |
1124 | if (GNUNET_OK != | 1046 | if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) |
1125 | GNUNET_HELLO_get_id (hello, | ||
1126 | &pid)) | ||
1127 | { | 1047 | { |
1128 | GNUNET_break (0); | 1048 | GNUNET_break (0); |
1129 | return GNUNET_SYSERR; | 1049 | return GNUNET_SYSERR; |
@@ -1139,21 +1059,17 @@ check_hello (void *cls, | |||
1139 | * @param hello the actual message | 1059 | * @param hello the actual message |
1140 | */ | 1060 | */ |
1141 | static void | 1061 | static void |
1142 | handle_hello (void *cls, | 1062 | handle_hello (void *cls, const struct GNUNET_HELLO_Message *hello) |
1143 | const struct GNUNET_HELLO_Message *hello) | ||
1144 | { | 1063 | { |
1145 | struct GNUNET_SERVICE_Client *client = cls; | 1064 | struct GNUNET_SERVICE_Client *client = cls; |
1146 | struct GNUNET_PeerIdentity pid; | 1065 | struct GNUNET_PeerIdentity pid; |
1147 | 1066 | ||
1148 | GNUNET_assert (GNUNET_OK == | 1067 | GNUNET_assert (GNUNET_OK == GNUNET_HELLO_get_id (hello, &pid)); |
1149 | GNUNET_HELLO_get_id (hello, | ||
1150 | &pid)); | ||
1151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1068 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1152 | "HELLO message received for peer `%s'\n", | 1069 | "HELLO message received for peer `%s'\n", |
1153 | GNUNET_i2s (&pid)); | 1070 | GNUNET_i2s (&pid)); |
1154 | add_host_to_known_hosts (&pid); | 1071 | add_host_to_known_hosts (&pid); |
1155 | update_hello (&pid, | 1072 | update_hello (&pid, hello); |
1156 | hello); | ||
1157 | GNUNET_SERVICE_client_continue (client); | 1073 | GNUNET_SERVICE_client_continue (client); |
1158 | } | 1074 | } |
1159 | 1075 | ||
@@ -1165,8 +1081,7 @@ handle_hello (void *cls, | |||
1165 | * @param lpm the actual message | 1081 | * @param lpm the actual message |
1166 | */ | 1082 | */ |
1167 | static void | 1083 | static void |
1168 | handle_get (void *cls, | 1084 | handle_get (void *cls, const struct ListPeerMessage *lpm) |
1169 | const struct ListPeerMessage *lpm) | ||
1170 | { | 1085 | { |
1171 | struct GNUNET_SERVICE_Client *client = cls; | 1086 | struct GNUNET_SERVICE_Client *client = cls; |
1172 | struct TransmitContext tcx; | 1087 | struct TransmitContext tcx; |
@@ -1182,10 +1097,8 @@ handle_get (void *cls, | |||
1182 | &lpm->peer, | 1097 | &lpm->peer, |
1183 | &add_to_tc, | 1098 | &add_to_tc, |
1184 | &tcx); | 1099 | &tcx); |
1185 | env = GNUNET_MQ_msg (msg, | 1100 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END); |
1186 | GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END); | 1101 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); |
1187 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | ||
1188 | env); | ||
1189 | GNUNET_SERVICE_client_continue (client); | 1102 | GNUNET_SERVICE_client_continue (client); |
1190 | } | 1103 | } |
1191 | 1104 | ||
@@ -1197,25 +1110,19 @@ handle_get (void *cls, | |||
1197 | * @param lapm the actual message | 1110 | * @param lapm the actual message |
1198 | */ | 1111 | */ |
1199 | static void | 1112 | static void |
1200 | handle_get_all (void *cls, | 1113 | handle_get_all (void *cls, const struct ListAllPeersMessage *lapm) |
1201 | const struct ListAllPeersMessage *lapm) | ||
1202 | { | 1114 | { |
1203 | struct GNUNET_SERVICE_Client *client = cls; | 1115 | struct GNUNET_SERVICE_Client *client = cls; |
1204 | struct TransmitContext tcx; | 1116 | struct TransmitContext tcx; |
1205 | struct GNUNET_MQ_Envelope *env; | 1117 | struct GNUNET_MQ_Envelope *env; |
1206 | struct GNUNET_MessageHeader *msg; | 1118 | struct GNUNET_MessageHeader *msg; |
1207 | 1119 | ||
1208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "GET_ALL message received\n"); |
1209 | "GET_ALL message received\n"); | ||
1210 | tcx.friend_only = ntohl (lapm->include_friend_only); | 1121 | tcx.friend_only = ntohl (lapm->include_friend_only); |
1211 | tcx.client = client; | 1122 | tcx.client = client; |
1212 | GNUNET_CONTAINER_multipeermap_iterate (hostmap, | 1123 | GNUNET_CONTAINER_multipeermap_iterate (hostmap, &add_to_tc, &tcx); |
1213 | &add_to_tc, | 1124 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END); |
1214 | &tcx); | 1125 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); |
1215 | env = GNUNET_MQ_msg (msg, | ||
1216 | GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END); | ||
1217 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | ||
1218 | env); | ||
1219 | GNUNET_SERVICE_client_continue (client); | 1126 | GNUNET_SERVICE_client_continue (client); |
1220 | } | 1127 | } |
1221 | 1128 | ||
@@ -1227,8 +1134,7 @@ handle_get_all (void *cls, | |||
1227 | * @param nm the actual message | 1134 | * @param nm the actual message |
1228 | */ | 1135 | */ |
1229 | static void | 1136 | static void |
1230 | handle_notify (void *cls, | 1137 | handle_notify (void *cls, const struct NotifyMessage *nm) |
1231 | const struct NotifyMessage *nm) | ||
1232 | { | 1138 | { |
1233 | struct GNUNET_SERVICE_Client *client = cls; | 1139 | struct GNUNET_SERVICE_Client *client = cls; |
1234 | struct GNUNET_MQ_Handle *mq; | 1140 | struct GNUNET_MQ_Handle *mq; |
@@ -1236,25 +1142,18 @@ handle_notify (void *cls, | |||
1236 | struct GNUNET_MQ_Envelope *env; | 1142 | struct GNUNET_MQ_Envelope *env; |
1237 | struct GNUNET_MessageHeader *msg; | 1143 | struct GNUNET_MessageHeader *msg; |
1238 | 1144 | ||
1239 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "NOTIFY message received\n"); |
1240 | "NOTIFY message received\n"); | ||
1241 | mq = GNUNET_SERVICE_client_get_mq (client); | 1146 | mq = GNUNET_SERVICE_client_get_mq (client); |
1242 | GNUNET_SERVICE_client_mark_monitor (client); | 1147 | GNUNET_SERVICE_client_mark_monitor (client); |
1243 | if (ntohl (nm->include_friend_only)) | 1148 | if (ntohl (nm->include_friend_only)) |
1244 | GNUNET_notification_context_add (notify_friend_only_list, | 1149 | GNUNET_notification_context_add (notify_friend_only_list, mq); |
1245 | mq); | ||
1246 | else | 1150 | else |
1247 | GNUNET_notification_context_add (notify_list, | 1151 | GNUNET_notification_context_add (notify_list, mq); |
1248 | mq); | ||
1249 | tcx.friend_only = ntohl (nm->include_friend_only); | 1152 | tcx.friend_only = ntohl (nm->include_friend_only); |
1250 | tcx.client = client; | 1153 | tcx.client = client; |
1251 | GNUNET_CONTAINER_multipeermap_iterate (hostmap, | 1154 | GNUNET_CONTAINER_multipeermap_iterate (hostmap, &add_to_tc, &tcx); |
1252 | &add_to_tc, | 1155 | env = GNUNET_MQ_msg (msg, GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END); |
1253 | &tcx); | 1156 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); |
1254 | env = GNUNET_MQ_msg (msg, | ||
1255 | GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END); | ||
1256 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), | ||
1257 | env); | ||
1258 | GNUNET_SERVICE_client_continue (client); | 1157 | GNUNET_SERVICE_client_continue (client); |
1259 | } | 1158 | } |
1260 | 1159 | ||
@@ -1304,9 +1203,7 @@ client_disconnect_cb (void *cls, | |||
1304 | * @return #GNUNET_YES (continue to iterate) | 1203 | * @return #GNUNET_YES (continue to iterate) |
1305 | */ | 1204 | */ |
1306 | static int | 1205 | static int |
1307 | free_host_entry (void *cls, | 1206 | free_host_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
1308 | const struct GNUNET_PeerIdentity *key, | ||
1309 | void *value) | ||
1310 | { | 1207 | { |
1311 | struct HostEntry *he = value; | 1208 | struct HostEntry *he = value; |
1312 | 1209 | ||
@@ -1333,14 +1230,11 @@ shutdown_task (void *cls) | |||
1333 | GNUNET_notification_context_destroy (notify_friend_only_list); | 1230 | GNUNET_notification_context_destroy (notify_friend_only_list); |
1334 | notify_friend_only_list = NULL; | 1231 | notify_friend_only_list = NULL; |
1335 | 1232 | ||
1336 | GNUNET_CONTAINER_multipeermap_iterate (hostmap, | 1233 | GNUNET_CONTAINER_multipeermap_iterate (hostmap, &free_host_entry, NULL); |
1337 | &free_host_entry, | ||
1338 | NULL); | ||
1339 | GNUNET_CONTAINER_multipeermap_destroy (hostmap); | 1234 | GNUNET_CONTAINER_multipeermap_destroy (hostmap); |
1340 | if (NULL != stats) | 1235 | if (NULL != stats) |
1341 | { | 1236 | { |
1342 | GNUNET_STATISTICS_destroy (stats, | 1237 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); |
1343 | GNUNET_NO); | ||
1344 | stats = NULL; | 1238 | stats = NULL; |
1345 | } | 1239 | } |
1346 | if (NULL != cron_clean) | 1240 | if (NULL != cron_clean) |
@@ -1381,60 +1275,48 @@ run (void *cls, | |||
1381 | 1275 | ||
1382 | (void) cls; | 1276 | (void) cls; |
1383 | (void) service; | 1277 | (void) service; |
1384 | hostmap | 1278 | hostmap = GNUNET_CONTAINER_multipeermap_create (1024, GNUNET_YES); |
1385 | = GNUNET_CONTAINER_multipeermap_create (1024, | 1279 | stats = GNUNET_STATISTICS_create ("peerinfo", cfg); |
1386 | GNUNET_YES); | 1280 | notify_list = GNUNET_notification_context_create (0); |
1387 | stats | 1281 | notify_friend_only_list = GNUNET_notification_context_create (0); |
1388 | = GNUNET_STATISTICS_create ("peerinfo", | 1282 | noio = GNUNET_CONFIGURATION_get_value_yesno (cfg, "peerinfo", "NO_IO"); |
1389 | cfg); | 1283 | use_included = GNUNET_CONFIGURATION_get_value_yesno (cfg, |
1390 | notify_list | 1284 | "peerinfo", |
1391 | = GNUNET_notification_context_create (0); | 1285 | "USE_INCLUDED_HELLOS"); |
1392 | notify_friend_only_list | ||
1393 | = GNUNET_notification_context_create (0); | ||
1394 | noio = GNUNET_CONFIGURATION_get_value_yesno (cfg, | ||
1395 | "peerinfo", | ||
1396 | "NO_IO"); | ||
1397 | use_included | ||
1398 | = GNUNET_CONFIGURATION_get_value_yesno (cfg, | ||
1399 | "peerinfo", | ||
1400 | "USE_INCLUDED_HELLOS"); | ||
1401 | if (GNUNET_SYSERR == use_included) | 1286 | if (GNUNET_SYSERR == use_included) |
1402 | use_included = GNUNET_NO; | 1287 | use_included = GNUNET_NO; |
1403 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 1288 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
1404 | NULL); | ||
1405 | if (GNUNET_YES != noio) | 1289 | if (GNUNET_YES != noio) |
1406 | { | 1290 | { |
1407 | GNUNET_assert (GNUNET_OK == | 1291 | GNUNET_assert ( |
1408 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 1292 | GNUNET_OK == |
1409 | "peerinfo", | 1293 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
1410 | "HOSTS", | 1294 | "peerinfo", |
1411 | &networkIdDirectory)); | 1295 | "HOSTS", |
1412 | if (GNUNET_OK != | 1296 | &networkIdDirectory)); |
1413 | GNUNET_DISK_directory_create (networkIdDirectory)) | 1297 | if (GNUNET_OK != GNUNET_DISK_directory_create (networkIdDirectory)) |
1414 | { | 1298 | { |
1415 | GNUNET_SCHEDULER_shutdown (); | 1299 | GNUNET_SCHEDULER_shutdown (); |
1416 | return; | 1300 | return; |
1417 | } | 1301 | } |
1418 | 1302 | ||
1419 | cron_scan | 1303 | cron_scan = |
1420 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 1304 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
1421 | &cron_scan_directory_data_hosts, | 1305 | &cron_scan_directory_data_hosts, |
1422 | NULL); | 1306 | NULL); |
1423 | 1307 | ||
1424 | cron_clean | 1308 | cron_clean = |
1425 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 1309 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
1426 | &cron_clean_data_hosts, | 1310 | &cron_clean_data_hosts, |
1427 | NULL); | 1311 | NULL); |
1428 | if (GNUNET_YES == use_included) | 1312 | if (GNUNET_YES == use_included) |
1429 | { | 1313 | { |
1430 | ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); | 1314 | ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); |
1431 | GNUNET_asprintf (&peerdir, | 1315 | GNUNET_asprintf (&peerdir, "%shellos", ip); |
1432 | "%shellos", | ||
1433 | ip); | ||
1434 | GNUNET_free (ip); | 1316 | GNUNET_free (ip); |
1435 | 1317 | ||
1436 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1318 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1437 | _("Importing HELLOs from `%s'\n"), | 1319 | _ ("Importing HELLOs from `%s'\n"), |
1438 | peerdir); | 1320 | peerdir); |
1439 | dsc.matched = 0; | 1321 | dsc.matched = 0; |
1440 | dsc.remove_files = GNUNET_NO; | 1322 | dsc.remove_files = GNUNET_NO; |
@@ -1447,7 +1329,7 @@ run (void *cls, | |||
1447 | else | 1329 | else |
1448 | { | 1330 | { |
1449 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1331 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1450 | _("Skipping import of included HELLOs\n")); | 1332 | _ ("Skipping import of included HELLOs\n")); |
1451 | } | 1333 | } |
1452 | } | 1334 | } |
1453 | } | 1335 | } |
@@ -1456,30 +1338,30 @@ run (void *cls, | |||
1456 | /** | 1338 | /** |
1457 | * Define "main" method using service macro. | 1339 | * Define "main" method using service macro. |
1458 | */ | 1340 | */ |
1459 | GNUNET_SERVICE_MAIN | 1341 | GNUNET_SERVICE_MAIN ( |
1460 | ("peerinfo", | 1342 | "peerinfo", |
1461 | GNUNET_SERVICE_OPTION_NONE, | 1343 | GNUNET_SERVICE_OPTION_NONE, |
1462 | &run, | 1344 | &run, |
1463 | &client_connect_cb, | 1345 | &client_connect_cb, |
1464 | &client_disconnect_cb, | 1346 | &client_disconnect_cb, |
1465 | NULL, | 1347 | NULL, |
1466 | GNUNET_MQ_hd_var_size (hello, | 1348 | GNUNET_MQ_hd_var_size (hello, |
1467 | GNUNET_MESSAGE_TYPE_HELLO, | 1349 | GNUNET_MESSAGE_TYPE_HELLO, |
1468 | struct GNUNET_HELLO_Message, | 1350 | struct GNUNET_HELLO_Message, |
1469 | NULL), | 1351 | NULL), |
1470 | GNUNET_MQ_hd_fixed_size (get, | 1352 | GNUNET_MQ_hd_fixed_size (get, |
1471 | GNUNET_MESSAGE_TYPE_PEERINFO_GET, | 1353 | GNUNET_MESSAGE_TYPE_PEERINFO_GET, |
1472 | struct ListPeerMessage, | 1354 | struct ListPeerMessage, |
1473 | NULL), | 1355 | NULL), |
1474 | GNUNET_MQ_hd_fixed_size (get_all, | 1356 | GNUNET_MQ_hd_fixed_size (get_all, |
1475 | GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL, | 1357 | GNUNET_MESSAGE_TYPE_PEERINFO_GET_ALL, |
1476 | struct ListAllPeersMessage, | 1358 | struct ListAllPeersMessage, |
1477 | NULL), | 1359 | NULL), |
1478 | GNUNET_MQ_hd_fixed_size (notify, | 1360 | GNUNET_MQ_hd_fixed_size (notify, |
1479 | GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY, | 1361 | GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY, |
1480 | struct NotifyMessage, | 1362 | struct NotifyMessage, |
1481 | NULL), | 1363 | NULL), |
1482 | GNUNET_MQ_handler_end ()); | 1364 | GNUNET_MQ_handler_end ()); |
1483 | 1365 | ||
1484 | 1366 | ||
1485 | /* end of gnunet-service-peerinfo.c */ | 1367 | /* end of gnunet-service-peerinfo.c */ |
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c index 29c27c48c..d56e0c558 100644 --- a/src/peerinfo/perf_peerinfo_api.c +++ b/src/peerinfo/perf_peerinfo_api.c | |||
@@ -177,7 +177,7 @@ main (int argc, | |||
177 | "test_peerinfo_api_data.conf", | 177 | "test_peerinfo_api_data.conf", |
178 | &run, NULL)) | 178 | &run, NULL)) |
179 | return 1; | 179 | return 1; |
180 | FPRINTF (stderr, | 180 | fprintf (stderr, |
181 | "Received %u/%u calls before timeout\n", | 181 | "Received %u/%u calls before timeout\n", |
182 | numpeers, | 182 | numpeers, |
183 | NUM_REQUESTS * NUM_REQUESTS / 2); | 183 | NUM_REQUESTS * NUM_REQUESTS / 2); |