diff options
Diffstat (limited to 'src/nse/gnunet-service-nse.c')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 2453c7e11..6dff5b8c5 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -53,7 +53,7 @@ | |||
53 | 53 | ||
54 | /** | 54 | /** |
55 | * Should messages be delayed randomly? This option should be set to | 55 | * Should messages be delayed randomly? This option should be set to |
56 | * #GNUNET_NO only for experiments, not in production. | 56 | * #GNUNET_NO only for experiments, not in production. |
57 | */ | 57 | */ |
58 | #define USE_RANDOM_DELAYS GNUNET_YES | 58 | #define USE_RANDOM_DELAYS GNUNET_YES |
59 | 59 | ||
@@ -406,13 +406,13 @@ setup_estimate_message (struct GNUNET_NSE_ClientMessage *em) | |||
406 | * @param message the message received | 406 | * @param message the message received |
407 | */ | 407 | */ |
408 | static void | 408 | static void |
409 | handle_start_message (void *cls, | 409 | handle_start_message (void *cls, |
410 | struct GNUNET_SERVER_Client *client, | 410 | struct GNUNET_SERVER_Client *client, |
411 | const struct GNUNET_MessageHeader *message) | 411 | const struct GNUNET_MessageHeader *message) |
412 | { | 412 | { |
413 | struct GNUNET_NSE_ClientMessage em; | 413 | struct GNUNET_NSE_ClientMessage em; |
414 | 414 | ||
415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
416 | "Received START message from client\n"); | 416 | "Received START message from client\n"); |
417 | GNUNET_SERVER_notification_context_add (nc, client); | 417 | GNUNET_SERVER_notification_context_add (nc, client); |
418 | setup_estimate_message (&em); | 418 | setup_estimate_message (&em); |
@@ -483,7 +483,7 @@ pow_hash (const void *buf, | |||
483 | size_t buf_len, | 483 | size_t buf_len, |
484 | struct GNUNET_HashCode *result) | 484 | struct GNUNET_HashCode *result) |
485 | { | 485 | { |
486 | GNUNET_break (0 == | 486 | GNUNET_break (0 == |
487 | gcry_kdf_derive (buf, buf_len, | 487 | gcry_kdf_derive (buf, buf_len, |
488 | GCRY_KDF_SCRYPT, | 488 | GCRY_KDF_SCRYPT, |
489 | 1 /* subalgo */, | 489 | 1 /* subalgo */, |
@@ -572,7 +572,7 @@ get_transmit_delay (int round_offset) | |||
572 | * @param tc scheduler context | 572 | * @param tc scheduler context |
573 | */ | 573 | */ |
574 | static void | 574 | static void |
575 | transmit_task_cb (void *cls, | 575 | transmit_task_cb (void *cls, |
576 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 576 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
577 | 577 | ||
578 | 578 | ||
@@ -586,7 +586,7 @@ transmit_task_cb (void *cls, | |||
586 | * @return number of bytes written to @a buf | 586 | * @return number of bytes written to @a buf |
587 | */ | 587 | */ |
588 | static size_t | 588 | static size_t |
589 | transmit_ready (void *cls, | 589 | transmit_ready (void *cls, |
590 | size_t size, | 590 | size_t size, |
591 | void *buf) | 591 | void *buf) |
592 | { | 592 | { |
@@ -635,7 +635,7 @@ transmit_ready (void *cls, | |||
635 | GNUNET_NO); | 635 | GNUNET_NO); |
636 | #if ENABLE_NSE_HISTOGRAM | 636 | #if ENABLE_NSE_HISTOGRAM |
637 | peer_entry->transmitted_messages++; | 637 | peer_entry->transmitted_messages++; |
638 | peer_entry->last_transmitted_size = | 638 | peer_entry->last_transmitted_size = |
639 | ntohl(size_estimate_messages[idx].matching_bits); | 639 | ntohl(size_estimate_messages[idx].matching_bits); |
640 | #endif | 640 | #endif |
641 | memcpy (buf, &size_estimate_messages[idx], | 641 | memcpy (buf, &size_estimate_messages[idx], |
@@ -651,7 +651,7 @@ transmit_ready (void *cls, | |||
651 | * @param tc scheduler context | 651 | * @param tc scheduler context |
652 | */ | 652 | */ |
653 | static void | 653 | static void |
654 | transmit_task_cb (void *cls, | 654 | transmit_task_cb (void *cls, |
655 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 655 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
656 | { | 656 | { |
657 | struct NSEPeerEntry *peer_entry = cls; | 657 | struct NSEPeerEntry *peer_entry = cls; |
@@ -681,8 +681,8 @@ update_network_size_estimate () | |||
681 | struct GNUNET_NSE_ClientMessage em; | 681 | struct GNUNET_NSE_ClientMessage em; |
682 | 682 | ||
683 | setup_estimate_message (&em); | 683 | setup_estimate_message (&em); |
684 | GNUNET_SERVER_notification_context_broadcast (nc, | 684 | GNUNET_SERVER_notification_context_broadcast (nc, |
685 | &em.header, | 685 | &em.header, |
686 | GNUNET_YES); | 686 | GNUNET_YES); |
687 | } | 687 | } |
688 | 688 | ||
@@ -734,8 +734,8 @@ setup_flood_message (unsigned int slot, | |||
734 | * @return #GNUNET_OK (continue to iterate) | 734 | * @return #GNUNET_OK (continue to iterate) |
735 | */ | 735 | */ |
736 | static int | 736 | static int |
737 | schedule_current_round (void *cls, | 737 | schedule_current_round (void *cls, |
738 | const struct GNUNET_PeerIdentity * key, | 738 | const struct GNUNET_PeerIdentity * key, |
739 | void *value) | 739 | void *value) |
740 | { | 740 | { |
741 | struct NSEPeerEntry *peer_entry = value; | 741 | struct NSEPeerEntry *peer_entry = value; |
@@ -774,7 +774,7 @@ schedule_current_round (void *cls, | |||
774 | * @param tc context for this message | 774 | * @param tc context for this message |
775 | */ | 775 | */ |
776 | static void | 776 | static void |
777 | update_flood_message (void *cls, | 777 | update_flood_message (void *cls, |
778 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 778 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
779 | { | 779 | { |
780 | struct GNUNET_TIME_Relative offset; | 780 | struct GNUNET_TIME_Relative offset; |
@@ -989,8 +989,8 @@ verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood) | |||
989 | * @return #GNUNET_OK (continue to iterate) | 989 | * @return #GNUNET_OK (continue to iterate) |
990 | */ | 990 | */ |
991 | static int | 991 | static int |
992 | update_flood_times (void *cls, | 992 | update_flood_times (void *cls, |
993 | const struct GNUNET_PeerIdentity *key, | 993 | const struct GNUNET_PeerIdentity *key, |
994 | void *value) | 994 | void *value) |
995 | { | 995 | { |
996 | struct NSEPeerEntry *exclude = cls; | 996 | struct NSEPeerEntry *exclude = cls; |
@@ -1032,7 +1032,7 @@ update_flood_times (void *cls, | |||
1032 | * @param peer peer identity this message is from (ignored) | 1032 | * @param peer peer identity this message is from (ignored) |
1033 | */ | 1033 | */ |
1034 | static int | 1034 | static int |
1035 | handle_p2p_size_estimate (void *cls, | 1035 | handle_p2p_size_estimate (void *cls, |
1036 | const struct GNUNET_PeerIdentity *peer, | 1036 | const struct GNUNET_PeerIdentity *peer, |
1037 | const struct GNUNET_MessageHeader *message) | 1037 | const struct GNUNET_MessageHeader *message) |
1038 | { | 1038 | { |
@@ -1059,12 +1059,12 @@ handle_p2p_size_estimate (void *cls, | |||
1059 | char pred[5]; | 1059 | char pred[5]; |
1060 | struct GNUNET_PeerIdentity os; | 1060 | struct GNUNET_PeerIdentity os; |
1061 | 1061 | ||
1062 | GNUNET_snprintf (origin, | 1062 | GNUNET_snprintf (origin, |
1063 | sizeof (origin), | 1063 | sizeof (origin), |
1064 | "%4s", | 1064 | "%4s", |
1065 | GNUNET_i2s (&incoming_flood->origin)); | 1065 | GNUNET_i2s (&incoming_flood->origin)); |
1066 | GNUNET_snprintf (pred, | 1066 | GNUNET_snprintf (pred, |
1067 | sizeof (pred), | 1067 | sizeof (pred), |
1068 | "%4s", | 1068 | "%4s", |
1069 | GNUNET_i2s (peer)); | 1069 | GNUNET_i2s (peer)); |
1070 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1070 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1083,7 +1083,7 @@ handle_p2p_size_estimate (void *cls, | |||
1083 | } | 1083 | } |
1084 | #if ENABLE_NSE_HISTOGRAM | 1084 | #if ENABLE_NSE_HISTOGRAM |
1085 | peer_entry->received_messages++; | 1085 | peer_entry->received_messages++; |
1086 | if (peer_entry->transmitted_messages > 0 && | 1086 | if (peer_entry->transmitted_messages > 0 && |
1087 | peer_entry->last_transmitted_size >= matching_bits) | 1087 | peer_entry->last_transmitted_size >= matching_bits) |
1088 | GNUNET_STATISTICS_update(stats, "# cross messages", 1, GNUNET_NO); | 1088 | GNUNET_STATISTICS_update(stats, "# cross messages", 1, GNUNET_NO); |
1089 | #endif | 1089 | #endif |
@@ -1117,7 +1117,7 @@ handle_p2p_size_estimate (void *cls, | |||
1117 | { | 1117 | { |
1118 | /* send to self, update our own estimate IF this also comes from us! */ | 1118 | /* send to self, update our own estimate IF this also comes from us! */ |
1119 | if (0 == | 1119 | if (0 == |
1120 | memcmp (&incoming_flood->origin, | 1120 | memcmp (&incoming_flood->origin, |
1121 | &my_identity, sizeof (my_identity))) | 1121 | &my_identity, sizeof (my_identity))) |
1122 | update_network_size_estimate (); | 1122 | update_network_size_estimate (); |
1123 | return GNUNET_OK; | 1123 | return GNUNET_OK; |
@@ -1131,7 +1131,7 @@ handle_p2p_size_estimate (void *cls, | |||
1131 | peer_entry->previous_round = GNUNET_YES; | 1131 | peer_entry->previous_round = GNUNET_YES; |
1132 | if (idx != estimate_index) | 1132 | if (idx != estimate_index) |
1133 | { | 1133 | { |
1134 | /* do not transmit information for the previous round to this peer | 1134 | /* do not transmit information for the previous round to this peer |
1135 | anymore (but allow current round) */ | 1135 | anymore (but allow current round) */ |
1136 | return GNUNET_OK; | 1136 | return GNUNET_OK; |
1137 | } | 1137 | } |
@@ -1249,7 +1249,7 @@ handle_core_connect (void *cls, | |||
1249 | * @param peer peer identity this notification is about | 1249 | * @param peer peer identity this notification is about |
1250 | */ | 1250 | */ |
1251 | static void | 1251 | static void |
1252 | handle_core_disconnect (void *cls, | 1252 | handle_core_disconnect (void *cls, |
1253 | const struct GNUNET_PeerIdentity *peer) | 1253 | const struct GNUNET_PeerIdentity *peer) |
1254 | { | 1254 | { |
1255 | struct NSEPeerEntry *pos; | 1255 | struct NSEPeerEntry *pos; |
@@ -1288,8 +1288,8 @@ handle_core_disconnect (void *cls, | |||
1288 | * @param cls NULL | 1288 | * @param cls NULL |
1289 | * @param size the amount of data sent (ignored) | 1289 | * @param size the amount of data sent (ignored) |
1290 | */ | 1290 | */ |
1291 | static void | 1291 | static void |
1292 | flush_comp_cb (void *cls, | 1292 | flush_comp_cb (void *cls, |
1293 | size_t size) | 1293 | size_t size) |
1294 | { | 1294 | { |
1295 | GNUNET_TESTBED_LOGGER_disconnect (lh); | 1295 | GNUNET_TESTBED_LOGGER_disconnect (lh); |
@@ -1359,7 +1359,7 @@ shutdown_task (void *cls, | |||
1359 | * @param identity the public identity of this peer | 1359 | * @param identity the public identity of this peer |
1360 | */ | 1360 | */ |
1361 | static void | 1361 | static void |
1362 | core_init (void *cls, | 1362 | core_init (void *cls, |
1363 | const struct GNUNET_PeerIdentity *identity) | 1363 | const struct GNUNET_PeerIdentity *identity) |
1364 | { | 1364 | { |
1365 | struct GNUNET_TIME_Absolute now; | 1365 | struct GNUNET_TIME_Absolute now; |
@@ -1406,7 +1406,7 @@ core_init (void *cls, | |||
1406 | * @param c configuration to use | 1406 | * @param c configuration to use |
1407 | */ | 1407 | */ |
1408 | static void | 1408 | static void |
1409 | run (void *cls, | 1409 | run (void *cls, |
1410 | struct GNUNET_SERVER_Handle *server, | 1410 | struct GNUNET_SERVER_Handle *server, |
1411 | const struct GNUNET_CONFIGURATION_Handle *c) | 1411 | const struct GNUNET_CONFIGURATION_Handle *c) |
1412 | { | 1412 | { |
@@ -1424,7 +1424,7 @@ run (void *cls, | |||
1424 | struct GNUNET_CRYPTO_EccPrivateKey *pk; | 1424 | struct GNUNET_CRYPTO_EccPrivateKey *pk; |
1425 | 1425 | ||
1426 | cfg = c; | 1426 | cfg = c; |
1427 | srv = server; | 1427 | srv = server; |
1428 | if (GNUNET_OK != | 1428 | if (GNUNET_OK != |
1429 | GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "INTERVAL", | 1429 | GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "INTERVAL", |
1430 | &gnunet_nse_interval)) | 1430 | &gnunet_nse_interval)) |
@@ -1436,7 +1436,7 @@ run (void *cls, | |||
1436 | } | 1436 | } |
1437 | if (GNUNET_OK != | 1437 | if (GNUNET_OK != |
1438 | GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "WORKDELAY", | 1438 | GNUNET_CONFIGURATION_get_value_time (cfg, "NSE", "WORKDELAY", |
1439 | &proof_find_delay)) | 1439 | &proof_find_delay)) |
1440 | { | 1440 | { |
1441 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 1441 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
1442 | "NSE", "WORKDELAY"); | 1442 | "NSE", "WORKDELAY"); |
@@ -1461,7 +1461,7 @@ run (void *cls, | |||
1461 | GNUNET_SCHEDULER_shutdown (); | 1461 | GNUNET_SCHEDULER_shutdown (); |
1462 | return; | 1462 | return; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | #if ENABLE_NSE_HISTOGRAM | 1465 | #if ENABLE_NSE_HISTOGRAM |
1466 | if (NULL == (lh = GNUNET_TESTBED_LOGGER_connect (cfg))) | 1466 | if (NULL == (lh = GNUNET_TESTBED_LOGGER_connect (cfg))) |
1467 | { | 1467 | { |
@@ -1477,7 +1477,7 @@ run (void *cls, | |||
1477 | pk = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg); | 1477 | pk = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg); |
1478 | GNUNET_assert (NULL != pk); | 1478 | GNUNET_assert (NULL != pk); |
1479 | my_private_key = pk; | 1479 | my_private_key = pk; |
1480 | GNUNET_CRYPTO_ecc_key_get_public_for_signature (my_private_key, | 1480 | GNUNET_CRYPTO_ecc_key_get_public_for_signature (my_private_key, |
1481 | &my_identity.public_key); | 1481 | &my_identity.public_key); |
1482 | if (GNUNET_OK != | 1482 | if (GNUNET_OK != |
1483 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) | 1483 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) |
@@ -1486,7 +1486,7 @@ run (void *cls, | |||
1486 | _ | 1486 | _ |
1487 | ("NSE service is lacking key configuration settings. Exiting.\n")); | 1487 | ("NSE service is lacking key configuration settings. Exiting.\n")); |
1488 | GNUNET_free (my_private_key); | 1488 | GNUNET_free (my_private_key); |
1489 | my_private_key = NULL; | 1489 | my_private_key = NULL; |
1490 | GNUNET_SCHEDULER_shutdown (); | 1490 | GNUNET_SCHEDULER_shutdown (); |
1491 | return; | 1491 | return; |
1492 | } | 1492 | } |
@@ -1530,7 +1530,7 @@ run (void *cls, | |||
1530 | * @return 0 ok, 1 on error | 1530 | * @return 0 ok, 1 on error |
1531 | */ | 1531 | */ |
1532 | int | 1532 | int |
1533 | main (int argc, | 1533 | main (int argc, |
1534 | char *const *argv) | 1534 | char *const *argv) |
1535 | { | 1535 | { |
1536 | return (GNUNET_OK == | 1536 | return (GNUNET_OK == |
@@ -1545,7 +1545,7 @@ main (int argc, | |||
1545 | /** | 1545 | /** |
1546 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. | 1546 | * MINIMIZE heap size (way below 128k) since this process doesn't need much. |
1547 | */ | 1547 | */ |
1548 | void __attribute__ ((constructor)) | 1548 | void __attribute__ ((constructor)) |
1549 | GNUNET_ARM_memory_init () | 1549 | GNUNET_ARM_memory_init () |
1550 | { | 1550 | { |
1551 | mallopt (M_TRIM_THRESHOLD, 4 * 1024); | 1551 | mallopt (M_TRIM_THRESHOLD, 4 * 1024); |